builtin.txt 350 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345
  1. *builtin.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Builtin functions *builtin-functions*
  4. Type |gO| to see the table of contents.
  5. ==============================================================================
  6. 1. Overview *builtin-function-list*
  7. Use CTRL-] on the function name to jump to the full explanation.
  8. USAGE RESULT DESCRIPTION ~
  9. abs({expr}) Float or Number absolute value of {expr}
  10. acos({expr}) Float arc cosine of {expr}
  11. add({object}, {item}) List/Blob append {item} to {object}
  12. and({expr}, {expr}) Number bitwise AND
  13. api_info() Dict api metadata
  14. append({lnum}, {text}) Number append {text} below line {lnum}
  15. appendbufline({expr}, {lnum}, {text})
  16. Number append {text} below line {lnum}
  17. in buffer {expr}
  18. argc([{winid}]) Number number of files in the argument list
  19. argidx() Number current index in the argument list
  20. arglistid([{winnr} [, {tabnr}]]) Number argument list id
  21. argv({nr} [, {winid}]) String {nr} entry of the argument list
  22. argv([-1, {winid}]) List the argument list
  23. asin({expr}) Float arc sine of {expr}
  24. assert_beeps({cmd}) Number assert {cmd} causes a beep
  25. assert_equal({exp}, {act} [, {msg}])
  26. Number assert {exp} is equal to {act}
  27. assert_equalfile({fname-one}, {fname-two} [, {msg}])
  28. Number assert file contents are equal
  29. assert_exception({error} [, {msg}])
  30. Number assert {error} is in v:exception
  31. assert_fails({cmd} [, {error}]) Number assert {cmd} fails
  32. assert_false({actual} [, {msg}])
  33. Number assert {actual} is false
  34. assert_inrange({lower}, {upper}, {actual} [, {msg}])
  35. Number assert {actual} is inside the range
  36. assert_match({pat}, {text} [, {msg}])
  37. Number assert {pat} matches {text}
  38. assert_nobeep({cmd}) Number assert {cmd} does not cause a beep
  39. assert_notequal({exp}, {act} [, {msg}])
  40. Number assert {exp} is not equal {act}
  41. assert_notmatch({pat}, {text} [, {msg}])
  42. Number assert {pat} not matches {text}
  43. assert_report({msg}) Number report a test failure
  44. assert_true({actual} [, {msg}]) Number assert {actual} is true
  45. atan({expr}) Float arc tangent of {expr}
  46. atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
  47. browse({save}, {title}, {initdir}, {default})
  48. String put up a file requester
  49. browsedir({title}, {initdir}) String put up a directory requester
  50. bufadd({name}) Number add a buffer to the buffer list
  51. bufexists({expr}) Number |TRUE| if buffer {expr} exists
  52. buflisted({expr}) Number |TRUE| if buffer {expr} is listed
  53. bufload({expr}) Number load buffer {expr} if not loaded yet
  54. bufloaded({expr}) Number |TRUE| if buffer {expr} is loaded
  55. bufname([{expr}]) String Name of the buffer {expr}
  56. bufnr([{expr} [, {create}]]) Number Number of the buffer {expr}
  57. bufwinid({expr}) Number |window-ID| of buffer {expr}
  58. bufwinnr({expr}) Number window number of buffer {expr}
  59. byte2line({byte}) Number line number at byte count {byte}
  60. byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr}
  61. byteidxcomp({expr}, {nr}) Number byte index of {nr}'th char in {expr}
  62. call({func}, {arglist} [, {dict}])
  63. any call {func} with arguments {arglist}
  64. ceil({expr}) Float round {expr} up
  65. changenr() Number current change number
  66. chanclose({id} [, {stream}]) Number Closes a channel or one of its streams
  67. chansend({id}, {data}) Number Writes {data} to channel
  68. char2nr({expr} [, {utf8}]) Number ASCII/UTF-8 value of first char in {expr}
  69. charclass({string}) Number character class of {string}
  70. charcol({expr}) Number column number of cursor or mark
  71. charidx({string}, {idx} [, {countcc}])
  72. Number char index of byte {idx} in {string}
  73. chdir({dir}) String change current working directory
  74. cindent({lnum}) Number C indent for line {lnum}
  75. clearmatches([{win}]) none clear all matches
  76. col({expr}) Number column byte index of cursor or mark
  77. complete({startcol}, {matches}) none set Insert mode completion
  78. complete_add({expr}) Number add completion match
  79. complete_check() Number check for key typed during completion
  80. complete_info([{what}]) Dict get current completion information
  81. confirm({msg} [, {choices} [, {default} [, {type}]]])
  82. Number number of choice picked by user
  83. copy({expr}) any make a shallow copy of {expr}
  84. cos({expr}) Float cosine of {expr}
  85. cosh({expr}) Float hyperbolic cosine of {expr}
  86. count({comp}, {expr} [, {ic} [, {start}]])
  87. Number count how many {expr} are in {comp}
  88. cscope_connection([{num}, {dbpath} [, {prepend}]])
  89. Number checks existence of cscope connection
  90. ctxget([{index}]) Dict return the |context| dict at {index}
  91. ctxpop() none pop and restore |context| from the
  92. |context-stack|
  93. ctxpush([{types}]) none push the current |context| to the
  94. |context-stack|
  95. ctxset({context} [, {index}]) none set |context| at {index}
  96. ctxsize() Number return |context-stack| size
  97. cursor({lnum}, {col} [, {off}])
  98. Number move cursor to {lnum}, {col}, {off}
  99. cursor({list}) Number move cursor to position in {list}
  100. debugbreak({pid}) Number interrupt process being debugged
  101. deepcopy({expr} [, {noref}]) any make a full copy of {expr}
  102. delete({fname} [, {flags}]) Number delete the file or directory {fname}
  103. deletebufline({buf}, {first} [, {last}])
  104. Number delete lines from buffer {buf}
  105. dictwatcheradd({dict}, {pattern}, {callback})
  106. Start watching a dictionary
  107. dictwatcherdel({dict}, {pattern}, {callback})
  108. Stop watching a dictionary
  109. did_filetype() Number |TRUE| if FileType autocommand event used
  110. diff_filler({lnum}) Number diff filler lines about {lnum}
  111. diff_hlID({lnum}, {col}) Number diff highlighting at {lnum}/{col}
  112. digraph_get({chars}) String get the |digraph| of {chars}
  113. digraph_getlist([{listall}]) List get all |digraph|s
  114. digraph_set({chars}, {digraph}) Boolean register |digraph|
  115. digraph_setlist({digraphlist}) Boolean register multiple |digraph|s
  116. empty({expr}) Number |TRUE| if {expr} is empty
  117. environ() Dict return environment variables
  118. escape({string}, {chars}) String escape {chars} in {string} with '\'
  119. eval({string}) any evaluate {string} into its value
  120. eventhandler() Number |TRUE| if inside an event handler
  121. executable({expr}) Number 1 if executable {expr} exists
  122. execute({command}) String execute and capture output of {command}
  123. exepath({expr}) String full path of the command {expr}
  124. exists({expr}) Number |TRUE| if {expr} exists
  125. exp({expr}) Float exponential of {expr}
  126. expand({expr} [, {nosuf} [, {list}]])
  127. any expand special keywords in {expr}
  128. expandcmd({expr}) String expand {expr} like with `:edit`
  129. extend({expr1}, {expr2} [, {expr3}])
  130. List/Dict insert items of {expr2} into {expr1}
  131. feedkeys({string} [, {mode}]) Number add key sequence to typeahead buffer
  132. filereadable({file}) Number |TRUE| if {file} is a readable file
  133. filewritable({file}) Number |TRUE| if {file} is a writable file
  134. filter({expr1}, {expr2}) List/Dict remove items from {expr1} where
  135. {expr2} is 0
  136. finddir({name} [, {path} [, {count}]])
  137. String find directory {name} in {path}
  138. findfile({name} [, {path} [, {count}]])
  139. String find file {name} in {path}
  140. flatten({list} [, {maxdepth}]) List flatten {list} up to {maxdepth} levels
  141. float2nr({expr}) Number convert Float {expr} to a Number
  142. floor({expr}) Float round {expr} down
  143. fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2}
  144. fnameescape({fname}) String escape special characters in {fname}
  145. fnamemodify({fname}, {mods}) String modify file name
  146. foldclosed({lnum}) Number first line of fold at {lnum} if closed
  147. foldclosedend({lnum}) Number last line of fold at {lnum} if closed
  148. foldlevel({lnum}) Number fold level at {lnum}
  149. foldtext() String line displayed for closed fold
  150. foldtextresult({lnum}) String text for closed fold at {lnum}
  151. fullcommand({name}) String get full command from {name}
  152. funcref({name} [, {arglist}] [, {dict}])
  153. Funcref reference to function {name}
  154. function({name} [, {arglist}] [, {dict}])
  155. Funcref named reference to function {name}
  156. garbagecollect([{atexit}]) none free memory, breaking cyclic references
  157. get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def}
  158. get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def}
  159. get({func}, {what}) any get property of funcref/partial {func}
  160. getbufinfo([{buf}]) List information about buffers
  161. getbufline({buf}, {lnum} [, {end}])
  162. List lines {lnum} to {end} of buffer {buf}
  163. getbufvar({buf}, {varname} [, {def}])
  164. any variable {varname} in buffer {buf}
  165. getchangelist([{buf}]) List list of change list items
  166. getchar([expr]) Number or String
  167. get one character from the user
  168. getcharmod() Number modifiers for the last typed character
  169. getcharpos({expr}) List position of cursor, mark, etc.
  170. getcharsearch() Dict last character search
  171. getcharstr([expr]) String get one character from the user
  172. getcmdcompltype() String return the type of the current
  173. command-line completion
  174. getcmdline() String return the current command-line
  175. getcmdpos() Number return cursor position in command-line
  176. getcmdscreenpos() Number return cursor screen position in
  177. command-line
  178. getcmdtype() String return current command-line type
  179. getcmdwintype() String return current command-line window type
  180. getcompletion({pat}, {type} [, {filtered}])
  181. List list of cmdline completion matches
  182. getcurpos([{winnr}]) List position of the cursor
  183. getcursorcharpos([{winnr}]) List character position of the cursor
  184. getcwd([{winnr} [, {tabnr}]]) String get the current working directory
  185. getenv({name}) String return environment variable
  186. getfontname([{name}]) String name of font being used
  187. getfperm({fname}) String file permissions of file {fname}
  188. getfsize({fname}) Number size in bytes of file {fname}
  189. getftime({fname}) Number last modification time of file
  190. getftype({fname}) String description of type of file {fname}
  191. getjumplist([{winnr} [, {tabnr}]])
  192. List list of jump list items
  193. getline({lnum}) String line {lnum} of current buffer
  194. getline({lnum}, {end}) List lines {lnum} to {end} of current buffer
  195. getloclist({nr}) List list of location list items
  196. getloclist({nr}, {what}) Dict get specific location list properties
  197. getmarklist([{buf}]) List list of global/local marks
  198. getmatches([{win}]) List list of current matches
  199. getmousepos() Dict last known mouse position
  200. getpid() Number process ID of Vim
  201. getpos({expr}) List position of cursor, mark, etc.
  202. getqflist() List list of quickfix items
  203. getqflist({what}) Dict get specific quickfix list properties
  204. getreg([{regname} [, 1 [, {list}]]])
  205. String or List contents of a register
  206. getreginfo([{regname}]) Dict information about a register
  207. getregtype([{regname}]) String type of a register
  208. gettabinfo([{expr}]) List list of tab pages
  209. gettabvar({nr}, {varname} [, {def}])
  210. any variable {varname} in tab {nr} or {def}
  211. gettabwinvar({tabnr}, {winnr}, {name} [, {def}])
  212. any {name} in {winnr} in tab page {tabnr}
  213. gettagstack([{nr}]) Dict get the tag stack of window {nr}
  214. getwininfo([{winid}]) List list of info about each window
  215. getwinpos([{timeout}]) List X and Y coord in pixels of the Vim window
  216. getwinposx() Number X coord in pixels of Vim window
  217. getwinposy() Number Y coord in pixels of Vim window
  218. getwinvar({nr}, {varname} [, {def}])
  219. any variable {varname} in window {nr}
  220. glob({expr} [, {nosuf} [, {list} [, {alllinks}]]])
  221. any expand file wildcards in {expr}
  222. glob2regpat({expr}) String convert a glob pat into a search pat
  223. globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
  224. String do glob({expr}) for all dirs in {path}
  225. has({feature}) Number |TRUE| if feature {feature} supported
  226. has_key({dict}, {key}) Number |TRUE| if {dict} has entry {key}
  227. haslocaldir([{winnr} [, {tabnr}]])
  228. Number |TRUE| if the window executed |:lcd| or
  229. the tab executed |:tcd|
  230. hasmapto({what} [, {mode} [, {abbr}]])
  231. Number |TRUE| if mapping to {what} exists
  232. histadd({history}, {item}) Number add an item to a history
  233. histdel({history} [, {item}]) Number remove an item from a history
  234. histget({history} [, {index}]) String get the item {index} from a history
  235. histnr({history}) Number highest index of a history
  236. hlID({name}) Number syntax ID of highlight group {name}
  237. hlexists({name}) Number |TRUE| if highlight group {name} exists
  238. hostname() String name of the machine Vim is running on
  239. iconv({expr}, {from}, {to}) String convert encoding of {expr}
  240. indent({lnum}) Number indent of line {lnum}
  241. index({object}, {expr} [, {start} [, {ic}]])
  242. Number index in {object} where {expr} appears
  243. input({prompt} [, {text} [, {completion}]])
  244. String get input from the user
  245. inputlist({textlist}) Number let the user pick from a choice list
  246. inputrestore() Number restore typeahead
  247. inputsave() Number save and clear typeahead
  248. inputsecret({prompt} [, {text}])
  249. String like input() but hiding the text
  250. insert({object}, {item} [, {idx}])
  251. List insert {item} in {object} [before {idx}]
  252. interrupt() none interrupt script execution
  253. invert({expr}) Number bitwise invert
  254. isdirectory({directory}) Number |TRUE| if {directory} is a directory
  255. isinf({expr}) Number determine if {expr} is infinity value
  256. (positive or negative)
  257. islocked({expr}) Number |TRUE| if {expr} is locked
  258. isnan({expr}) Number |TRUE| if {expr} is NaN
  259. id({expr}) String identifier of the container
  260. items({dict}) List key-value pairs in {dict}
  261. jobpid({id}) Number Returns pid of a job.
  262. jobresize({id}, {width}, {height})
  263. Number Resize pseudo terminal window of a job
  264. jobstart({cmd} [, {opts}]) Number Spawns {cmd} as a job
  265. jobstop({id}) Number Stops a job
  266. jobwait({ids} [, {timeout}]) Number Wait for a set of jobs
  267. join({list} [, {sep}]) String join {list} items into one String
  268. json_decode({expr}) any Convert {expr} from JSON
  269. json_encode({expr}) String Convert {expr} to JSON
  270. keys({dict}) List keys in {dict}
  271. keytrans({string}) String translate internal keycodes to a form
  272. that can be used by |:map|
  273. len({expr}) Number the length of {expr}
  274. libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
  275. libcallnr({lib}, {func}, {arg}) Number idem, but return a Number
  276. line({expr} [, {winid}]) Number line nr of cursor, last line or mark
  277. line2byte({lnum}) Number byte count of line {lnum}
  278. lispindent({lnum}) Number Lisp indent for line {lnum}
  279. list2str({list} [, {utf8}]) String turn numbers in {list} into a String
  280. localtime() Number current time
  281. log({expr}) Float natural logarithm (base e) of {expr}
  282. log10({expr}) Float logarithm of Float {expr} to base 10
  283. luaeval({expr} [, {expr}]) any evaluate |Lua| expression
  284. map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr}
  285. maparg({name} [, {mode} [, {abbr} [, {dict}]]])
  286. String or Dict
  287. rhs of mapping {name} in mode {mode}
  288. mapcheck({name} [, {mode} [, {abbr}]])
  289. String check for mappings matching {name}
  290. mapset({mode}, {abbr}, {dict})
  291. none restore mapping from |maparg()| result
  292. match({expr}, {pat} [, {start} [, {count}]])
  293. Number position where {pat} matches in {expr}
  294. matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
  295. Number highlight {pattern} with {group}
  296. matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
  297. Number highlight positions with {group}
  298. matcharg({nr}) List arguments of |:match|
  299. matchdelete({id} [, {win}]) Number delete match identified by {id}
  300. matchend({expr}, {pat} [, {start} [, {count}]])
  301. Number position where {pat} ends in {expr}
  302. matchfuzzy({list}, {str} [, {dict}])
  303. List fuzzy match {str} in {list}
  304. matchfuzzypos({list}, {str} [, {dict}])
  305. List fuzzy match {str} in {list}
  306. matchlist({expr}, {pat} [, {start} [, {count}]])
  307. List match and submatches of {pat} in {expr}
  308. matchstr({expr}, {pat} [, {start} [, {count}]])
  309. String {count}'th match of {pat} in {expr}
  310. matchstrpos({expr}, {pat} [, {start} [, {count}]])
  311. List {count}'th match of {pat} in {expr}
  312. max({expr}) Number maximum value of items in {expr}
  313. menu_get({path} [, {modes}]) List description of |menus| matched by {path}
  314. menu_info({name} [, {mode}]) Dict get menu item information
  315. min({expr}) Number minimum value of items in {expr}
  316. mkdir({name} [, {path} [, {prot}]])
  317. Number create directory {name}
  318. mode([expr]) String current editing mode
  319. msgpackdump({list} [, {type}]) List/Blob dump objects to msgpack
  320. msgpackparse({data}) List parse msgpack to a list of objects
  321. nextnonblank({lnum}) Number line nr of non-blank line >= {lnum}
  322. nr2char({expr} [, {utf8}]) String single char with ASCII/UTF-8 value {expr}
  323. nvim_...({args}...) any call nvim |api| functions
  324. or({expr}, {expr}) Number bitwise OR
  325. pathshorten({expr} [, {len}]) String shorten directory names in a path
  326. perleval({expr}) any evaluate |perl| expression
  327. pow({x}, {y}) Float {x} to the power of {y}
  328. prevnonblank({lnum}) Number line nr of non-blank line <= {lnum}
  329. printf({fmt}, {expr1}...) String format text
  330. prompt_getprompt({buf}) String get prompt text
  331. prompt_setcallback({buf}, {expr}) none set prompt callback function
  332. prompt_setinterrupt({buf}, {text}) none set prompt interrupt function
  333. prompt_setprompt({buf}, {text}) none set prompt text
  334. pum_getpos() Dict position and size of pum if visible
  335. pumvisible() Number whether popup menu is visible
  336. py3eval({expr}) any evaluate |python3| expression
  337. pyeval({expr}) any evaluate |Python| expression
  338. pyxeval({expr}) any evaluate |python_x| expression
  339. rand([{expr}]) Number get pseudo-random number
  340. range({expr} [, {max} [, {stride}]])
  341. List items from {expr} to {max}
  342. readdir({dir} [, {expr}]) List file names in {dir} selected by {expr}
  343. readfile({fname} [, {type} [, {max}]])
  344. List get list of lines from file {fname}
  345. reduce({object}, {func} [, {initial}])
  346. any reduce {object} using {func}
  347. reg_executing() String get the executing register name
  348. reg_recorded() String get the last recorded register name
  349. reg_recording() String get the recording register name
  350. reltime([{start} [, {end}]]) List get time value
  351. reltimefloat({time}) Float turn the time value into a Float
  352. reltimestr({time}) String turn time value into a String
  353. remove({list}, {idx} [, {end}]) any/List
  354. remove items {idx}-{end} from {list}
  355. remove({blob}, {idx} [, {end}]) Number/Blob
  356. remove bytes {idx}-{end} from {blob}
  357. remove({dict}, {key}) any remove entry {key} from {dict}
  358. rename({from}, {to}) Number rename (move) file from {from} to {to}
  359. repeat({expr}, {count}) String repeat {expr} {count} times
  360. resolve({filename}) String get filename a shortcut points to
  361. reverse({list}) List reverse {list} in-place
  362. round({expr}) Float round off {expr}
  363. rubyeval({expr}) any evaluate |Ruby| expression
  364. rpcnotify({channel}, {event} [, {args}...])
  365. Sends an |RPC| notification to {channel}
  366. rpcrequest({channel}, {method} [, {args}...])
  367. Sends an |RPC| request to {channel}
  368. screenattr({row}, {col}) Number attribute at screen position
  369. screenchar({row}, {col}) Number character at screen position
  370. screenchars({row}, {col}) List List of characters at screen position
  371. screencol() Number current cursor column
  372. screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character
  373. screenrow() Number current cursor row
  374. screenstring({row}, {col}) String characters at screen position
  375. search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  376. Number search for {pattern}
  377. searchcount([{options}]) Dict Get or update the last search count
  378. searchdecl({name} [, {global} [, {thisblock}]])
  379. Number search for variable declaration
  380. searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]])
  381. Number search for other end of start/end pair
  382. searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]])
  383. List search for other end of start/end pair
  384. searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  385. List search for {pattern}
  386. serverlist() String get a list of available servers
  387. setbufline({expr}, {lnum}, {text})
  388. Number set line {lnum} to {text} in buffer
  389. {expr}
  390. setbufvar({buf}, {varname}, {val}) set {varname} in buffer {buf} to {val}
  391. setcellwidths({list}) none set character cell width overrides
  392. setcharpos({expr}, {list}) Number set the {expr} position to {list}
  393. setcharsearch({dict}) Dict set character search from {dict}
  394. setcmdline({str} [, {pos}]) Number set command-line
  395. setcmdpos({pos}) Number set cursor position in command-line
  396. setcursorcharpos({list}) Number move cursor to position in {list}
  397. setenv({name}, {val}) none set environment variable
  398. setfperm({fname}, {mode} Number set {fname} file permissions to {mode}
  399. setline({lnum}, {line}) Number set line {lnum} to {line}
  400. setloclist({nr}, {list} [, {action}])
  401. Number modify location list using {list}
  402. setloclist({nr}, {list}, {action}, {what})
  403. Number modify specific location list props
  404. setmatches({list} [, {win}]) Number restore a list of matches
  405. setpos({expr}, {list}) Number set the {expr} position to {list}
  406. setqflist({list} [, {action}]) Number modify quickfix list using {list}
  407. setqflist({list}, {action}, {what})
  408. Number modify specific quickfix list props
  409. setreg({n}, {v} [, {opt}]) Number set register to value and type
  410. settabvar({nr}, {varname}, {val}) set {varname} in tab page {nr} to {val}
  411. settabwinvar({tabnr}, {winnr}, {varname}, {val}) set {varname} in window
  412. {winnr} in tab page {tabnr} to {val}
  413. settagstack({nr}, {dict} [, {action}])
  414. Number modify tag stack using {dict}
  415. setwinvar({nr}, {varname}, {val}) set {varname} in window {nr} to {val}
  416. sha256({string}) String SHA256 checksum of {string}
  417. shellescape({string} [, {special}])
  418. String escape {string} for use as shell
  419. command argument
  420. shiftwidth([{col}]) Number effective value of 'shiftwidth'
  421. sign_define({name} [, {dict}]) Number define or update a sign
  422. sign_define({list}) List define or update a list of signs
  423. sign_getdefined([{name}]) List get a list of defined signs
  424. sign_getplaced([{buf} [, {dict}]])
  425. List get a list of placed signs
  426. sign_jump({id}, {group}, {buf})
  427. Number jump to a sign
  428. sign_place({id}, {group}, {name}, {buf} [, {dict}])
  429. Number place a sign
  430. sign_placelist({list}) List place a list of signs
  431. sign_undefine([{name}]) Number undefine a sign
  432. sign_undefine({list}) List undefine a list of signs
  433. sign_unplace({group} [, {dict}])
  434. Number unplace a sign
  435. sign_unplacelist({list}) List unplace a list of signs
  436. simplify({filename}) String simplify filename as much as possible
  437. sin({expr}) Float sine of {expr}
  438. sinh({expr}) Float hyperbolic sine of {expr}
  439. sockconnect({mode}, {address} [, {opts}])
  440. Number Connects to socket
  441. sort({list} [, {func} [, {dict}]])
  442. List sort {list}, using {func} to compare
  443. soundfold({word}) String sound-fold {word}
  444. spellbadword() String badly spelled word at cursor
  445. spellsuggest({word} [, {max} [, {capital}]])
  446. List spelling suggestions
  447. split({expr} [, {pat} [, {keepempty}]])
  448. List make |List| from {pat} separated {expr}
  449. sqrt({expr}) Float square root of {expr}
  450. srand([{expr}]) List get seed for |rand()|
  451. stdioopen({dict}) Number open stdio in a headless instance.
  452. stdpath({what}) String/List returns the standard path(s) for {what}
  453. str2float({expr} [, {quoted}]) Float convert String to Float
  454. str2list({expr} [, {utf8}]) List convert each character of {expr} to
  455. ASCII/UTF-8 value
  456. str2nr({expr} [, {base} [, {quoted}]])
  457. Number convert String to Number
  458. strcharpart({str}, {start} [, {len}])
  459. String {len} characters of {str} at
  460. character {start}
  461. strchars({expr} [, {skipcc}]) Number character length of the String {expr}
  462. strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
  463. strftime({format} [, {time}]) String format time with a specified format
  464. strgetchar({str}, {index}) Number get char {index} from {str}
  465. stridx({haystack}, {needle} [, {start}])
  466. Number index of {needle} in {haystack}
  467. string({expr}) String String representation of {expr} value
  468. strlen({expr}) Number length of the String {expr}
  469. strpart({str}, {start} [, {len} [, {chars}]])
  470. String {len} bytes/chars of {str} at
  471. byte {start}
  472. strptime({format}, {timestring})
  473. Number Convert {timestring} to unix timestamp
  474. strridx({haystack}, {needle} [, {start}])
  475. Number last index of {needle} in {haystack}
  476. strtrans({expr}) String translate string to make it printable
  477. strwidth({expr}) Number display cell length of the String {expr}
  478. submatch({nr} [, {list}]) String or List
  479. specific match in ":s" or substitute()
  480. substitute({expr}, {pat}, {sub}, {flags})
  481. String all {pat} in {expr} replaced with {sub}
  482. swapinfo({fname}) Dict information about swap file {fname}
  483. swapname({buf}) String swap file of buffer {buf}
  484. synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col}
  485. synIDattr({synID}, {what} [, {mode}])
  486. String attribute {what} of syntax ID {synID}
  487. synIDtrans({synID}) Number translated syntax ID of {synID}
  488. synconcealed({lnum}, {col}) List info about concealing
  489. synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col}
  490. system({cmd} [, {input}]) String output of shell command/filter {cmd}
  491. systemlist({cmd} [, {input}]) List output of shell command/filter {cmd}
  492. tabpagebuflist([{arg}]) List list of buffer numbers in tab page
  493. tabpagenr([{arg}]) Number number of current or last tab page
  494. tabpagewinnr({tabarg} [, {arg}])
  495. Number number of current window in tab page
  496. tagfiles() List tags files used
  497. taglist({expr} [, {filename}]) List list of tags matching {expr}
  498. tan({expr}) Float tangent of {expr}
  499. tanh({expr}) Float hyperbolic tangent of {expr}
  500. tempname() String name for a temporary file
  501. test_garbagecollect_now() none free memory right now for testing
  502. timer_info([{id}]) List information about timers
  503. timer_pause({id}, {pause}) none pause or unpause a timer
  504. timer_start({time}, {callback} [, {options}])
  505. Number create a timer
  506. timer_stop({timer}) none stop a timer
  507. timer_stopall() none stop all timers
  508. tolower({expr}) String the String {expr} switched to lowercase
  509. toupper({expr}) String the String {expr} switched to uppercase
  510. tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
  511. to chars in {tostr}
  512. trim({text} [, {mask} [, {dir}]])
  513. String trim characters in {mask} from {text}
  514. trunc({expr}) Float truncate Float {expr}
  515. type({name}) Number type of variable {name}
  516. undofile({name}) String undo file name for {name}
  517. undotree() List undo file tree
  518. uniq({list} [, {func} [, {dict}]])
  519. List remove adjacent duplicates from a list
  520. values({dict}) List values in {dict}
  521. virtcol({expr}) Number screen column of cursor or mark
  522. virtcol2col({winid}, {lnum}, {col})
  523. Number byte index of a character on screen
  524. visualmode([expr]) String last visual mode used
  525. wait({timeout}, {condition} [, {interval}])
  526. Number Wait until {condition} is satisfied
  527. wildmenumode() Number whether 'wildmenu' mode is active
  528. win_execute({id}, {command} [, {silent}])
  529. String execute {command} in window {id}
  530. win_findbuf({bufnr}) List find windows containing {bufnr}
  531. win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab}
  532. win_gettype([{nr}]) String type of window {nr}
  533. win_gotoid({expr}) Number go to |window-ID| {expr}
  534. win_id2tabwin({expr}) List get tab and window nr from |window-ID|
  535. win_id2win({expr}) Number get window nr from |window-ID|
  536. win_move_separator({nr}) Number move window vertical separator
  537. win_move_statusline({nr}) Number move window status line
  538. win_screenpos({nr}) List get screen position of window {nr}
  539. win_splitmove({nr}, {target} [, {options}])
  540. Number move window {nr} to split of {target}
  541. winbufnr({nr}) Number buffer number of window {nr}
  542. wincol() Number window column of the cursor
  543. windowsversion() String MS-Windows OS version
  544. winheight({nr}) Number height of window {nr}
  545. winlayout([{tabnr}]) List layout of windows in tab {tabnr}
  546. winline() Number window line of the cursor
  547. winnr([{expr}]) Number number of current window
  548. winrestcmd() String returns command to restore window sizes
  549. winrestview({dict}) none restore view of current window
  550. winsaveview() Dict save view of current window
  551. winwidth({nr}) Number width of window {nr}
  552. wordcount() Dict get byte/char/word statistics
  553. writefile({object}, {fname} [, {flags}])
  554. Number write |Blob| or |List| of lines to file
  555. xor({expr}, {expr}) Number bitwise XOR
  556. ==============================================================================
  557. 2. Details *builtin-function-details*
  558. Not all functions are here, some have been moved to a help file covering the
  559. specific functionality.
  560. abs({expr}) *abs()*
  561. Return the absolute value of {expr}. When {expr} evaluates to
  562. a |Float| abs() returns a |Float|. When {expr} can be
  563. converted to a |Number| abs() returns a |Number|. Otherwise
  564. abs() gives an error message and returns -1.
  565. Examples: >
  566. echo abs(1.456)
  567. < 1.456 >
  568. echo abs(-5.456)
  569. < 5.456 >
  570. echo abs(-4)
  571. < 4
  572. Can also be used as a |method|: >
  573. Compute()->abs()
  574. acos({expr}) *acos()*
  575. Return the arc cosine of {expr} measured in radians, as a
  576. |Float| in the range of [0, pi].
  577. {expr} must evaluate to a |Float| or a |Number| in the range
  578. [-1, 1].
  579. Returns NaN if {expr} is outside the range [-1, 1]. Returns
  580. 0.0 if {expr} is not a |Float| or a |Number|.
  581. Examples: >
  582. :echo acos(0)
  583. < 1.570796 >
  584. :echo acos(-0.5)
  585. < 2.094395
  586. Can also be used as a |method|: >
  587. Compute()->acos()
  588. add({object}, {expr}) *add()*
  589. Append the item {expr} to |List| or |Blob| {object}. Returns
  590. the resulting |List| or |Blob|. Examples: >
  591. :let alist = add([1, 2, 3], item)
  592. :call add(mylist, "woodstock")
  593. < Note that when {expr} is a |List| it is appended as a single
  594. item. Use |extend()| to concatenate |Lists|.
  595. When {object} is a |Blob| then {expr} must be a number.
  596. Use |insert()| to add an item at another position.
  597. Returns 1 if {object} is not a |List| or a |Blob|.
  598. Can also be used as a |method|: >
  599. mylist->add(val1)->add(val2)
  600. and({expr}, {expr}) *and()*
  601. Bitwise AND on the two arguments. The arguments are converted
  602. to a number. A List, Dict or Float argument causes an error.
  603. Example: >
  604. :let flag = and(bits, 0x80)
  605. < Can also be used as a |method|: >
  606. :let flag = bits->and(0x80)
  607. api_info() *api_info()*
  608. Returns Dictionary of |api-metadata|.
  609. View it in a nice human-readable format: >
  610. :lua print(vim.inspect(vim.fn.api_info()))
  611. append({lnum}, {text}) *append()*
  612. When {text} is a |List|: Append each item of the |List| as a
  613. text line below line {lnum} in the current buffer.
  614. Otherwise append {text} as one text line below line {lnum} in
  615. the current buffer.
  616. {lnum} can be zero to insert a line before the first one.
  617. {lnum} is used like with |getline()|.
  618. Returns 1 for failure ({lnum} out of range or out of memory),
  619. 0 for success. Example: >
  620. :let failed = append(line('$'), "# THE END")
  621. :let failed = append(0, ["Chapter 1", "the beginning"])
  622. < Can also be used as a |method| after a List: >
  623. mylist->append(lnum)
  624. appendbufline({buf}, {lnum}, {text}) *appendbufline()*
  625. Like |append()| but append the text in buffer {expr}.
  626. This function works only for loaded buffers. First call
  627. |bufload()| if needed.
  628. For the use of {buf}, see |bufname()|.
  629. {lnum} is used like with |append()|. Note that using |line()|
  630. would use the current buffer, not the one appending to.
  631. Use "$" to append at the end of the buffer.
  632. On success 0 is returned, on failure 1 is returned.
  633. If {buf} is not a valid buffer or {lnum} is not valid, an
  634. error message is given. Example: >
  635. :let failed = appendbufline(13, 0, "# THE START")
  636. <
  637. Can also be used as a |method| after a List: >
  638. mylist->appendbufline(buf, lnum)
  639. argc([{winid}]) *argc()*
  640. The result is the number of files in the argument list. See
  641. |arglist|.
  642. If {winid} is not supplied, the argument list of the current
  643. window is used.
  644. If {winid} is -1, the global argument list is used.
  645. Otherwise {winid} specifies the window of which the argument
  646. list is used: either the window number or the window ID.
  647. Returns -1 if the {winid} argument is invalid.
  648. *argidx()*
  649. argidx() The result is the current index in the argument list. 0 is
  650. the first file. argc() - 1 is the last one. See |arglist|.
  651. *arglistid()*
  652. arglistid([{winnr} [, {tabnr}]])
  653. Return the argument list ID. This is a number which
  654. identifies the argument list being used. Zero is used for the
  655. global argument list. See |arglist|.
  656. Returns -1 if the arguments are invalid.
  657. Without arguments use the current window.
  658. With {winnr} only use this window in the current tab page.
  659. With {winnr} and {tabnr} use the window in the specified tab
  660. page.
  661. {winnr} can be the window number or the |window-ID|.
  662. *argv()*
  663. argv([{nr} [, {winid}]])
  664. The result is the {nr}th file in the argument list. See
  665. |arglist|. "argv(0)" is the first one. Example: >
  666. :let i = 0
  667. :while i < argc()
  668. : let f = escape(fnameescape(argv(i)), '.')
  669. : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
  670. : let i = i + 1
  671. :endwhile
  672. < Without the {nr} argument, or when {nr} is -1, a |List| with
  673. the whole |arglist| is returned.
  674. The {winid} argument specifies the window ID, see |argc()|.
  675. For the Vim command line arguments see |v:argv|.
  676. Returns an empty string if {nr}th argument is not present in
  677. the argument list. Returns an empty List if the {winid}
  678. argument is invalid.
  679. asin({expr}) *asin()*
  680. Return the arc sine of {expr} measured in radians, as a |Float|
  681. in the range of [-pi/2, pi/2].
  682. {expr} must evaluate to a |Float| or a |Number| in the range
  683. [-1, 1].
  684. Returns NaN if {expr} is outside the range [-1, 1]. Returns
  685. 0.0 if {expr} is not a |Float| or a |Number|.
  686. Examples: >
  687. :echo asin(0.8)
  688. < 0.927295 >
  689. :echo asin(-0.5)
  690. < -0.523599
  691. Can also be used as a |method|: >
  692. Compute()->asin()
  693. assert_ functions are documented here: |assert-functions-details|
  694. atan({expr}) *atan()*
  695. Return the principal value of the arc tangent of {expr}, in
  696. the range [-pi/2, +pi/2] radians, as a |Float|.
  697. {expr} must evaluate to a |Float| or a |Number|.
  698. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  699. Examples: >
  700. :echo atan(100)
  701. < 1.560797 >
  702. :echo atan(-4.01)
  703. < -1.326405
  704. Can also be used as a |method|: >
  705. Compute()->atan()
  706. atan2({expr1}, {expr2}) *atan2()*
  707. Return the arc tangent of {expr1} / {expr2}, measured in
  708. radians, as a |Float| in the range [-pi, pi].
  709. {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  710. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  711. |Number|.
  712. Examples: >
  713. :echo atan2(-1, 1)
  714. < -0.785398 >
  715. :echo atan2(1, -1)
  716. < 2.356194
  717. Can also be used as a |method|: >
  718. Compute()->atan2(1)
  719. *browse()*
  720. browse({save}, {title}, {initdir}, {default})
  721. Put up a file requester. This only works when "has("browse")"
  722. returns |TRUE| (only in some GUI versions).
  723. The input fields are:
  724. {save} when |TRUE|, select file to write
  725. {title} title for the requester
  726. {initdir} directory to start browsing in
  727. {default} default file name
  728. An empty string is returned when the "Cancel" button is hit,
  729. something went wrong, or browsing is not possible.
  730. *browsedir()*
  731. browsedir({title}, {initdir})
  732. Put up a directory requester. This only works when
  733. "has("browse")" returns |TRUE| (only in some GUI versions).
  734. On systems where a directory browser is not supported a file
  735. browser is used. In that case: select a file in the directory
  736. to be used.
  737. The input fields are:
  738. {title} title for the requester
  739. {initdir} directory to start browsing in
  740. When the "Cancel" button is hit, something went wrong, or
  741. browsing is not possible, an empty string is returned.
  742. bufadd({name}) *bufadd()*
  743. Add a buffer to the buffer list with name {name} (must be a
  744. String).
  745. If a buffer for file {name} already exists, return that buffer
  746. number. Otherwise return the buffer number of the newly
  747. created buffer. When {name} is an empty string then a new
  748. buffer is always created.
  749. The buffer will not have 'buflisted' set and not be loaded
  750. yet. To add some text to the buffer use this: >
  751. let bufnr = bufadd('someName')
  752. call bufload(bufnr)
  753. call setbufline(bufnr, 1, ['some', 'text'])
  754. < Returns 0 on error.
  755. Can also be used as a |method|: >
  756. let bufnr = 'somename'->bufadd()
  757. bufexists({buf}) *bufexists()*
  758. The result is a Number, which is |TRUE| if a buffer called
  759. {buf} exists.
  760. If the {buf} argument is a number, buffer numbers are used.
  761. Number zero is the alternate buffer for the current window.
  762. If the {buf} argument is a string it must match a buffer name
  763. exactly. The name can be:
  764. - Relative to the current directory.
  765. - A full path.
  766. - The name of a buffer with 'buftype' set to "nofile".
  767. - A URL name.
  768. Unlisted buffers will be found.
  769. Note that help files are listed by their short name in the
  770. output of |:buffers|, but bufexists() requires using their
  771. long name to be able to find them.
  772. bufexists() may report a buffer exists, but to use the name
  773. with a |:buffer| command you may need to use |expand()|. Esp
  774. for MS-Windows 8.3 names in the form "c:\DOCUME~1"
  775. Use "bufexists(0)" to test for the existence of an alternate
  776. file name.
  777. Can also be used as a |method|: >
  778. let exists = 'somename'->bufexists()
  779. buflisted({buf}) *buflisted()*
  780. The result is a Number, which is |TRUE| if a buffer called
  781. {buf} exists and is listed (has the 'buflisted' option set).
  782. The {buf} argument is used like with |bufexists()|.
  783. Can also be used as a |method|: >
  784. let listed = 'somename'->buflisted()
  785. bufload({buf}) *bufload()*
  786. Ensure the buffer {buf} is loaded. When the buffer name
  787. refers to an existing file then the file is read. Otherwise
  788. the buffer will be empty. If the buffer was already loaded
  789. then there is no change. If the buffer is not related to a
  790. file the no file is read (e.g., when 'buftype' is "nofile").
  791. If there is an existing swap file for the file of the buffer,
  792. there will be no dialog, the buffer will be loaded anyway.
  793. The {buf} argument is used like with |bufexists()|.
  794. Can also be used as a |method|: >
  795. eval 'somename'->bufload()
  796. bufloaded({buf}) *bufloaded()*
  797. The result is a Number, which is |TRUE| if a buffer called
  798. {buf} exists and is loaded (shown in a window or hidden).
  799. The {buf} argument is used like with |bufexists()|.
  800. Can also be used as a |method|: >
  801. let loaded = 'somename'->bufloaded()
  802. bufname([{buf}]) *bufname()*
  803. The result is the name of a buffer. Mostly as it is displayed
  804. by the `:ls` command, but not using special names such as
  805. "[No Name]".
  806. If {buf} is omitted the current buffer is used.
  807. If {buf} is a Number, that buffer number's name is given.
  808. Number zero is the alternate buffer for the current window.
  809. If {buf} is a String, it is used as a |file-pattern| to match
  810. with the buffer names. This is always done like 'magic' is
  811. set and 'cpoptions' is empty. When there is more than one
  812. match an empty string is returned.
  813. "" or "%" can be used for the current buffer, "#" for the
  814. alternate buffer.
  815. A full match is preferred, otherwise a match at the start, end
  816. or middle of the buffer name is accepted. If you only want a
  817. full match then put "^" at the start and "$" at the end of the
  818. pattern.
  819. Listed buffers are found first. If there is a single match
  820. with a listed buffer, that one is returned. Next unlisted
  821. buffers are searched for.
  822. If the {buf} is a String, but you want to use it as a buffer
  823. number, force it to be a Number by adding zero to it: >
  824. :echo bufname("3" + 0)
  825. < Can also be used as a |method|: >
  826. echo bufnr->bufname()
  827. < If the buffer doesn't exist, or doesn't have a name, an empty
  828. string is returned. >
  829. bufname("#") alternate buffer name
  830. bufname(3) name of buffer 3
  831. bufname("%") name of current buffer
  832. bufname("file2") name of buffer where "file2" matches.
  833. <
  834. *bufnr()*
  835. bufnr([{buf} [, {create}]])
  836. The result is the number of a buffer, as it is displayed by
  837. the `:ls` command. For the use of {buf}, see |bufname()|
  838. above.
  839. If the buffer doesn't exist, -1 is returned. Or, if the
  840. {create} argument is present and TRUE, a new, unlisted,
  841. buffer is created and its number is returned.
  842. bufnr("$") is the last buffer: >
  843. :let last_buffer = bufnr("$")
  844. < The result is a Number, which is the highest buffer number
  845. of existing buffers. Note that not all buffers with a smaller
  846. number necessarily exist, because ":bwipeout" may have removed
  847. them. Use bufexists() to test for the existence of a buffer.
  848. Can also be used as a |method|: >
  849. echo bufref->bufnr()
  850. bufwinid({buf}) *bufwinid()*
  851. The result is a Number, which is the |window-ID| of the first
  852. window associated with buffer {buf}. For the use of {buf},
  853. see |bufname()| above. If buffer {buf} doesn't exist or
  854. there is no such window, -1 is returned. Example: >
  855. echo "A window containing buffer 1 is " .. (bufwinid(1))
  856. <
  857. Only deals with the current tab page.
  858. Can also be used as a |method|: >
  859. FindBuffer()->bufwinid()
  860. bufwinnr({buf}) *bufwinnr()*
  861. Like |bufwinid()| but return the window number instead of the
  862. |window-ID|.
  863. If buffer {buf} doesn't exist or there is no such window, -1
  864. is returned. Example: >
  865. echo "A window containing buffer 1 is " .. (bufwinnr(1))
  866. < The number can be used with |CTRL-W_w| and ":wincmd w"
  867. |:wincmd|.
  868. Can also be used as a |method|: >
  869. FindBuffer()->bufwinnr()
  870. byte2line({byte}) *byte2line()*
  871. Return the line number that contains the character at byte
  872. count {byte} in the current buffer. This includes the
  873. end-of-line character, depending on the 'fileformat' option
  874. for the current buffer. The first character has byte count
  875. one.
  876. Also see |line2byte()|, |go| and |:goto|.
  877. Returns -1 if the {byte} value is invalid.
  878. Can also be used as a |method|: >
  879. GetOffset()->byte2line()
  880. byteidx({expr}, {nr}) *byteidx()*
  881. Return byte index of the {nr}'th character in the String
  882. {expr}. Use zero for the first character, it then returns
  883. zero.
  884. If there are no multibyte characters the returned value is
  885. equal to {nr}.
  886. Composing characters are not counted separately, their byte
  887. length is added to the preceding base character. See
  888. |byteidxcomp()| below for counting composing characters
  889. separately.
  890. Example : >
  891. echo matchstr(str, ".", byteidx(str, 3))
  892. < will display the fourth character. Another way to do the
  893. same: >
  894. let s = strpart(str, byteidx(str, 3))
  895. echo strpart(s, 0, byteidx(s, 1))
  896. < Also see |strgetchar()| and |strcharpart()|.
  897. If there are less than {nr} characters -1 is returned.
  898. If there are exactly {nr} characters the length of the string
  899. in bytes is returned.
  900. Can also be used as a |method|: >
  901. GetName()->byteidx(idx)
  902. byteidxcomp({expr}, {nr}) *byteidxcomp()*
  903. Like byteidx(), except that a composing character is counted
  904. as a separate character. Example: >
  905. let s = 'e' .. nr2char(0x301)
  906. echo byteidx(s, 1)
  907. echo byteidxcomp(s, 1)
  908. echo byteidxcomp(s, 2)
  909. < The first and third echo result in 3 ('e' plus composing
  910. character is 3 bytes), the second echo results in 1 ('e' is
  911. one byte).
  912. Can also be used as a |method|: >
  913. GetName()->byteidxcomp(idx)
  914. call({func}, {arglist} [, {dict}]) *call()* *E699*
  915. Call function {func} with the items in |List| {arglist} as
  916. arguments.
  917. {func} can either be a |Funcref| or the name of a function.
  918. a:firstline and a:lastline are set to the cursor line.
  919. Returns the return value of the called function.
  920. {dict} is for functions with the "dict" attribute. It will be
  921. used to set the local variable "self". |Dictionary-function|
  922. Can also be used as a |method|: >
  923. GetFunc()->call([arg, arg], dict)
  924. ceil({expr}) *ceil()*
  925. Return the smallest integral value greater than or equal to
  926. {expr} as a |Float| (round up).
  927. {expr} must evaluate to a |Float| or a |Number|.
  928. Examples: >
  929. echo ceil(1.456)
  930. < 2.0 >
  931. echo ceil(-5.456)
  932. < -5.0 >
  933. echo ceil(4.0)
  934. < 4.0
  935. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  936. Can also be used as a |method|: >
  937. Compute()->ceil()
  938. changenr() *changenr()*
  939. Return the number of the most recent change. This is the same
  940. number as what is displayed with |:undolist| and can be used
  941. with the |:undo| command.
  942. When a change was made it is the number of that change. After
  943. redo it is the number of the redone change. After undo it is
  944. one less than the number of the undone change.
  945. Returns 0 if the undo list is empty.
  946. chanclose({id} [, {stream}]) *chanclose()*
  947. Close a channel or a specific stream associated with it.
  948. For a job, {stream} can be one of "stdin", "stdout",
  949. "stderr" or "rpc" (closes stdin/stdout for a job started
  950. with `"rpc":v:true`) If {stream} is omitted, all streams
  951. are closed. If the channel is a pty, this will then close the
  952. pty master, sending SIGHUP to the job process.
  953. For a socket, there is only one stream, and {stream} should be
  954. omitted.
  955. chansend({id}, {data}) *chansend()*
  956. Send data to channel {id}. For a job, it writes it to the
  957. stdin of the process. For the stdio channel |channel-stdio|,
  958. it writes to Nvim's stdout. Returns the number of bytes
  959. written if the write succeeded, 0 otherwise.
  960. See |channel-bytes| for more information.
  961. {data} may be a string, string convertible, |Blob|, or a list.
  962. If {data} is a list, the items will be joined by newlines; any
  963. newlines in an item will be sent as NUL. To send a final
  964. newline, include a final empty string. Example: >
  965. :call chansend(id, ["abc", "123\n456", ""])
  966. < will send "abc<NL>123<NUL>456<NL>".
  967. chansend() writes raw data, not RPC messages. If the channel
  968. was created with `"rpc":v:true` then the channel expects RPC
  969. messages, use |rpcnotify()| and |rpcrequest()| instead.
  970. char2nr({string} [, {utf8}]) *char2nr()*
  971. Return Number value of the first char in {string}.
  972. Examples: >
  973. char2nr(" ") returns 32
  974. char2nr("ABC") returns 65
  975. char2nr("á") returns 225
  976. char2nr("á"[0]) returns 195
  977. char2nr("\<M-x>") returns 128
  978. < Non-ASCII characters are always treated as UTF-8 characters.
  979. {utf8} is ignored, it exists only for backwards-compatibility.
  980. A combining character is a separate character.
  981. |nr2char()| does the opposite.
  982. Returns 0 if {string} is not a |String|.
  983. Can also be used as a |method|: >
  984. GetChar()->char2nr()
  985. charclass({string}) *charclass()*
  986. Return the character class of the first character in {string}.
  987. The character class is one of:
  988. 0 blank
  989. 1 punctuation
  990. 2 word character
  991. 3 emoji
  992. other specific Unicode class
  993. The class is used in patterns and word motions.
  994. Returns 0 if {string} is not a |String|.
  995. *charcol()*
  996. charcol({expr}) Same as |col()| but returns the character index of the column
  997. position given with {expr} instead of the byte position.
  998. Example:
  999. With the cursor on '세' in line 5 with text "여보세요": >
  1000. charcol('.') returns 3
  1001. col('.') returns 7
  1002. < Can also be used as a |method|: >
  1003. GetPos()->col()
  1004. <
  1005. *charidx()*
  1006. charidx({string}, {idx} [, {countcc}])
  1007. Return the character index of the byte at {idx} in {string}.
  1008. The index of the first character is zero.
  1009. If there are no multibyte characters the returned value is
  1010. equal to {idx}.
  1011. When {countcc} is omitted or |FALSE|, then composing characters
  1012. are not counted separately, their byte length is
  1013. added to the preceding base character.
  1014. When {countcc} is |TRUE|, then composing characters are
  1015. counted as separate characters.
  1016. Returns -1 if the arguments are invalid or if {idx} is greater
  1017. than the index of the last byte in {string}. An error is
  1018. given if the first argument is not a string, the second
  1019. argument is not a number or when the third argument is present
  1020. and is not zero or one.
  1021. See |byteidx()| and |byteidxcomp()| for getting the byte index
  1022. from the character index.
  1023. Examples: >
  1024. echo charidx('áb́ć', 3) returns 1
  1025. echo charidx('áb́ć', 6, 1) returns 4
  1026. echo charidx('áb́ć', 16) returns -1
  1027. <
  1028. Can also be used as a |method|: >
  1029. GetName()->charidx(idx)
  1030. chdir({dir}) *chdir()*
  1031. Change the current working directory to {dir}. The scope of
  1032. the directory change depends on the directory of the current
  1033. window:
  1034. - If the current window has a window-local directory
  1035. (|:lcd|), then changes the window local directory.
  1036. - Otherwise, if the current tabpage has a local
  1037. directory (|:tcd|) then changes the tabpage local
  1038. directory.
  1039. - Otherwise, changes the global directory.
  1040. {dir} must be a String.
  1041. If successful, returns the previous working directory. Pass
  1042. this to another chdir() to restore the directory.
  1043. On failure, returns an empty string.
  1044. Example: >
  1045. let save_dir = chdir(newdir)
  1046. if save_dir != ""
  1047. " ... do some work
  1048. call chdir(save_dir)
  1049. endif
  1050. < Can also be used as a |method|: >
  1051. GetDir()->chdir()
  1052. <
  1053. cindent({lnum}) *cindent()*
  1054. Get the amount of indent for line {lnum} according the C
  1055. indenting rules, as with 'cindent'.
  1056. The indent is counted in spaces, the value of 'tabstop' is
  1057. relevant. {lnum} is used just like in |getline()|.
  1058. When {lnum} is invalid -1 is returned.
  1059. See |C-indenting|.
  1060. Can also be used as a |method|: >
  1061. GetLnum()->cindent()
  1062. clearmatches([{win}]) *clearmatches()*
  1063. Clears all matches previously defined for the current window
  1064. by |matchadd()| and the |:match| commands.
  1065. If {win} is specified, use the window with this number or
  1066. window ID instead of the current window.
  1067. Can also be used as a |method|: >
  1068. GetWin()->clearmatches()
  1069. <
  1070. *col()*
  1071. col({expr}) The result is a Number, which is the byte index of the column
  1072. position given with {expr}. The accepted positions are:
  1073. . the cursor position
  1074. $ the end of the cursor line (the result is the
  1075. number of bytes in the cursor line plus one)
  1076. 'x position of mark x (if the mark is not set, 0 is
  1077. returned)
  1078. v In Visual mode: the start of the Visual area (the
  1079. cursor is the end). When not in Visual mode
  1080. returns the cursor position. Differs from |'<| in
  1081. that it's updated right away.
  1082. Additionally {expr} can be [lnum, col]: a |List| with the line
  1083. and column number. Most useful when the column is "$", to get
  1084. the last column of a specific line. When "lnum" or "col" is
  1085. out of range then col() returns zero.
  1086. To get the line number use |line()|. To get both use
  1087. |getpos()|.
  1088. For the screen column position use |virtcol()|. For the
  1089. character position use |charcol()|.
  1090. Note that only marks in the current file can be used.
  1091. Examples: >
  1092. col(".") column of cursor
  1093. col("$") length of cursor line plus one
  1094. col("'t") column of mark t
  1095. col("'" .. markname) column of mark markname
  1096. < The first column is 1. Returns 0 if {expr} is invalid.
  1097. For an uppercase mark the column may actually be in another
  1098. buffer.
  1099. For the cursor position, when 'virtualedit' is active, the
  1100. column is one higher if the cursor is after the end of the
  1101. line. This can be used to obtain the column in Insert mode: >
  1102. :imap <F2> <C-O>:let save_ve = &ve<CR>
  1103. \<C-O>:set ve=all<CR>
  1104. \<C-O>:echo col(".") .. "\n" <Bar>
  1105. \let &ve = save_ve<CR>
  1106. < Can also be used as a |method|: >
  1107. GetPos()->col()
  1108. <
  1109. complete({startcol}, {matches}) *complete()* *E785*
  1110. Set the matches for Insert mode completion.
  1111. Can only be used in Insert mode. You need to use a mapping
  1112. with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O
  1113. or with an expression mapping.
  1114. {startcol} is the byte offset in the line where the completed
  1115. text start. The text up to the cursor is the original text
  1116. that will be replaced by the matches. Use col('.') for an
  1117. empty string. "col('.') - 1" will replace one character by a
  1118. match.
  1119. {matches} must be a |List|. Each |List| item is one match.
  1120. See |complete-items| for the kind of items that are possible.
  1121. "longest" in 'completeopt' is ignored.
  1122. Note that the after calling this function you need to avoid
  1123. inserting anything that would cause completion to stop.
  1124. The match can be selected with CTRL-N and CTRL-P as usual with
  1125. Insert mode completion. The popup menu will appear if
  1126. specified, see |ins-completion-menu|.
  1127. Example: >
  1128. inoremap <F5> <C-R>=ListMonths()<CR>
  1129. func! ListMonths()
  1130. call complete(col('.'), ['January', 'February', 'March',
  1131. \ 'April', 'May', 'June', 'July', 'August', 'September',
  1132. \ 'October', 'November', 'December'])
  1133. return ''
  1134. endfunc
  1135. < This isn't very useful, but it shows how it works. Note that
  1136. an empty string is returned to avoid a zero being inserted.
  1137. Can also be used as a |method|, the base is passed as the
  1138. second argument: >
  1139. GetMatches()->complete(col('.'))
  1140. complete_add({expr}) *complete_add()*
  1141. Add {expr} to the list of matches. Only to be used by the
  1142. function specified with the 'completefunc' option.
  1143. Returns 0 for failure (empty string or out of memory),
  1144. 1 when the match was added, 2 when the match was already in
  1145. the list.
  1146. See |complete-functions| for an explanation of {expr}. It is
  1147. the same as one item in the list that 'omnifunc' would return.
  1148. Can also be used as a |method|: >
  1149. GetMoreMatches()->complete_add()
  1150. complete_check() *complete_check()*
  1151. Check for a key typed while looking for completion matches.
  1152. This is to be used when looking for matches takes some time.
  1153. Returns |TRUE| when searching for matches is to be aborted,
  1154. zero otherwise.
  1155. Only to be used by the function specified with the
  1156. 'completefunc' option.
  1157. complete_info([{what}]) *complete_info()*
  1158. Returns a |Dictionary| with information about Insert mode
  1159. completion. See |ins-completion|.
  1160. The items are:
  1161. mode Current completion mode name string.
  1162. See |complete_info_mode| for the values.
  1163. pum_visible |TRUE| if popup menu is visible.
  1164. See |pumvisible()|.
  1165. items List of completion matches. Each item is a
  1166. dictionary containing the entries "word",
  1167. "abbr", "menu", "kind", "info" and "user_data".
  1168. See |complete-items|.
  1169. selected Selected item index. First index is zero.
  1170. Index is -1 if no item is selected (showing
  1171. typed text only, or the last completion after
  1172. no item is selected when using the <Up> or
  1173. <Down> keys)
  1174. inserted Inserted string. [NOT IMPLEMENTED YET]
  1175. *complete_info_mode*
  1176. mode values are:
  1177. "" Not in completion mode
  1178. "keyword" Keyword completion |i_CTRL-X_CTRL-N|
  1179. "ctrl_x" Just pressed CTRL-X |i_CTRL-X|
  1180. "scroll" Scrolling with |i_CTRL-X_CTRL-E| or
  1181. |i_CTRL-X_CTRL-Y|
  1182. "whole_line" Whole lines |i_CTRL-X_CTRL-L|
  1183. "files" File names |i_CTRL-X_CTRL-F|
  1184. "tags" Tags |i_CTRL-X_CTRL-]|
  1185. "path_defines" Definition completion |i_CTRL-X_CTRL-D|
  1186. "path_patterns" Include completion |i_CTRL-X_CTRL-I|
  1187. "dictionary" Dictionary |i_CTRL-X_CTRL-K|
  1188. "thesaurus" Thesaurus |i_CTRL-X_CTRL-T|
  1189. "cmdline" Vim Command line |i_CTRL-X_CTRL-V|
  1190. "function" User defined completion |i_CTRL-X_CTRL-U|
  1191. "omni" Omni completion |i_CTRL-X_CTRL-O|
  1192. "spell" Spelling suggestions |i_CTRL-X_s|
  1193. "eval" |complete()| completion
  1194. "unknown" Other internal modes
  1195. If the optional {what} list argument is supplied, then only
  1196. the items listed in {what} are returned. Unsupported items in
  1197. {what} are silently ignored.
  1198. To get the position and size of the popup menu, see
  1199. |pum_getpos()|. It's also available in |v:event| during the
  1200. |CompleteChanged| event.
  1201. Returns an empty |Dictionary| on error.
  1202. Examples: >
  1203. " Get all items
  1204. call complete_info()
  1205. " Get only 'mode'
  1206. call complete_info(['mode'])
  1207. " Get only 'mode' and 'pum_visible'
  1208. call complete_info(['mode', 'pum_visible'])
  1209. < Can also be used as a |method|: >
  1210. GetItems()->complete_info()
  1211. <
  1212. *confirm()*
  1213. confirm({msg} [, {choices} [, {default} [, {type}]]])
  1214. confirm() offers the user a dialog, from which a choice can be
  1215. made. It returns the number of the choice. For the first
  1216. choice this is 1.
  1217. {msg} is displayed in a dialog with {choices} as the
  1218. alternatives. When {choices} is missing or empty, "&OK" is
  1219. used (and translated).
  1220. {msg} is a String, use '\n' to include a newline. Only on
  1221. some systems the string is wrapped when it doesn't fit.
  1222. {choices} is a String, with the individual choices separated
  1223. by '\n', e.g. >
  1224. confirm("Save changes?", "&Yes\n&No\n&Cancel")
  1225. < The letter after the '&' is the shortcut key for that choice.
  1226. Thus you can type 'c' to select "Cancel". The shortcut does
  1227. not need to be the first letter: >
  1228. confirm("file has been modified", "&Save\nSave &All")
  1229. < For the console, the first letter of each choice is used as
  1230. the default shortcut key. Case is ignored.
  1231. The optional {type} String argument gives the type of dialog.
  1232. It can be one of these values: "Error", "Question", "Info",
  1233. "Warning" or "Generic". Only the first character is relevant.
  1234. When {type} is omitted, "Generic" is used.
  1235. The optional {type} argument gives the type of dialog. This
  1236. is only used for the icon of the Win32 GUI. It can be one of
  1237. these values: "Error", "Question", "Info", "Warning" or
  1238. "Generic". Only the first character is relevant.
  1239. When {type} is omitted, "Generic" is used.
  1240. If the user aborts the dialog by pressing <Esc>, CTRL-C,
  1241. or another valid interrupt key, confirm() returns 0.
  1242. An example: >
  1243. let choice = confirm("What do you want?",
  1244. \ "&Apples\n&Oranges\n&Bananas", 2)
  1245. if choice == 0
  1246. echo "make up your mind!"
  1247. elseif choice == 3
  1248. echo "tasteful"
  1249. else
  1250. echo "I prefer bananas myself."
  1251. endif
  1252. < In a GUI dialog, buttons are used. The layout of the buttons
  1253. depends on the 'v' flag in 'guioptions'. If it is included,
  1254. the buttons are always put vertically. Otherwise, confirm()
  1255. tries to put the buttons in one horizontal line. If they
  1256. don't fit, a vertical layout is used anyway. For some systems
  1257. the horizontal layout is always used.
  1258. Can also be used as a |method|in: >
  1259. BuildMessage()->confirm("&Yes\n&No")
  1260. <
  1261. *copy()*
  1262. copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
  1263. different from using {expr} directly.
  1264. When {expr} is a |List| a shallow copy is created. This means
  1265. that the original |List| can be changed without changing the
  1266. copy, and vice versa. But the items are identical, thus
  1267. changing an item changes the contents of both |Lists|.
  1268. A |Dictionary| is copied in a similar way as a |List|.
  1269. Also see |deepcopy()|.
  1270. Can also be used as a |method|: >
  1271. mylist->copy()
  1272. cos({expr}) *cos()*
  1273. Return the cosine of {expr}, measured in radians, as a |Float|.
  1274. {expr} must evaluate to a |Float| or a |Number|.
  1275. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1276. Examples: >
  1277. :echo cos(100)
  1278. < 0.862319 >
  1279. :echo cos(-4.01)
  1280. < -0.646043
  1281. Can also be used as a |method|: >
  1282. Compute()->cos()
  1283. cosh({expr}) *cosh()*
  1284. Return the hyperbolic cosine of {expr} as a |Float| in the range
  1285. [1, inf].
  1286. {expr} must evaluate to a |Float| or a |Number|.
  1287. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1288. Examples: >
  1289. :echo cosh(0.5)
  1290. < 1.127626 >
  1291. :echo cosh(-0.5)
  1292. < -1.127626
  1293. Can also be used as a |method|: >
  1294. Compute()->cosh()
  1295. count({comp}, {expr} [, {ic} [, {start}]]) *count()*
  1296. Return the number of times an item with value {expr} appears
  1297. in |String|, |List| or |Dictionary| {comp}.
  1298. If {start} is given then start with the item with this index.
  1299. {start} can only be used with a |List|.
  1300. When {ic} is given and it's |TRUE| then case is ignored.
  1301. When {comp} is a string then the number of not overlapping
  1302. occurrences of {expr} is returned. Zero is returned when
  1303. {expr} is an empty string.
  1304. Can also be used as a |method|: >
  1305. mylist->count(val)
  1306. <
  1307. *cscope_connection()*
  1308. cscope_connection([{num} , {dbpath} [, {prepend}]])
  1309. Checks for the existence of a |cscope| connection. If no
  1310. parameters are specified, then the function returns:
  1311. 0, if there are no cscope connections;
  1312. 1, if there is at least one cscope connection.
  1313. If parameters are specified, then the value of {num}
  1314. determines how existence of a cscope connection is checked:
  1315. {num} Description of existence check
  1316. ----- ------------------------------
  1317. 0 Same as no parameters (e.g., "cscope_connection()").
  1318. 1 Ignore {prepend}, and use partial string matches for
  1319. {dbpath}.
  1320. 2 Ignore {prepend}, and use exact string matches for
  1321. {dbpath}.
  1322. 3 Use {prepend}, use partial string matches for both
  1323. {dbpath} and {prepend}.
  1324. 4 Use {prepend}, use exact string matches for both
  1325. {dbpath} and {prepend}.
  1326. Note: All string comparisons are case sensitive!
  1327. Examples. Suppose we had the following (from ":cs show"): >
  1328. # pid database name prepend path
  1329. 0 27664 cscope.out /usr/local
  1330. <
  1331. Invocation Return Val ~
  1332. ---------- ---------- >
  1333. cscope_connection() 1
  1334. cscope_connection(1, "out") 1
  1335. cscope_connection(2, "out") 0
  1336. cscope_connection(3, "out") 0
  1337. cscope_connection(3, "out", "local") 1
  1338. cscope_connection(4, "out") 0
  1339. cscope_connection(4, "out", "local") 0
  1340. cscope_connection(4, "cscope.out", "/usr/local") 1
  1341. <
  1342. ctxget([{index}]) *ctxget()*
  1343. Returns a |Dictionary| representing the |context| at {index}
  1344. from the top of the |context-stack| (see |context-dict|).
  1345. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1346. ctxpop() *ctxpop()*
  1347. Pops and restores the |context| at the top of the
  1348. |context-stack|.
  1349. ctxpush([{types}]) *ctxpush()*
  1350. Pushes the current editor state (|context|) on the
  1351. |context-stack|.
  1352. If {types} is given and is a |List| of |String|s, it specifies
  1353. which |context-types| to include in the pushed context.
  1354. Otherwise, all context types are included.
  1355. ctxset({context} [, {index}]) *ctxset()*
  1356. Sets the |context| at {index} from the top of the
  1357. |context-stack| to that represented by {context}.
  1358. {context} is a Dictionary with context data (|context-dict|).
  1359. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1360. ctxsize() *ctxsize()*
  1361. Returns the size of the |context-stack|.
  1362. cursor({lnum}, {col} [, {off}]) *cursor()*
  1363. cursor({list})
  1364. Positions the cursor at the column (byte count) {col} in the
  1365. line {lnum}. The first column is one.
  1366. When there is one argument {list} this is used as a |List|
  1367. with two, three or four item:
  1368. [{lnum}, {col}]
  1369. [{lnum}, {col}, {off}]
  1370. [{lnum}, {col}, {off}, {curswant}]
  1371. This is like the return value of |getpos()| or |getcurpos()|,
  1372. but without the first item.
  1373. To position the cursor using the character count, use
  1374. |setcursorcharpos()|.
  1375. Does not change the jumplist.
  1376. If {lnum} is greater than the number of lines in the buffer,
  1377. the cursor will be positioned at the last line in the buffer.
  1378. If {lnum} is zero, the cursor will stay in the current line.
  1379. If {col} is greater than the number of bytes in the line,
  1380. the cursor will be positioned at the last character in the
  1381. line.
  1382. If {col} is zero, the cursor will stay in the current column.
  1383. If {curswant} is given it is used to set the preferred column
  1384. for vertical movement. Otherwise {col} is used.
  1385. When 'virtualedit' is used {off} specifies the offset in
  1386. screen columns from the start of the character. E.g., a
  1387. position within a <Tab> or after the last character.
  1388. Returns 0 when the position could be set, -1 otherwise.
  1389. Can also be used as a |method|: >
  1390. GetCursorPos()->cursor()
  1391. debugbreak({pid}) *debugbreak()*
  1392. Specifically used to interrupt a program being debugged. It
  1393. will cause process {pid} to get a SIGTRAP. Behavior for other
  1394. processes is undefined. See |terminal-debug|.
  1395. {Sends a SIGINT to a process {pid} other than MS-Windows}
  1396. Returns |TRUE| if successfully interrupted the program.
  1397. Otherwise returns |FALSE|.
  1398. Can also be used as a |method|: >
  1399. GetPid()->debugbreak()
  1400. deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
  1401. Make a copy of {expr}. For Numbers and Strings this isn't
  1402. different from using {expr} directly.
  1403. When {expr} is a |List| a full copy is created. This means
  1404. that the original |List| can be changed without changing the
  1405. copy, and vice versa. When an item is a |List|, a copy for it
  1406. is made, recursively. Thus changing an item in the copy does
  1407. not change the contents of the original |List|.
  1408. When {noref} is omitted or zero a contained |List| or
  1409. |Dictionary| is only copied once. All references point to
  1410. this single copy. With {noref} set to 1 every occurrence of a
  1411. |List| or |Dictionary| results in a new copy. This also means
  1412. that a cyclic reference causes deepcopy() to fail.
  1413. *E724*
  1414. Nesting is possible up to 100 levels. When there is an item
  1415. that refers back to a higher level making a deep copy with
  1416. {noref} set to 1 will fail.
  1417. Also see |copy()|.
  1418. Can also be used as a |method|: >
  1419. GetObject()->deepcopy()
  1420. delete({fname} [, {flags}]) *delete()*
  1421. Without {flags} or with {flags} empty: Deletes the file by the
  1422. name {fname}.
  1423. This also works when {fname} is a symbolic link. The symbolic
  1424. link itself is deleted, not what it points to.
  1425. When {flags} is "d": Deletes the directory by the name
  1426. {fname}. This fails when directory {fname} is not empty.
  1427. When {flags} is "rf": Deletes the directory by the name
  1428. {fname} and everything in it, recursively. BE CAREFUL!
  1429. Note: on MS-Windows it is not possible to delete a directory
  1430. that is being used.
  1431. The result is a Number, which is 0/false if the delete
  1432. operation was successful and -1/true when the deletion failed
  1433. or partly failed.
  1434. Can also be used as a |method|: >
  1435. GetName()->delete()
  1436. deletebufline({buf}, {first} [, {last}]) *deletebufline()*
  1437. Delete lines {first} to {last} (inclusive) from buffer {buf}.
  1438. If {last} is omitted then delete line {first} only.
  1439. On success 0 is returned, on failure 1 is returned.
  1440. This function works only for loaded buffers. First call
  1441. |bufload()| if needed.
  1442. For the use of {buf}, see |bufname()| above.
  1443. {first} and {last} are used like with |getline()|. Note that
  1444. when using |line()| this refers to the current buffer. Use "$"
  1445. to refer to the last line in buffer {buf}.
  1446. Can also be used as a |method|: >
  1447. GetBuffer()->deletebufline(1)
  1448. <
  1449. dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
  1450. Adds a watcher to a dictionary. A dictionary watcher is
  1451. identified by three components:
  1452. - A dictionary({dict});
  1453. - A key pattern({pattern}).
  1454. - A function({callback}).
  1455. After this is called, every change on {dict} and on keys
  1456. matching {pattern} will result in {callback} being invoked.
  1457. For example, to watch all global variables: >
  1458. silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
  1459. function! OnDictChanged(d,k,z)
  1460. echomsg string(a:k) string(a:z)
  1461. endfunction
  1462. call dictwatcheradd(g:, '*', 'OnDictChanged')
  1463. <
  1464. For now {pattern} only accepts very simple patterns that can
  1465. contain a '*' at the end of the string, in which case it will
  1466. match every key that begins with the substring before the '*'.
  1467. That means if '*' is not the last character of {pattern}, only
  1468. keys that are exactly equal as {pattern} will be matched.
  1469. The {callback} receives three arguments:
  1470. - The dictionary being watched.
  1471. - The key which changed.
  1472. - A dictionary containing the new and old values for the key.
  1473. The type of change can be determined by examining the keys
  1474. present on the third argument:
  1475. - If contains both `old` and `new`, the key was updated.
  1476. - If it contains only `new`, the key was added.
  1477. - If it contains only `old`, the key was deleted.
  1478. This function can be used by plugins to implement options with
  1479. validation and parsing logic.
  1480. dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()*
  1481. Removes a watcher added with |dictwatcheradd()|. All three
  1482. arguments must match the ones passed to |dictwatcheradd()| in
  1483. order for the watcher to be successfully deleted.
  1484. *did_filetype()*
  1485. did_filetype() Returns |TRUE| when autocommands are being executed and the
  1486. FileType event has been triggered at least once. Can be used
  1487. to avoid triggering the FileType event again in the scripts
  1488. that detect the file type. |FileType|
  1489. Returns |FALSE| when `:setf FALLBACK` was used.
  1490. When editing another file, the counter is reset, thus this
  1491. really checks if the FileType event has been triggered for the
  1492. current buffer. This allows an autocommand that starts
  1493. editing another buffer to set 'filetype' and load a syntax
  1494. file.
  1495. diff_filler({lnum}) *diff_filler()*
  1496. Returns the number of filler lines above line {lnum}.
  1497. These are the lines that were inserted at this point in
  1498. another diff'ed window. These filler lines are shown in the
  1499. display but don't exist in the buffer.
  1500. {lnum} is used like with |getline()|. Thus "." is the current
  1501. line, "'m" mark m, etc.
  1502. Returns 0 if the current window is not in diff mode.
  1503. Can also be used as a |method|: >
  1504. GetLnum()->diff_filler()
  1505. diff_hlID({lnum}, {col}) *diff_hlID()*
  1506. Returns the highlight ID for diff mode at line {lnum} column
  1507. {col} (byte index). When the current line does not have a
  1508. diff change zero is returned.
  1509. {lnum} is used like with |getline()|. Thus "." is the current
  1510. line, "'m" mark m, etc.
  1511. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  1512. line.
  1513. The highlight ID can be used with |synIDattr()| to obtain
  1514. syntax information about the highlighting.
  1515. Can also be used as a |method|: >
  1516. GetLnum()->diff_hlID(col)
  1517. <
  1518. digraph_get({chars}) *digraph_get()* *E1214*
  1519. Return the digraph of {chars}. This should be a string with
  1520. exactly two characters. If {chars} are not just two
  1521. characters, or the digraph of {chars} does not exist, an error
  1522. is given and an empty string is returned.
  1523. Also see |digraph_getlist()|.
  1524. Examples: >
  1525. " Get a built-in digraph
  1526. :echo digraph_get('00') " Returns '∞'
  1527. " Get a user-defined digraph
  1528. :call digraph_set('aa', 'あ')
  1529. :echo digraph_get('aa') " Returns 'あ'
  1530. <
  1531. Can also be used as a |method|: >
  1532. GetChars()->digraph_get()
  1533. <
  1534. digraph_getlist([{listall}]) *digraph_getlist()*
  1535. Return a list of digraphs. If the {listall} argument is given
  1536. and it is TRUE, return all digraphs, including the default
  1537. digraphs. Otherwise, return only user-defined digraphs.
  1538. Also see |digraph_get()|.
  1539. Examples: >
  1540. " Get user-defined digraphs
  1541. :echo digraph_getlist()
  1542. " Get all the digraphs, including default digraphs
  1543. :echo digraph_getlist(1)
  1544. <
  1545. Can also be used as a |method|: >
  1546. GetNumber()->digraph_getlist()
  1547. <
  1548. digraph_set({chars}, {digraph}) *digraph_set()*
  1549. Add digraph {chars} to the list. {chars} must be a string
  1550. with two characters. {digraph} is a string with one UTF-8
  1551. encoded character. *E1215*
  1552. Be careful, composing characters are NOT ignored. This
  1553. function is similar to |:digraphs| command, but useful to add
  1554. digraphs start with a white space.
  1555. The function result is v:true if |digraph| is registered. If
  1556. this fails an error message is given and v:false is returned.
  1557. If you want to define multiple digraphs at once, you can use
  1558. |digraph_setlist()|.
  1559. Example: >
  1560. call digraph_set(' ', 'あ')
  1561. <
  1562. Can be used as a |method|: >
  1563. GetString()->digraph_set('あ')
  1564. <
  1565. digraph_setlist({digraphlist}) *digraph_setlist()*
  1566. Similar to |digraph_set()| but this function can add multiple
  1567. digraphs at once. {digraphlist} is a list composed of lists,
  1568. where each list contains two strings with {chars} and
  1569. {digraph} as in |digraph_set()|. *E1216*
  1570. Example: >
  1571. call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
  1572. <
  1573. It is similar to the following: >
  1574. for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
  1575. call digraph_set(chars, digraph)
  1576. endfor
  1577. < Except that the function returns after the first error,
  1578. following digraphs will not be added.
  1579. Can be used as a |method|: >
  1580. GetList()->digraph_setlist()
  1581. <
  1582. empty({expr}) *empty()*
  1583. Return the Number 1 if {expr} is empty, zero otherwise.
  1584. - A |List| or |Dictionary| is empty when it does not have any
  1585. items.
  1586. - A |String| is empty when its length is zero.
  1587. - A |Number| and |Float| are empty when their value is zero.
  1588. - |v:false| and |v:null| are empty, |v:true| is not.
  1589. - A |Blob| is empty when its length is zero.
  1590. Can also be used as a |method|: >
  1591. mylist->empty()
  1592. environ() *environ()*
  1593. Return all of environment variables as dictionary. You can
  1594. check if an environment variable exists like this: >
  1595. :echo has_key(environ(), 'HOME')
  1596. < Note that the variable name may be CamelCase; to ignore case
  1597. use this: >
  1598. :echo index(keys(environ()), 'HOME', 0, 1) != -1
  1599. escape({string}, {chars}) *escape()*
  1600. Escape the characters in {chars} that occur in {string} with a
  1601. backslash. Example: >
  1602. :echo escape('c:\program files\vim', ' \')
  1603. < results in: >
  1604. c:\\program\ files\\vim
  1605. < Also see |shellescape()| and |fnameescape()|.
  1606. Can also be used as a |method|: >
  1607. GetText()->escape(' \')
  1608. <
  1609. *eval()*
  1610. eval({string}) Evaluate {string} and return the result. Especially useful to
  1611. turn the result of |string()| back into the original value.
  1612. This works for Numbers, Floats, Strings, Blobs and composites
  1613. of them. Also works for |Funcref|s that refer to existing
  1614. functions.
  1615. Can also be used as a |method|: >
  1616. argv->join()->eval()
  1617. eventhandler() *eventhandler()*
  1618. Returns 1 when inside an event handler. That is that Vim got
  1619. interrupted while waiting for the user to type a character,
  1620. e.g., when dropping a file on Vim. This means interactive
  1621. commands cannot be used. Otherwise zero is returned.
  1622. executable({expr}) *executable()*
  1623. This function checks if an executable with the name {expr}
  1624. exists. {expr} must be the name of the program without any
  1625. arguments.
  1626. executable() uses the value of $PATH and/or the normal
  1627. searchpath for programs. *PATHEXT*
  1628. On MS-Windows the ".exe", ".bat", etc. can optionally be
  1629. included. Then the extensions in $PATHEXT are tried. Thus if
  1630. "foo.exe" does not exist, "foo.exe.bat" can be found. If
  1631. $PATHEXT is not set then ".exe;.com;.bat;.cmd" is used. A dot
  1632. by itself can be used in $PATHEXT to try using the name
  1633. without an extension. When 'shell' looks like a Unix shell,
  1634. then the name is also tried without adding an extension.
  1635. On MS-Windows it only checks if the file exists and is not a
  1636. directory, not if it's really executable.
  1637. On Windows an executable in the same directory as Vim is
  1638. always found (it is added to $PATH at |startup|).
  1639. The result is a Number:
  1640. 1 exists
  1641. 0 does not exist
  1642. -1 not implemented on this system
  1643. |exepath()| can be used to get the full path of an executable.
  1644. Can also be used as a |method|: >
  1645. GetCommand()->executable()
  1646. execute({command} [, {silent}]) *execute()*
  1647. Execute {command} and capture its output.
  1648. If {command} is a |String|, returns {command} output.
  1649. If {command} is a |List|, returns concatenated outputs.
  1650. Examples: >
  1651. echo execute('echon "foo"')
  1652. < foo >
  1653. echo execute(['echon "foo"', 'echon "bar"'])
  1654. < foobar
  1655. The optional {silent} argument can have these values:
  1656. "" no `:silent` used
  1657. "silent" `:silent` used
  1658. "silent!" `:silent!` used
  1659. The default is "silent". Note that with "silent!", unlike
  1660. `:redir`, error messages are dropped.
  1661. To get a list of lines use |split()| on the result: >
  1662. execute('args')->split("\n")
  1663. < This function is not available in the |sandbox|.
  1664. Note: If nested, an outer execute() will not observe output of
  1665. the inner calls.
  1666. Note: Text attributes (highlights) are not captured.
  1667. To execute a command in another window than the current one
  1668. use `win_execute()`.
  1669. Can also be used as a |method|: >
  1670. GetCommand()->execute()
  1671. exepath({expr}) *exepath()*
  1672. Returns the full path of {expr} if it is an executable and
  1673. given as a (partial or full) path or is found in $PATH.
  1674. Returns empty string otherwise.
  1675. If {expr} starts with "./" the |current-directory| is used.
  1676. Can also be used as a |method|: >
  1677. GetCommand()->exepath()
  1678. <
  1679. *exists()*
  1680. exists({expr}) The result is a Number, which is |TRUE| if {expr} is
  1681. defined, zero otherwise.
  1682. For checking for a supported feature use |has()|.
  1683. For checking if a file exists use |filereadable()|.
  1684. The {expr} argument is a string, which contains one of these:
  1685. varname internal variable (see
  1686. dict.key |internal-variables|). Also works
  1687. list[i] for |curly-braces-names|, |Dictionary|
  1688. entries, |List| items, etc.
  1689. Beware that evaluating an index may
  1690. cause an error message for an invalid
  1691. expression. E.g.: >
  1692. :let l = [1, 2, 3]
  1693. :echo exists("l[5]")
  1694. < 0 >
  1695. :echo exists("l[xx]")
  1696. < E121: Undefined variable: xx
  1697. 0
  1698. &option-name Vim option (only checks if it exists,
  1699. not if it really works)
  1700. +option-name Vim option that works.
  1701. $ENVNAME environment variable (could also be
  1702. done by comparing with an empty
  1703. string)
  1704. *funcname built-in function (see |functions|)
  1705. or user defined function (see
  1706. |user-function|). Also works for a
  1707. variable that is a Funcref.
  1708. :cmdname Ex command: built-in command, user
  1709. command or command modifier |:command|.
  1710. Returns:
  1711. 1 for match with start of a command
  1712. 2 full match with a command
  1713. 3 matches several user commands
  1714. To check for a supported command
  1715. always check the return value to be 2.
  1716. :2match The |:2match| command.
  1717. :3match The |:3match| command (but you
  1718. probably should not use it, it is
  1719. reserved for internal usage)
  1720. #event autocommand defined for this event
  1721. #event#pattern autocommand defined for this event and
  1722. pattern (the pattern is taken
  1723. literally and compared to the
  1724. autocommand patterns character by
  1725. character)
  1726. #group autocommand group exists
  1727. #group#event autocommand defined for this group and
  1728. event.
  1729. #group#event#pattern
  1730. autocommand defined for this group,
  1731. event and pattern.
  1732. ##event autocommand for this event is
  1733. supported.
  1734. Examples: >
  1735. exists("&mouse")
  1736. exists("$HOSTNAME")
  1737. exists("*strftime")
  1738. exists("*s:MyFunc")
  1739. exists("*MyFunc")
  1740. exists("bufcount")
  1741. exists(":Make")
  1742. exists("#CursorHold")
  1743. exists("#BufReadPre#*.gz")
  1744. exists("#filetypeindent")
  1745. exists("#filetypeindent#FileType")
  1746. exists("#filetypeindent#FileType#*")
  1747. exists("##ColorScheme")
  1748. < There must be no space between the symbol (&/$/*/#) and the
  1749. name.
  1750. There must be no extra characters after the name, although in
  1751. a few cases this is ignored. That may become stricter in the
  1752. future, thus don't count on it!
  1753. Working example: >
  1754. exists(":make")
  1755. < NOT working example: >
  1756. exists(":make install")
  1757. < Note that the argument must be a string, not the name of the
  1758. variable itself. For example: >
  1759. exists(bufcount)
  1760. < This doesn't check for existence of the "bufcount" variable,
  1761. but gets the value of "bufcount", and checks if that exists.
  1762. Can also be used as a |method|: >
  1763. Varname()->exists()
  1764. exp({expr}) *exp()*
  1765. Return the exponential of {expr} as a |Float| in the range
  1766. [0, inf].
  1767. {expr} must evaluate to a |Float| or a |Number|.
  1768. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1769. Examples: >
  1770. :echo exp(2)
  1771. < 7.389056 >
  1772. :echo exp(-1)
  1773. < 0.367879
  1774. Can also be used as a |method|: >
  1775. Compute()->exp()
  1776. expand({string} [, {nosuf} [, {list}]]) *expand()*
  1777. Expand wildcards and the following special keywords in
  1778. {string}. 'wildignorecase' applies.
  1779. If {list} is given and it is |TRUE|, a List will be returned.
  1780. Otherwise the result is a String and when there are several
  1781. matches, they are separated by <NL> characters.
  1782. If the expansion fails, the result is an empty string. A name
  1783. for a non-existing file is not included, unless {string} does
  1784. not start with '%', '#' or '<', see below.
  1785. When {string} starts with '%', '#' or '<', the expansion is
  1786. done like for the |cmdline-special| variables with their
  1787. associated modifiers. Here is a short overview:
  1788. % current file name
  1789. # alternate file name
  1790. #n alternate file name n
  1791. <cfile> file name under the cursor
  1792. <afile> autocmd file name
  1793. <abuf> autocmd buffer number (as a String!)
  1794. <amatch> autocmd matched name
  1795. <cexpr> C expression under the cursor
  1796. <sfile> sourced script file or function name
  1797. <slnum> sourced script line number or function
  1798. line number
  1799. <sflnum> script file line number, also when in
  1800. a function
  1801. <SID> "<SNR>123_" where "123" is the
  1802. current script ID |<SID>|
  1803. <script> sourced script file, or script file
  1804. where the current function was defined
  1805. <stack> call stack
  1806. <cword> word under the cursor
  1807. <cWORD> WORD under the cursor
  1808. <client> the {clientid} of the last received
  1809. message
  1810. Modifiers:
  1811. :p expand to full path
  1812. :h head (last path component removed)
  1813. :t tail (last path component only)
  1814. :r root (one extension removed)
  1815. :e extension only
  1816. Example: >
  1817. :let &tags = expand("%:p:h") .. "/tags"
  1818. < Note that when expanding a string that starts with '%', '#' or
  1819. '<', any following text is ignored. This does NOT work: >
  1820. :let doesntwork = expand("%:h.bak")
  1821. < Use this: >
  1822. :let doeswork = expand("%:h") .. ".bak"
  1823. < Also note that expanding "<cfile>" and others only returns the
  1824. referenced file name without further expansion. If "<cfile>"
  1825. is "~/.cshrc", you need to do another expand() to have the
  1826. "~/" expanded into the path of the home directory: >
  1827. :echo expand(expand("<cfile>"))
  1828. <
  1829. There cannot be white space between the variables and the
  1830. following modifier. The |fnamemodify()| function can be used
  1831. to modify normal file names.
  1832. When using '%' or '#', and the current or alternate file name
  1833. is not defined, an empty string is used. Using "%:p" in a
  1834. buffer with no name, results in the current directory, with a
  1835. '/' added.
  1836. When 'verbose' is set then expanding '%', '#' and <> items
  1837. will result in an error message if the argument cannot be
  1838. expanded.
  1839. When {string} does not start with '%', '#' or '<', it is
  1840. expanded like a file name is expanded on the command line.
  1841. 'suffixes' and 'wildignore' are used, unless the optional
  1842. {nosuf} argument is given and it is |TRUE|.
  1843. Names for non-existing files are included. The "**" item can
  1844. be used to search in a directory tree. For example, to find
  1845. all "README" files in the current directory and below: >
  1846. :echo expand("**/README")
  1847. <
  1848. expand() can also be used to expand variables and environment
  1849. variables that are only known in a shell. But this can be
  1850. slow, because a shell may be used to do the expansion. See
  1851. |expr-env-expand|.
  1852. The expanded variable is still handled like a list of file
  1853. names. When an environment variable cannot be expanded, it is
  1854. left unchanged. Thus ":echo expand('$FOOBAR')" results in
  1855. "$FOOBAR".
  1856. See |glob()| for finding existing files. See |system()| for
  1857. getting the raw output of an external command.
  1858. Can also be used as a |method|: >
  1859. Getpattern()->expand()
  1860. expandcmd({string}) *expandcmd()*
  1861. Expand special items in String {string} like what is done for
  1862. an Ex command such as `:edit`. This expands special keywords,
  1863. like with |expand()|, and environment variables, anywhere in
  1864. {string}. "~user" and "~/path" are only expanded at the
  1865. start.
  1866. Returns the expanded string. If an error is encountered
  1867. during expansion, the unmodified {string} is returned.
  1868. Example: >
  1869. :echo expandcmd('make %<.o')
  1870. < make /path/runtime/doc/builtin.o ~
  1871. Can also be used as a |method|: >
  1872. GetCommand()->expandcmd()
  1873. <
  1874. extend({expr1}, {expr2} [, {expr3}]) *extend()*
  1875. {expr1} and {expr2} must be both |Lists| or both
  1876. |Dictionaries|.
  1877. If they are |Lists|: Append {expr2} to {expr1}.
  1878. If {expr3} is given insert the items of {expr2} before the
  1879. item with index {expr3} in {expr1}. When {expr3} is zero
  1880. insert before the first item. When {expr3} is equal to
  1881. len({expr1}) then {expr2} is appended.
  1882. Examples: >
  1883. :echo sort(extend(mylist, [7, 5]))
  1884. :call extend(mylist, [2, 3], 1)
  1885. < When {expr1} is the same List as {expr2} then the number of
  1886. items copied is equal to the original length of the List.
  1887. E.g., when {expr3} is 1 you get N new copies of the first item
  1888. (where N is the original length of the List).
  1889. Use |add()| to concatenate one item to a list. To concatenate
  1890. two lists into a new list use the + operator: >
  1891. :let newlist = [1, 2, 3] + [4, 5]
  1892. <
  1893. If they are |Dictionaries|:
  1894. Add all entries from {expr2} to {expr1}.
  1895. If a key exists in both {expr1} and {expr2} then {expr3} is
  1896. used to decide what to do:
  1897. {expr3} = "keep": keep the value of {expr1}
  1898. {expr3} = "force": use the value of {expr2}
  1899. {expr3} = "error": give an error message *E737*
  1900. When {expr3} is omitted then "force" is assumed.
  1901. {expr1} is changed when {expr2} is not empty. If necessary
  1902. make a copy of {expr1} first.
  1903. {expr2} remains unchanged.
  1904. When {expr1} is locked and {expr2} is not empty the operation
  1905. fails.
  1906. Returns {expr1}. Returns 0 on error.
  1907. Can also be used as a |method|: >
  1908. mylist->extend(otherlist)
  1909. feedkeys({string} [, {mode}]) *feedkeys()*
  1910. Characters in {string} are queued for processing as if they
  1911. come from a mapping or were typed by the user.
  1912. By default the string is added to the end of the typeahead
  1913. buffer, thus if a mapping is still being executed the
  1914. characters come after them. Use the 'i' flag to insert before
  1915. other characters, they will be executed next, before any
  1916. characters from a mapping.
  1917. The function does not wait for processing of keys contained in
  1918. {string}.
  1919. To include special keys into {string}, use double-quotes
  1920. and "\..." notation |expr-quote|. For example,
  1921. feedkeys("\<CR>") simulates pressing of the <Enter> key. But
  1922. feedkeys('\<CR>') pushes 5 characters.
  1923. The |<Ignore>| keycode may be used to exit the
  1924. wait-for-character without doing anything.
  1925. {mode} is a String, which can contain these character flags:
  1926. 'm' Remap keys. This is default. If {mode} is absent,
  1927. keys are remapped.
  1928. 'n' Do not remap keys.
  1929. 't' Handle keys as if typed; otherwise they are handled as
  1930. if coming from a mapping. This matters for undo,
  1931. opening folds, etc.
  1932. 'i' Insert the string instead of appending (see above).
  1933. 'x' Execute commands until typeahead is empty. This is
  1934. similar to using ":normal!". You can call feedkeys()
  1935. several times without 'x' and then one time with 'x'
  1936. (possibly with an empty {string}) to execute all the
  1937. typeahead. Note that when Vim ends in Insert mode it
  1938. will behave as if <Esc> is typed, to avoid getting
  1939. stuck, waiting for a character to be typed before the
  1940. script continues.
  1941. Note that if you manage to call feedkeys() while
  1942. executing commands, thus calling it recursively, then
  1943. all typeahead will be consumed by the last call.
  1944. '!' When used with 'x' will not end Insert mode. Can be
  1945. used in a test when a timer is set to exit Insert mode
  1946. a little later. Useful for testing CursorHoldI.
  1947. Return value is always 0.
  1948. Can also be used as a |method|: >
  1949. GetInput()->feedkeys()
  1950. filereadable({file}) *filereadable()*
  1951. The result is a Number, which is |TRUE| when a file with the
  1952. name {file} exists, and can be read. If {file} doesn't exist,
  1953. or is a directory, the result is |FALSE|. {file} is any
  1954. expression, which is used as a String.
  1955. If you don't care about the file being readable you can use
  1956. |glob()|.
  1957. {file} is used as-is, you may want to expand wildcards first: >
  1958. echo filereadable('~/.vimrc')
  1959. 0
  1960. echo filereadable(expand('~/.vimrc'))
  1961. 1
  1962. < Can also be used as a |method|: >
  1963. GetName()->filereadable()
  1964. filewritable({file}) *filewritable()*
  1965. The result is a Number, which is 1 when a file with the
  1966. name {file} exists, and can be written. If {file} doesn't
  1967. exist, or is not writable, the result is 0. If {file} is a
  1968. directory, and we can write to it, the result is 2.
  1969. Can also be used as a |method|: >
  1970. GetName()->filewritable()
  1971. filter({expr1}, {expr2}) *filter()*
  1972. {expr1} must be a |List|, |Blob|, or a |Dictionary|.
  1973. For each item in {expr1} evaluate {expr2} and when the result
  1974. is zero remove the item from the |List| or |Dictionary|. For a
  1975. |Blob| each byte is removed.
  1976. {expr2} must be a |string| or |Funcref|.
  1977. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  1978. of the current item. For a |Dictionary| |v:key| has the key
  1979. of the current item and for a |List| |v:key| has the index of
  1980. the current item. For a |Blob| |v:key| has the index of the
  1981. current byte.
  1982. Examples: >
  1983. call filter(mylist, 'v:val !~ "OLD"')
  1984. < Removes the items where "OLD" appears. >
  1985. call filter(mydict, 'v:key >= 8')
  1986. < Removes the items with a key below 8. >
  1987. call filter(var, 0)
  1988. < Removes all the items, thus clears the |List| or |Dictionary|.
  1989. Note that {expr2} is the result of expression and is then
  1990. used as an expression again. Often it is good to use a
  1991. |literal-string| to avoid having to double backslashes.
  1992. If {expr2} is a |Funcref| it must take two arguments:
  1993. 1. the key or the index of the current item.
  1994. 2. the value of the current item.
  1995. The function must return |TRUE| if the item should be kept.
  1996. Example that keeps the odd items of a list: >
  1997. func Odd(idx, val)
  1998. return a:idx % 2 == 1
  1999. endfunc
  2000. call filter(mylist, function('Odd'))
  2001. < It is shorter when using a |lambda|: >
  2002. call filter(myList, {idx, val -> idx * val <= 42})
  2003. < If you do not use "val" you can leave it out: >
  2004. call filter(myList, {idx -> idx % 2 == 1})
  2005. <
  2006. The operation is done in-place. If you want a |List| or
  2007. |Dictionary| to remain unmodified make a copy first: >
  2008. :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  2009. < Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
  2010. filtered. When an error is encountered while evaluating
  2011. {expr2} no further items in {expr1} are processed. When
  2012. {expr2} is a Funcref errors inside a function are ignored,
  2013. unless it was defined with the "abort" flag.
  2014. Can also be used as a |method|: >
  2015. mylist->filter(expr2)
  2016. finddir({name} [, {path} [, {count}]]) *finddir()*
  2017. Find directory {name} in {path}. Supports both downwards and
  2018. upwards recursive directory searches. See |file-searching|
  2019. for the syntax of {path}.
  2020. Returns the path of the first found match. When the found
  2021. directory is below the current directory a relative path is
  2022. returned. Otherwise a full path is returned.
  2023. If {path} is omitted or empty then 'path' is used.
  2024. If the optional {count} is given, find {count}'s occurrence of
  2025. {name} in {path} instead of the first one.
  2026. When {count} is negative return all the matches in a |List|.
  2027. Returns an empty string if the directory is not found.
  2028. This is quite similar to the ex-command `:find`.
  2029. Can also be used as a |method|: >
  2030. GetName()->finddir()
  2031. findfile({name} [, {path} [, {count}]]) *findfile()*
  2032. Just like |finddir()|, but find a file instead of a directory.
  2033. Uses 'suffixesadd'.
  2034. Example: >
  2035. :echo findfile("tags.vim", ".;")
  2036. < Searches from the directory of the current file upwards until
  2037. it finds the file "tags.vim".
  2038. Can also be used as a |method|: >
  2039. GetName()->findfile()
  2040. flatten({list} [, {maxdepth}]) *flatten()*
  2041. Flatten {list} up to {maxdepth} levels. Without {maxdepth}
  2042. the result is a |List| without nesting, as if {maxdepth} is
  2043. a very large number.
  2044. The {list} is changed in place, make a copy first if you do
  2045. not want that.
  2046. *E900*
  2047. {maxdepth} means how deep in nested lists changes are made.
  2048. {list} is not modified when {maxdepth} is 0.
  2049. {maxdepth} must be positive number.
  2050. If there is an error the number zero is returned.
  2051. Example: >
  2052. :echo flatten([1, [2, [3, 4]], 5])
  2053. < [1, 2, 3, 4, 5] >
  2054. :echo flatten([1, [2, [3, 4]], 5], 1)
  2055. < [1, 2, [3, 4], 5]
  2056. Can also be used as a |method|: >
  2057. mylist->flatten()
  2058. <
  2059. float2nr({expr}) *float2nr()*
  2060. Convert {expr} to a Number by omitting the part after the
  2061. decimal point.
  2062. {expr} must evaluate to a |Float| or a Number.
  2063. Returns 0 if {expr} is not a |Float| or a |Number|.
  2064. When the value of {expr} is out of range for a |Number| the
  2065. result is truncated to 0x7fffffff or -0x7fffffff (or when
  2066. 64-bit Number support is enabled, 0x7fffffffffffffff or
  2067. -0x7fffffffffffffff). NaN results in -0x80000000 (or when
  2068. 64-bit Number support is enabled, -0x8000000000000000).
  2069. Examples: >
  2070. echo float2nr(3.95)
  2071. < 3 >
  2072. echo float2nr(-23.45)
  2073. < -23 >
  2074. echo float2nr(1.0e100)
  2075. < 2147483647 (or 9223372036854775807) >
  2076. echo float2nr(-1.0e150)
  2077. < -2147483647 (or -9223372036854775807) >
  2078. echo float2nr(1.0e-100)
  2079. < 0
  2080. Can also be used as a |method|: >
  2081. Compute()->float2nr()
  2082. floor({expr}) *floor()*
  2083. Return the largest integral value less than or equal to
  2084. {expr} as a |Float| (round down).
  2085. {expr} must evaluate to a |Float| or a |Number|.
  2086. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  2087. Examples: >
  2088. echo floor(1.856)
  2089. < 1.0 >
  2090. echo floor(-5.456)
  2091. < -6.0 >
  2092. echo floor(4.0)
  2093. < 4.0
  2094. Can also be used as a |method|: >
  2095. Compute()->floor()
  2096. fmod({expr1}, {expr2}) *fmod()*
  2097. Return the remainder of {expr1} / {expr2}, even if the
  2098. division is not representable. Returns {expr1} - i * {expr2}
  2099. for some integer i such that if {expr2} is non-zero, the
  2100. result has the same sign as {expr1} and magnitude less than
  2101. the magnitude of {expr2}. If {expr2} is zero, the value
  2102. returned is zero. The value returned is a |Float|.
  2103. {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  2104. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  2105. |Number|.
  2106. Examples: >
  2107. :echo fmod(12.33, 1.22)
  2108. < 0.13 >
  2109. :echo fmod(-12.33, 1.22)
  2110. < -0.13
  2111. Can also be used as a |method|: >
  2112. Compute()->fmod(1.22)
  2113. fnameescape({string}) *fnameescape()*
  2114. Escape {string} for use as file name command argument. All
  2115. characters that have a special meaning, such as '%' and '|'
  2116. are escaped with a backslash.
  2117. For most systems the characters escaped are
  2118. " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
  2119. appears in a filename, it depends on the value of 'isfname'.
  2120. A leading '+' and '>' is also escaped (special after |:edit|
  2121. and |:write|). And a "-" by itself (special after |:cd|).
  2122. Returns an empty string on error.
  2123. Example: >
  2124. :let fname = '+some str%nge|name'
  2125. :exe "edit " .. fnameescape(fname)
  2126. < results in executing: >
  2127. edit \+some\ str\%nge\|name
  2128. <
  2129. Can also be used as a |method|: >
  2130. GetName()->fnameescape()
  2131. fnamemodify({fname}, {mods}) *fnamemodify()*
  2132. Modify file name {fname} according to {mods}. {mods} is a
  2133. string of characters like it is used for file names on the
  2134. command line. See |filename-modifiers|.
  2135. Example: >
  2136. :echo fnamemodify("main.c", ":p:h")
  2137. < results in: >
  2138. /home/user/vim/vim/src
  2139. < If {mods} is empty or an unsupported modifier is used then
  2140. {fname} is returned.
  2141. When {fname} is empty then with {mods} ":h" returns ".", so
  2142. that `:cd` can be used with it. This is different from
  2143. expand('%:h') without a buffer name, which returns an empty
  2144. string.
  2145. Note: Environment variables don't work in {fname}, use
  2146. |expand()| first then.
  2147. Can also be used as a |method|: >
  2148. GetName()->fnamemodify(':p:h')
  2149. foldclosed({lnum}) *foldclosed()*
  2150. The result is a Number. If the line {lnum} is in a closed
  2151. fold, the result is the number of the first line in that fold.
  2152. If the line {lnum} is not in a closed fold, -1 is returned.
  2153. {lnum} is used like with |getline()|. Thus "." is the current
  2154. line, "'m" mark m, etc.
  2155. Can also be used as a |method|: >
  2156. GetLnum()->foldclosed()
  2157. foldclosedend({lnum}) *foldclosedend()*
  2158. The result is a Number. If the line {lnum} is in a closed
  2159. fold, the result is the number of the last line in that fold.
  2160. If the line {lnum} is not in a closed fold, -1 is returned.
  2161. {lnum} is used like with |getline()|. Thus "." is the current
  2162. line, "'m" mark m, etc.
  2163. Can also be used as a |method|: >
  2164. GetLnum()->foldclosedend()
  2165. foldlevel({lnum}) *foldlevel()*
  2166. The result is a Number, which is the foldlevel of line {lnum}
  2167. in the current buffer. For nested folds the deepest level is
  2168. returned. If there is no fold at line {lnum}, zero is
  2169. returned. It doesn't matter if the folds are open or closed.
  2170. When used while updating folds (from 'foldexpr') -1 is
  2171. returned for lines where folds are still to be updated and the
  2172. foldlevel is unknown. As a special case the level of the
  2173. previous line is usually available.
  2174. {lnum} is used like with |getline()|. Thus "." is the current
  2175. line, "'m" mark m, etc.
  2176. Can also be used as a |method|: >
  2177. GetLnum()->foldlevel()
  2178. <
  2179. *foldtext()*
  2180. foldtext() Returns a String, to be displayed for a closed fold. This is
  2181. the default function used for the 'foldtext' option and should
  2182. only be called from evaluating 'foldtext'. It uses the
  2183. |v:foldstart|, |v:foldend| and |v:folddashes| variables.
  2184. The returned string looks like this: >
  2185. +-- 45 lines: abcdef
  2186. < The number of leading dashes depends on the foldlevel. The
  2187. "45" is the number of lines in the fold. "abcdef" is the text
  2188. in the first non-blank line of the fold. Leading white space,
  2189. "//" or "/*" and the text from the 'foldmarker' and
  2190. 'commentstring' options is removed.
  2191. When used to draw the actual foldtext, the rest of the line
  2192. will be filled with the fold char from the 'fillchars'
  2193. setting.
  2194. Returns an empty string when there is no fold.
  2195. foldtextresult({lnum}) *foldtextresult()*
  2196. Returns the text that is displayed for the closed fold at line
  2197. {lnum}. Evaluates 'foldtext' in the appropriate context.
  2198. When there is no closed fold at {lnum} an empty string is
  2199. returned.
  2200. {lnum} is used like with |getline()|. Thus "." is the current
  2201. line, "'m" mark m, etc.
  2202. Useful when exporting folded text, e.g., to HTML.
  2203. Can also be used as a |method|: >
  2204. GetLnum()->foldtextresult()
  2205. <
  2206. fullcommand({name}) *fullcommand()*
  2207. Get the full command name from a short abbreviated command
  2208. name; see |20.2| for details on command abbreviations.
  2209. The string argument {name} may start with a `:` and can
  2210. include a [range], these are skipped and not returned.
  2211. Returns an empty string if a command doesn't exist or if it's
  2212. ambiguous (for user-defined commands).
  2213. For example `fullcommand('s')`, `fullcommand('sub')`,
  2214. `fullcommand(':%substitute')` all return "substitute".
  2215. Can also be used as a |method|: >
  2216. GetName()->fullcommand()
  2217. <
  2218. *funcref()*
  2219. funcref({name} [, {arglist}] [, {dict}])
  2220. Just like |function()|, but the returned Funcref will lookup
  2221. the function by reference, not by name. This matters when the
  2222. function {name} is redefined later.
  2223. Unlike |function()|, {name} must be an existing user function.
  2224. It only works for an autoloaded function if it has already
  2225. been loaded (to avoid mistakenly loading the autoload script
  2226. when only intending to use the function name, use |function()|
  2227. instead). {name} cannot be a builtin function.
  2228. Returns 0 on error.
  2229. Can also be used as a |method|: >
  2230. GetFuncname()->funcref([arg])
  2231. <
  2232. *function()* *partial* *E700* *E922* *E923*
  2233. function({name} [, {arglist}] [, {dict}])
  2234. Return a |Funcref| variable that refers to function {name}.
  2235. {name} can be the name of a user defined function or an
  2236. internal function.
  2237. {name} can also be a Funcref or a partial. When it is a
  2238. partial the dict stored in it will be used and the {dict}
  2239. argument is not allowed. E.g.: >
  2240. let FuncWithArg = function(dict.Func, [arg])
  2241. let Broken = function(dict.Func, [arg], dict)
  2242. <
  2243. When using the Funcref the function will be found by {name},
  2244. also when it was redefined later. Use |funcref()| to keep the
  2245. same function.
  2246. When {arglist} or {dict} is present this creates a partial.
  2247. That means the argument list and/or the dictionary is stored in
  2248. the Funcref and will be used when the Funcref is called.
  2249. The arguments are passed to the function in front of other
  2250. arguments, but after any argument from |method|. Example: >
  2251. func Callback(arg1, arg2, name)
  2252. "...
  2253. let Partial = function('Callback', ['one', 'two'])
  2254. "...
  2255. call Partial('name')
  2256. < Invokes the function as with: >
  2257. call Callback('one', 'two', 'name')
  2258. < With a |method|: >
  2259. func Callback(one, two, three)
  2260. "...
  2261. let Partial = function('Callback', ['two'])
  2262. "...
  2263. eval 'one'->Partial('three')
  2264. < Invokes the function as with: >
  2265. call Callback('one', 'two', 'three')
  2266. < The function() call can be nested to add more arguments to the
  2267. Funcref. The extra arguments are appended to the list of
  2268. arguments. Example: >
  2269. func Callback(arg1, arg2, name)
  2270. "...
  2271. let Func = function('Callback', ['one'])
  2272. let Func2 = function(Func, ['two'])
  2273. "...
  2274. call Func2('name')
  2275. < Invokes the function as with: >
  2276. call Callback('one', 'two', 'name')
  2277. < The Dictionary is only useful when calling a "dict" function.
  2278. In that case the {dict} is passed in as "self". Example: >
  2279. function Callback() dict
  2280. echo "called for " .. self.name
  2281. endfunction
  2282. "...
  2283. let context = {"name": "example"}
  2284. let Func = function('Callback', context)
  2285. "...
  2286. call Func() " will echo: called for example
  2287. < The use of function() is not needed when there are no extra
  2288. arguments, these two are equivalent, if Callback() is defined
  2289. as context.Callback(): >
  2290. let Func = function('Callback', context)
  2291. let Func = context.Callback
  2292. < The argument list and the Dictionary can be combined: >
  2293. function Callback(arg1, count) dict
  2294. "...
  2295. let context = {"name": "example"}
  2296. let Func = function('Callback', ['one'], context)
  2297. "...
  2298. call Func(500)
  2299. < Invokes the function as with: >
  2300. call context.Callback('one', 500)
  2301. <
  2302. Returns 0 on error.
  2303. Can also be used as a |method|: >
  2304. GetFuncname()->function([arg])
  2305. garbagecollect([{atexit}]) *garbagecollect()*
  2306. Cleanup unused |Lists| and |Dictionaries| that have circular
  2307. references.
  2308. There is hardly ever a need to invoke this function, as it is
  2309. automatically done when Vim runs out of memory or is waiting
  2310. for the user to press a key after 'updatetime'. Items without
  2311. circular references are always freed when they become unused.
  2312. This is useful if you have deleted a very big |List| and/or
  2313. |Dictionary| with circular references in a script that runs
  2314. for a long time.
  2315. When the optional {atexit} argument is one, garbage
  2316. collection will also be done when exiting Vim, if it wasn't
  2317. done before. This is useful when checking for memory leaks.
  2318. The garbage collection is not done immediately but only when
  2319. it's safe to perform. This is when waiting for the user to
  2320. type a character.
  2321. get({list}, {idx} [, {default}]) *get()*
  2322. Get item {idx} from |List| {list}. When this item is not
  2323. available return {default}. Return zero when {default} is
  2324. omitted.
  2325. Can also be used as a |method|: >
  2326. mylist->get(idx)
  2327. get({blob}, {idx} [, {default}])
  2328. Get byte {idx} from |Blob| {blob}. When this byte is not
  2329. available return {default}. Return -1 when {default} is
  2330. omitted.
  2331. get({dict}, {key} [, {default}])
  2332. Get item with key {key} from |Dictionary| {dict}. When this
  2333. item is not available return {default}. Return zero when
  2334. {default} is omitted. Useful example: >
  2335. let val = get(g:, 'var_name', 'default')
  2336. < This gets the value of g:var_name if it exists, and uses
  2337. "default" when it does not exist.
  2338. get({func}, {what})
  2339. Get item {what} from Funcref {func}. Possible values for
  2340. {what} are:
  2341. "name" The function name
  2342. "func" The function
  2343. "dict" The dictionary
  2344. "args" The list with arguments
  2345. Returns zero on error.
  2346. *getbufinfo()*
  2347. getbufinfo([{buf}])
  2348. getbufinfo([{dict}])
  2349. Get information about buffers as a List of Dictionaries.
  2350. Without an argument information about all the buffers is
  2351. returned.
  2352. When the argument is a |Dictionary| only the buffers matching
  2353. the specified criteria are returned. The following keys can
  2354. be specified in {dict}:
  2355. buflisted include only listed buffers.
  2356. bufloaded include only loaded buffers.
  2357. bufmodified include only modified buffers.
  2358. Otherwise, {buf} specifies a particular buffer to return
  2359. information for. For the use of {buf}, see |bufname()|
  2360. above. If the buffer is found the returned List has one item.
  2361. Otherwise the result is an empty list.
  2362. Each returned List item is a dictionary with the following
  2363. entries:
  2364. bufnr Buffer number.
  2365. changed TRUE if the buffer is modified.
  2366. changedtick Number of changes made to the buffer.
  2367. hidden TRUE if the buffer is hidden.
  2368. lastused Timestamp in seconds, like
  2369. |localtime()|, when the buffer was
  2370. last used.
  2371. listed TRUE if the buffer is listed.
  2372. lnum Line number used for the buffer when
  2373. opened in the current window.
  2374. Only valid if the buffer has been
  2375. displayed in the window in the past.
  2376. If you want the line number of the
  2377. last known cursor position in a given
  2378. window, use |line()|: >
  2379. :echo line('.', {winid})
  2380. <
  2381. linecount Number of lines in the buffer (only
  2382. valid when loaded)
  2383. loaded TRUE if the buffer is loaded.
  2384. name Full path to the file in the buffer.
  2385. signs List of signs placed in the buffer.
  2386. Each list item is a dictionary with
  2387. the following fields:
  2388. id sign identifier
  2389. lnum line number
  2390. name sign name
  2391. variables A reference to the dictionary with
  2392. buffer-local variables.
  2393. windows List of |window-ID|s that display this
  2394. buffer
  2395. Examples: >
  2396. for buf in getbufinfo()
  2397. echo buf.name
  2398. endfor
  2399. for buf in getbufinfo({'buflisted':1})
  2400. if buf.changed
  2401. ....
  2402. endif
  2403. endfor
  2404. <
  2405. To get buffer-local options use: >
  2406. getbufvar({bufnr}, '&option_name')
  2407. <
  2408. Can also be used as a |method|: >
  2409. GetBufnr()->getbufinfo()
  2410. <
  2411. *getbufline()*
  2412. getbufline({buf}, {lnum} [, {end}])
  2413. Return a |List| with the lines starting from {lnum} to {end}
  2414. (inclusive) in the buffer {buf}. If {end} is omitted, a
  2415. |List| with only the line {lnum} is returned.
  2416. For the use of {buf}, see |bufname()| above.
  2417. For {lnum} and {end} "$" can be used for the last line of the
  2418. buffer. Otherwise a number must be used.
  2419. When {lnum} is smaller than 1 or bigger than the number of
  2420. lines in the buffer, an empty |List| is returned.
  2421. When {end} is greater than the number of lines in the buffer,
  2422. it is treated as {end} is set to the number of lines in the
  2423. buffer. When {end} is before {lnum} an empty |List| is
  2424. returned.
  2425. This function works only for loaded buffers. For unloaded and
  2426. non-existing buffers, an empty |List| is returned.
  2427. Example: >
  2428. :let lines = getbufline(bufnr("myfile"), 1, "$")
  2429. < Can also be used as a |method|: >
  2430. GetBufnr()->getbufline(lnum)
  2431. getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
  2432. The result is the value of option or local buffer variable
  2433. {varname} in buffer {buf}. Note that the name without "b:"
  2434. must be used.
  2435. The {varname} argument is a string.
  2436. When {varname} is empty returns a |Dictionary| with all the
  2437. buffer-local variables.
  2438. When {varname} is equal to "&" returns a |Dictionary| with all
  2439. the buffer-local options.
  2440. Otherwise, when {varname} starts with "&" returns the value of
  2441. a buffer-local option.
  2442. This also works for a global or buffer-local option, but it
  2443. doesn't work for a global variable, window-local variable or
  2444. window-local option.
  2445. For the use of {buf}, see |bufname()| above.
  2446. When the buffer or variable doesn't exist {def} or an empty
  2447. string is returned, there is no error message.
  2448. Examples: >
  2449. :let bufmodified = getbufvar(1, "&mod")
  2450. :echo "todo myvar = " .. getbufvar("todo", "myvar")
  2451. < Can also be used as a |method|: >
  2452. GetBufnr()->getbufvar(varname)
  2453. <
  2454. getchangelist([{buf}]) *getchangelist()*
  2455. Returns the |changelist| for the buffer {buf}. For the use
  2456. of {buf}, see |bufname()| above. If buffer {buf} doesn't
  2457. exist, an empty list is returned.
  2458. The returned list contains two entries: a list with the change
  2459. locations and the current position in the list. Each
  2460. entry in the change list is a dictionary with the following
  2461. entries:
  2462. col column number
  2463. coladd column offset for 'virtualedit'
  2464. lnum line number
  2465. If buffer {buf} is the current buffer, then the current
  2466. position refers to the position in the list. For other
  2467. buffers, it is set to the length of the list.
  2468. Can also be used as a |method|: >
  2469. GetBufnr()->getchangelist()
  2470. getchar([expr]) *getchar()*
  2471. Get a single character from the user or input stream.
  2472. If [expr] is omitted, wait until a character is available.
  2473. If [expr] is 0, only get a character when one is available.
  2474. Return zero otherwise.
  2475. If [expr] is 1, only check if a character is available, it is
  2476. not consumed. Return zero if no character available.
  2477. If you prefer always getting a string use |getcharstr()|.
  2478. Without [expr] and when [expr] is 0 a whole character or
  2479. special key is returned. If it is a single character, the
  2480. result is a Number. Use |nr2char()| to convert it to a String.
  2481. Otherwise a String is returned with the encoded character.
  2482. For a special key it's a String with a sequence of bytes
  2483. starting with 0x80 (decimal: 128). This is the same value as
  2484. the String "\<Key>", e.g., "\<Left>". The returned value is
  2485. also a String when a modifier (shift, control, alt) was used
  2486. that is not included in the character.
  2487. When [expr] is 0 and Esc is typed, there will be a short delay
  2488. while Vim waits to see if this is the start of an escape
  2489. sequence.
  2490. When [expr] is 1 only the first byte is returned. For a
  2491. one-byte character it is the character itself as a number.
  2492. Use nr2char() to convert it to a String.
  2493. Use getcharmod() to obtain any additional modifiers.
  2494. When the user clicks a mouse button, the mouse event will be
  2495. returned. The position can then be found in |v:mouse_col|,
  2496. |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
  2497. |getmousepos()| can also be used. Mouse move events will be
  2498. ignored.
  2499. This example positions the mouse as it would normally happen: >
  2500. let c = getchar()
  2501. if c == "\<LeftMouse>" && v:mouse_win > 0
  2502. exe v:mouse_win .. "wincmd w"
  2503. exe v:mouse_lnum
  2504. exe "normal " .. v:mouse_col .. "|"
  2505. endif
  2506. <
  2507. There is no prompt, you will somehow have to make clear to the
  2508. user that a character has to be typed. The screen is not
  2509. redrawn, e.g. when resizing the window.
  2510. There is no mapping for the character.
  2511. Key codes are replaced, thus when the user presses the <Del>
  2512. key you get the code for the <Del> key, not the raw character
  2513. sequence. Examples: >
  2514. getchar() == "\<Del>"
  2515. getchar() == "\<S-Left>"
  2516. < This example redefines "f" to ignore case: >
  2517. :nmap f :call FindChar()<CR>
  2518. :function FindChar()
  2519. : let c = nr2char(getchar())
  2520. : while col('.') < col('$') - 1
  2521. : normal l
  2522. : if getline('.')[col('.') - 1] ==? c
  2523. : break
  2524. : endif
  2525. : endwhile
  2526. :endfunction
  2527. <
  2528. getcharmod() *getcharmod()*
  2529. The result is a Number which is the state of the modifiers for
  2530. the last obtained character with getchar() or in another way.
  2531. These values are added together:
  2532. 2 shift
  2533. 4 control
  2534. 8 alt (meta)
  2535. 16 meta (when it's different from ALT)
  2536. 32 mouse double click
  2537. 64 mouse triple click
  2538. 96 mouse quadruple click (== 32 + 64)
  2539. 128 command (Macintosh only)
  2540. Only the modifiers that have not been included in the
  2541. character itself are obtained. Thus Shift-a results in "A"
  2542. without a modifier. Returns 0 if no modifiers are used.
  2543. *getcharpos()*
  2544. getcharpos({expr})
  2545. Get the position for String {expr}. Same as |getpos()| but the
  2546. column number in the returned List is a character index
  2547. instead of a byte index.
  2548. Example:
  2549. With the cursor on '세' in line 5 with text "여보세요": >
  2550. getcharpos('.') returns [0, 5, 3, 0]
  2551. getpos('.') returns [0, 5, 7, 0]
  2552. <
  2553. Can also be used as a |method|: >
  2554. GetMark()->getcharpos()
  2555. getcharsearch() *getcharsearch()*
  2556. Return the current character search information as a {dict}
  2557. with the following entries:
  2558. char character previously used for a character
  2559. search (|t|, |f|, |T|, or |F|); empty string
  2560. if no character search has been performed
  2561. forward direction of character search; 1 for forward,
  2562. 0 for backward
  2563. until type of character search; 1 for a |t| or |T|
  2564. character search, 0 for an |f| or |F|
  2565. character search
  2566. This can be useful to always have |;| and |,| search
  2567. forward/backward regardless of the direction of the previous
  2568. character search: >
  2569. :nnoremap <expr> ; getcharsearch().forward ? ';' : ','
  2570. :nnoremap <expr> , getcharsearch().forward ? ',' : ';'
  2571. < Also see |setcharsearch()|.
  2572. getcharstr([expr]) *getcharstr()*
  2573. Get a single character from the user or input stream as a
  2574. string.
  2575. If [expr] is omitted, wait until a character is available.
  2576. If [expr] is 0 or false, only get a character when one is
  2577. available. Return an empty string otherwise.
  2578. If [expr] is 1 or true, only check if a character is
  2579. available, it is not consumed. Return an empty string
  2580. if no character is available.
  2581. Otherwise this works like |getchar()|, except that a number
  2582. result is converted to a string.
  2583. getcmdcompltype() *getcmdcompltype()*
  2584. Return the type of the current command-line completion.
  2585. Only works when the command line is being edited, thus
  2586. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2587. See |:command-completion| for the return string.
  2588. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and
  2589. |setcmdline()|.
  2590. Returns an empty string when completion is not defined.
  2591. getcmdline() *getcmdline()*
  2592. Return the current command-line. Only works when the command
  2593. line is being edited, thus requires use of |c_CTRL-\_e| or
  2594. |c_CTRL-R_=|.
  2595. Example: >
  2596. :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
  2597. < Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and
  2598. |setcmdline()|.
  2599. Returns an empty string when entering a password or using
  2600. |inputsecret()|.
  2601. getcmdpos() *getcmdpos()*
  2602. Return the position of the cursor in the command line as a
  2603. byte count. The first column is 1.
  2604. Only works when editing the command line, thus requires use of
  2605. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2606. Returns 0 otherwise.
  2607. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and
  2608. |setcmdline()|.
  2609. getcmdscreenpos() *getcmdscreenpos()*
  2610. Return the screen position of the cursor in the command line
  2611. as a byte count. The first column is 1.
  2612. Instead of |getcmdpos()|, it adds the prompt position.
  2613. Only works when editing the command line, thus requires use of
  2614. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2615. Returns 0 otherwise.
  2616. Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
  2617. |setcmdline()|.
  2618. getcmdtype() *getcmdtype()*
  2619. Return the current command-line type. Possible return values
  2620. are:
  2621. : normal Ex command
  2622. > debug mode command |debug-mode|
  2623. / forward search command
  2624. ? backward search command
  2625. @ |input()| command
  2626. - |:insert| or |:append| command
  2627. = |i_CTRL-R_=|
  2628. Only works when editing the command line, thus requires use of
  2629. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2630. Returns an empty string otherwise.
  2631. Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  2632. getcmdwintype() *getcmdwintype()*
  2633. Return the current |command-line-window| type. Possible return
  2634. values are the same as |getcmdtype()|. Returns an empty string
  2635. when not in the command-line window.
  2636. getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
  2637. Return a list of command-line completion matches. The String
  2638. {type} argument specifies what for. The following completion
  2639. types are supported:
  2640. arglist file names in argument list
  2641. augroup autocmd groups
  2642. buffer buffer names
  2643. behave :behave suboptions
  2644. cmdline |cmdline-completion| result
  2645. color color schemes
  2646. command Ex command
  2647. compiler compilers
  2648. cscope |:cscope| suboptions
  2649. diff_buffer |:diffget| and |:diffput| completion
  2650. dir directory names
  2651. environment environment variable names
  2652. event autocommand events
  2653. expression Vim expression
  2654. file file and directory names
  2655. file_in_path file and directory names in |'path'|
  2656. filetype filetype names |'filetype'|
  2657. function function name
  2658. help help subjects
  2659. highlight highlight groups
  2660. history :history suboptions
  2661. locale locale names (as output of locale -a)
  2662. mapclear buffer argument
  2663. mapping mapping name
  2664. menu menus
  2665. messages |:messages| suboptions
  2666. option options
  2667. packadd optional package |pack-add| names
  2668. shellcmd Shell command
  2669. sign |:sign| suboptions
  2670. syntax syntax file names |'syntax'|
  2671. syntime |:syntime| suboptions
  2672. tag tags
  2673. tag_listfiles tags, file names
  2674. user user names
  2675. var user variables
  2676. If {pat} is an empty string, then all the matches are
  2677. returned. Otherwise only items matching {pat} are returned.
  2678. See |wildcards| for the use of special characters in {pat}.
  2679. If the optional {filtered} flag is set to 1, then 'wildignore'
  2680. is applied to filter the results. Otherwise all the matches
  2681. are returned. The 'wildignorecase' option always applies.
  2682. If {type} is "cmdline", then the |cmdline-completion| result is
  2683. returned. For example, to complete the possible values after
  2684. a ":call" command: >
  2685. echo getcompletion('call ', 'cmdline')
  2686. <
  2687. If there are no matches, an empty list is returned. An
  2688. invalid value for {type} produces an error.
  2689. Can also be used as a |method|: >
  2690. GetPattern()->getcompletion('color')
  2691. <
  2692. *getcurpos()*
  2693. getcurpos([{winid}])
  2694. Get the position of the cursor. This is like getpos('.'), but
  2695. includes an extra "curswant" in the list:
  2696. [0, lnum, col, off, curswant] ~
  2697. The "curswant" number is the preferred column when moving the
  2698. cursor vertically. Also see |getcursorcharpos()| and
  2699. |getpos()|.
  2700. The first "bufnum" item is always zero. The byte position of
  2701. the cursor is returned in "col". To get the character
  2702. position, use |getcursorcharpos()|.
  2703. The optional {winid} argument can specify the window. It can
  2704. be the window number or the |window-ID|. The last known
  2705. cursor position is returned, this may be invalid for the
  2706. current value of the buffer if it is not the current window.
  2707. If {winid} is invalid a list with zeroes is returned.
  2708. This can be used to save and restore the cursor position: >
  2709. let save_cursor = getcurpos()
  2710. MoveTheCursorAround
  2711. call setpos('.', save_cursor)
  2712. < Note that this only works within the window. See
  2713. |winrestview()| for restoring more state.
  2714. Can also be used as a |method|: >
  2715. GetWinid()->getcurpos()
  2716. <
  2717. *getcursorcharpos()*
  2718. getcursorcharpos([{winid}])
  2719. Same as |getcurpos()| but the column number in the returned
  2720. List is a character index instead of a byte index.
  2721. Example:
  2722. With the cursor on '보' in line 3 with text "여보세요": >
  2723. getcursorcharpos() returns [0, 3, 2, 0, 3]
  2724. getcurpos() returns [0, 3, 4, 0, 3]
  2725. <
  2726. Can also be used as a |method|: >
  2727. GetWinid()->getcursorcharpos()
  2728. getcwd([{winnr} [, {tabnr}]]) *getcwd()*
  2729. With no arguments, returns the name of the effective
  2730. |current-directory|. With {winnr} or {tabnr} the working
  2731. directory of that scope is returned, and 'autochdir' is
  2732. ignored.
  2733. Tabs and windows are identified by their respective numbers,
  2734. 0 means current tab or window. Missing tab number implies 0.
  2735. Thus the following are equivalent: >
  2736. getcwd(0)
  2737. getcwd(0, 0)
  2738. < If {winnr} is -1 it is ignored, only the tab is resolved.
  2739. {winnr} can be the window number or the |window-ID|.
  2740. If both {winnr} and {tabnr} are -1 the global working
  2741. directory is returned.
  2742. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  2743. Can also be used as a |method|: >
  2744. GetWinnr()->getcwd()
  2745. getenv({name}) *getenv()*
  2746. Return the value of environment variable {name}. The {name}
  2747. argument is a string, without a leading '$'. Example: >
  2748. myHome = getenv('HOME')
  2749. < When the variable does not exist |v:null| is returned. That
  2750. is different from a variable set to an empty string.
  2751. See also |expr-env|.
  2752. Can also be used as a |method|: >
  2753. GetVarname()->getenv()
  2754. getfontname([{name}]) *getfontname()*
  2755. Without an argument returns the name of the normal font being
  2756. used. Like what is used for the Normal highlight group
  2757. |hl-Normal|.
  2758. With an argument a check is done whether String {name} is a
  2759. valid font name. If not then an empty string is returned.
  2760. Otherwise the actual font name is returned, or {name} if the
  2761. GUI does not support obtaining the real name.
  2762. Only works when the GUI is running, thus not in your vimrc or
  2763. gvimrc file. Use the |GUIEnter| autocommand to use this
  2764. function just after the GUI has started.
  2765. getfperm({fname}) *getfperm()*
  2766. The result is a String, which is the read, write, and execute
  2767. permissions of the given file {fname}.
  2768. If {fname} does not exist or its directory cannot be read, an
  2769. empty string is returned.
  2770. The result is of the form "rwxrwxrwx", where each group of
  2771. "rwx" flags represent, in turn, the permissions of the owner
  2772. of the file, the group the file belongs to, and other users.
  2773. If a user does not have a given permission the flag for this
  2774. is replaced with the string "-". Examples: >
  2775. :echo getfperm("/etc/passwd")
  2776. :echo getfperm(expand("~/.config/nvim/init.vim"))
  2777. < This will hopefully (from a security point of view) display
  2778. the string "rw-r--r--" or even "rw-------".
  2779. Can also be used as a |method|: >
  2780. GetFilename()->getfperm()
  2781. <
  2782. For setting permissions use |setfperm()|.
  2783. getfsize({fname}) *getfsize()*
  2784. The result is a Number, which is the size in bytes of the
  2785. given file {fname}.
  2786. If {fname} is a directory, 0 is returned.
  2787. If the file {fname} can't be found, -1 is returned.
  2788. If the size of {fname} is too big to fit in a Number then -2
  2789. is returned.
  2790. Can also be used as a |method|: >
  2791. GetFilename()->getfsize()
  2792. getftime({fname}) *getftime()*
  2793. The result is a Number, which is the last modification time of
  2794. the given file {fname}. The value is measured as seconds
  2795. since 1st Jan 1970, and may be passed to strftime(). See also
  2796. |localtime()| and |strftime()|.
  2797. If the file {fname} can't be found -1 is returned.
  2798. Can also be used as a |method|: >
  2799. GetFilename()->getftime()
  2800. getftype({fname}) *getftype()*
  2801. The result is a String, which is a description of the kind of
  2802. file of the given file {fname}.
  2803. If {fname} does not exist an empty string is returned.
  2804. Here is a table over different kinds of files and their
  2805. results:
  2806. Normal file "file"
  2807. Directory "dir"
  2808. Symbolic link "link"
  2809. Block device "bdev"
  2810. Character device "cdev"
  2811. Socket "socket"
  2812. FIFO "fifo"
  2813. All other "other"
  2814. Example: >
  2815. getftype("/home")
  2816. < Note that a type such as "link" will only be returned on
  2817. systems that support it. On some systems only "dir" and
  2818. "file" are returned.
  2819. Can also be used as a |method|: >
  2820. GetFilename()->getftype()
  2821. getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
  2822. Returns the |jumplist| for the specified window.
  2823. Without arguments use the current window.
  2824. With {winnr} only use this window in the current tab page.
  2825. {winnr} can also be a |window-ID|.
  2826. With {winnr} and {tabnr} use the window in the specified tab
  2827. page. If {winnr} or {tabnr} is invalid, an empty list is
  2828. returned.
  2829. The returned list contains two entries: a list with the jump
  2830. locations and the last used jump position number in the list.
  2831. Each entry in the jump location list is a dictionary with
  2832. the following entries:
  2833. bufnr buffer number
  2834. col column number
  2835. coladd column offset for 'virtualedit'
  2836. filename filename if available
  2837. lnum line number
  2838. Can also be used as a |method|: >
  2839. GetWinnr()->getjumplist()
  2840. < *getline()*
  2841. getline({lnum} [, {end}])
  2842. Without {end} the result is a String, which is line {lnum}
  2843. from the current buffer. Example: >
  2844. getline(1)
  2845. < When {lnum} is a String that doesn't start with a
  2846. digit, |line()| is called to translate the String into a Number.
  2847. To get the line under the cursor: >
  2848. getline(".")
  2849. < When {lnum} is a number smaller than 1 or bigger than the
  2850. number of lines in the buffer, an empty string is returned.
  2851. When {end} is given the result is a |List| where each item is
  2852. a line from the current buffer in the range {lnum} to {end},
  2853. including line {end}.
  2854. {end} is used in the same way as {lnum}.
  2855. Non-existing lines are silently omitted.
  2856. When {end} is before {lnum} an empty |List| is returned.
  2857. Example: >
  2858. :let start = line('.')
  2859. :let end = search("^$") - 1
  2860. :let lines = getline(start, end)
  2861. < Can also be used as a |method|: >
  2862. ComputeLnum()->getline()
  2863. < To get lines from another buffer see |getbufline()|
  2864. getloclist({nr} [, {what}]) *getloclist()*
  2865. Returns a |List| with all the entries in the location list for
  2866. window {nr}. {nr} can be the window number or the |window-ID|.
  2867. When {nr} is zero the current window is used.
  2868. For a location list window, the displayed location list is
  2869. returned. For an invalid window number {nr}, an empty list is
  2870. returned. Otherwise, same as |getqflist()|.
  2871. If the optional {what} dictionary argument is supplied, then
  2872. returns the items listed in {what} as a dictionary. Refer to
  2873. |getqflist()| for the supported items in {what}.
  2874. In addition to the items supported by |getqflist()| in {what},
  2875. the following item is supported by |getloclist()|:
  2876. filewinid id of the window used to display files
  2877. from the location list. This field is
  2878. applicable only when called from a
  2879. location list window. See
  2880. |location-list-file-window| for more
  2881. details.
  2882. Returns a |Dictionary| with default values if there is no
  2883. location list for the window {nr}.
  2884. Returns an empty Dictionary if window {nr} does not exist.
  2885. Examples (See also |getqflist-examples|): >
  2886. :echo getloclist(3, {'all': 0})
  2887. :echo getloclist(5, {'filewinid': 0})
  2888. getmarklist([{buf}]) *getmarklist()*
  2889. Without the {buf} argument returns a |List| with information
  2890. about all the global marks. |mark|
  2891. If the optional {buf} argument is specified, returns the
  2892. local marks defined in buffer {buf}. For the use of {buf},
  2893. see |bufname()|. If {buf} is invalid, an empty list is
  2894. returned.
  2895. Each item in the returned List is a |Dict| with the following:
  2896. mark name of the mark prefixed by "'"
  2897. pos a |List| with the position of the mark:
  2898. [bufnum, lnum, col, off]
  2899. Refer to |getpos()| for more information.
  2900. file file name
  2901. Refer to |getpos()| for getting information about a specific
  2902. mark.
  2903. Can also be used as a |method|: >
  2904. GetBufnr()->getmarklist()
  2905. getmatches([{win}]) *getmatches()*
  2906. Returns a |List| with all matches previously defined for the
  2907. current window by |matchadd()| and the |:match| commands.
  2908. |getmatches()| is useful in combination with |setmatches()|,
  2909. as |setmatches()| can restore a list of matches saved by
  2910. |getmatches()|.
  2911. If {win} is specified, use the window with this number or
  2912. window ID instead of the current window. If {win} is invalid,
  2913. an empty list is returned.
  2914. Example: >
  2915. :echo getmatches()
  2916. < [{"group": "MyGroup1", "pattern": "TODO",
  2917. "priority": 10, "id": 1}, {"group": "MyGroup2",
  2918. "pattern": "FIXME", "priority": 10, "id": 2}] >
  2919. :let m = getmatches()
  2920. :call clearmatches()
  2921. :echo getmatches()
  2922. < [] >
  2923. :call setmatches(m)
  2924. :echo getmatches()
  2925. < [{"group": "MyGroup1", "pattern": "TODO",
  2926. "priority": 10, "id": 1}, {"group": "MyGroup2",
  2927. "pattern": "FIXME", "priority": 10, "id": 2}] >
  2928. :unlet m
  2929. <
  2930. getmousepos() *getmousepos()*
  2931. Returns a Dictionary with the last known position of the
  2932. mouse. This can be used in a mapping for a mouse click. The
  2933. items are:
  2934. screenrow screen row
  2935. screencol screen column
  2936. winid Window ID of the click
  2937. winrow row inside "winid"
  2938. wincol column inside "winid"
  2939. line text line inside "winid"
  2940. column text column inside "winid"
  2941. All numbers are 1-based.
  2942. If not over a window, e.g. when in the command line, then only
  2943. "screenrow" and "screencol" are valid, the others are zero.
  2944. When on the status line below a window or the vertical
  2945. separator right of a window, the "line" and "column" values
  2946. are zero.
  2947. When the position is after the text then "column" is the
  2948. length of the text in bytes plus one.
  2949. If the mouse is over a focusable floating window then that
  2950. window is used.
  2951. When using |getchar()| the Vim variables |v:mouse_lnum|,
  2952. |v:mouse_col| and |v:mouse_winid| also provide these values.
  2953. *getpid()*
  2954. getpid() Return a Number which is the process ID of the Vim process.
  2955. This is a unique number, until Vim exits.
  2956. *getpos()*
  2957. getpos({expr}) Get the position for String {expr}. For possible values of
  2958. {expr} see |line()|. For getting the cursor position see
  2959. |getcurpos()|.
  2960. The result is a |List| with four numbers:
  2961. [bufnum, lnum, col, off]
  2962. "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  2963. is the buffer number of the mark.
  2964. "lnum" and "col" are the position in the buffer. The first
  2965. column is 1.
  2966. The "off" number is zero, unless 'virtualedit' is used. Then
  2967. it is the offset in screen columns from the start of the
  2968. character. E.g., a position within a <Tab> or after the last
  2969. character.
  2970. Note that for '< and '> Visual mode matters: when it is "V"
  2971. (visual line mode) the column of '< is zero and the column of
  2972. '> is a large number.
  2973. The column number in the returned List is the byte position
  2974. within the line. To get the character position in the line,
  2975. use |getcharpos()|.
  2976. The column number can be very large, e.g. 2147483647, in which
  2977. case it means "after the end of the line".
  2978. If {expr} is invalid, returns a list with all zeros.
  2979. This can be used to save and restore the position of a mark: >
  2980. let save_a_mark = getpos("'a")
  2981. ...
  2982. call setpos("'a", save_a_mark)
  2983. < Also see |getcharpos()|, |getcurpos()| and |setpos()|.
  2984. Can also be used as a |method|: >
  2985. GetMark()->getpos()
  2986. getqflist([{what}]) *getqflist()*
  2987. Returns a |List| with all the current quickfix errors. Each
  2988. list item is a dictionary with these entries:
  2989. bufnr number of buffer that has the file name, use
  2990. bufname() to get the name
  2991. module module name
  2992. lnum line number in the buffer (first line is 1)
  2993. end_lnum
  2994. end of line number if the item is multiline
  2995. col column number (first column is 1)
  2996. end_col end of column number if the item has range
  2997. vcol |TRUE|: "col" is visual column
  2998. |FALSE|: "col" is byte index
  2999. nr error number
  3000. pattern search pattern used to locate the error
  3001. text description of the error
  3002. type type of the error, 'E', '1', etc.
  3003. valid |TRUE|: recognized error message
  3004. When there is no error list or it's empty, an empty list is
  3005. returned. Quickfix list entries with a non-existing buffer
  3006. number are returned with "bufnr" set to zero (Note: some
  3007. functions accept buffer number zero for the alternate buffer,
  3008. you may need to explicitly check for zero).
  3009. Useful application: Find pattern matches in multiple files and
  3010. do something with them: >
  3011. :vimgrep /theword/jg *.c
  3012. :for d in getqflist()
  3013. : echo bufname(d.bufnr) ':' d.lnum '=' d.text
  3014. :endfor
  3015. <
  3016. If the optional {what} dictionary argument is supplied, then
  3017. returns only the items listed in {what} as a dictionary. The
  3018. following string items are supported in {what}:
  3019. changedtick get the total number of changes made
  3020. to the list |quickfix-changedtick|
  3021. context get the |quickfix-context|
  3022. efm errorformat to use when parsing "lines". If
  3023. not present, then the 'errorformat' option
  3024. value is used.
  3025. id get information for the quickfix list with
  3026. |quickfix-ID|; zero means the id for the
  3027. current list or the list specified by "nr"
  3028. idx get information for the quickfix entry at this
  3029. index in the list specified by "id" or "nr".
  3030. If set to zero, then uses the current entry.
  3031. See |quickfix-index|
  3032. items quickfix list entries
  3033. lines parse a list of lines using 'efm' and return
  3034. the resulting entries. Only a |List| type is
  3035. accepted. The current quickfix list is not
  3036. modified. See |quickfix-parse|.
  3037. nr get information for this quickfix list; zero
  3038. means the current quickfix list and "$" means
  3039. the last quickfix list
  3040. qfbufnr number of the buffer displayed in the quickfix
  3041. window. Returns 0 if the quickfix buffer is
  3042. not present. See |quickfix-buffer|.
  3043. size number of entries in the quickfix list
  3044. title get the list title |quickfix-title|
  3045. winid get the quickfix |window-ID|
  3046. all all of the above quickfix properties
  3047. Non-string items in {what} are ignored. To get the value of a
  3048. particular item, set it to zero.
  3049. If "nr" is not present then the current quickfix list is used.
  3050. If both "nr" and a non-zero "id" are specified, then the list
  3051. specified by "id" is used.
  3052. To get the number of lists in the quickfix stack, set "nr" to
  3053. "$" in {what}. The "nr" value in the returned dictionary
  3054. contains the quickfix stack size.
  3055. When "lines" is specified, all the other items except "efm"
  3056. are ignored. The returned dictionary contains the entry
  3057. "items" with the list of entries.
  3058. The returned dictionary contains the following entries:
  3059. changedtick total number of changes made to the
  3060. list |quickfix-changedtick|
  3061. context quickfix list context. See |quickfix-context|
  3062. If not present, set to "".
  3063. id quickfix list ID |quickfix-ID|. If not
  3064. present, set to 0.
  3065. idx index of the quickfix entry in the list. If not
  3066. present, set to 0.
  3067. items quickfix list entries. If not present, set to
  3068. an empty list.
  3069. nr quickfix list number. If not present, set to 0
  3070. qfbufnr number of the buffer displayed in the quickfix
  3071. window. If not present, set to 0.
  3072. size number of entries in the quickfix list. If not
  3073. present, set to 0.
  3074. title quickfix list title text. If not present, set
  3075. to "".
  3076. winid quickfix |window-ID|. If not present, set to 0
  3077. Examples (See also |getqflist-examples|): >
  3078. :echo getqflist({'all': 1})
  3079. :echo getqflist({'nr': 2, 'title': 1})
  3080. :echo getqflist({'lines' : ["F1:10:L10"]})
  3081. <
  3082. getreg([{regname} [, 1 [, {list}]]]) *getreg()*
  3083. The result is a String, which is the contents of register
  3084. {regname}. Example: >
  3085. :let cliptext = getreg('*')
  3086. < When register {regname} was not set the result is an empty
  3087. string.
  3088. The {regname} argument must be a string.
  3089. getreg('=') returns the last evaluated value of the expression
  3090. register. (For use in maps.)
  3091. getreg('=', 1) returns the expression itself, so that it can
  3092. be restored with |setreg()|. For other registers the extra
  3093. argument is ignored, thus you can always give it.
  3094. If {list} is present and |TRUE|, the result type is changed
  3095. to |List|. Each list item is one text line. Use it if you care
  3096. about zero bytes possibly present inside register: without
  3097. third argument both NLs and zero bytes are represented as NLs
  3098. (see |NL-used-for-Nul|).
  3099. When the register was not set an empty list is returned.
  3100. If {regname} is not specified, |v:register| is used.
  3101. Can also be used as a |method|: >
  3102. GetRegname()->getreg()
  3103. getreginfo([{regname}]) *getreginfo()*
  3104. Returns detailed information about register {regname} as a
  3105. Dictionary with the following entries:
  3106. regcontents List of lines contained in register
  3107. {regname}, like
  3108. getreg({regname}, 1, 1).
  3109. regtype the type of register {regname}, as in
  3110. |getregtype()|.
  3111. isunnamed Boolean flag, v:true if this register
  3112. is currently pointed to by the unnamed
  3113. register.
  3114. points_to for the unnamed register, gives the
  3115. single letter name of the register
  3116. currently pointed to (see |quotequote|).
  3117. For example, after deleting a line
  3118. with `dd`, this field will be "1",
  3119. which is the register that got the
  3120. deleted text.
  3121. The {regname} argument is a string. If {regname} is invalid
  3122. or not set, an empty Dictionary will be returned.
  3123. If {regname} is not specified, |v:register| is used.
  3124. The returned Dictionary can be passed to |setreg()|.
  3125. Can also be used as a |method|: >
  3126. GetRegname()->getreginfo()
  3127. getregtype([{regname}]) *getregtype()*
  3128. The result is a String, which is type of register {regname}.
  3129. The value will be one of:
  3130. "v" for |charwise| text
  3131. "V" for |linewise| text
  3132. "<CTRL-V>{width}" for |blockwise-visual| text
  3133. "" for an empty or unknown register
  3134. <CTRL-V> is one character with value 0x16.
  3135. The {regname} argument is a string. If {regname} is not
  3136. specified, |v:register| is used.
  3137. Can also be used as a |method|: >
  3138. GetRegname()->getregtype()
  3139. gettabinfo([{tabnr}]) *gettabinfo()*
  3140. If {tabnr} is not specified, then information about all the
  3141. tab pages is returned as a |List|. Each List item is a
  3142. |Dictionary|. Otherwise, {tabnr} specifies the tab page
  3143. number and information about that one is returned. If the tab
  3144. page does not exist an empty List is returned.
  3145. Each List item is a |Dictionary| with the following entries:
  3146. tabnr tab page number.
  3147. variables a reference to the dictionary with
  3148. tabpage-local variables
  3149. windows List of |window-ID|s in the tab page.
  3150. Can also be used as a |method|: >
  3151. GetTabnr()->gettabinfo()
  3152. gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
  3153. Get the value of a tab-local variable {varname} in tab page
  3154. {tabnr}. |t:var|
  3155. Tabs are numbered starting with one.
  3156. The {varname} argument is a string. When {varname} is empty a
  3157. dictionary with all tab-local variables is returned.
  3158. Note that the name without "t:" must be used.
  3159. When the tab or variable doesn't exist {def} or an empty
  3160. string is returned, there is no error message.
  3161. Can also be used as a |method|: >
  3162. GetTabnr()->gettabvar(varname)
  3163. gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
  3164. Get the value of window-local variable {varname} in window
  3165. {winnr} in tab page {tabnr}.
  3166. The {varname} argument is a string. When {varname} is empty a
  3167. dictionary with all window-local variables is returned.
  3168. When {varname} is equal to "&" get the values of all
  3169. window-local options in a |Dictionary|.
  3170. Otherwise, when {varname} starts with "&" get the value of a
  3171. window-local option.
  3172. Note that {varname} must be the name without "w:".
  3173. Tabs are numbered starting with one. For the current tabpage
  3174. use |getwinvar()|.
  3175. {winnr} can be the window number or the |window-ID|.
  3176. When {winnr} is zero the current window is used.
  3177. This also works for a global option, buffer-local option and
  3178. window-local option, but it doesn't work for a global variable
  3179. or buffer-local variable.
  3180. When the tab, window or variable doesn't exist {def} or an
  3181. empty string is returned, there is no error message.
  3182. Examples: >
  3183. :let list_is_on = gettabwinvar(1, 2, '&list')
  3184. :echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
  3185. <
  3186. To obtain all window-local variables use: >
  3187. gettabwinvar({tabnr}, {winnr}, '&')
  3188. < Can also be used as a |method|: >
  3189. GetTabnr()->gettabwinvar(winnr, varname)
  3190. gettagstack([{winnr}]) *gettagstack()*
  3191. The result is a Dict, which is the tag stack of window {winnr}.
  3192. {winnr} can be the window number or the |window-ID|.
  3193. When {winnr} is not specified, the current window is used.
  3194. When window {winnr} doesn't exist, an empty Dict is returned.
  3195. The returned dictionary contains the following entries:
  3196. curidx Current index in the stack. When at
  3197. top of the stack, set to (length + 1).
  3198. Index of bottom of the stack is 1.
  3199. items List of items in the stack. Each item
  3200. is a dictionary containing the
  3201. entries described below.
  3202. length Number of entries in the stack.
  3203. Each item in the stack is a dictionary with the following
  3204. entries:
  3205. bufnr buffer number of the current jump
  3206. from cursor position before the tag jump.
  3207. See |getpos()| for the format of the
  3208. returned list.
  3209. matchnr current matching tag number. Used when
  3210. multiple matching tags are found for a
  3211. name.
  3212. tagname name of the tag
  3213. See |tagstack| for more information about the tag stack.
  3214. Can also be used as a |method|: >
  3215. GetWinnr()->gettagstack()
  3216. getwininfo([{winid}]) *getwininfo()*
  3217. Returns information about windows as a |List| with Dictionaries.
  3218. If {winid} is given Information about the window with that ID
  3219. is returned, as a |List| with one item. If the window does not
  3220. exist the result is an empty list.
  3221. Without {winid} information about all the windows in all the
  3222. tab pages is returned.
  3223. Each List item is a |Dictionary| with the following entries:
  3224. botline last complete displayed buffer line
  3225. bufnr number of buffer in the window
  3226. height window height (excluding winbar)
  3227. loclist 1 if showing a location list
  3228. quickfix 1 if quickfix or location list window
  3229. terminal 1 if a terminal window
  3230. tabnr tab page number
  3231. topline first displayed buffer line
  3232. variables a reference to the dictionary with
  3233. window-local variables
  3234. width window width
  3235. winbar 1 if the window has a toolbar, 0
  3236. otherwise
  3237. wincol leftmost screen column of the window;
  3238. "col" from |win_screenpos()|
  3239. textoff number of columns occupied by any
  3240. 'foldcolumn', 'signcolumn' and line
  3241. number in front of the text
  3242. winid |window-ID|
  3243. winnr window number
  3244. winrow topmost screen line of the window;
  3245. "row" from |win_screenpos()|
  3246. Can also be used as a |method|: >
  3247. GetWinnr()->getwininfo()
  3248. getwinpos([{timeout}]) *getwinpos()*
  3249. The result is a |List| with two numbers, the result of
  3250. |getwinposx()| and |getwinposy()| combined:
  3251. [x-pos, y-pos]
  3252. {timeout} can be used to specify how long to wait in msec for
  3253. a response from the terminal. When omitted 100 msec is used.
  3254. Use a longer time for a remote terminal.
  3255. When using a value less than 10 and no response is received
  3256. within that time, a previously reported position is returned,
  3257. if available. This can be used to poll for the position and
  3258. do some work in the meantime: >
  3259. while 1
  3260. let res = getwinpos(1)
  3261. if res[0] >= 0
  3262. break
  3263. endif
  3264. " Do some work here
  3265. endwhile
  3266. <
  3267. Can also be used as a |method|: >
  3268. GetTimeout()->getwinpos()
  3269. <
  3270. *getwinposx()*
  3271. getwinposx() The result is a Number, which is the X coordinate in pixels of
  3272. the left hand side of the GUI Vim window. The result will be
  3273. -1 if the information is not available.
  3274. The value can be used with `:winpos`.
  3275. *getwinposy()*
  3276. getwinposy() The result is a Number, which is the Y coordinate in pixels of
  3277. the top of the GUI Vim window. The result will be -1 if the
  3278. information is not available.
  3279. The value can be used with `:winpos`.
  3280. getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
  3281. Like |gettabwinvar()| for the current tabpage.
  3282. Examples: >
  3283. :let list_is_on = getwinvar(2, '&list')
  3284. :echo "myvar = " .. getwinvar(1, 'myvar')
  3285. < Can also be used as a |method|: >
  3286. GetWinnr()->getwinvar(varname)
  3287. <
  3288. glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
  3289. Expand the file wildcards in {expr}. See |wildcards| for the
  3290. use of special characters.
  3291. Unless the optional {nosuf} argument is given and is |TRUE|,
  3292. the 'suffixes' and 'wildignore' options apply: Names matching
  3293. one of the patterns in 'wildignore' will be skipped and
  3294. 'suffixes' affect the ordering of matches.
  3295. 'wildignorecase' always applies.
  3296. When {list} is present and it is |TRUE| the result is a |List|
  3297. with all matching files. The advantage of using a List is,
  3298. you also get filenames containing newlines correctly.
  3299. Otherwise the result is a String and when there are several
  3300. matches, they are separated by <NL> characters.
  3301. If the expansion fails, the result is an empty String or List.
  3302. You can also use |readdir()| if you need to do complicated
  3303. things, such as limiting the number of matches.
  3304. A name for a non-existing file is not included. A symbolic
  3305. link is only included if it points to an existing file.
  3306. However, when the {alllinks} argument is present and it is
  3307. |TRUE| then all symbolic links are included.
  3308. For most systems backticks can be used to get files names from
  3309. any external command. Example: >
  3310. :let tagfiles = glob("`find . -name tags -print`")
  3311. :let &tags = substitute(tagfiles, "\n", ",", "g")
  3312. < The result of the program inside the backticks should be one
  3313. item per line. Spaces inside an item are allowed.
  3314. See |expand()| for expanding special Vim variables. See
  3315. |system()| for getting the raw output of an external command.
  3316. Can also be used as a |method|: >
  3317. GetExpr()->glob()
  3318. glob2regpat({string}) *glob2regpat()*
  3319. Convert a file pattern, as used by glob(), into a search
  3320. pattern. The result can be used to match with a string that
  3321. is a file name. E.g. >
  3322. if filename =~ glob2regpat('Make*.mak')
  3323. < This is equivalent to: >
  3324. if filename =~ '^Make.*\.mak$'
  3325. < When {string} is an empty string the result is "^$", match an
  3326. empty string.
  3327. Note that the result depends on the system. On MS-Windows
  3328. a backslash usually means a path separator.
  3329. Can also be used as a |method|: >
  3330. GetExpr()->glob2regpat()
  3331. < *globpath()*
  3332. globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
  3333. Perform glob() for String {expr} on all directories in {path}
  3334. and concatenate the results. Example: >
  3335. :echo globpath(&rtp, "syntax/c.vim")
  3336. <
  3337. {path} is a comma-separated list of directory names. Each
  3338. directory name is prepended to {expr} and expanded like with
  3339. |glob()|. A path separator is inserted when needed.
  3340. To add a comma inside a directory name escape it with a
  3341. backslash. Note that on MS-Windows a directory may have a
  3342. trailing backslash, remove it if you put a comma after it.
  3343. If the expansion fails for one of the directories, there is no
  3344. error message.
  3345. Unless the optional {nosuf} argument is given and is |TRUE|,
  3346. the 'suffixes' and 'wildignore' options apply: Names matching
  3347. one of the patterns in 'wildignore' will be skipped and
  3348. 'suffixes' affect the ordering of matches.
  3349. When {list} is present and it is |TRUE| the result is a |List|
  3350. with all matching files. The advantage of using a List is, you
  3351. also get filenames containing newlines correctly. Otherwise
  3352. the result is a String and when there are several matches,
  3353. they are separated by <NL> characters. Example: >
  3354. :echo globpath(&rtp, "syntax/c.vim", 0, 1)
  3355. <
  3356. {allinks} is used as with |glob()|.
  3357. The "**" item can be used to search in a directory tree.
  3358. For example, to find all "README.txt" files in the directories
  3359. in 'runtimepath' and below: >
  3360. :echo globpath(&rtp, "**/README.txt")
  3361. < Upwards search and limiting the depth of "**" is not
  3362. supported, thus using 'path' will not always work properly.
  3363. Can also be used as a |method|, the base is passed as the
  3364. second argument: >
  3365. GetExpr()->globpath(&rtp)
  3366. <
  3367. *has()*
  3368. has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
  3369. {feature} argument is a feature name like "nvim-0.2.1" or
  3370. "win32", see below. See also |exists()|.
  3371. To get the system name use |vim.loop|.os_uname() in Lua: >
  3372. :lua print(vim.loop.os_uname().sysname)
  3373. < If the code has a syntax error then Vimscript may skip the
  3374. rest of the line. Put |:if| and |:endif| on separate lines to
  3375. avoid the syntax error: >
  3376. if has('feature')
  3377. let x = this->breaks->without->the->feature
  3378. endif
  3379. <
  3380. Vim's compile-time feature-names (prefixed with "+") are not
  3381. recognized because Nvim is always compiled with all possible
  3382. features. |feature-compile|
  3383. Feature names can be:
  3384. 1. Nvim version. For example the "nvim-0.2.1" feature means
  3385. that Nvim is version 0.2.1 or later: >
  3386. :if has("nvim-0.2.1")
  3387. < 2. Runtime condition or other pseudo-feature. For example the
  3388. "win32" feature checks if the current system is Windows: >
  3389. :if has("win32")
  3390. < *feature-list*
  3391. List of supported pseudo-feature names:
  3392. acl |ACL| support.
  3393. bsd BSD system (not macOS, use "mac" for that).
  3394. clipboard |clipboard| provider is available.
  3395. fname_case Case in file names matters (for Darwin and MS-Windows
  3396. this is not present).
  3397. iconv Can use |iconv()| for conversion.
  3398. linux Linux system.
  3399. mac MacOS system.
  3400. nvim This is Nvim.
  3401. python3 Legacy Vim |python3| interface. |has-python|
  3402. pythonx Legacy Vim |python_x| interface. |has-pythonx|
  3403. sun SunOS system.
  3404. ttyin input is a terminal (tty).
  3405. ttyout output is a terminal (tty).
  3406. unix Unix system.
  3407. *vim_starting* True during |startup|.
  3408. win32 Windows system (32 or 64 bit).
  3409. win64 Windows system (64 bit).
  3410. wsl WSL (Windows Subsystem for Linux) system.
  3411. *has-patch*
  3412. 3. Vim patch. For example the "patch123" feature means that
  3413. Vim patch 123 at the current |v:version| was included: >
  3414. :if v:version > 602 || v:version == 602 && has("patch148")
  3415. < 4. Vim version. For example the "patch-7.4.237" feature means
  3416. that Nvim is Vim-compatible to version 7.4.237 or later. >
  3417. :if has("patch-7.4.237")
  3418. has_key({dict}, {key}) *has_key()*
  3419. The result is a Number, which is TRUE if |Dictionary| {dict}
  3420. has an entry with key {key}. FALSE otherwise. The {key}
  3421. argument is a string.
  3422. Can also be used as a |method|: >
  3423. mydict->has_key(key)
  3424. haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
  3425. The result is a Number, which is 1 when the window has set a
  3426. local path via |:lcd| or when {winnr} is -1 and the tabpage
  3427. has set a local path via |:tcd|, otherwise 0.
  3428. Tabs and windows are identified by their respective numbers,
  3429. 0 means current tab or window. Missing argument implies 0.
  3430. Thus the following are equivalent: >
  3431. haslocaldir()
  3432. haslocaldir(0)
  3433. haslocaldir(0, 0)
  3434. < With {winnr} use that window in the current tabpage.
  3435. With {winnr} and {tabnr} use the window in that tabpage.
  3436. {winnr} can be the window number or the |window-ID|.
  3437. If {winnr} is -1 it is ignored, only the tab is resolved.
  3438. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  3439. Can also be used as a |method|: >
  3440. GetWinnr()->haslocaldir()
  3441. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
  3442. The result is a Number, which is TRUE if there is a mapping
  3443. that contains {what} in somewhere in the rhs (what it is
  3444. mapped to) and this mapping exists in one of the modes
  3445. indicated by {mode}.
  3446. The arguments {what} and {mode} are strings.
  3447. When {abbr} is there and it is |TRUE| use abbreviations
  3448. instead of mappings. Don't forget to specify Insert and/or
  3449. Command-line mode.
  3450. Both the global mappings and the mappings local to the current
  3451. buffer are checked for a match.
  3452. If no matching mapping is found FALSE is returned.
  3453. The following characters are recognized in {mode}:
  3454. n Normal mode
  3455. v Visual and Select mode
  3456. x Visual mode
  3457. s Select mode
  3458. o Operator-pending mode
  3459. i Insert mode
  3460. l Language-Argument ("r", "f", "t", etc.)
  3461. c Command-line mode
  3462. When {mode} is omitted, "nvo" is used.
  3463. This function is useful to check if a mapping already exists
  3464. to a function in a Vim script. Example: >
  3465. :if !hasmapto('\ABCdoit')
  3466. : map <Leader>d \ABCdoit
  3467. :endif
  3468. < This installs the mapping to "\ABCdoit" only if there isn't
  3469. already a mapping to "\ABCdoit".
  3470. Can also be used as a |method|: >
  3471. GetRHS()->hasmapto()
  3472. histadd({history}, {item}) *histadd()*
  3473. Add the String {item} to the history {history} which can be
  3474. one of: *hist-names*
  3475. "cmd" or ":" command line history
  3476. "search" or "/" search pattern history
  3477. "expr" or "=" typed expression history
  3478. "input" or "@" input line history
  3479. "debug" or ">" debug command history
  3480. empty the current or last used history
  3481. The {history} string does not need to be the whole name, one
  3482. character is sufficient.
  3483. If {item} does already exist in the history, it will be
  3484. shifted to become the newest entry.
  3485. The result is a Number: TRUE if the operation was successful,
  3486. otherwise FALSE is returned.
  3487. Example: >
  3488. :call histadd("input", strftime("%Y %b %d"))
  3489. :let date=input("Enter date: ")
  3490. < This function is not available in the |sandbox|.
  3491. Can also be used as a |method|, the base is passed as the
  3492. second argument: >
  3493. GetHistory()->histadd('search')
  3494. histdel({history} [, {item}]) *histdel()*
  3495. Clear {history}, i.e. delete all its entries. See |hist-names|
  3496. for the possible values of {history}.
  3497. If the parameter {item} evaluates to a String, it is used as a
  3498. regular expression. All entries matching that expression will
  3499. be removed from the history (if there are any).
  3500. Upper/lowercase must match, unless "\c" is used |/\c|.
  3501. If {item} evaluates to a Number, it will be interpreted as
  3502. an index, see |:history-indexing|. The respective entry will
  3503. be removed if it exists.
  3504. The result is TRUE for a successful operation, otherwise FALSE
  3505. is returned.
  3506. Examples:
  3507. Clear expression register history: >
  3508. :call histdel("expr")
  3509. <
  3510. Remove all entries starting with "*" from the search history: >
  3511. :call histdel("/", '^\*')
  3512. <
  3513. The following three are equivalent: >
  3514. :call histdel("search", histnr("search"))
  3515. :call histdel("search", -1)
  3516. :call histdel("search", '^' .. histget("search", -1) .. '$')
  3517. <
  3518. To delete the last search pattern and use the last-but-one for
  3519. the "n" command and 'hlsearch': >
  3520. :call histdel("search", -1)
  3521. :let @/ = histget("search", -1)
  3522. <
  3523. Can also be used as a |method|: >
  3524. GetHistory()->histdel()
  3525. histget({history} [, {index}]) *histget()*
  3526. The result is a String, the entry with Number {index} from
  3527. {history}. See |hist-names| for the possible values of
  3528. {history}, and |:history-indexing| for {index}. If there is
  3529. no such entry, an empty String is returned. When {index} is
  3530. omitted, the most recent item from the history is used.
  3531. Examples:
  3532. Redo the second last search from history. >
  3533. :execute '/' .. histget("search", -2)
  3534. < Define an Ex command ":H {num}" that supports re-execution of
  3535. the {num}th entry from the output of |:history|. >
  3536. :command -nargs=1 H execute histget("cmd", 0+<args>)
  3537. <
  3538. Can also be used as a |method|: >
  3539. GetHistory()->histget()
  3540. histnr({history}) *histnr()*
  3541. The result is the Number of the current entry in {history}.
  3542. See |hist-names| for the possible values of {history}.
  3543. If an error occurred, -1 is returned.
  3544. Example: >
  3545. :let inp_index = histnr("expr")
  3546. < Can also be used as a |method|: >
  3547. GetHistory()->histnr()
  3548. <
  3549. hlexists({name}) *hlexists()*
  3550. The result is a Number, which is TRUE if a highlight group
  3551. called {name} exists. This is when the group has been
  3552. defined in some way. Not necessarily when highlighting has
  3553. been defined for it, it may also have been used for a syntax
  3554. item.
  3555. Can also be used as a |method|: >
  3556. GetName()->hlexists()
  3557. <
  3558. *hlID()*
  3559. hlID({name}) The result is a Number, which is the ID of the highlight group
  3560. with name {name}. When the highlight group doesn't exist,
  3561. zero is returned.
  3562. This can be used to retrieve information about the highlight
  3563. group. For example, to get the background color of the
  3564. "Comment" group: >
  3565. :echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  3566. <
  3567. Can also be used as a |method|: >
  3568. GetName()->hlID()
  3569. hostname() *hostname()*
  3570. The result is a String, which is the name of the machine on
  3571. which Vim is currently running. Machine names greater than
  3572. 256 characters long are truncated.
  3573. iconv({string}, {from}, {to}) *iconv()*
  3574. The result is a String, which is the text {string} converted
  3575. from encoding {from} to encoding {to}.
  3576. When the conversion completely fails an empty string is
  3577. returned. When some characters could not be converted they
  3578. are replaced with "?".
  3579. The encoding names are whatever the iconv() library function
  3580. can accept, see ":!man 3 iconv".
  3581. Note that Vim uses UTF-8 for all Unicode encodings, conversion
  3582. from/to UCS-2 is automatically changed to use UTF-8. You
  3583. cannot use UCS-2 in a string anyway, because of the NUL bytes.
  3584. Can also be used as a |method|: >
  3585. GetText()->iconv('latin1', 'utf-8')
  3586. <
  3587. *indent()*
  3588. indent({lnum}) The result is a Number, which is indent of line {lnum} in the
  3589. current buffer. The indent is counted in spaces, the value
  3590. of 'tabstop' is relevant. {lnum} is used just like in
  3591. |getline()|.
  3592. When {lnum} is invalid -1 is returned.
  3593. Can also be used as a |method|: >
  3594. GetLnum()->indent()
  3595. index({object}, {expr} [, {start} [, {ic}]]) *index()*
  3596. If {object} is a |List| return the lowest index where the item
  3597. has a value equal to {expr}. There is no automatic
  3598. conversion, so the String "4" is different from the Number 4.
  3599. And the Number 4 is different from the Float 4.0. The value
  3600. of 'ignorecase' is not used here, case always matters.
  3601. If {object} is a |Blob| return the lowest index where the byte
  3602. value is equal to {expr}.
  3603. If {start} is given then start looking at the item with index
  3604. {start} (may be negative for an item relative to the end).
  3605. When {ic} is given and it is |TRUE|, ignore case. Otherwise
  3606. case must match.
  3607. -1 is returned when {expr} is not found in {object}.
  3608. Example: >
  3609. :let idx = index(words, "the")
  3610. :if index(numbers, 123) >= 0
  3611. < Can also be used as a |method|: >
  3612. GetObject()->index(what)
  3613. input({prompt} [, {text} [, {completion}]]) *input()*
  3614. input({opts})
  3615. The result is a String, which is whatever the user typed on
  3616. the command-line. The {prompt} argument is either a prompt
  3617. string, or a blank string (for no prompt). A '\n' can be used
  3618. in the prompt to start a new line.
  3619. In the second form it accepts a single dictionary with the
  3620. following keys, any of which may be omitted:
  3621. Key Default Description ~
  3622. prompt "" Same as {prompt} in the first form.
  3623. default "" Same as {text} in the first form.
  3624. completion nothing Same as {completion} in the first form.
  3625. cancelreturn "" The value returned when the dialog is
  3626. cancelled.
  3627. highlight nothing Highlight handler: |Funcref|.
  3628. The highlighting set with |:echohl| is used for the prompt.
  3629. The input is entered just like a command-line, with the same
  3630. editing commands and mappings. There is a separate history
  3631. for lines typed for input().
  3632. Example: >
  3633. :if input("Coffee or beer? ") == "beer"
  3634. : echo "Cheers!"
  3635. :endif
  3636. <
  3637. If the optional {text} argument is present and not empty, this
  3638. is used for the default reply, as if the user typed this.
  3639. Example: >
  3640. :let color = input("Color? ", "white")
  3641. < The optional {completion} argument specifies the type of
  3642. completion supported for the input. Without it completion is
  3643. not performed. The supported completion types are the same as
  3644. that can be supplied to a user-defined command using the
  3645. "-complete=" argument. Refer to |:command-completion| for
  3646. more information. Example: >
  3647. let fname = input("File: ", "", "file")
  3648. < *input()-highlight* *E5400* *E5402*
  3649. The optional `highlight` key allows specifying function which
  3650. will be used for highlighting user input. This function
  3651. receives user input as its only argument and must return
  3652. a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
  3653. where
  3654. hl_start_col is the first highlighted column,
  3655. hl_end_col is the last highlighted column (+ 1!),
  3656. hl_group is |:hi| group used for highlighting.
  3657. *E5403* *E5404* *E5405* *E5406*
  3658. Both hl_start_col and hl_end_col + 1 must point to the start
  3659. of the multibyte character (highlighting must not break
  3660. multibyte characters), hl_end_col + 1 may be equal to the
  3661. input length. Start column must be in range [0, len(input)),
  3662. end column must be in range (hl_start_col, len(input)],
  3663. sections must be ordered so that next hl_start_col is greater
  3664. then or equal to previous hl_end_col.
  3665. Example (try some input with parentheses): >
  3666. highlight RBP1 guibg=Red ctermbg=red
  3667. highlight RBP2 guibg=Yellow ctermbg=yellow
  3668. highlight RBP3 guibg=Green ctermbg=green
  3669. highlight RBP4 guibg=Blue ctermbg=blue
  3670. let g:rainbow_levels = 4
  3671. function! RainbowParens(cmdline)
  3672. let ret = []
  3673. let i = 0
  3674. let lvl = 0
  3675. while i < len(a:cmdline)
  3676. if a:cmdline[i] is# '('
  3677. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  3678. let lvl += 1
  3679. elseif a:cmdline[i] is# ')'
  3680. let lvl -= 1
  3681. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  3682. endif
  3683. let i += 1
  3684. endwhile
  3685. return ret
  3686. endfunction
  3687. call input({'prompt':'>','highlight':'RainbowParens'})
  3688. <
  3689. Highlight function is called at least once for each new
  3690. displayed input string, before command-line is redrawn. It is
  3691. expected that function is pure for the duration of one input()
  3692. call, i.e. it produces the same output for the same input, so
  3693. output may be memoized. Function is run like under |:silent|
  3694. modifier. If the function causes any errors, it will be
  3695. skipped for the duration of the current input() call.
  3696. Highlighting is disabled if command-line contains arabic
  3697. characters.
  3698. NOTE: This function must not be used in a startup file, for
  3699. the versions that only run in GUI mode (e.g., the Win32 GUI).
  3700. Note: When input() is called from within a mapping it will
  3701. consume remaining characters from that mapping, because a
  3702. mapping is handled like the characters were typed.
  3703. Use |inputsave()| before input() and |inputrestore()|
  3704. after input() to avoid that. Another solution is to avoid
  3705. that further characters follow in the mapping, e.g., by using
  3706. |:execute| or |:normal|.
  3707. Example with a mapping: >
  3708. :nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
  3709. :function GetFoo()
  3710. : call inputsave()
  3711. : let g:Foo = input("enter search pattern: ")
  3712. : call inputrestore()
  3713. :endfunction
  3714. < Can also be used as a |method|: >
  3715. GetPrompt()->input()
  3716. inputlist({textlist}) *inputlist()*
  3717. {textlist} must be a |List| of strings. This |List| is
  3718. displayed, one string per line. The user will be prompted to
  3719. enter a number, which is returned.
  3720. The user can also select an item by clicking on it with the
  3721. mouse, if the mouse is enabled in the command line ('mouse' is
  3722. "a" or includes "c"). For the first string 0 is returned.
  3723. When clicking above the first item a negative number is
  3724. returned. When clicking on the prompt one more than the
  3725. length of {textlist} is returned.
  3726. Make sure {textlist} has less than 'lines' entries, otherwise
  3727. it won't work. It's a good idea to put the entry number at
  3728. the start of the string. And put a prompt in the first item.
  3729. Example: >
  3730. let color = inputlist(['Select color:', '1. red',
  3731. \ '2. green', '3. blue'])
  3732. < Can also be used as a |method|: >
  3733. GetChoices()->inputlist()
  3734. inputrestore() *inputrestore()*
  3735. Restore typeahead that was saved with a previous |inputsave()|.
  3736. Should be called the same number of times inputsave() is
  3737. called. Calling it more often is harmless though.
  3738. Returns TRUE when there is nothing to restore, FALSE otherwise.
  3739. inputsave() *inputsave()*
  3740. Preserve typeahead (also from mappings) and clear it, so that
  3741. a following prompt gets input from the user. Should be
  3742. followed by a matching inputrestore() after the prompt. Can
  3743. be used several times, in which case there must be just as
  3744. many inputrestore() calls.
  3745. Returns TRUE when out of memory, FALSE otherwise.
  3746. inputsecret({prompt} [, {text}]) *inputsecret()*
  3747. This function acts much like the |input()| function with but
  3748. two exceptions:
  3749. a) the user's response will be displayed as a sequence of
  3750. asterisks ("*") thereby keeping the entry secret, and
  3751. b) the user's response will not be recorded on the input
  3752. |history| stack.
  3753. The result is a String, which is whatever the user actually
  3754. typed on the command-line in response to the issued prompt.
  3755. NOTE: Command-line completion is not supported.
  3756. Can also be used as a |method|: >
  3757. GetPrompt()->inputsecret()
  3758. insert({object}, {item} [, {idx}]) *insert()*
  3759. When {object} is a |List| or a |Blob| insert {item} at the start
  3760. of it.
  3761. If {idx} is specified insert {item} before the item with index
  3762. {idx}. If {idx} is zero it goes before the first item, just
  3763. like omitting {idx}. A negative {idx} is also possible, see
  3764. |list-index|. -1 inserts just before the last item.
  3765. Returns the resulting |List| or |Blob|. Examples: >
  3766. :let mylist = insert([2, 3, 5], 1)
  3767. :call insert(mylist, 4, -1)
  3768. :call insert(mylist, 6, len(mylist))
  3769. < The last example can be done simpler with |add()|.
  3770. Note that when {item} is a |List| it is inserted as a single
  3771. item. Use |extend()| to concatenate |Lists|.
  3772. Can also be used as a |method|: >
  3773. mylist->insert(item)
  3774. interrupt() *interrupt()*
  3775. Interrupt script execution. It works more or less like the
  3776. user typing CTRL-C, most commands won't execute and control
  3777. returns to the user. This is useful to abort execution
  3778. from lower down, e.g. in an autocommand. Example: >
  3779. :function s:check_typoname(file)
  3780. : if fnamemodify(a:file, ':t') == '['
  3781. : echomsg 'Maybe typo'
  3782. : call interrupt()
  3783. : endif
  3784. :endfunction
  3785. :au BufWritePre * call s:check_typoname(expand('<amatch>'))
  3786. invert({expr}) *invert()*
  3787. Bitwise invert. The argument is converted to a number. A
  3788. List, Dict or Float argument causes an error. Example: >
  3789. :let bits = invert(bits)
  3790. < Can also be used as a |method|: >
  3791. :let bits = bits->invert()
  3792. isdirectory({directory}) *isdirectory()*
  3793. The result is a Number, which is |TRUE| when a directory
  3794. with the name {directory} exists. If {directory} doesn't
  3795. exist, or isn't a directory, the result is |FALSE|. {directory}
  3796. is any expression, which is used as a String.
  3797. Can also be used as a |method|: >
  3798. GetName()->isdirectory()
  3799. isinf({expr}) *isinf()*
  3800. Return 1 if {expr} is a positive infinity, or -1 a negative
  3801. infinity, otherwise 0. >
  3802. :echo isinf(1.0 / 0.0)
  3803. < 1 >
  3804. :echo isinf(-1.0 / 0.0)
  3805. < -1
  3806. Can also be used as a |method|: >
  3807. Compute()->isinf()
  3808. islocked({expr}) *islocked()* *E786*
  3809. The result is a Number, which is |TRUE| when {expr} is the
  3810. name of a locked variable.
  3811. The string argument {expr} must be the name of a variable,
  3812. |List| item or |Dictionary| entry, not the variable itself!
  3813. Example: >
  3814. :let alist = [0, ['a', 'b'], 2, 3]
  3815. :lockvar 1 alist
  3816. :echo islocked('alist') " 1
  3817. :echo islocked('alist[1]') " 0
  3818. < When {expr} is a variable that does not exist you get an error
  3819. message. Use |exists()| to check for existence.
  3820. Can also be used as a |method|: >
  3821. GetName()->islocked()
  3822. id({expr}) *id()*
  3823. Returns a |String| which is a unique identifier of the
  3824. container type (|List|, |Dict|, |Blob| and |Partial|). It is
  3825. guaranteed that for the mentioned types `id(v1) ==# id(v2)`
  3826. returns true iff `type(v1) == type(v2) && v1 is v2`.
  3827. Note that |v:_null_string|, |v:_null_list|, |v:_null_dict| and
  3828. |v:_null_blob| have the same `id()` with different types
  3829. because they are internally represented as NULL pointers.
  3830. `id()` returns a hexadecimal representanion of the pointers to
  3831. the containers (i.e. like `0x994a40`), same as `printf("%p",
  3832. {expr})`, but it is advised against counting on the exact
  3833. format of the return value.
  3834. It is not guaranteed that `id(no_longer_existing_container)`
  3835. will not be equal to some other `id()`: new containers may
  3836. reuse identifiers of the garbage-collected ones.
  3837. items({dict}) *items()*
  3838. Return a |List| with all the key-value pairs of {dict}. Each
  3839. |List| item is a list with two items: the key of a {dict}
  3840. entry and the value of this entry. The |List| is in arbitrary
  3841. order. Also see |keys()| and |values()|.
  3842. Example: >
  3843. for [key, value] in items(mydict)
  3844. echo key .. ': ' .. value
  3845. endfor
  3846. < Can also be used as a |method|: >
  3847. mydict->items()
  3848. isnan({expr}) *isnan()*
  3849. Return |TRUE| if {expr} is a float with value NaN. >
  3850. echo isnan(0.0 / 0.0)
  3851. < 1
  3852. Can also be used as a |method|: >
  3853. Compute()->isnan()
  3854. jobpid({job}) *jobpid()*
  3855. Return the PID (process id) of |job-id| {job}.
  3856. jobresize({job}, {width}, {height}) *jobresize()*
  3857. Resize the pseudo terminal window of |job-id| {job} to {width}
  3858. columns and {height} rows.
  3859. Fails if the job was not started with `"pty":v:true`.
  3860. jobstart({cmd} [, {opts}]) *jobstart()*
  3861. Spawns {cmd} as a job.
  3862. If {cmd} is a List it runs directly (no 'shell').
  3863. If {cmd} is a String it runs in the 'shell', like this: >
  3864. :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  3865. < (See |shell-unquoting| for details.)
  3866. Example: >
  3867. :call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
  3868. <
  3869. Returns |job-id| on success, 0 on invalid arguments (or job
  3870. table is full), -1 if {cmd}[0] or 'shell' is not executable.
  3871. The returned job-id is a valid |channel-id| representing the
  3872. job's stdio streams. Use |chansend()| (or |rpcnotify()| and
  3873. |rpcrequest()| if "rpc" was enabled) to send data to stdin and
  3874. |chanclose()| to close the streams without stopping the job.
  3875. See |job-control| and |RPC|.
  3876. NOTE: on Windows if {cmd} is a List:
  3877. - cmd[0] must be an executable (not a "built-in"). If it is
  3878. in $PATH it can be called by name, without an extension: >
  3879. :call jobstart(['ping', 'neovim.io'])
  3880. < If it is a full or partial path, extension is required: >
  3881. :call jobstart(['System32\ping.exe', 'neovim.io'])
  3882. < - {cmd} is collapsed to a string of quoted args as expected
  3883. by CommandLineToArgvW https://msdn.microsoft.com/bb776391
  3884. unless cmd[0] is some form of "cmd.exe".
  3885. *jobstart-env*
  3886. The job environment is initialized as follows:
  3887. $NVIM is set to |v:servername| of the parent Nvim
  3888. $NVIM_LISTEN_ADDRESS is unset
  3889. $NVIM_LOG_FILE is unset
  3890. $VIM is unset
  3891. $VIMRUNTIME is unset
  3892. You can set these with the `env` option.
  3893. *jobstart-options*
  3894. {opts} is a dictionary with these keys:
  3895. clear_env: (boolean) `env` defines the job environment
  3896. exactly, instead of merging current environment.
  3897. cwd: (string, default=|current-directory|) Working
  3898. directory of the job.
  3899. detach: (boolean) Detach the job process: it will not be
  3900. killed when Nvim exits. If the process exits
  3901. before Nvim, `on_exit` will be invoked.
  3902. env: (dict) Map of environment variable name:value
  3903. pairs extending (or replace with "clear_env")
  3904. the current environment. |jobstart-env|
  3905. height: (number) Height of the `pty` terminal.
  3906. |on_exit|: (function) Callback invoked when the job exits.
  3907. |on_stdout|: (function) Callback invoked when the job emits
  3908. stdout data.
  3909. |on_stderr|: (function) Callback invoked when the job emits
  3910. stderr data.
  3911. overlapped: (boolean) Set FILE_FLAG_OVERLAPPED for the
  3912. standard input/output passed to the child process.
  3913. Normally you do not need to set this.
  3914. (Only available on MS-Windows, On other
  3915. platforms, this option is silently ignored.)
  3916. pty: (boolean) Connect the job to a new pseudo
  3917. terminal, and its streams to the master file
  3918. descriptor. `on_stdout` receives all output,
  3919. `on_stderr` is ignored. |terminal-start|
  3920. rpc: (boolean) Use |msgpack-rpc| to communicate with
  3921. the job over stdio. Then `on_stdout` is ignored,
  3922. but `on_stderr` can still be used.
  3923. stderr_buffered: (boolean) Collect data until EOF (stream closed)
  3924. before invoking `on_stderr`. |channel-buffered|
  3925. stdout_buffered: (boolean) Collect data until EOF (stream
  3926. closed) before invoking `on_stdout`. |channel-buffered|
  3927. stdin: (string) Either "pipe" (default) to connect the
  3928. job's stdin to a channel or "null" to disconnect
  3929. stdin.
  3930. width: (number) Width of the `pty` terminal.
  3931. {opts} is passed as |self| dictionary to the callback; the
  3932. caller may set other keys to pass application-specific data.
  3933. Returns:
  3934. - |channel-id| on success
  3935. - 0 on invalid arguments
  3936. - -1 if {cmd}[0] is not executable.
  3937. See also |job-control|, |channel|, |msgpack-rpc|.
  3938. jobstop({id}) *jobstop()*
  3939. Stop |job-id| {id} by sending SIGTERM to the job process. If
  3940. the process does not terminate after a timeout then SIGKILL
  3941. will be sent. When the job terminates its |on_exit| handler
  3942. (if any) will be invoked.
  3943. See |job-control|.
  3944. Returns 1 for valid job id, 0 for invalid id, including jobs have
  3945. exited or stopped.
  3946. jobwait({jobs} [, {timeout}]) *jobwait()*
  3947. Waits for jobs and their |on_exit| handlers to complete.
  3948. {jobs} is a List of |job-id|s to wait for.
  3949. {timeout} is the maximum waiting time in milliseconds. If
  3950. omitted or -1, wait forever.
  3951. Timeout of 0 can be used to check the status of a job: >
  3952. let running = jobwait([{job-id}], 0)[0] == -1
  3953. <
  3954. During jobwait() callbacks for jobs not in the {jobs} list may
  3955. be invoked. The screen will not redraw unless |:redraw| is
  3956. invoked by a callback.
  3957. Returns a list of len({jobs}) integers, where each integer is
  3958. the status of the corresponding job:
  3959. Exit-code, if the job exited
  3960. -1 if the timeout was exceeded
  3961. -2 if the job was interrupted (by |CTRL-C|)
  3962. -3 if the job-id is invalid
  3963. join({list} [, {sep}]) *join()*
  3964. Join the items in {list} together into one String.
  3965. When {sep} is specified it is put in between the items. If
  3966. {sep} is omitted a single space is used.
  3967. Note that {sep} is not added at the end. You might want to
  3968. add it there too: >
  3969. let lines = join(mylist, "\n") .. "\n"
  3970. < String items are used as-is. |Lists| and |Dictionaries| are
  3971. converted into a string like with |string()|.
  3972. The opposite function is |split()|.
  3973. Can also be used as a |method|: >
  3974. mylist->join()
  3975. json_decode({expr}) *json_decode()*
  3976. Convert {expr} from JSON object. Accepts |readfile()|-style
  3977. list as the input, as well as regular string. May output any
  3978. Vim value. In the following cases it will output
  3979. |msgpack-special-dict|:
  3980. 1. Dictionary contains duplicate key.
  3981. 2. Dictionary contains empty key.
  3982. 3. String contains NUL byte. Two special dictionaries: for
  3983. dictionary and for string will be emitted in case string
  3984. with NUL byte was a dictionary key.
  3985. Note: function treats its input as UTF-8 always. The JSON
  3986. standard allows only a few encodings, of which UTF-8 is
  3987. recommended and the only one required to be supported.
  3988. Non-UTF-8 characters are an error.
  3989. Can also be used as a |method|: >
  3990. ReadObject()->json_decode()
  3991. json_encode({expr}) *json_encode()*
  3992. Convert {expr} into a JSON string. Accepts
  3993. |msgpack-special-dict| as the input. Will not convert
  3994. |Funcref|s, mappings with non-string keys (can be created as
  3995. |msgpack-special-dict|), values with self-referencing
  3996. containers, strings which contain non-UTF-8 characters,
  3997. pseudo-UTF-8 strings which contain codepoints reserved for
  3998. surrogate pairs (such strings are not valid UTF-8 strings).
  3999. Non-printable characters are converted into "\u1234" escapes
  4000. or special escapes like "\t", other are dumped as-is.
  4001. |Blob|s are converted to arrays of the individual bytes.
  4002. Can also be used as a |method|: >
  4003. GetObject()->json_encode()
  4004. keys({dict}) *keys()*
  4005. Return a |List| with all the keys of {dict}. The |List| is in
  4006. arbitrary order. Also see |items()| and |values()|.
  4007. Can also be used as a |method|: >
  4008. mydict->keys()
  4009. keytrans({string}) *keytrans()*
  4010. Turn the internal byte representation of keys into a form that
  4011. can be used for |:map|. E.g. >
  4012. :let xx = "\<C-Home>"
  4013. :echo keytrans(xx)
  4014. < <C-Home>
  4015. Can also be used as a |method|: >
  4016. "\<C-Home>"->keytrans()
  4017. < *len()* *E701*
  4018. len({expr}) The result is a Number, which is the length of the argument.
  4019. When {expr} is a String or a Number the length in bytes is
  4020. used, as with |strlen()|.
  4021. When {expr} is a |List| the number of items in the |List| is
  4022. returned.
  4023. When {expr} is a |Blob| the number of bytes is returned.
  4024. When {expr} is a |Dictionary| the number of entries in the
  4025. |Dictionary| is returned.
  4026. Otherwise an error is given and returns zero.
  4027. Can also be used as a |method|: >
  4028. mylist->len()
  4029. < *libcall()* *E364* *E368*
  4030. libcall({libname}, {funcname}, {argument})
  4031. Call function {funcname} in the run-time library {libname}
  4032. with single argument {argument}.
  4033. This is useful to call functions in a library that you
  4034. especially made to be used with Vim. Since only one argument
  4035. is possible, calling standard library functions is rather
  4036. limited.
  4037. The result is the String returned by the function. If the
  4038. function returns NULL, this will appear as an empty string ""
  4039. to Vim.
  4040. If the function returns a number, use libcallnr()!
  4041. If {argument} is a number, it is passed to the function as an
  4042. int; if {argument} is a string, it is passed as a
  4043. null-terminated string.
  4044. libcall() allows you to write your own 'plug-in' extensions to
  4045. Vim without having to recompile the program. It is NOT a
  4046. means to call system functions! If you try to do so Vim will
  4047. very probably crash.
  4048. For Win32, the functions you write must be placed in a DLL
  4049. and use the normal C calling convention (NOT Pascal which is
  4050. used in Windows System DLLs). The function must take exactly
  4051. one parameter, either a character pointer or a long integer,
  4052. and must return a character pointer or NULL. The character
  4053. pointer returned must point to memory that will remain valid
  4054. after the function has returned (e.g. in static data in the
  4055. DLL). If it points to allocated memory, that memory will
  4056. leak away. Using a static buffer in the function should work,
  4057. it's then freed when the DLL is unloaded.
  4058. WARNING: If the function returns a non-valid pointer, Vim may
  4059. crash! This also happens if the function returns a number,
  4060. because Vim thinks it's a pointer.
  4061. For Win32 systems, {libname} should be the filename of the DLL
  4062. without the ".DLL" suffix. A full path is only required if
  4063. the DLL is not in the usual places.
  4064. For Unix: When compiling your own plugins, remember that the
  4065. object code must be compiled as position-independent ('PIC').
  4066. Examples: >
  4067. :echo libcall("libc.so", "getenv", "HOME")
  4068. < Can also be used as a |method|, the base is passed as the
  4069. third argument: >
  4070. GetValue()->libcall("libc.so", "getenv")
  4071. <
  4072. *libcallnr()*
  4073. libcallnr({libname}, {funcname}, {argument})
  4074. Just like |libcall()|, but used for a function that returns an
  4075. int instead of a string.
  4076. Examples: >
  4077. :echo libcallnr("/usr/lib/libc.so", "getpid", "")
  4078. :call libcallnr("libc.so", "printf", "Hello World!\n")
  4079. :call libcallnr("libc.so", "sleep", 10)
  4080. <
  4081. Can also be used as a |method|, the base is passed as the
  4082. third argument: >
  4083. GetValue()->libcallnr("libc.so", "printf")
  4084. <
  4085. line({expr} [, {winid}]) *line()*
  4086. The result is a Number, which is the line number of the file
  4087. position given with {expr}. The {expr} argument is a string.
  4088. The accepted positions are:
  4089. . the cursor position
  4090. $ the last line in the current buffer
  4091. 'x position of mark x (if the mark is not set, 0 is
  4092. returned)
  4093. w0 first line visible in current window (one if the
  4094. display isn't updated, e.g. in silent Ex mode)
  4095. w$ last line visible in current window (this is one
  4096. less than "w0" if no lines are visible)
  4097. v In Visual mode: the start of the Visual area (the
  4098. cursor is the end). When not in Visual mode
  4099. returns the cursor position. Differs from |'<| in
  4100. that it's updated right away.
  4101. Note that a mark in another file can be used. The line number
  4102. then applies to another buffer.
  4103. To get the column number use |col()|. To get both use
  4104. |getpos()|.
  4105. With the optional {winid} argument the values are obtained for
  4106. that window instead of the current window.
  4107. Returns 0 for invalid values of {expr} and {winid}.
  4108. Examples: >
  4109. line(".") line number of the cursor
  4110. line(".", winid) idem, in window "winid"
  4111. line("'t") line number of mark t
  4112. line("'" .. marker) line number of mark marker
  4113. <
  4114. To jump to the last known position when opening a file see
  4115. |last-position-jump|.
  4116. Can also be used as a |method|: >
  4117. GetValue()->line()
  4118. line2byte({lnum}) *line2byte()*
  4119. Return the byte count from the start of the buffer for line
  4120. {lnum}. This includes the end-of-line character, depending on
  4121. the 'fileformat' option for the current buffer. The first
  4122. line returns 1. UTF-8 encoding is used, 'fileencoding' is
  4123. ignored. This can also be used to get the byte count for the
  4124. line just below the last line: >
  4125. line2byte(line("$") + 1)
  4126. < This is the buffer size plus one. If 'fileencoding' is empty
  4127. it is the file size plus one. {lnum} is used like with
  4128. |getline()|. When {lnum} is invalid -1 is returned.
  4129. Also see |byte2line()|, |go| and |:goto|.
  4130. Can also be used as a |method|: >
  4131. GetLnum()->line2byte()
  4132. lispindent({lnum}) *lispindent()*
  4133. Get the amount of indent for line {lnum} according the lisp
  4134. indenting rules, as with 'lisp'.
  4135. The indent is counted in spaces, the value of 'tabstop' is
  4136. relevant. {lnum} is used just like in |getline()|.
  4137. When {lnum} is invalid, -1 is returned.
  4138. Can also be used as a |method|: >
  4139. GetLnum()->lispindent()
  4140. list2str({list} [, {utf8}]) *list2str()*
  4141. Convert each number in {list} to a character string can
  4142. concatenate them all. Examples: >
  4143. list2str([32]) returns " "
  4144. list2str([65, 66, 67]) returns "ABC"
  4145. < The same can be done (slowly) with: >
  4146. join(map(list, {nr, val -> nr2char(val)}), '')
  4147. < |str2list()| does the opposite.
  4148. UTF-8 encoding is always used, {utf8} option has no effect,
  4149. and exists only for backwards-compatibility.
  4150. With UTF-8 composing characters work as expected: >
  4151. list2str([97, 769]) returns "á"
  4152. <
  4153. Returns an empty string on error.
  4154. Can also be used as a |method|: >
  4155. GetList()->list2str()
  4156. localtime() *localtime()*
  4157. Return the current time, measured as seconds since 1st Jan
  4158. 1970. See also |strftime()|, |strptime()| and |getftime()|.
  4159. log({expr}) *log()*
  4160. Return the natural logarithm (base e) of {expr} as a |Float|.
  4161. {expr} must evaluate to a |Float| or a |Number| in the range
  4162. (0, inf].
  4163. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4164. Examples: >
  4165. :echo log(10)
  4166. < 2.302585 >
  4167. :echo log(exp(5))
  4168. < 5.0
  4169. Can also be used as a |method|: >
  4170. Compute()->log()
  4171. log10({expr}) *log10()*
  4172. Return the logarithm of Float {expr} to base 10 as a |Float|.
  4173. {expr} must evaluate to a |Float| or a |Number|.
  4174. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4175. Examples: >
  4176. :echo log10(1000)
  4177. < 3.0 >
  4178. :echo log10(0.01)
  4179. < -2.0
  4180. Can also be used as a |method|: >
  4181. Compute()->log10()
  4182. luaeval({expr} [, {expr}])
  4183. Evaluate Lua expression {expr} and return its result converted
  4184. to Vim data structures. See |lua-eval| for more details.
  4185. Can also be used as a |method|: >
  4186. GetExpr()->luaeval()
  4187. map({expr1}, {expr2}) *map()*
  4188. {expr1} must be a |List|, |Blob| or |Dictionary|.
  4189. Replace each item in {expr1} with the result of evaluating
  4190. {expr2}. For a |Blob| each byte is replaced.
  4191. {expr2} must be a |string| or |Funcref|.
  4192. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  4193. of the current item. For a |Dictionary| |v:key| has the key
  4194. of the current item and for a |List| |v:key| has the index of
  4195. the current item. For a |Blob| |v:key| has the index of the
  4196. current byte.
  4197. Example: >
  4198. :call map(mylist, '"> " .. v:val .. " <"')
  4199. < This puts "> " before and " <" after each item in "mylist".
  4200. Note that {expr2} is the result of an expression and is then
  4201. used as an expression again. Often it is good to use a
  4202. |literal-string| to avoid having to double backslashes. You
  4203. still have to double ' quotes
  4204. If {expr2} is a |Funcref| it is called with two arguments:
  4205. 1. The key or the index of the current item.
  4206. 2. the value of the current item.
  4207. The function must return the new value of the item. Example
  4208. that changes each value by "key-value": >
  4209. func KeyValue(key, val)
  4210. return a:key .. '-' .. a:val
  4211. endfunc
  4212. call map(myDict, function('KeyValue'))
  4213. < It is shorter when using a |lambda|: >
  4214. call map(myDict, {key, val -> key .. '-' .. val})
  4215. < If you do not use "val" you can leave it out: >
  4216. call map(myDict, {key -> 'item: ' .. key})
  4217. < If you do not use "key" you can use a short name: >
  4218. call map(myDict, {_, val -> 'item: ' .. val})
  4219. <
  4220. The operation is done in-place. If you want a |List| or
  4221. |Dictionary| to remain unmodified make a copy first: >
  4222. :let tlist = map(copy(mylist), ' v:val .. "\t"')
  4223. < Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
  4224. filtered. When an error is encountered while evaluating
  4225. {expr2} no further items in {expr1} are processed. When
  4226. {expr2} is a Funcref errors inside a function are ignored,
  4227. unless it was defined with the "abort" flag.
  4228. Can also be used as a |method|: >
  4229. mylist->map(expr2)
  4230. maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
  4231. When {dict} is omitted or zero: Return the rhs of mapping
  4232. {name} in mode {mode}. The returned String has special
  4233. characters translated like in the output of the ":map" command
  4234. listing.
  4235. When there is no mapping for {name}, an empty String is
  4236. returned if {dict} is FALSE, otherwise returns an empty Dict.
  4237. When the mapping for {name} is empty, then "<Nop>" is
  4238. returned.
  4239. The {name} can have special key names, like in the ":map"
  4240. command.
  4241. {mode} can be one of these strings:
  4242. "n" Normal
  4243. "v" Visual (including Select)
  4244. "o" Operator-pending
  4245. "i" Insert
  4246. "c" Cmd-line
  4247. "s" Select
  4248. "x" Visual
  4249. "l" langmap |language-mapping|
  4250. "t" Terminal
  4251. "" Normal, Visual and Operator-pending
  4252. When {mode} is omitted, the modes for "" are used.
  4253. When {abbr} is there and it is |TRUE| use abbreviations
  4254. instead of mappings.
  4255. When {dict} is there and it is |TRUE| return a dictionary
  4256. containing all the information of the mapping with the
  4257. following items:
  4258. "lhs" The {lhs} of the mapping as it would be typed
  4259. "lhsraw" The {lhs} of the mapping as raw bytes
  4260. "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
  4261. form, only present when it differs from "lhsraw"
  4262. "rhs" The {rhs} of the mapping as typed.
  4263. "silent" 1 for a |:map-silent| mapping, else 0.
  4264. "noremap" 1 if the {rhs} of the mapping is not remappable.
  4265. "script" 1 if mapping was defined with <script>.
  4266. "expr" 1 for an expression mapping (|:map-<expr>|).
  4267. "buffer" 1 for a buffer local mapping (|:map-local|).
  4268. "mode" Modes for which the mapping is defined. In
  4269. addition to the modes mentioned above, these
  4270. characters will be used:
  4271. " " Normal, Visual and Operator-pending
  4272. "!" Insert and Commandline mode
  4273. (|mapmode-ic|)
  4274. "sid" The script local ID, used for <sid> mappings
  4275. (|<SID>|).
  4276. "lnum" The line number in "sid", zero if unknown.
  4277. "nowait" Do not wait for other, longer mappings.
  4278. (|:map-<nowait>|).
  4279. The dictionary can be used to restore a mapping with
  4280. |mapset()|.
  4281. The mappings local to the current buffer are checked first,
  4282. then the global mappings.
  4283. This function can be used to map a key even when it's already
  4284. mapped, and have it do the original mapping too. Sketch: >
  4285. exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
  4286. < Can also be used as a |method|: >
  4287. GetKey()->maparg('n')
  4288. mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
  4289. Check if there is a mapping that matches with {name} in mode
  4290. {mode}. See |maparg()| for {mode} and special names in
  4291. {name}.
  4292. When {abbr} is there and it is non-zero use abbreviations
  4293. instead of mappings.
  4294. A match happens with a mapping that starts with {name} and
  4295. with a mapping which is equal to the start of {name}.
  4296. matches mapping "a" "ab" "abc" ~
  4297. mapcheck("a") yes yes yes
  4298. mapcheck("abc") yes yes yes
  4299. mapcheck("ax") yes no no
  4300. mapcheck("b") no no no
  4301. The difference with maparg() is that mapcheck() finds a
  4302. mapping that matches with {name}, while maparg() only finds a
  4303. mapping for {name} exactly.
  4304. When there is no mapping that starts with {name}, an empty
  4305. String is returned. If there is one, the RHS of that mapping
  4306. is returned. If there are several mappings that start with
  4307. {name}, the RHS of one of them is returned. This will be
  4308. "<Nop>" if the RHS is empty.
  4309. The mappings local to the current buffer are checked first,
  4310. then the global mappings.
  4311. This function can be used to check if a mapping can be added
  4312. without being ambiguous. Example: >
  4313. :if mapcheck("_vv") == ""
  4314. : map _vv :set guifont=7x13<CR>
  4315. :endif
  4316. < This avoids adding the "_vv" mapping when there already is a
  4317. mapping for "_v" or for "_vvv".
  4318. Can also be used as a |method|: >
  4319. GetKey()->mapcheck('n')
  4320. mapset({mode}, {abbr}, {dict}) *mapset()*
  4321. Restore a mapping from a dictionary returned by |maparg()|.
  4322. {mode} and {abbr} should be the same as for the call to
  4323. |maparg()|. *E460*
  4324. {mode} is used to define the mode in which the mapping is set,
  4325. not the "mode" entry in {dict}.
  4326. Example for saving and restoring a mapping: >
  4327. let save_map = maparg('K', 'n', 0, 1)
  4328. nnoremap K somethingelse
  4329. ...
  4330. call mapset('n', 0, save_map)
  4331. < Note that if you are going to replace a map in several modes,
  4332. e.g. with `:map!`, you need to save the mapping for all of
  4333. them, since they can differ.
  4334. match({expr}, {pat} [, {start} [, {count}]]) *match()*
  4335. When {expr} is a |List| then this returns the index of the
  4336. first item where {pat} matches. Each item is used as a
  4337. String, |Lists| and |Dictionaries| are used as echoed.
  4338. Otherwise, {expr} is used as a String. The result is a
  4339. Number, which gives the index (byte offset) in {expr} where
  4340. {pat} matches.
  4341. A match at the first character or |List| item returns zero.
  4342. If there is no match -1 is returned.
  4343. For getting submatches see |matchlist()|.
  4344. Example: >
  4345. :echo match("testing", "ing") " results in 4
  4346. :echo match([1, 'x'], '\a') " results in 1
  4347. < See |string-match| for how {pat} is used.
  4348. *strpbrk()*
  4349. Vim doesn't have a strpbrk() function. But you can do: >
  4350. :let sepidx = match(line, '[.,;: \t]')
  4351. < *strcasestr()*
  4352. Vim doesn't have a strcasestr() function. But you can add
  4353. "\c" to the pattern to ignore case: >
  4354. :let idx = match(haystack, '\cneedle')
  4355. <
  4356. If {start} is given, the search starts from byte index
  4357. {start} in a String or item {start} in a |List|.
  4358. The result, however, is still the index counted from the
  4359. first character/item. Example: >
  4360. :echo match("testing", "ing", 2)
  4361. < result is again "4". >
  4362. :echo match("testing", "ing", 4)
  4363. < result is again "4". >
  4364. :echo match("testing", "t", 2)
  4365. < result is "3".
  4366. For a String, if {start} > 0 then it is like the string starts
  4367. {start} bytes later, thus "^" will match at {start}. Except
  4368. when {count} is given, then it's like matches before the
  4369. {start} byte are ignored (this is a bit complicated to keep it
  4370. backwards compatible).
  4371. For a String, if {start} < 0, it will be set to 0. For a list
  4372. the index is counted from the end.
  4373. If {start} is out of range ({start} > strlen({expr}) for a
  4374. String or {start} > len({expr}) for a |List|) -1 is returned.
  4375. When {count} is given use the {count}'th match. When a match
  4376. is found in a String the search for the next one starts one
  4377. character further. Thus this example results in 1: >
  4378. echo match("testing", "..", 0, 2)
  4379. < In a |List| the search continues in the next item.
  4380. Note that when {count} is added the way {start} works changes,
  4381. see above.
  4382. See |pattern| for the patterns that are accepted.
  4383. The 'ignorecase' option is used to set the ignore-caseness of
  4384. the pattern. 'smartcase' is NOT used. The matching is always
  4385. done like 'magic' is set and 'cpoptions' is empty.
  4386. Note that a match at the start is preferred, thus when the
  4387. pattern is using "*" (any number of matches) it tends to find
  4388. zero matches at the start instead of a number of matches
  4389. further down in the text.
  4390. Can also be used as a |method|: >
  4391. GetText()->match('word')
  4392. GetList()->match('word')
  4393. <
  4394. *matchadd()* *E798* *E799* *E801* *E957*
  4395. matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
  4396. Defines a pattern to be highlighted in the current window (a
  4397. "match"). It will be highlighted with {group}. Returns an
  4398. identification number (ID), which can be used to delete the
  4399. match using |matchdelete()|. The ID is bound to the window.
  4400. Matching is case sensitive and magic, unless case sensitivity
  4401. or magicness are explicitly overridden in {pattern}. The
  4402. 'magic', 'smartcase' and 'ignorecase' options are not used.
  4403. The "Conceal" value is special, it causes the match to be
  4404. concealed.
  4405. The optional {priority} argument assigns a priority to the
  4406. match. A match with a high priority will have its
  4407. highlighting overrule that of a match with a lower priority.
  4408. A priority is specified as an integer (negative numbers are no
  4409. exception). If the {priority} argument is not specified, the
  4410. default priority is 10. The priority of 'hlsearch' is zero,
  4411. hence all matches with a priority greater than zero will
  4412. overrule it. Syntax highlighting (see 'syntax') is a separate
  4413. mechanism, and regardless of the chosen priority a match will
  4414. always overrule syntax highlighting.
  4415. The optional {id} argument allows the request for a specific
  4416. match ID. If a specified ID is already taken, an error
  4417. message will appear and the match will not be added. An ID
  4418. is specified as a positive integer (zero excluded). IDs 1, 2
  4419. and 3 are reserved for |:match|, |:2match| and |:3match|,
  4420. respectively. 3 is reserved for use by the |matchparen|
  4421. plugin.
  4422. If the {id} argument is not specified or -1, |matchadd()|
  4423. automatically chooses a free ID.
  4424. The optional {dict} argument allows for further custom
  4425. values. Currently this is used to specify a match specific
  4426. conceal character that will be shown for |hl-Conceal|
  4427. highlighted matches. The dict can have the following members:
  4428. conceal Special character to show instead of the
  4429. match (only for |hl-Conceal| highlighted
  4430. matches, see |:syn-cchar|)
  4431. window Instead of the current window use the
  4432. window with this number or window ID.
  4433. The number of matches is not limited, as it is the case with
  4434. the |:match| commands.
  4435. Returns -1 on error.
  4436. Example: >
  4437. :highlight MyGroup ctermbg=green guibg=green
  4438. :let m = matchadd("MyGroup", "TODO")
  4439. < Deletion of the pattern: >
  4440. :call matchdelete(m)
  4441. < A list of matches defined by |matchadd()| and |:match| are
  4442. available from |getmatches()|. All matches can be deleted in
  4443. one operation by |clearmatches()|.
  4444. Can also be used as a |method|: >
  4445. GetGroup()->matchadd('TODO')
  4446. <
  4447. *matchaddpos()*
  4448. matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
  4449. Same as |matchadd()|, but requires a list of positions {pos}
  4450. instead of a pattern. This command is faster than |matchadd()|
  4451. because it does not require to handle regular expressions and
  4452. sets buffer line boundaries to redraw screen. It is supposed
  4453. to be used when fast match additions and deletions are
  4454. required, for example to highlight matching parentheses.
  4455. *E5030* *E5031*
  4456. {pos} is a list of positions. Each position can be one of
  4457. these:
  4458. - A number. This whole line will be highlighted. The first
  4459. line has number 1.
  4460. - A list with one number, e.g., [23]. The whole line with this
  4461. number will be highlighted.
  4462. - A list with two numbers, e.g., [23, 11]. The first number is
  4463. the line number, the second one is the column number (first
  4464. column is 1, the value must correspond to the byte index as
  4465. |col()| would return). The character at this position will
  4466. be highlighted.
  4467. - A list with three numbers, e.g., [23, 11, 3]. As above, but
  4468. the third number gives the length of the highlight in bytes.
  4469. Entries with zero and negative line numbers are silently
  4470. ignored, as well as entries with negative column numbers and
  4471. lengths.
  4472. The maximum number of positions in {pos} is 8.
  4473. Returns -1 on error.
  4474. Example: >
  4475. :highlight MyGroup ctermbg=green guibg=green
  4476. :let m = matchaddpos("MyGroup", [[23, 24], 34])
  4477. < Deletion of the pattern: >
  4478. :call matchdelete(m)
  4479. < Matches added by |matchaddpos()| are returned by
  4480. |getmatches()|.
  4481. Can also be used as a |method|: >
  4482. GetGroup()->matchaddpos([23, 11])
  4483. matcharg({nr}) *matcharg()*
  4484. Selects the {nr} match item, as set with a |:match|,
  4485. |:2match| or |:3match| command.
  4486. Return a |List| with two elements:
  4487. The name of the highlight group used
  4488. The pattern used.
  4489. When {nr} is not 1, 2 or 3 returns an empty |List|.
  4490. When there is no match item set returns ['', ''].
  4491. This is useful to save and restore a |:match|.
  4492. Highlighting matches using the |:match| commands are limited
  4493. to three matches. |matchadd()| does not have this limitation.
  4494. Can also be used as a |method|: >
  4495. GetMatch()->matcharg()
  4496. matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
  4497. Deletes a match with ID {id} previously defined by |matchadd()|
  4498. or one of the |:match| commands. Returns 0 if successful,
  4499. otherwise -1. See example for |matchadd()|. All matches can
  4500. be deleted in one operation by |clearmatches()|.
  4501. If {win} is specified, use the window with this number or
  4502. window ID instead of the current window.
  4503. Can also be used as a |method|: >
  4504. GetMatch()->matchdelete()
  4505. matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
  4506. Same as |match()|, but return the index of first character
  4507. after the match. Example: >
  4508. :echo matchend("testing", "ing")
  4509. < results in "7".
  4510. *strspn()* *strcspn()*
  4511. Vim doesn't have a strspn() or strcspn() function, but you can
  4512. do it with matchend(): >
  4513. :let span = matchend(line, '[a-zA-Z]')
  4514. :let span = matchend(line, '[^a-zA-Z]')
  4515. < Except that -1 is returned when there are no matches.
  4516. The {start}, if given, has the same meaning as for |match()|. >
  4517. :echo matchend("testing", "ing", 2)
  4518. < results in "7". >
  4519. :echo matchend("testing", "ing", 5)
  4520. < result is "-1".
  4521. When {expr} is a |List| the result is equal to |match()|.
  4522. Can also be used as a |method|: >
  4523. GetText()->matchend('word')
  4524. matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
  4525. If {list} is a list of strings, then returns a |List| with all
  4526. the strings in {list} that fuzzy match {str}. The strings in
  4527. the returned list are sorted based on the matching score.
  4528. The optional {dict} argument always supports the following
  4529. items:
  4530. matchseq When this item is present return only matches
  4531. that contain the characters in {str} in the
  4532. given sequence.
  4533. limit Maximum number of matches in {list} to be
  4534. returned. Zero means no limit.
  4535. If {list} is a list of dictionaries, then the optional {dict}
  4536. argument supports the following additional items:
  4537. key Key of the item which is fuzzy matched against
  4538. {str}. The value of this item should be a
  4539. string.
  4540. text_cb |Funcref| that will be called for every item
  4541. in {list} to get the text for fuzzy matching.
  4542. This should accept a dictionary item as the
  4543. argument and return the text for that item to
  4544. use for fuzzy matching.
  4545. {str} is treated as a literal string and regular expression
  4546. matching is NOT supported. The maximum supported {str} length
  4547. is 256.
  4548. When {str} has multiple words each separated by white space,
  4549. then the list of strings that have all the words is returned.
  4550. If there are no matching strings or there is an error, then an
  4551. empty list is returned. If length of {str} is greater than
  4552. 256, then returns an empty list.
  4553. When {limit} is given, matchfuzzy() will find up to this
  4554. number of matches in {list} and return them in sorted order.
  4555. Refer to |fuzzy-matching| for more information about fuzzy
  4556. matching strings.
  4557. Example: >
  4558. :echo matchfuzzy(["clay", "crow"], "cay")
  4559. < results in ["clay"]. >
  4560. :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
  4561. < results in a list of buffer names fuzzy matching "ndl". >
  4562. :echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
  4563. < results in a list of buffer information dicts with buffer
  4564. names fuzzy matching "ndl". >
  4565. :echo getbufinfo()->matchfuzzy("spl",
  4566. \ {'text_cb' : {v -> v.name}})
  4567. < results in a list of buffer information dicts with buffer
  4568. names fuzzy matching "spl". >
  4569. :echo v:oldfiles->matchfuzzy("test")
  4570. < results in a list of file names fuzzy matching "test". >
  4571. :let l = readfile("buffer.c")->matchfuzzy("str")
  4572. < results in a list of lines in "buffer.c" fuzzy matching "str". >
  4573. :echo ['one two', 'two one']->matchfuzzy('two one')
  4574. < results in ['two one', 'one two']. >
  4575. :echo ['one two', 'two one']->matchfuzzy('two one',
  4576. \ {'matchseq': 1})
  4577. < results in ['two one'].
  4578. matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
  4579. Same as |matchfuzzy()|, but returns the list of matched
  4580. strings, the list of character positions where characters
  4581. in {str} matches and a list of matching scores. You can
  4582. use |byteidx()| to convert a character position to a byte
  4583. position.
  4584. If {str} matches multiple times in a string, then only the
  4585. positions for the best match is returned.
  4586. If there are no matching strings or there is an error, then a
  4587. list with three empty list items is returned.
  4588. Example: >
  4589. :echo matchfuzzypos(['testing'], 'tsg')
  4590. < results in [["testing"], [[0, 2, 6]], [99]] >
  4591. :echo matchfuzzypos(['clay', 'lacy'], 'la')
  4592. < results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >
  4593. :echo [{'text': 'hello', 'id' : 10}]
  4594. \ ->matchfuzzypos('ll', {'key' : 'text'})
  4595. < results in [[{"id": 10, "text": "hello"}], [[2, 3]], [127]]
  4596. matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
  4597. Same as |match()|, but return a |List|. The first item in the
  4598. list is the matched string, same as what matchstr() would
  4599. return. Following items are submatches, like "\1", "\2", etc.
  4600. in |:substitute|. When an optional submatch didn't match an
  4601. empty string is used. Example: >
  4602. echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
  4603. < Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
  4604. When there is no match an empty list is returned.
  4605. You can pass in a List, but that is not very useful.
  4606. Can also be used as a |method|: >
  4607. GetText()->matchlist('word')
  4608. matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
  4609. Same as |match()|, but return the matched string. Example: >
  4610. :echo matchstr("testing", "ing")
  4611. < results in "ing".
  4612. When there is no match "" is returned.
  4613. The {start}, if given, has the same meaning as for |match()|. >
  4614. :echo matchstr("testing", "ing", 2)
  4615. < results in "ing". >
  4616. :echo matchstr("testing", "ing", 5)
  4617. < result is "".
  4618. When {expr} is a |List| then the matching item is returned.
  4619. The type isn't changed, it's not necessarily a String.
  4620. Can also be used as a |method|: >
  4621. GetText()->matchstr('word')
  4622. matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
  4623. Same as |matchstr()|, but return the matched string, the start
  4624. position and the end position of the match. Example: >
  4625. :echo matchstrpos("testing", "ing")
  4626. < results in ["ing", 4, 7].
  4627. When there is no match ["", -1, -1] is returned.
  4628. The {start}, if given, has the same meaning as for |match()|. >
  4629. :echo matchstrpos("testing", "ing", 2)
  4630. < results in ["ing", 4, 7]. >
  4631. :echo matchstrpos("testing", "ing", 5)
  4632. < result is ["", -1, -1].
  4633. When {expr} is a |List| then the matching item, the index
  4634. of first item where {pat} matches, the start position and the
  4635. end position of the match are returned. >
  4636. :echo matchstrpos([1, '__x'], '\a')
  4637. < result is ["x", 1, 2, 3].
  4638. The type isn't changed, it's not necessarily a String.
  4639. Can also be used as a |method|: >
  4640. GetText()->matchstrpos('word')
  4641. <
  4642. *max()*
  4643. max({expr}) Return the maximum value of all items in {expr}. Example: >
  4644. echo max([apples, pears, oranges])
  4645. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  4646. it returns the maximum of all values in the Dictionary.
  4647. If {expr} is neither a List nor a Dictionary, or one of the
  4648. items in {expr} cannot be used as a Number this results in
  4649. an error. An empty |List| or |Dictionary| results in zero.
  4650. Can also be used as a |method|: >
  4651. mylist->max()
  4652. menu_get({path} [, {modes}]) *menu_get()*
  4653. Returns a |List| of |Dictionaries| describing |menus| (defined
  4654. by |:menu|, |:amenu|, …), including |hidden-menus|.
  4655. {path} matches a menu by name, or all menus if {path} is an
  4656. empty string. Example: >
  4657. :echo menu_get('File','')
  4658. :echo menu_get('')
  4659. <
  4660. {modes} is a string of zero or more modes (see |maparg()| or
  4661. |creating-menus| for the list of modes). "a" means "all".
  4662. Example: >
  4663. nnoremenu &Test.Test inormal
  4664. inoremenu Test.Test insert
  4665. vnoremenu Test.Test x
  4666. echo menu_get("")
  4667. < returns something like this: >
  4668. [ {
  4669. "hidden": 0,
  4670. "name": "Test",
  4671. "priority": 500,
  4672. "shortcut": 84,
  4673. "submenus": [ {
  4674. "hidden": 0,
  4675. "mappings": {
  4676. i": {
  4677. "enabled": 1,
  4678. "noremap": 1,
  4679. "rhs": "insert",
  4680. "sid": 1,
  4681. "silent": 0
  4682. },
  4683. n": { ... },
  4684. s": { ... },
  4685. v": { ... }
  4686. },
  4687. "name": "Test",
  4688. "priority": 500,
  4689. "shortcut": 0
  4690. } ]
  4691. } ]
  4692. <
  4693. menu_info({name} [, {mode}]) *menu_info()*
  4694. Return information about the specified menu {name} in
  4695. mode {mode}. The menu name should be specified without the
  4696. shortcut character ('&'). If {name} is "", then the top-level
  4697. menu names are returned.
  4698. {mode} can be one of these strings:
  4699. "n" Normal
  4700. "v" Visual (including Select)
  4701. "o" Operator-pending
  4702. "i" Insert
  4703. "c" Cmd-line
  4704. "s" Select
  4705. "x" Visual
  4706. "t" Terminal-Job
  4707. "" Normal, Visual and Operator-pending
  4708. "!" Insert and Cmd-line
  4709. When {mode} is omitted, the modes for "" are used.
  4710. Returns a |Dictionary| containing the following items:
  4711. accel menu item accelerator text |menu-text|
  4712. display display name (name without '&')
  4713. enabled v:true if this menu item is enabled
  4714. Refer to |:menu-enable|
  4715. icon name of the icon file (for toolbar)
  4716. |toolbar-icon|
  4717. iconidx index of a built-in icon
  4718. modes modes for which the menu is defined. In
  4719. addition to the modes mentioned above, these
  4720. characters will be used:
  4721. " " Normal, Visual and Operator-pending
  4722. name menu item name.
  4723. noremenu v:true if the {rhs} of the menu item is not
  4724. remappable else v:false.
  4725. priority menu order priority |menu-priority|
  4726. rhs right-hand-side of the menu item. The returned
  4727. string has special characters translated like
  4728. in the output of the ":menu" command listing.
  4729. When the {rhs} of a menu item is empty, then
  4730. "<Nop>" is returned.
  4731. script v:true if script-local remapping of {rhs} is
  4732. allowed else v:false. See |:menu-script|.
  4733. shortcut shortcut key (character after '&' in
  4734. the menu name) |menu-shortcut|
  4735. silent v:true if the menu item is created
  4736. with <silent> argument |:menu-silent|
  4737. submenus |List| containing the names of
  4738. all the submenus. Present only if the menu
  4739. item has submenus.
  4740. Returns an empty dictionary if the menu item is not found.
  4741. Examples: >
  4742. :echo menu_info('Edit.Cut')
  4743. :echo menu_info('File.Save', 'n')
  4744. " Display the entire menu hierarchy in a buffer
  4745. func ShowMenu(name, pfx)
  4746. let m = menu_info(a:name)
  4747. call append(line('$'), a:pfx .. m.display)
  4748. for child in m->get('submenus', [])
  4749. call ShowMenu(a:name .. '.' .. escape(child, '.'),
  4750. \ a:pfx .. ' ')
  4751. endfor
  4752. endfunc
  4753. new
  4754. for topmenu in menu_info('').submenus
  4755. call ShowMenu(topmenu, '')
  4756. endfor
  4757. <
  4758. Can also be used as a |method|: >
  4759. GetMenuName()->menu_info('v')
  4760. < *min()*
  4761. min({expr}) Return the minimum value of all items in {expr}. Example: >
  4762. echo min([apples, pears, oranges])
  4763. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  4764. it returns the minimum of all values in the Dictionary.
  4765. If {expr} is neither a List nor a Dictionary, or one of the
  4766. items in {expr} cannot be used as a Number this results in
  4767. an error. An empty |List| or |Dictionary| results in zero.
  4768. Can also be used as a |method|: >
  4769. mylist->min()
  4770. < *mkdir()* *E739*
  4771. mkdir({name} [, {path} [, {prot}]])
  4772. Create directory {name}.
  4773. If {path} is "p" then intermediate directories are created as
  4774. necessary. Otherwise it must be "".
  4775. If {prot} is given it is used to set the protection bits of
  4776. the new directory. The default is 0o755 (rwxr-xr-x: r/w for
  4777. the user, readable for others). Use 0o700 to make it
  4778. unreadable for others.
  4779. {prot} is applied for all parts of {name}. Thus if you create
  4780. /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >
  4781. :call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
  4782. < This function is not available in the |sandbox|.
  4783. If you try to create an existing directory with {path} set to
  4784. "p" mkdir() will silently exit.
  4785. The function result is a Number, which is TRUE if the call was
  4786. successful or FALSE if the directory creation failed or partly
  4787. failed.
  4788. Can also be used as a |method|: >
  4789. GetName()->mkdir()
  4790. <
  4791. *mode()*
  4792. mode([expr]) Return a string that indicates the current mode.
  4793. If [expr] is supplied and it evaluates to a non-zero Number or
  4794. a non-empty String (|non-zero-arg|), then the full mode is
  4795. returned, otherwise only the first letter is returned.
  4796. n Normal
  4797. no Operator-pending
  4798. nov Operator-pending (forced charwise |o_v|)
  4799. noV Operator-pending (forced linewise |o_V|)
  4800. noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
  4801. CTRL-V is one character
  4802. niI Normal using |i_CTRL-O| in |Insert-mode|
  4803. niR Normal using |i_CTRL-O| in |Replace-mode|
  4804. niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
  4805. nt Normal in |terminal-emulator| (insert goes to
  4806. Terminal mode)
  4807. ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
  4808. v Visual by character
  4809. vs Visual by character using |v_CTRL-O| in Select mode
  4810. V Visual by line
  4811. Vs Visual by line using |v_CTRL-O| in Select mode
  4812. CTRL-V Visual blockwise
  4813. CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
  4814. s Select by character
  4815. S Select by line
  4816. CTRL-S Select blockwise
  4817. i Insert
  4818. ic Insert mode completion |compl-generic|
  4819. ix Insert mode |i_CTRL-X| completion
  4820. R Replace |R|
  4821. Rc Replace mode completion |compl-generic|
  4822. Rx Replace mode |i_CTRL-X| completion
  4823. Rv Virtual Replace |gR|
  4824. Rvc Virtual Replace mode completion |compl-generic|
  4825. Rvx Virtual Replace mode |i_CTRL-X| completion
  4826. c Command-line editing
  4827. cv Vim Ex mode |gQ|
  4828. r Hit-enter prompt
  4829. rm The -- more -- prompt
  4830. r? A |:confirm| query of some sort
  4831. ! Shell or external command is executing
  4832. t Terminal mode: keys go to the job
  4833. This is useful in the 'statusline' option or RPC calls. In
  4834. most other places it always returns "c" or "n".
  4835. Note that in the future more modes and more specific modes may
  4836. be added. It's better not to compare the whole string but only
  4837. the leading character(s).
  4838. Also see |visualmode()|.
  4839. Can also be used as a |method|: >
  4840. DoFull()->mode()
  4841. msgpackdump({list} [, {type}]) *msgpackdump()*
  4842. Convert a list of VimL objects to msgpack. Returned value is a
  4843. |readfile()|-style list. When {type} contains "B", a |Blob| is
  4844. returned instead. Example: >
  4845. call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
  4846. < or, using a |Blob|: >
  4847. call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
  4848. <
  4849. This will write the single 0x80 byte to a `fname.mpack` file
  4850. (dictionary with zero items is represented by 0x80 byte in
  4851. messagepack).
  4852. Limitations: *E5004* *E5005*
  4853. 1. |Funcref|s cannot be dumped.
  4854. 2. Containers that reference themselves cannot be dumped.
  4855. 3. Dictionary keys are always dumped as STR strings.
  4856. 4. Other strings and |Blob|s are always dumped as BIN strings.
  4857. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
  4858. msgpackparse({data}) *msgpackparse()*
  4859. Convert a |readfile()|-style list or a |Blob| to a list of
  4860. VimL objects.
  4861. Example: >
  4862. let fname = expand('~/.config/nvim/shada/main.shada')
  4863. let mpack = readfile(fname, 'b')
  4864. let shada_objects = msgpackparse(mpack)
  4865. < This will read ~/.config/nvim/shada/main.shada file to
  4866. `shada_objects` list.
  4867. Limitations:
  4868. 1. Mapping ordering is not preserved unless messagepack
  4869. mapping is dumped using generic mapping
  4870. (|msgpack-special-map|).
  4871. 2. Since the parser aims to preserve all data untouched
  4872. (except for 1.) some strings are parsed to
  4873. |msgpack-special-dict| format which is not convenient to
  4874. use.
  4875. *msgpack-special-dict*
  4876. Some messagepack strings may be parsed to special
  4877. dictionaries. Special dictionaries are dictionaries which
  4878. 1. Contain exactly two keys: `_TYPE` and `_VAL`.
  4879. 2. `_TYPE` key is one of the types found in |v:msgpack_types|
  4880. variable.
  4881. 3. Value for `_VAL` has the following format (Key column
  4882. contains name of the key from |v:msgpack_types|):
  4883. Key Value ~
  4884. nil Zero, ignored when dumping. Not returned by
  4885. |msgpackparse()| since |v:null| was introduced.
  4886. boolean One or zero. When dumping it is only checked that
  4887. value is a |Number|. Not returned by |msgpackparse()|
  4888. since |v:true| and |v:false| were introduced.
  4889. integer |List| with four numbers: sign (-1 or 1), highest two
  4890. bits, number with bits from 62nd to 31st, lowest 31
  4891. bits. I.e. to get actual number one will need to use
  4892. code like >
  4893. _VAL[0] * ((_VAL[1] << 62)
  4894. & (_VAL[2] << 31)
  4895. & _VAL[3])
  4896. < Special dictionary with this type will appear in
  4897. |msgpackparse()| output under one of the following
  4898. circumstances:
  4899. 1. |Number| is 32-bit and value is either above
  4900. INT32_MAX or below INT32_MIN.
  4901. 2. |Number| is 64-bit and value is above INT64_MAX. It
  4902. cannot possibly be below INT64_MIN because msgpack
  4903. C parser does not support such values.
  4904. float |Float|. This value cannot possibly appear in
  4905. |msgpackparse()| output.
  4906. string |readfile()|-style list of strings. This value will
  4907. appear in |msgpackparse()| output if string contains
  4908. zero byte or if string is a mapping key and mapping is
  4909. being represented as special dictionary for other
  4910. reasons.
  4911. binary |String|, or |Blob| if binary string contains zero
  4912. byte. This value cannot appear in |msgpackparse()|
  4913. output since blobs were introduced.
  4914. array |List|. This value cannot appear in |msgpackparse()|
  4915. output.
  4916. *msgpack-special-map*
  4917. map |List| of |List|s with two items (key and value) each.
  4918. This value will appear in |msgpackparse()| output if
  4919. parsed mapping contains one of the following keys:
  4920. 1. Any key that is not a string (including keys which
  4921. are binary strings).
  4922. 2. String with NUL byte inside.
  4923. 3. Duplicate key.
  4924. 4. Empty key.
  4925. ext |List| with two values: first is a signed integer
  4926. representing extension type. Second is
  4927. |readfile()|-style list of strings.
  4928. nextnonblank({lnum}) *nextnonblank()*
  4929. Return the line number of the first line at or below {lnum}
  4930. that is not blank. Example: >
  4931. if getline(nextnonblank(1)) =~ "Java"
  4932. < When {lnum} is invalid or there is no non-blank line at or
  4933. below it, zero is returned.
  4934. {lnum} is used like with |getline()|.
  4935. See also |prevnonblank()|.
  4936. Can also be used as a |method|: >
  4937. GetLnum()->nextnonblank()
  4938. nr2char({expr} [, {utf8}]) *nr2char()*
  4939. Return a string with a single character, which has the number
  4940. value {expr}. Examples: >
  4941. nr2char(64) returns "@"
  4942. nr2char(32) returns " "
  4943. < Example for "utf-8": >
  4944. nr2char(300) returns I with bow character
  4945. < UTF-8 encoding is always used, {utf8} option has no effect,
  4946. and exists only for backwards-compatibility.
  4947. Note that a NUL character in the file is specified with
  4948. nr2char(10), because NULs are represented with newline
  4949. characters. nr2char(0) is a real NUL and terminates the
  4950. string, thus results in an empty string.
  4951. Can also be used as a |method|: >
  4952. GetNumber()->nr2char()
  4953. nvim_...({...}) *E5555* *nvim_...()* *eval-api*
  4954. Call nvim |api| functions. The type checking of arguments will
  4955. be stricter than for most other builtins. For instance,
  4956. if Integer is expected, a |Number| must be passed in, a
  4957. |String| will not be autoconverted.
  4958. Buffer numbers, as returned by |bufnr()| could be used as
  4959. first argument to nvim_buf_... functions. All functions
  4960. expecting an object (buffer, window or tabpage) can
  4961. also take the numerical value 0 to indicate the current
  4962. (focused) object.
  4963. or({expr}, {expr}) *or()*
  4964. Bitwise OR on the two arguments. The arguments are converted
  4965. to a number. A List, Dict or Float argument causes an error.
  4966. Also see `and()` and `xor()`.
  4967. Example: >
  4968. :let bits = or(bits, 0x80)
  4969. < Can also be used as a |method|: >
  4970. :let bits = bits->or(0x80)
  4971. < Rationale: The reason this is a function and not using the "|"
  4972. character like many languages, is that Vi has always used "|"
  4973. to separate commands. In many places it would not be clear if
  4974. "|" is an operator or a command separator.
  4975. pathshorten({path} [, {len}]) *pathshorten()*
  4976. Shorten directory names in the path {path} and return the
  4977. result. The tail, the file name, is kept as-is. The other
  4978. components in the path are reduced to {len} letters in length.
  4979. If {len} is omitted or smaller than 1 then 1 is used (single
  4980. letters). Leading '~' and '.' characters are kept. Examples: >
  4981. :echo pathshorten('~/.config/nvim/autoload/file1.vim')
  4982. < ~/.c/n/a/file1.vim ~
  4983. >
  4984. :echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
  4985. < ~/.co/nv/au/file2.vim ~
  4986. It doesn't matter if the path exists or not.
  4987. Returns an empty string on error.
  4988. Can also be used as a |method|: >
  4989. GetDirectories()->pathshorten()
  4990. perleval({expr}) *perleval()*
  4991. Evaluate |perl| expression {expr} and return its result
  4992. converted to Vim data structures.
  4993. Numbers and strings are returned as they are (strings are
  4994. copied though).
  4995. Lists are represented as Vim |List| type.
  4996. Dictionaries are represented as Vim |Dictionary| type,
  4997. non-string keys result in error.
  4998. Note: If you want an array or hash, {expr} must return a
  4999. reference to it.
  5000. Example: >
  5001. :echo perleval('[1 .. 4]')
  5002. < [1, 2, 3, 4]
  5003. Can also be used as a |method|: >
  5004. GetExpr()->perleval()
  5005. pow({x}, {y}) *pow()*
  5006. Return the power of {x} to the exponent {y} as a |Float|.
  5007. {x} and {y} must evaluate to a |Float| or a |Number|.
  5008. Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
  5009. Examples: >
  5010. :echo pow(3, 3)
  5011. < 27.0 >
  5012. :echo pow(2, 16)
  5013. < 65536.0 >
  5014. :echo pow(32, 0.20)
  5015. < 2.0
  5016. Can also be used as a |method|: >
  5017. Compute()->pow(3)
  5018. prevnonblank({lnum}) *prevnonblank()*
  5019. Return the line number of the first line at or above {lnum}
  5020. that is not blank. Example: >
  5021. let ind = indent(prevnonblank(v:lnum - 1))
  5022. < When {lnum} is invalid or there is no non-blank line at or
  5023. above it, zero is returned.
  5024. {lnum} is used like with |getline()|.
  5025. Also see |nextnonblank()|.
  5026. Can also be used as a |method|: >
  5027. GetLnum()->prevnonblank()
  5028. printf({fmt}, {expr1} ...) *printf()*
  5029. Return a String with {fmt}, where "%" items are replaced by
  5030. the formatted form of their respective arguments. Example: >
  5031. printf("%4d: E%d %.30s", lnum, errno, msg)
  5032. < May result in:
  5033. " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
  5034. When used as a |method| the base is passed as the second
  5035. argument: >
  5036. Compute()->printf("result: %d")
  5037. <
  5038. You can use `call()` to pass the items as a list.
  5039. Often used items are:
  5040. %s string
  5041. %6S string right-aligned in 6 display cells
  5042. %6s string right-aligned in 6 bytes
  5043. %.9s string truncated to 9 bytes
  5044. %c single byte
  5045. %d decimal number
  5046. %5d decimal number padded with spaces to 5 characters
  5047. %b binary number
  5048. %08b binary number padded with zeros to at least 8 characters
  5049. %B binary number using upper case letters
  5050. %x hex number
  5051. %04x hex number padded with zeros to at least 4 characters
  5052. %X hex number using upper case letters
  5053. %o octal number
  5054. %f floating point number as 12.23, inf, -inf or nan
  5055. %F floating point number as 12.23, INF, -INF or NAN
  5056. %e floating point number as 1.23e3, inf, -inf or nan
  5057. %E floating point number as 1.23E3, INF, -INF or NAN
  5058. %g floating point number, as %f or %e depending on value
  5059. %G floating point number, as %F or %E depending on value
  5060. %% the % character itself
  5061. %p representation of the pointer to the container
  5062. Conversion specifications start with '%' and end with the
  5063. conversion type. All other characters are copied unchanged to
  5064. the result.
  5065. The "%" starts a conversion specification. The following
  5066. arguments appear in sequence:
  5067. % [flags] [field-width] [.precision] type
  5068. flags
  5069. Zero or more of the following flags:
  5070. # The value should be converted to an "alternate
  5071. form". For c, d, and s conversions, this option
  5072. has no effect. For o conversions, the precision
  5073. of the number is increased to force the first
  5074. character of the output string to a zero (except
  5075. if a zero value is printed with an explicit
  5076. precision of zero).
  5077. For x and X conversions, a non-zero result has
  5078. the string "0x" (or "0X" for X conversions)
  5079. prepended to it.
  5080. 0 (zero) Zero padding. For all conversions the converted
  5081. value is padded on the left with zeros rather
  5082. than blanks. If a precision is given with a
  5083. numeric conversion (d, o, x, and X), the 0 flag
  5084. is ignored.
  5085. - A negative field width flag; the converted value
  5086. is to be left adjusted on the field boundary.
  5087. The converted value is padded on the right with
  5088. blanks, rather than on the left with blanks or
  5089. zeros. A - overrides a 0 if both are given.
  5090. ' ' (space) A blank should be left before a positive
  5091. number produced by a signed conversion (d).
  5092. + A sign must always be placed before a number
  5093. produced by a signed conversion. A + overrides
  5094. a space if both are used.
  5095. field-width
  5096. An optional decimal digit string specifying a minimum
  5097. field width. If the converted value has fewer bytes
  5098. than the field width, it will be padded with spaces on
  5099. the left (or right, if the left-adjustment flag has
  5100. been given) to fill out the field width. For the S
  5101. conversion the count is in cells.
  5102. .precision
  5103. An optional precision, in the form of a period '.'
  5104. followed by an optional digit string. If the digit
  5105. string is omitted, the precision is taken as zero.
  5106. This gives the minimum number of digits to appear for
  5107. d, o, x, and X conversions, the maximum number of
  5108. bytes to be printed from a string for s conversions,
  5109. or the maximum number of cells to be printed from a
  5110. string for S conversions.
  5111. For floating point it is the number of digits after
  5112. the decimal point.
  5113. type
  5114. A character that specifies the type of conversion to
  5115. be applied, see below.
  5116. A field width or precision, or both, may be indicated by an
  5117. asterisk '*' instead of a digit string. In this case, a
  5118. Number argument supplies the field width or precision. A
  5119. negative field width is treated as a left adjustment flag
  5120. followed by a positive field width; a negative precision is
  5121. treated as though it were missing. Example: >
  5122. :echo printf("%d: %.*s", nr, width, line)
  5123. < This limits the length of the text used from "line" to
  5124. "width" bytes.
  5125. The conversion specifiers and their meanings are:
  5126. *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
  5127. dbBoxX The Number argument is converted to signed decimal (d),
  5128. unsigned binary (b and B), unsigned octal (o), or
  5129. unsigned hexadecimal (x and X) notation. The letters
  5130. "abcdef" are used for x conversions; the letters
  5131. "ABCDEF" are used for X conversions. The precision, if
  5132. any, gives the minimum number of digits that must
  5133. appear; if the converted value requires fewer digits, it
  5134. is padded on the left with zeros. In no case does a
  5135. non-existent or small field width cause truncation of a
  5136. numeric field; if the result of a conversion is wider
  5137. than the field width, the field is expanded to contain
  5138. the conversion result.
  5139. The 'h' modifier indicates the argument is 16 bits.
  5140. The 'l' modifier indicates the argument is 32 bits.
  5141. The 'L' modifier indicates the argument is 64 bits.
  5142. Generally, these modifiers are not useful. They are
  5143. ignored when type is known from the argument.
  5144. i alias for d
  5145. D alias for ld
  5146. U alias for lu
  5147. O alias for lo
  5148. *printf-c*
  5149. c The Number argument is converted to a byte, and the
  5150. resulting character is written.
  5151. *printf-s*
  5152. s The text of the String argument is used. If a
  5153. precision is specified, no more bytes than the number
  5154. specified are used.
  5155. If the argument is not a String type, it is
  5156. automatically converted to text with the same format
  5157. as ":echo".
  5158. *printf-S*
  5159. S The text of the String argument is used. If a
  5160. precision is specified, no more display cells than the
  5161. number specified are used.
  5162. *printf-f* *E807*
  5163. f F The Float argument is converted into a string of the
  5164. form 123.456. The precision specifies the number of
  5165. digits after the decimal point. When the precision is
  5166. zero the decimal point is omitted. When the precision
  5167. is not specified 6 is used. A really big number
  5168. (out of range or dividing by zero) results in "inf"
  5169. or "-inf" with %f (INF or -INF with %F).
  5170. "0.0 / 0.0" results in "nan" with %f (NAN with %F).
  5171. Example: >
  5172. echo printf("%.2f", 12.115)
  5173. < 12.12
  5174. Note that roundoff depends on the system libraries.
  5175. Use |round()| when in doubt.
  5176. *printf-e* *printf-E*
  5177. e E The Float argument is converted into a string of the
  5178. form 1.234e+03 or 1.234E+03 when using 'E'. The
  5179. precision specifies the number of digits after the
  5180. decimal point, like with 'f'.
  5181. *printf-g* *printf-G*
  5182. g G The Float argument is converted like with 'f' if the
  5183. value is between 0.001 (inclusive) and 10000000.0
  5184. (exclusive). Otherwise 'e' is used for 'g' and 'E'
  5185. for 'G'. When no precision is specified superfluous
  5186. zeroes and '+' signs are removed, except for the zero
  5187. immediately after the decimal point. Thus 10000000.0
  5188. results in 1.0e7.
  5189. *printf-%*
  5190. % A '%' is written. No argument is converted. The
  5191. complete conversion specification is "%%".
  5192. When a Number argument is expected a String argument is also
  5193. accepted and automatically converted.
  5194. When a Float or String argument is expected a Number argument
  5195. is also accepted and automatically converted.
  5196. Any other argument type results in an error message.
  5197. *E766* *E767*
  5198. The number of {exprN} arguments must exactly match the number
  5199. of "%" items. If there are not sufficient or too many
  5200. arguments an error is given. Up to 18 arguments can be used.
  5201. prompt_getprompt({buf}) *prompt_getprompt()*
  5202. Returns the effective prompt text for buffer {buf}. {buf} can
  5203. be a buffer name or number. See |prompt-buffer|.
  5204. If the buffer doesn't exist or isn't a prompt buffer, an empty
  5205. string is returned.
  5206. Can also be used as a |method|: >
  5207. GetBuffer()->prompt_getprompt()
  5208. prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
  5209. Set prompt callback for buffer {buf} to {expr}. When {expr}
  5210. is an empty string the callback is removed. This has only
  5211. effect if {buf} has 'buftype' set to "prompt".
  5212. The callback is invoked when pressing Enter. The current
  5213. buffer will always be the prompt buffer. A new line for a
  5214. prompt is added before invoking the callback, thus the prompt
  5215. for which the callback was invoked will be in the last but one
  5216. line.
  5217. If the callback wants to add text to the buffer, it must
  5218. insert it above the last line, since that is where the current
  5219. prompt is. This can also be done asynchronously.
  5220. The callback is invoked with one argument, which is the text
  5221. that was entered at the prompt. This can be an empty string
  5222. if the user only typed Enter.
  5223. Example: >
  5224. call prompt_setcallback(bufnr(''), function('s:TextEntered'))
  5225. func s:TextEntered(text)
  5226. if a:text == 'exit' || a:text == 'quit'
  5227. stopinsert
  5228. close
  5229. else
  5230. call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
  5231. " Reset 'modified' to allow the buffer to be closed.
  5232. set nomodified
  5233. endif
  5234. endfunc
  5235. < Can also be used as a |method|: >
  5236. GetBuffer()->prompt_setcallback(callback)
  5237. prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
  5238. Set a callback for buffer {buf} to {expr}. When {expr} is an
  5239. empty string the callback is removed. This has only effect if
  5240. {buf} has 'buftype' set to "prompt".
  5241. This callback will be invoked when pressing CTRL-C in Insert
  5242. mode. Without setting a callback Vim will exit Insert mode,
  5243. as in any buffer.
  5244. Can also be used as a |method|: >
  5245. GetBuffer()->prompt_setinterrupt(callback)
  5246. prompt_setprompt({buf}, {text}) *prompt_setprompt()*
  5247. Set prompt for buffer {buf} to {text}. You most likely want
  5248. {text} to end in a space.
  5249. The result is only visible if {buf} has 'buftype' set to
  5250. "prompt". Example: >
  5251. call prompt_setprompt(bufnr(''), 'command: ')
  5252. <
  5253. Can also be used as a |method|: >
  5254. GetBuffer()->prompt_setprompt('command: ')
  5255. pum_getpos() *pum_getpos()*
  5256. If the popup menu (see |ins-completion-menu|) is not visible,
  5257. returns an empty |Dictionary|, otherwise, returns a
  5258. |Dictionary| with the following keys:
  5259. height nr of items visible
  5260. width screen cells
  5261. row top screen row (0 first row)
  5262. col leftmost screen column (0 first col)
  5263. size total nr of items
  5264. scrollbar |TRUE| if scrollbar is visible
  5265. The values are the same as in |v:event| during |CompleteChanged|.
  5266. pumvisible() *pumvisible()*
  5267. Returns non-zero when the popup menu is visible, zero
  5268. otherwise. See |ins-completion-menu|.
  5269. This can be used to avoid some things that would remove the
  5270. popup menu.
  5271. py3eval({expr}) *py3eval()*
  5272. Evaluate Python expression {expr} and return its result
  5273. converted to Vim data structures.
  5274. Numbers and strings are returned as they are (strings are
  5275. copied though, Unicode strings are additionally converted to
  5276. UTF-8).
  5277. Lists are represented as Vim |List| type.
  5278. Dictionaries are represented as Vim |Dictionary| type with
  5279. keys converted to strings.
  5280. Can also be used as a |method|: >
  5281. GetExpr()->py3eval()
  5282. <
  5283. *E858* *E859*
  5284. pyeval({expr}) *pyeval()*
  5285. Evaluate Python expression {expr} and return its result
  5286. converted to Vim data structures.
  5287. Numbers and strings are returned as they are (strings are
  5288. copied though).
  5289. Lists are represented as Vim |List| type.
  5290. Dictionaries are represented as Vim |Dictionary| type,
  5291. non-string keys result in error.
  5292. Can also be used as a |method|: >
  5293. GetExpr()->pyeval()
  5294. pyxeval({expr}) *pyxeval()*
  5295. Evaluate Python expression {expr} and return its result
  5296. converted to Vim data structures.
  5297. Uses Python 2 or 3, see |python_x| and 'pyxversion'.
  5298. See also: |pyeval()|, |py3eval()|
  5299. Can also be used as a |method|: >
  5300. GetExpr()->pyxeval()
  5301. <
  5302. *E726* *E727*
  5303. range({expr} [, {max} [, {stride}]]) *range()*
  5304. Returns a |List| with Numbers:
  5305. - If only {expr} is specified: [0, 1, ..., {expr} - 1]
  5306. - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
  5307. - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
  5308. {max}] (increasing {expr} with {stride} each time, not
  5309. producing a value past {max}).
  5310. When the maximum is one before the start the result is an
  5311. empty list. When the maximum is more than one before the
  5312. start this is an error.
  5313. Examples: >
  5314. range(4) " [0, 1, 2, 3]
  5315. range(2, 4) " [2, 3, 4]
  5316. range(2, 9, 3) " [2, 5, 8]
  5317. range(2, -2, -1) " [2, 1, 0, -1, -2]
  5318. range(0) " []
  5319. range(2, 0) " error!
  5320. <
  5321. Can also be used as a |method|: >
  5322. GetExpr()->range()
  5323. <
  5324. rand([{expr}]) *rand()*
  5325. Return a pseudo-random Number generated with an xoshiro128**
  5326. algorithm using seed {expr}. The returned number is 32 bits,
  5327. also on 64 bits systems, for consistency.
  5328. {expr} can be initialized by |srand()| and will be updated by
  5329. rand(). If {expr} is omitted, an internal seed value is used
  5330. and updated.
  5331. Returns -1 if {expr} is invalid.
  5332. Examples: >
  5333. :echo rand()
  5334. :let seed = srand()
  5335. :echo rand(seed)
  5336. :echo rand(seed) % 16 " random number 0 - 15
  5337. <
  5338. Can also be used as a |method|: >
  5339. seed->rand()
  5340. <
  5341. *readdir()*
  5342. readdir({directory} [, {expr}])
  5343. Return a list with file and directory names in {directory}.
  5344. You can also use |glob()| if you don't need to do complicated
  5345. things, such as limiting the number of matches.
  5346. When {expr} is omitted all entries are included.
  5347. When {expr} is given, it is evaluated to check what to do:
  5348. If {expr} results in -1 then no further entries will
  5349. be handled.
  5350. If {expr} results in 0 then this entry will not be
  5351. added to the list.
  5352. If {expr} results in 1 then this entry will be added
  5353. to the list.
  5354. Each time {expr} is evaluated |v:val| is set to the entry name.
  5355. When {expr} is a function the name is passed as the argument.
  5356. For example, to get a list of files ending in ".txt": >
  5357. readdir(dirname, {n -> n =~ '.txt$'})
  5358. < To skip hidden and backup files: >
  5359. readdir(dirname, {n -> n !~ '^\.\|\~$'})
  5360. < If you want to get a directory tree: >
  5361. function! s:tree(dir)
  5362. return {a:dir : map(readdir(a:dir),
  5363. \ {_, x -> isdirectory(x) ?
  5364. \ {x : s:tree(a:dir .. '/' .. x)} : x})}
  5365. endfunction
  5366. echo s:tree(".")
  5367. <
  5368. Returns an empty List on error.
  5369. Can also be used as a |method|: >
  5370. GetDirName()->readdir()
  5371. <
  5372. *readfile()*
  5373. readfile({fname} [, {type} [, {max}]])
  5374. Read file {fname} and return a |List|, each line of the file
  5375. as an item. Lines are broken at NL characters. Macintosh
  5376. files separated with CR will result in a single long line
  5377. (unless a NL appears somewhere).
  5378. All NUL characters are replaced with a NL character.
  5379. When {type} contains "b" binary mode is used:
  5380. - When the last line ends in a NL an extra empty list item is
  5381. added.
  5382. - No CR characters are removed.
  5383. When {type} contains "B" a |Blob| is returned with the binary
  5384. data of the file unmodified.
  5385. Otherwise:
  5386. - CR characters that appear before a NL are removed.
  5387. - Whether the last line ends in a NL or not does not matter.
  5388. - Any UTF-8 byte order mark is removed from the text.
  5389. When {max} is given this specifies the maximum number of lines
  5390. to be read. Useful if you only want to check the first ten
  5391. lines of a file: >
  5392. :for line in readfile(fname, '', 10)
  5393. : if line =~ 'Date' | echo line | endif
  5394. :endfor
  5395. < When {max} is negative -{max} lines from the end of the file
  5396. are returned, or as many as there are.
  5397. When {max} is zero the result is an empty list.
  5398. Note that without {max} the whole file is read into memory.
  5399. Also note that there is no recognition of encoding. Read a
  5400. file into a buffer if you need to.
  5401. When the file can't be opened an error message is given and
  5402. the result is an empty list.
  5403. Also see |writefile()|.
  5404. Can also be used as a |method|: >
  5405. GetFileName()->readfile()
  5406. reduce({object}, {func} [, {initial}]) *reduce()* *E998*
  5407. {func} is called for every item in {object}, which can be a
  5408. |List| or a |Blob|. {func} is called with two arguments: the
  5409. result so far and current item. After processing all items
  5410. the result is returned.
  5411. {initial} is the initial result. When omitted, the first item
  5412. in {object} is used and {func} is first called for the second
  5413. item. If {initial} is not given and {object} is empty no
  5414. result can be computed, an E998 error is given.
  5415. Examples: >
  5416. echo reduce([1, 3, 5], { acc, val -> acc + val })
  5417. echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
  5418. echo reduce(0z1122, { acc, val -> 2 * acc + val })
  5419. <
  5420. Can also be used as a |method|: >
  5421. echo mylist->reduce({ acc, val -> acc + val }, 0)
  5422. reg_executing() *reg_executing()*
  5423. Returns the single letter name of the register being executed.
  5424. Returns an empty string when no register is being executed.
  5425. See |@|.
  5426. reg_recorded() *reg_recorded()*
  5427. Returns the single letter name of the last recorded register.
  5428. Returns an empty string when nothing was recorded yet.
  5429. See |q| and |Q|.
  5430. reg_recording() *reg_recording()*
  5431. Returns the single letter name of the register being recorded.
  5432. Returns an empty string when not recording. See |q|.
  5433. reltime([{start} [, {end}]]) *reltime()*
  5434. Return an item that represents a time value. The item is a
  5435. list with items that depend on the system.
  5436. The item can be passed to |reltimestr()| to convert it to a
  5437. string or |reltimefloat()| to convert to a Float.
  5438. Without an argument it returns the current "relative time", an
  5439. implementation-defined value meaningful only when used as an
  5440. argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
  5441. With one argument it returns the time passed since the time
  5442. specified in the argument.
  5443. With two arguments it returns the time passed between {start}
  5444. and {end}.
  5445. The {start} and {end} arguments must be values returned by
  5446. reltime(). Returns zero on error.
  5447. Can also be used as a |method|: >
  5448. GetStart()->reltime()
  5449. <
  5450. Note: |localtime()| returns the current (non-relative) time.
  5451. reltimefloat({time}) *reltimefloat()*
  5452. Return a Float that represents the time value of {time}.
  5453. Unit of time is seconds.
  5454. Example:
  5455. let start = reltime()
  5456. call MyFunction()
  5457. let seconds = reltimefloat(reltime(start))
  5458. See the note of reltimestr() about overhead.
  5459. Also see |profiling|.
  5460. If there is an error an empty string is returned
  5461. Can also be used as a |method|: >
  5462. reltime(start)->reltimefloat()
  5463. reltimestr({time}) *reltimestr()*
  5464. Return a String that represents the time value of {time}.
  5465. This is the number of seconds, a dot and the number of
  5466. microseconds. Example: >
  5467. let start = reltime()
  5468. call MyFunction()
  5469. echo reltimestr(reltime(start))
  5470. < Note that overhead for the commands will be added to the time.
  5471. Leading spaces are used to make the string align nicely. You
  5472. can use split() to remove it. >
  5473. echo split(reltimestr(reltime(start)))[0]
  5474. < Also see |profiling|.
  5475. If there is an error an empty string is returned
  5476. Can also be used as a |method|: >
  5477. reltime(start)->reltimestr()
  5478. <
  5479. remove({list}, {idx} [, {end}]) *remove()*
  5480. Without {end}: Remove the item at {idx} from |List| {list} and
  5481. return the item.
  5482. With {end}: Remove items from {idx} to {end} (inclusive) and
  5483. return a |List| with these items. When {idx} points to the same
  5484. item as {end} a list with one item is returned. When {end}
  5485. points to an item before {idx} this is an error.
  5486. See |list-index| for possible values of {idx} and {end}.
  5487. Returns zero on error.
  5488. Example: >
  5489. :echo "last item: " .. remove(mylist, -1)
  5490. :call remove(mylist, 0, 9)
  5491. <
  5492. Use |delete()| to remove a file.
  5493. Can also be used as a |method|: >
  5494. mylist->remove(idx)
  5495. remove({blob}, {idx} [, {end}])
  5496. Without {end}: Remove the byte at {idx} from |Blob| {blob} and
  5497. return the byte.
  5498. With {end}: Remove bytes from {idx} to {end} (inclusive) and
  5499. return a |Blob| with these bytes. When {idx} points to the same
  5500. byte as {end} a |Blob| with one byte is returned. When {end}
  5501. points to a byte before {idx} this is an error.
  5502. Returns zero on error.
  5503. Example: >
  5504. :echo "last byte: " .. remove(myblob, -1)
  5505. :call remove(mylist, 0, 9)
  5506. remove({dict}, {key})
  5507. Remove the entry from {dict} with key {key} and return it.
  5508. Example: >
  5509. :echo "removed " .. remove(dict, "one")
  5510. < If there is no {key} in {dict} this is an error.
  5511. Returns zero on error.
  5512. rename({from}, {to}) *rename()*
  5513. Rename the file by the name {from} to the name {to}. This
  5514. should also work to move files across file systems. The
  5515. result is a Number, which is 0 if the file was renamed
  5516. successfully, and non-zero when the renaming failed.
  5517. NOTE: If {to} exists it is overwritten without warning.
  5518. This function is not available in the |sandbox|.
  5519. Can also be used as a |method|: >
  5520. GetOldName()->rename(newname)
  5521. repeat({expr}, {count}) *repeat()*
  5522. Repeat {expr} {count} times and return the concatenated
  5523. result. Example: >
  5524. :let separator = repeat('-', 80)
  5525. < When {count} is zero or negative the result is empty.
  5526. When {expr} is a |List| the result is {expr} concatenated
  5527. {count} times. Example: >
  5528. :let longlist = repeat(['a', 'b'], 3)
  5529. < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
  5530. Can also be used as a |method|: >
  5531. mylist->repeat(count)
  5532. resolve({filename}) *resolve()* *E655*
  5533. On MS-Windows, when {filename} is a shortcut (a .lnk file),
  5534. returns the path the shortcut points to in a simplified form.
  5535. On Unix, repeat resolving symbolic links in all path
  5536. components of {filename} and return the simplified result.
  5537. To cope with link cycles, resolving of symbolic links is
  5538. stopped after 100 iterations.
  5539. On other systems, return the simplified {filename}.
  5540. The simplification step is done as by |simplify()|.
  5541. resolve() keeps a leading path component specifying the
  5542. current directory (provided the result is still a relative
  5543. path name) and also keeps a trailing path separator.
  5544. Can also be used as a |method|: >
  5545. GetName()->resolve()
  5546. <
  5547. *reverse()*
  5548. reverse({object})
  5549. Reverse the order of items in {object} in-place.
  5550. {object} can be a |List| or a |Blob|.
  5551. Returns {object}.
  5552. Returns zero if {object} is not a List or a Blob.
  5553. If you want an object to remain unmodified make a copy first: >
  5554. :let revlist = reverse(copy(mylist))
  5555. < Can also be used as a |method|: >
  5556. mylist->reverse()
  5557. round({expr}) *round()*
  5558. Round off {expr} to the nearest integral value and return it
  5559. as a |Float|. If {expr} lies halfway between two integral
  5560. values, then use the larger one (away from zero).
  5561. {expr} must evaluate to a |Float| or a |Number|.
  5562. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  5563. Examples: >
  5564. echo round(0.456)
  5565. < 0.0 >
  5566. echo round(4.5)
  5567. < 5.0 >
  5568. echo round(-4.5)
  5569. < -5.0
  5570. Can also be used as a |method|: >
  5571. Compute()->round()
  5572. rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()*
  5573. Sends {event} to {channel} via |RPC| and returns immediately.
  5574. If {channel} is 0, the event is broadcast to all channels.
  5575. Example: >
  5576. :au VimLeave call rpcnotify(0, "leaving")
  5577. rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()*
  5578. Sends a request to {channel} to invoke {method} via
  5579. |RPC| and blocks until a response is received.
  5580. Example: >
  5581. :let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
  5582. rpcstart({prog} [, {argv}]) *rpcstart()*
  5583. Deprecated. Replace >
  5584. :let id = rpcstart('prog', ['arg1', 'arg2'])
  5585. < with >
  5586. :let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
  5587. rubyeval({expr}) *rubyeval()*
  5588. Evaluate Ruby expression {expr} and return its result
  5589. converted to Vim data structures.
  5590. Numbers, floats and strings are returned as they are (strings
  5591. are copied though).
  5592. Arrays are represented as Vim |List| type.
  5593. Hashes are represented as Vim |Dictionary| type.
  5594. Other objects are represented as strings resulted from their
  5595. "Object#to_s" method.
  5596. Can also be used as a |method|: >
  5597. GetRubyExpr()->rubyeval()
  5598. screenattr({row}, {col}) *screenattr()*
  5599. Like |screenchar()|, but return the attribute. This is a rather
  5600. arbitrary number that can only be used to compare to the
  5601. attribute at other positions.
  5602. Returns -1 when row or col is out of range.
  5603. Can also be used as a |method|: >
  5604. GetRow()->screenattr(col)
  5605. screenchar({row}, {col}) *screenchar()*
  5606. The result is a Number, which is the character at position
  5607. [row, col] on the screen. This works for every possible
  5608. screen position, also status lines, window separators and the
  5609. command line. The top left position is row one, column one
  5610. The character excludes composing characters. For double-byte
  5611. encodings it may only be the first byte.
  5612. This is mainly to be used for testing.
  5613. Returns -1 when row or col is out of range.
  5614. Can also be used as a |method|: >
  5615. GetRow()->screenchar(col)
  5616. screenchars({row}, {col}) *screenchars()*
  5617. The result is a List of Numbers. The first number is the same
  5618. as what |screenchar()| returns. Further numbers are
  5619. composing characters on top of the base character.
  5620. This is mainly to be used for testing.
  5621. Returns an empty List when row or col is out of range.
  5622. Can also be used as a |method|: >
  5623. GetRow()->screenchars(col)
  5624. screencol() *screencol()*
  5625. The result is a Number, which is the current screen column of
  5626. the cursor. The leftmost column has number 1.
  5627. This function is mainly used for testing.
  5628. Note: Always returns the current screen column, thus if used
  5629. in a command (e.g. ":echo screencol()") it will return the
  5630. column inside the command line, which is 1 when the command is
  5631. executed. To get the cursor position in the file use one of
  5632. the following mappings: >
  5633. nnoremap <expr> GG ":echom " .. screencol() .. "\n"
  5634. nnoremap <silent> GG :echom screencol()<CR>
  5635. noremap GG <Cmd>echom screencol()<Cr>
  5636. <
  5637. screenpos({winid}, {lnum}, {col}) *screenpos()*
  5638. The result is a Dict with the screen position of the text
  5639. character in window {winid} at buffer line {lnum} and column
  5640. {col}. {col} is a one-based byte index.
  5641. The Dict has these members:
  5642. row screen row
  5643. col first screen column
  5644. endcol last screen column
  5645. curscol cursor screen column
  5646. If the specified position is not visible, all values are zero.
  5647. The "endcol" value differs from "col" when the character
  5648. occupies more than one screen cell. E.g. for a Tab "col" can
  5649. be 1 and "endcol" can be 8.
  5650. The "curscol" value is where the cursor would be placed. For
  5651. a Tab it would be the same as "endcol", while for a double
  5652. width character it would be the same as "col".
  5653. The |conceal| feature is ignored here, the column numbers are
  5654. as if 'conceallevel' is zero. You can set the cursor to the
  5655. right position and use |screencol()| to get the value with
  5656. |conceal| taken into account.
  5657. Returns an empty Dict if {winid} is invalid.
  5658. Can also be used as a |method|: >
  5659. GetWinid()->screenpos(lnum, col)
  5660. screenrow() *screenrow()*
  5661. The result is a Number, which is the current screen row of the
  5662. cursor. The top line has number one.
  5663. This function is mainly used for testing.
  5664. Alternatively you can use |winline()|.
  5665. Note: Same restrictions as with |screencol()|.
  5666. screenstring({row}, {col}) *screenstring()*
  5667. The result is a String that contains the base character and
  5668. any composing characters at position [row, col] on the screen.
  5669. This is like |screenchars()| but returning a String with the
  5670. characters.
  5671. This is mainly to be used for testing.
  5672. Returns an empty String when row or col is out of range.
  5673. Can also be used as a |method|: >
  5674. GetRow()->screenstring(col)
  5675. <
  5676. *search()*
  5677. search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  5678. Search for regexp pattern {pattern}. The search starts at the
  5679. cursor position (you can use |cursor()| to set it).
  5680. When a match has been found its line number is returned.
  5681. If there is no match a 0 is returned and the cursor doesn't
  5682. move. No error message is given.
  5683. {flags} is a String, which can contain these character flags:
  5684. 'b' search Backward instead of forward
  5685. 'c' accept a match at the Cursor position
  5686. 'e' move to the End of the match
  5687. 'n' do Not move the cursor
  5688. 'p' return number of matching sub-Pattern (see below)
  5689. 's' Set the ' mark at the previous location of the cursor
  5690. 'w' Wrap around the end of the file
  5691. 'W' don't Wrap around the end of the file
  5692. 'z' start searching at the cursor column instead of Zero
  5693. If neither 'w' or 'W' is given, the 'wrapscan' option applies.
  5694. If the 's' flag is supplied, the ' mark is set, only if the
  5695. cursor is moved. The 's' flag cannot be combined with the 'n'
  5696. flag.
  5697. 'ignorecase', 'smartcase' and 'magic' are used.
  5698. When the 'z' flag is not given, forward searching always
  5699. starts in column zero and then matches before the cursor are
  5700. skipped. When the 'c' flag is present in 'cpo' the next
  5701. search starts after the match. Without the 'c' flag the next
  5702. search starts one column after the start of the match. This
  5703. matters for overlapping matches. See |cpo-c|. You can also
  5704. insert "\ze" to change where the match ends, see |/\ze|.
  5705. When searching backwards and the 'z' flag is given then the
  5706. search starts in column zero, thus no match in the current
  5707. line will be found (unless wrapping around the end of the
  5708. file).
  5709. When the {stopline} argument is given then the search stops
  5710. after searching this line. This is useful to restrict the
  5711. search to a range of lines. Examples: >
  5712. let match = search('(', 'b', line("w0"))
  5713. let end = search('END', '', line("w$"))
  5714. < When {stopline} is used and it is not zero this also implies
  5715. that the search does not wrap around the end of the file.
  5716. A zero value is equal to not giving the argument.
  5717. When the {timeout} argument is given the search stops when
  5718. more than this many milliseconds have passed. Thus when
  5719. {timeout} is 500 the search stops after half a second.
  5720. The value must not be negative. A zero value is like not
  5721. giving the argument.
  5722. If the {skip} expression is given it is evaluated with the
  5723. cursor positioned on the start of a match. If it evaluates to
  5724. non-zero this match is skipped. This can be used, for
  5725. example, to skip a match in a comment or a string.
  5726. {skip} can be a string, which is evaluated as an expression, a
  5727. function reference or a lambda.
  5728. When {skip} is omitted or empty, every match is accepted.
  5729. When evaluating {skip} causes an error the search is aborted
  5730. and -1 returned.
  5731. *search()-sub-match*
  5732. With the 'p' flag the returned value is one more than the
  5733. first sub-match in \(\). One if none of them matched but the
  5734. whole pattern did match.
  5735. To get the column number too use |searchpos()|.
  5736. The cursor will be positioned at the match, unless the 'n'
  5737. flag is used.
  5738. Example (goes over all files in the argument list): >
  5739. :let n = 1
  5740. :while n <= argc() " loop over all files in arglist
  5741. : exe "argument " .. n
  5742. : " start at the last char in the file and wrap for the
  5743. : " first search to find match at start of file
  5744. : normal G$
  5745. : let flags = "w"
  5746. : while search("foo", flags) > 0
  5747. : s/foo/bar/g
  5748. : let flags = "W"
  5749. : endwhile
  5750. : update " write the file if modified
  5751. : let n = n + 1
  5752. :endwhile
  5753. <
  5754. Example for using some flags: >
  5755. :echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
  5756. < This will search for the keywords "if", "else", and "endif"
  5757. under or after the cursor. Because of the 'p' flag, it
  5758. returns 1, 2, or 3 depending on which keyword is found, or 0
  5759. if the search fails. With the cursor on the first word of the
  5760. line:
  5761. if (foo == 0) | let foo = foo + 1 | endif ~
  5762. the function returns 1. Without the 'c' flag, the function
  5763. finds the "endif" and returns 3. The same thing happens
  5764. without the 'e' flag if the cursor is on the "f" of "if".
  5765. The 'n' flag tells the function not to move the cursor.
  5766. Can also be used as a |method|: >
  5767. GetPattern()->search()
  5768. searchcount([{options}]) *searchcount()*
  5769. Get or update the last search count, like what is displayed
  5770. without the "S" flag in 'shortmess'. This works even if
  5771. 'shortmess' does contain the "S" flag.
  5772. This returns a Dictionary. The dictionary is empty if the
  5773. previous pattern was not set and "pattern" was not specified.
  5774. key type meaning ~
  5775. current |Number| current position of match;
  5776. 0 if the cursor position is
  5777. before the first match
  5778. exact_match |Boolean| 1 if "current" is matched on
  5779. "pos", otherwise 0
  5780. total |Number| total count of matches found
  5781. incomplete |Number| 0: search was fully completed
  5782. 1: recomputing was timed out
  5783. 2: max count exceeded
  5784. For {options} see further down.
  5785. To get the last search count when |n| or |N| was pressed, call
  5786. this function with `recompute: 0` . This sometimes returns
  5787. wrong information because |n| and |N|'s maximum count is 99.
  5788. If it exceeded 99 the result must be max count + 1 (100). If
  5789. you want to get correct information, specify `recompute: 1`: >
  5790. " result == maxcount + 1 (100) when many matches
  5791. let result = searchcount(#{recompute: 0})
  5792. " Below returns correct result (recompute defaults
  5793. " to 1)
  5794. let result = searchcount()
  5795. <
  5796. The function is useful to add the count to 'statusline': >
  5797. function! LastSearchCount() abort
  5798. let result = searchcount(#{recompute: 0})
  5799. if empty(result)
  5800. return ''
  5801. endif
  5802. if result.incomplete ==# 1 " timed out
  5803. return printf(' /%s [?/??]', @/)
  5804. elseif result.incomplete ==# 2 " max count exceeded
  5805. if result.total > result.maxcount &&
  5806. \ result.current > result.maxcount
  5807. return printf(' /%s [>%d/>%d]', @/,
  5808. \ result.current, result.total)
  5809. elseif result.total > result.maxcount
  5810. return printf(' /%s [%d/>%d]', @/,
  5811. \ result.current, result.total)
  5812. endif
  5813. endif
  5814. return printf(' /%s [%d/%d]', @/,
  5815. \ result.current, result.total)
  5816. endfunction
  5817. let &statusline ..= '%{LastSearchCount()}'
  5818. " Or if you want to show the count only when
  5819. " 'hlsearch' was on
  5820. " let &statusline ..=
  5821. " \ '%{v:hlsearch ? LastSearchCount() : ""}'
  5822. <
  5823. You can also update the search count, which can be useful in a
  5824. |CursorMoved| or |CursorMovedI| autocommand: >
  5825. autocmd CursorMoved,CursorMovedI *
  5826. \ let s:searchcount_timer = timer_start(
  5827. \ 200, function('s:update_searchcount'))
  5828. function! s:update_searchcount(timer) abort
  5829. if a:timer ==# s:searchcount_timer
  5830. call searchcount(#{
  5831. \ recompute: 1, maxcount: 0, timeout: 100})
  5832. redrawstatus
  5833. endif
  5834. endfunction
  5835. <
  5836. This can also be used to count matched texts with specified
  5837. pattern in the current buffer using "pattern": >
  5838. " Count '\<foo\>' in this buffer
  5839. " (Note that it also updates search count)
  5840. let result = searchcount(#{pattern: '\<foo\>'})
  5841. " To restore old search count by old pattern,
  5842. " search again
  5843. call searchcount()
  5844. <
  5845. {options} must be a Dictionary. It can contain:
  5846. key type meaning ~
  5847. recompute |Boolean| if |TRUE|, recompute the count
  5848. like |n| or |N| was executed.
  5849. otherwise returns the last
  5850. computed result (when |n| or
  5851. |N| was used when "S" is not
  5852. in 'shortmess', or this
  5853. function was called).
  5854. (default: |TRUE|)
  5855. pattern |String| recompute if this was given
  5856. and different with |@/|.
  5857. this works as same as the
  5858. below command is executed
  5859. before calling this function >
  5860. let @/ = pattern
  5861. < (default: |@/|)
  5862. timeout |Number| 0 or negative number is no
  5863. timeout. timeout milliseconds
  5864. for recomputing the result
  5865. (default: 0)
  5866. maxcount |Number| 0 or negative number is no
  5867. limit. max count of matched
  5868. text while recomputing the
  5869. result. if search exceeded
  5870. total count, "total" value
  5871. becomes `maxcount + 1`
  5872. (default: 0)
  5873. pos |List| `[lnum, col, off]` value
  5874. when recomputing the result.
  5875. this changes "current" result
  5876. value. see |cursor()|, |getpos()
  5877. (default: cursor's position)
  5878. Can also be used as a |method|: >
  5879. GetSearchOpts()->searchcount()
  5880. <
  5881. searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
  5882. Search for the declaration of {name}.
  5883. With a non-zero {global} argument it works like |gD|, find
  5884. first match in the file. Otherwise it works like |gd|, find
  5885. first match in the function.
  5886. With a non-zero {thisblock} argument matches in a {} block
  5887. that ends before the cursor position are ignored. Avoids
  5888. finding variable declarations only valid in another scope.
  5889. Moves the cursor to the found match.
  5890. Returns zero for success, non-zero for failure.
  5891. Example: >
  5892. if searchdecl('myvar') == 0
  5893. echo getline('.')
  5894. endif
  5895. <
  5896. Can also be used as a |method|: >
  5897. GetName()->searchdecl()
  5898. <
  5899. *searchpair()*
  5900. searchpair({start}, {middle}, {end} [, {flags} [, {skip}
  5901. [, {stopline} [, {timeout}]]]])
  5902. Search for the match of a nested start-end pair. This can be
  5903. used to find the "endif" that matches an "if", while other
  5904. if/endif pairs in between are ignored.
  5905. The search starts at the cursor. The default is to search
  5906. forward, include 'b' in {flags} to search backward.
  5907. If a match is found, the cursor is positioned at it and the
  5908. line number is returned. If no match is found 0 or -1 is
  5909. returned and the cursor doesn't move. No error message is
  5910. given.
  5911. {start}, {middle} and {end} are patterns, see |pattern|. They
  5912. must not contain \( \) pairs. Use of \%( \) is allowed. When
  5913. {middle} is not empty, it is found when searching from either
  5914. direction, but only when not in a nested start-end pair. A
  5915. typical use is: >
  5916. searchpair('\<if\>', '\<else\>', '\<endif\>')
  5917. < By leaving {middle} empty the "else" is skipped.
  5918. {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
  5919. |search()|. Additionally:
  5920. 'r' Repeat until no more matches found; will find the
  5921. outer pair. Implies the 'W' flag.
  5922. 'm' Return number of matches instead of line number with
  5923. the match; will be > 1 when 'r' is used.
  5924. Note: it's nearly always a good idea to use the 'W' flag, to
  5925. avoid wrapping around the end of the file.
  5926. When a match for {start}, {middle} or {end} is found, the
  5927. {skip} expression is evaluated with the cursor positioned on
  5928. the start of the match. It should return non-zero if this
  5929. match is to be skipped. E.g., because it is inside a comment
  5930. or a string.
  5931. When {skip} is omitted or empty, every match is accepted.
  5932. When evaluating {skip} causes an error the search is aborted
  5933. and -1 returned.
  5934. {skip} can be a string, a lambda, a funcref or a partial.
  5935. Anything else makes the function fail.
  5936. For {stopline} and {timeout} see |search()|.
  5937. The value of 'ignorecase' is used. 'magic' is ignored, the
  5938. patterns are used like it's on.
  5939. The search starts exactly at the cursor. A match with
  5940. {start}, {middle} or {end} at the next character, in the
  5941. direction of searching, is the first one found. Example: >
  5942. if 1
  5943. if 2
  5944. endif 2
  5945. endif 1
  5946. < When starting at the "if 2", with the cursor on the "i", and
  5947. searching forwards, the "endif 2" is found. When starting on
  5948. the character just before the "if 2", the "endif 1" will be
  5949. found. That's because the "if 2" will be found first, and
  5950. then this is considered to be a nested if/endif from "if 2" to
  5951. "endif 2".
  5952. When searching backwards and {end} is more than one character,
  5953. it may be useful to put "\zs" at the end of the pattern, so
  5954. that when the cursor is inside a match with the end it finds
  5955. the matching start.
  5956. Example, to find the "endif" command in a Vim script: >
  5957. :echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
  5958. \ 'getline(".") =~ "^\\s*\""')
  5959. < The cursor must be at or after the "if" for which a match is
  5960. to be found. Note that single-quote strings are used to avoid
  5961. having to double the backslashes. The skip expression only
  5962. catches comments at the start of a line, not after a command.
  5963. Also, a word "en" or "if" halfway through a line is considered
  5964. a match.
  5965. Another example, to search for the matching "{" of a "}": >
  5966. :echo searchpair('{', '', '}', 'bW')
  5967. < This works when the cursor is at or before the "}" for which a
  5968. match is to be found. To reject matches that syntax
  5969. highlighting recognized as strings: >
  5970. :echo searchpair('{', '', '}', 'bW',
  5971. \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
  5972. <
  5973. *searchpairpos()*
  5974. searchpairpos({start}, {middle}, {end} [, {flags} [, {skip}
  5975. [, {stopline} [, {timeout}]]]])
  5976. Same as |searchpair()|, but returns a |List| with the line and
  5977. column position of the match. The first element of the |List|
  5978. is the line number and the second element is the byte index of
  5979. the column position of the match. If no match is found,
  5980. returns [0, 0]. >
  5981. :let [lnum,col] = searchpairpos('{', '', '}', 'n')
  5982. <
  5983. See |match-parens| for a bigger and more useful example.
  5984. *searchpos()*
  5985. searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  5986. Same as |search()|, but returns a |List| with the line and
  5987. column position of the match. The first element of the |List|
  5988. is the line number and the second element is the byte index of
  5989. the column position of the match. If no match is found,
  5990. returns [0, 0].
  5991. Example: >
  5992. :let [lnum, col] = searchpos('mypattern', 'n')
  5993. < When the 'p' flag is given then there is an extra item with
  5994. the sub-pattern match number |search()-sub-match|. Example: >
  5995. :let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
  5996. < In this example "submatch" is 2 when a lowercase letter is
  5997. found |/\l|, 3 when an uppercase letter is found |/\u|.
  5998. Can also be used as a |method|: >
  5999. GetPattern()->searchpos()
  6000. serverlist() *serverlist()*
  6001. Returns a list of server addresses, or empty if all servers
  6002. were stopped. |serverstart()| |serverstop()|
  6003. Example: >
  6004. :echo serverlist()
  6005. serverstart([{address}]) *serverstart()*
  6006. Opens a socket or named pipe at {address} and listens for
  6007. |RPC| messages. Clients can send |API| commands to the
  6008. returned address to control Nvim.
  6009. Returns the address string (which may differ from the
  6010. {address} argument, see below).
  6011. - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
  6012. where the last ":" separates host and port (empty or zero
  6013. assigns a random port).
  6014. - Else {address} is the path to a named pipe (except on Windows).
  6015. - If {address} has no slashes ("/") it is treated as the
  6016. "name" part of a generated path in this format: >
  6017. stdpath("run").."/{name}.{pid}.{counter}"
  6018. < - If {address} is omitted the name is "nvim". >
  6019. :echo serverstart()
  6020. => /tmp/nvim.bram/oknANW/nvim.15430.5
  6021. < Example bash command to list all Nvim servers: >
  6022. ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
  6023. < Example named pipe: >
  6024. if has('win32')
  6025. echo serverstart('\\.\pipe\nvim-pipe-1234')
  6026. else
  6027. echo serverstart('nvim.sock')
  6028. endif
  6029. <
  6030. Example TCP/IP address: >
  6031. echo serverstart('::1:12345')
  6032. serverstop({address}) *serverstop()*
  6033. Closes the pipe or socket at {address}.
  6034. Returns TRUE if {address} is valid, else FALSE.
  6035. If |v:servername| is stopped it is set to the next available
  6036. address in |serverlist()|.
  6037. setbufline({buf}, {lnum}, {text}) *setbufline()*
  6038. Set line {lnum} to {text} in buffer {buf}. This works like
  6039. |setline()| for the specified buffer.
  6040. This function works only for loaded buffers. First call
  6041. |bufload()| if needed.
  6042. To insert lines use |appendbufline()|.
  6043. {text} can be a string to set one line, or a list of strings
  6044. to set multiple lines. If the list extends below the last
  6045. line then those lines are added.
  6046. For the use of {buf}, see |bufname()| above.
  6047. {lnum} is used like with |setline()|.
  6048. Use "$" to refer to the last line in buffer {buf}.
  6049. When {lnum} is just below the last line the {text} will be
  6050. added below the last line.
  6051. On success 0 is returned, on failure 1 is returned.
  6052. If {buf} is not a valid buffer or {lnum} is not valid, an
  6053. error message is given.
  6054. Can also be used as a |method|, the base is passed as the
  6055. third argument: >
  6056. GetText()->setbufline(buf, lnum)
  6057. setbufvar({buf}, {varname}, {val}) *setbufvar()*
  6058. Set option or local variable {varname} in buffer {buf} to
  6059. {val}.
  6060. This also works for a global or local window option, but it
  6061. doesn't work for a global or local window variable.
  6062. For a local window option the global value is unchanged.
  6063. For the use of {buf}, see |bufname()| above.
  6064. The {varname} argument is a string.
  6065. Note that the variable name without "b:" must be used.
  6066. Examples: >
  6067. :call setbufvar(1, "&mod", 1)
  6068. :call setbufvar("todo", "myvar", "foobar")
  6069. < This function is not available in the |sandbox|.
  6070. Can also be used as a |method|, the base is passed as the
  6071. third argument: >
  6072. GetValue()->setbufvar(buf, varname)
  6073. setcellwidths({list}) *setcellwidths()*
  6074. Specify overrides for cell widths of character ranges. This
  6075. tells Vim how wide characters are, counted in screen cells.
  6076. This overrides 'ambiwidth'. Example: >
  6077. setcellwidths([[0xad, 0xad, 1],
  6078. \ [0x2194, 0x2199, 2]])
  6079. < *E1109* *E1110* *E1111* *E1112* *E1113* *E1114*
  6080. The {list} argument is a list of lists with each three
  6081. numbers. These three numbers are [low, high, width]. "low"
  6082. and "high" can be the same, in which case this refers to one
  6083. character. Otherwise it is the range of characters from "low"
  6084. to "high" (inclusive). "width" is either 1 or 2, indicating
  6085. the character width in screen cells.
  6086. An error is given if the argument is invalid, also when a
  6087. range overlaps with another.
  6088. Only characters with value 0x100 and higher can be used.
  6089. If the new value causes 'fillchars' or 'listchars' to become
  6090. invalid it is rejected and an error is given.
  6091. To clear the overrides pass an empty list: >
  6092. setcellwidths([]);
  6093. < You can use the script $VIMRUNTIME/tools/emoji_list.vim to see
  6094. the effect for known emoji characters.
  6095. setcharpos({expr}, {list}) *setcharpos()*
  6096. Same as |setpos()| but uses the specified column number as the
  6097. character index instead of the byte index in the line.
  6098. Example:
  6099. With the text "여보세요" in line 8: >
  6100. call setcharpos('.', [0, 8, 4, 0])
  6101. < positions the cursor on the fourth character '요'. >
  6102. call setpos('.', [0, 8, 4, 0])
  6103. < positions the cursor on the second character '보'.
  6104. Can also be used as a |method|: >
  6105. GetPosition()->setcharpos('.')
  6106. setcharsearch({dict}) *setcharsearch()*
  6107. Set the current character search information to {dict},
  6108. which contains one or more of the following entries:
  6109. char character which will be used for a subsequent
  6110. |,| or |;| command; an empty string clears the
  6111. character search
  6112. forward direction of character search; 1 for forward,
  6113. 0 for backward
  6114. until type of character search; 1 for a |t| or |T|
  6115. character search, 0 for an |f| or |F|
  6116. character search
  6117. This can be useful to save/restore a user's character search
  6118. from a script: >
  6119. :let prevsearch = getcharsearch()
  6120. :" Perform a command which clobbers user's search
  6121. :call setcharsearch(prevsearch)
  6122. < Also see |getcharsearch()|.
  6123. Can also be used as a |method|: >
  6124. SavedSearch()->setcharsearch()
  6125. setcmdline({str} [, {pos}]) *setcmdline()*
  6126. Set the command line to {str} and set the cursor position to
  6127. {pos}.
  6128. If {pos} is omitted, the cursor is positioned after the text.
  6129. Returns 0 when successful, 1 when not editing the command
  6130. line.
  6131. Can also be used as a |method|: >
  6132. GetText()->setcmdline()
  6133. setcmdpos({pos}) *setcmdpos()*
  6134. Set the cursor position in the command line to byte position
  6135. {pos}. The first position is 1.
  6136. Use |getcmdpos()| to obtain the current position.
  6137. Only works while editing the command line, thus you must use
  6138. |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
  6139. |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
  6140. set after the command line is set to the expression. For
  6141. |c_CTRL-R_=| it is set after evaluating the expression but
  6142. before inserting the resulting text.
  6143. When the number is too big the cursor is put at the end of the
  6144. line. A number smaller than one has undefined results.
  6145. Returns 0 when successful, 1 when not editing the command
  6146. line.
  6147. Can also be used as a |method|: >
  6148. GetPos()->setcmdpos()
  6149. setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()*
  6150. setcursorcharpos({list})
  6151. Same as |cursor()| but uses the specified column number as the
  6152. character index instead of the byte index in the line.
  6153. Example:
  6154. With the text "여보세요" in line 4: >
  6155. call setcursorcharpos(4, 3)
  6156. < positions the cursor on the third character '세'. >
  6157. call cursor(4, 3)
  6158. < positions the cursor on the first character '여'.
  6159. Can also be used as a |method|: >
  6160. GetCursorPos()->setcursorcharpos()
  6161. setenv({name}, {val}) *setenv()*
  6162. Set environment variable {name} to {val}. Example: >
  6163. call setenv('HOME', '/home/myhome')
  6164. < When {val} is |v:null| the environment variable is deleted.
  6165. See also |expr-env|.
  6166. Can also be used as a |method|, the base is passed as the
  6167. second argument: >
  6168. GetPath()->setenv('PATH')
  6169. setfperm({fname}, {mode}) *setfperm()* *chmod*
  6170. Set the file permissions for {fname} to {mode}.
  6171. {mode} must be a string with 9 characters. It is of the form
  6172. "rwxrwxrwx", where each group of "rwx" flags represent, in
  6173. turn, the permissions of the owner of the file, the group the
  6174. file belongs to, and other users. A '-' character means the
  6175. permission is off, any other character means on. Multi-byte
  6176. characters are not supported.
  6177. For example "rw-r-----" means read-write for the user,
  6178. readable by the group, not accessible by others. "xx-x-----"
  6179. would do the same thing.
  6180. Returns non-zero for success, zero for failure.
  6181. Can also be used as a |method|: >
  6182. GetFilename()->setfperm(mode)
  6183. <
  6184. To read permissions see |getfperm()|.
  6185. setline({lnum}, {text}) *setline()*
  6186. Set line {lnum} of the current buffer to {text}. To insert
  6187. lines use |append()|. To set lines in another buffer use
  6188. |setbufline()|.
  6189. {lnum} is used like with |getline()|.
  6190. When {lnum} is just below the last line the {text} will be
  6191. added below the last line.
  6192. If this succeeds, FALSE is returned. If this fails (most likely
  6193. because {lnum} is invalid) TRUE is returned.
  6194. Example: >
  6195. :call setline(5, strftime("%c"))
  6196. < When {text} is a |List| then line {lnum} and following lines
  6197. will be set to the items in the list. Example: >
  6198. :call setline(5, ['aaa', 'bbb', 'ccc'])
  6199. < This is equivalent to: >
  6200. :for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
  6201. : call setline(n, l)
  6202. :endfor
  6203. < Note: The '[ and '] marks are not set.
  6204. Can also be used as a |method|, the base is passed as the
  6205. second argument: >
  6206. GetText()->setline(lnum)
  6207. setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
  6208. Create or replace or add to the location list for window {nr}.
  6209. {nr} can be the window number or the |window-ID|.
  6210. When {nr} is zero the current window is used.
  6211. For a location list window, the displayed location list is
  6212. modified. For an invalid window number {nr}, -1 is returned.
  6213. Otherwise, same as |setqflist()|.
  6214. Also see |location-list|.
  6215. For {action} see |setqflist-action|.
  6216. If the optional {what} dictionary argument is supplied, then
  6217. only the items listed in {what} are set. Refer to |setqflist()|
  6218. for the list of supported keys in {what}.
  6219. Can also be used as a |method|, the base is passed as the
  6220. second argument: >
  6221. GetLoclist()->setloclist(winnr)
  6222. setmatches({list} [, {win}]) *setmatches()*
  6223. Restores a list of matches saved by |getmatches() for the
  6224. current window|. Returns 0 if successful, otherwise -1. All
  6225. current matches are cleared before the list is restored. See
  6226. example for |getmatches()|.
  6227. If {win} is specified, use the window with this number or
  6228. window ID instead of the current window.
  6229. Can also be used as a |method|: >
  6230. GetMatches()->setmatches()
  6231. <
  6232. *setpos()*
  6233. setpos({expr}, {list})
  6234. Set the position for String {expr}. Possible values:
  6235. . the cursor
  6236. 'x mark x
  6237. {list} must be a |List| with four or five numbers:
  6238. [bufnum, lnum, col, off]
  6239. [bufnum, lnum, col, off, curswant]
  6240. "bufnum" is the buffer number. Zero can be used for the
  6241. current buffer. When setting an uppercase mark "bufnum" is
  6242. used for the mark position. For other marks it specifies the
  6243. buffer to set the mark in. You can use the |bufnr()| function
  6244. to turn a file name into a buffer number.
  6245. For setting the cursor and the ' mark "bufnum" is ignored,
  6246. since these are associated with a window, not a buffer.
  6247. Does not change the jumplist.
  6248. "lnum" and "col" are the position in the buffer. The first
  6249. column is 1. Use a zero "lnum" to delete a mark. If "col" is
  6250. smaller than 1 then 1 is used. To use the character count
  6251. instead of the byte count, use |setcharpos()|.
  6252. The "off" number is only used when 'virtualedit' is set. Then
  6253. it is the offset in screen columns from the start of the
  6254. character. E.g., a position within a <Tab> or after the last
  6255. character.
  6256. The "curswant" number is only used when setting the cursor
  6257. position. It sets the preferred column for when moving the
  6258. cursor vertically. When the "curswant" number is missing the
  6259. preferred column is not set. When it is present and setting a
  6260. mark position it is not used.
  6261. Note that for '< and '> changing the line number may result in
  6262. the marks to be effectively be swapped, so that '< is always
  6263. before '>.
  6264. Returns 0 when the position could be set, -1 otherwise.
  6265. An error message is given if {expr} is invalid.
  6266. Also see |setcharpos()|, |getpos()| and |getcurpos()|.
  6267. This does not restore the preferred column for moving
  6268. vertically; if you set the cursor position with this, |j| and
  6269. |k| motions will jump to previous columns! Use |cursor()| to
  6270. also set the preferred column. Also see the "curswant" key in
  6271. |winrestview()|.
  6272. Can also be used as a |method|: >
  6273. GetPosition()->setpos('.')
  6274. setqflist({list} [, {action} [, {what}]]) *setqflist()*
  6275. Create or replace or add to the quickfix list.
  6276. If the optional {what} dictionary argument is supplied, then
  6277. only the items listed in {what} are set. The first {list}
  6278. argument is ignored. See below for the supported items in
  6279. {what}.
  6280. *setqflist-what*
  6281. When {what} is not present, the items in {list} are used. Each
  6282. item must be a dictionary. Non-dictionary items in {list} are
  6283. ignored. Each dictionary item can contain the following
  6284. entries:
  6285. bufnr buffer number; must be the number of a valid
  6286. buffer
  6287. filename name of a file; only used when "bufnr" is not
  6288. present or it is invalid.
  6289. module name of a module; if given it will be used in
  6290. quickfix error window instead of the filename.
  6291. lnum line number in the file
  6292. end_lnum end of lines, if the item spans multiple lines
  6293. pattern search pattern used to locate the error
  6294. col column number
  6295. vcol when non-zero: "col" is visual column
  6296. when zero: "col" is byte index
  6297. end_col end column, if the item spans multiple columns
  6298. nr error number
  6299. text description of the error
  6300. type single-character error type, 'E', 'W', etc.
  6301. valid recognized error message
  6302. The "col", "vcol", "nr", "type" and "text" entries are
  6303. optional. Either "lnum" or "pattern" entry can be used to
  6304. locate a matching error line.
  6305. If the "filename" and "bufnr" entries are not present or
  6306. neither the "lnum" or "pattern" entries are present, then the
  6307. item will not be handled as an error line.
  6308. If both "pattern" and "lnum" are present then "pattern" will
  6309. be used.
  6310. If the "valid" entry is not supplied, then the valid flag is
  6311. set when "bufnr" is a valid buffer or "filename" exists.
  6312. If you supply an empty {list}, the quickfix list will be
  6313. cleared.
  6314. Note that the list is not exactly the same as what
  6315. |getqflist()| returns.
  6316. {action} values: *setqflist-action* *E927*
  6317. 'a' The items from {list} are added to the existing
  6318. quickfix list. If there is no existing list, then a
  6319. new list is created.
  6320. 'r' The items from the current quickfix list are replaced
  6321. with the items from {list}. This can also be used to
  6322. clear the list: >
  6323. :call setqflist([], 'r')
  6324. <
  6325. 'f' All the quickfix lists in the quickfix stack are
  6326. freed.
  6327. If {action} is not present or is set to ' ', then a new list
  6328. is created. The new quickfix list is added after the current
  6329. quickfix list in the stack and all the following lists are
  6330. freed. To add a new quickfix list at the end of the stack,
  6331. set "nr" in {what} to "$".
  6332. The following items can be specified in dictionary {what}:
  6333. context quickfix list context. See |quickfix-context|
  6334. efm errorformat to use when parsing text from
  6335. "lines". If this is not present, then the
  6336. 'errorformat' option value is used.
  6337. See |quickfix-parse|
  6338. id quickfix list identifier |quickfix-ID|
  6339. idx index of the current entry in the quickfix
  6340. list specified by "id" or "nr". If set to '$',
  6341. then the last entry in the list is set as the
  6342. current entry. See |quickfix-index|
  6343. items list of quickfix entries. Same as the {list}
  6344. argument.
  6345. lines use 'errorformat' to parse a list of lines and
  6346. add the resulting entries to the quickfix list
  6347. {nr} or {id}. Only a |List| value is supported.
  6348. See |quickfix-parse|
  6349. nr list number in the quickfix stack; zero
  6350. means the current quickfix list and "$" means
  6351. the last quickfix list.
  6352. quickfixtextfunc
  6353. function to get the text to display in the
  6354. quickfix window. The value can be the name of
  6355. a function or a funcref or a lambda. Refer to
  6356. |quickfix-window-function| for an explanation
  6357. of how to write the function and an example.
  6358. title quickfix list title text. See |quickfix-title|
  6359. Unsupported keys in {what} are ignored.
  6360. If the "nr" item is not present, then the current quickfix list
  6361. is modified. When creating a new quickfix list, "nr" can be
  6362. set to a value one greater than the quickfix stack size.
  6363. When modifying a quickfix list, to guarantee that the correct
  6364. list is modified, "id" should be used instead of "nr" to
  6365. specify the list.
  6366. Examples (See also |setqflist-examples|): >
  6367. :call setqflist([], 'r', {'title': 'My search'})
  6368. :call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
  6369. :call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
  6370. <
  6371. Returns zero for success, -1 for failure.
  6372. This function can be used to create a quickfix list
  6373. independent of the 'errorformat' setting. Use a command like
  6374. `:cc 1` to jump to the first position.
  6375. Can also be used as a |method|, the base is passed as the
  6376. second argument: >
  6377. GetErrorlist()->setqflist()
  6378. <
  6379. *setreg()*
  6380. setreg({regname}, {value} [, {options}])
  6381. Set the register {regname} to {value}.
  6382. The {regname} argument is a string.
  6383. {value} may be any value returned by |getreg()| or
  6384. |getreginfo()|, including a |List| or |Dict|.
  6385. If {options} contains "a" or {regname} is upper case,
  6386. then the value is appended.
  6387. {options} can also contain a register type specification:
  6388. "c" or "v" |charwise| mode
  6389. "l" or "V" |linewise| mode
  6390. "b" or "<CTRL-V>" |blockwise-visual| mode
  6391. If a number immediately follows "b" or "<CTRL-V>" then this is
  6392. used as the width of the selection - if it is not specified
  6393. then the width of the block is set to the number of characters
  6394. in the longest line (counting a <Tab> as 1 character).
  6395. If {options} contains "u" or '"', then the unnamed register is
  6396. set to point to register {regname}.
  6397. If {options} contains no register settings, then the default
  6398. is to use character mode unless {value} ends in a <NL> for
  6399. string {value} and linewise mode for list {value}. Blockwise
  6400. mode is never selected automatically.
  6401. Returns zero for success, non-zero for failure.
  6402. *E883*
  6403. Note: you may not use |List| containing more than one item to
  6404. set search and expression registers. Lists containing no
  6405. items act like empty strings.
  6406. Examples: >
  6407. :call setreg(v:register, @*)
  6408. :call setreg('*', @%, 'ac')
  6409. :call setreg('a', "1\n2\n3", 'b5')
  6410. :call setreg('"', { 'points_to': 'a'})
  6411. < This example shows using the functions to save and restore a
  6412. register: >
  6413. :let var_a = getreginfo()
  6414. :call setreg('a', var_a)
  6415. < or: >
  6416. :let var_a = getreg('a', 1, 1)
  6417. :let var_amode = getregtype('a')
  6418. ....
  6419. :call setreg('a', var_a, var_amode)
  6420. < Note: you may not reliably restore register value
  6421. without using the third argument to |getreg()| as without it
  6422. newlines are represented as newlines AND Nul bytes are
  6423. represented as newlines as well, see |NL-used-for-Nul|.
  6424. You can also change the type of a register by appending
  6425. nothing: >
  6426. :call setreg('a', '', 'al')
  6427. < Can also be used as a |method|, the base is passed as the
  6428. second argument: >
  6429. GetText()->setreg('a')
  6430. settabvar({tabnr}, {varname}, {val}) *settabvar()*
  6431. Set tab-local variable {varname} to {val} in tab page {tabnr}.
  6432. |t:var|
  6433. The {varname} argument is a string.
  6434. Note that the variable name without "t:" must be used.
  6435. Tabs are numbered starting with one.
  6436. This function is not available in the |sandbox|.
  6437. Can also be used as a |method|, the base is passed as the
  6438. third argument: >
  6439. GetValue()->settabvar(tab, name)
  6440. settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
  6441. Set option or local variable {varname} in window {winnr} to
  6442. {val}.
  6443. Tabs are numbered starting with one. For the current tabpage
  6444. use |setwinvar()|.
  6445. {winnr} can be the window number or the |window-ID|.
  6446. When {winnr} is zero the current window is used.
  6447. This also works for a global or local buffer option, but it
  6448. doesn't work for a global or local buffer variable.
  6449. For a local buffer option the global value is unchanged.
  6450. Note that the variable name without "w:" must be used.
  6451. Examples: >
  6452. :call settabwinvar(1, 1, "&list", 0)
  6453. :call settabwinvar(3, 2, "myvar", "foobar")
  6454. < This function is not available in the |sandbox|.
  6455. Can also be used as a |method|, the base is passed as the
  6456. fourth argument: >
  6457. GetValue()->settabwinvar(tab, winnr, name)
  6458. settagstack({nr}, {dict} [, {action}]) *settagstack()*
  6459. Modify the tag stack of the window {nr} using {dict}.
  6460. {nr} can be the window number or the |window-ID|.
  6461. For a list of supported items in {dict}, refer to
  6462. |gettagstack()|. "curidx" takes effect before changing the tag
  6463. stack.
  6464. *E962*
  6465. How the tag stack is modified depends on the {action}
  6466. argument:
  6467. - If {action} is not present or is set to 'r', then the tag
  6468. stack is replaced.
  6469. - If {action} is set to 'a', then new entries from {dict} are
  6470. pushed (added) onto the tag stack.
  6471. - If {action} is set to 't', then all the entries from the
  6472. current entry in the tag stack or "curidx" in {dict} are
  6473. removed and then new entries are pushed to the stack.
  6474. The current index is set to one after the length of the tag
  6475. stack after the modification.
  6476. Returns zero for success, -1 for failure.
  6477. Examples (for more examples see |tagstack-examples|):
  6478. Empty the tag stack of window 3: >
  6479. call settagstack(3, {'items' : []})
  6480. < Save and restore the tag stack: >
  6481. let stack = gettagstack(1003)
  6482. " do something else
  6483. call settagstack(1003, stack)
  6484. unlet stack
  6485. <
  6486. Can also be used as a |method|, the base is passed as the
  6487. second argument: >
  6488. GetStack()->settagstack(winnr)
  6489. setwinvar({nr}, {varname}, {val}) *setwinvar()*
  6490. Like |settabwinvar()| for the current tab page.
  6491. Examples: >
  6492. :call setwinvar(1, "&list", 0)
  6493. :call setwinvar(2, "myvar", "foobar")
  6494. < Can also be used as a |method|, the base is passed as the
  6495. third argument: >
  6496. GetValue()->setwinvar(winnr, name)
  6497. sha256({string}) *sha256()*
  6498. Returns a String with 64 hex characters, which is the SHA256
  6499. checksum of {string}.
  6500. Can also be used as a |method|: >
  6501. GetText()->sha256()
  6502. shellescape({string} [, {special}]) *shellescape()*
  6503. Escape {string} for use as a shell command argument.
  6504. On Windows when 'shellslash' is not set, encloses {string} in
  6505. double-quotes and doubles all double-quotes within {string}.
  6506. Otherwise encloses {string} in single-quotes and replaces all
  6507. "'" with "'\''".
  6508. If {special} is a |non-zero-arg|:
  6509. - Special items such as "!", "%", "#" and "<cword>" will be
  6510. preceded by a backslash. The backslash will be removed again
  6511. by the |:!| command.
  6512. - The <NL> character is escaped.
  6513. If 'shell' contains "csh" in the tail:
  6514. - The "!" character will be escaped. This is because csh and
  6515. tcsh use "!" for history replacement even in single-quotes.
  6516. - The <NL> character is escaped (twice if {special} is
  6517. a |non-zero-arg|).
  6518. If 'shell' contains "fish" in the tail, the "\" character will
  6519. be escaped because in fish it is used as an escape character
  6520. inside single quotes.
  6521. Example of use with a |:!| command: >
  6522. :exe '!dir ' .. shellescape(expand('<cfile>'), 1)
  6523. < This results in a directory listing for the file under the
  6524. cursor. Example of use with |system()|: >
  6525. :call system("chmod +w -- " .. shellescape(expand("%")))
  6526. < See also |::S|.
  6527. Can also be used as a |method|: >
  6528. GetCommand()->shellescape()
  6529. shiftwidth([{col}]) *shiftwidth()*
  6530. Returns the effective value of 'shiftwidth'. This is the
  6531. 'shiftwidth' value unless it is zero, in which case it is the
  6532. 'tabstop' value. To be backwards compatible in indent
  6533. plugins, use this: >
  6534. if exists('*shiftwidth')
  6535. func s:sw()
  6536. return shiftwidth()
  6537. endfunc
  6538. else
  6539. func s:sw()
  6540. return &sw
  6541. endfunc
  6542. endif
  6543. < And then use s:sw() instead of &sw.
  6544. When there is one argument {col} this is used as column number
  6545. for which to return the 'shiftwidth' value. This matters for the
  6546. 'vartabstop' feature. If no {col} argument is given, column 1
  6547. will be assumed.
  6548. Can also be used as a |method|: >
  6549. GetColumn()->shiftwidth()
  6550. sign_ functions are documented here: |sign-functions-details|
  6551. simplify({filename}) *simplify()*
  6552. Simplify the file name as much as possible without changing
  6553. the meaning. Shortcuts (on MS-Windows) or symbolic links (on
  6554. Unix) are not resolved. If the first path component in
  6555. {filename} designates the current directory, this will be
  6556. valid for the result as well. A trailing path separator is
  6557. not removed either. On Unix "//path" is unchanged, but
  6558. "///path" is simplified to "/path" (this follows the Posix
  6559. standard).
  6560. Example: >
  6561. simplify("./dir/.././/file/") == "./file/"
  6562. < Note: The combination "dir/.." is only removed if "dir" is
  6563. a searchable directory or does not exist. On Unix, it is also
  6564. removed when "dir" is a symbolic link within the same
  6565. directory. In order to resolve all the involved symbolic
  6566. links before simplifying the path name, use |resolve()|.
  6567. Can also be used as a |method|: >
  6568. GetName()->simplify()
  6569. sin({expr}) *sin()*
  6570. Return the sine of {expr}, measured in radians, as a |Float|.
  6571. {expr} must evaluate to a |Float| or a |Number|.
  6572. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6573. Examples: >
  6574. :echo sin(100)
  6575. < -0.506366 >
  6576. :echo sin(-4.01)
  6577. < 0.763301
  6578. Can also be used as a |method|: >
  6579. Compute()->sin()
  6580. sinh({expr}) *sinh()*
  6581. Return the hyperbolic sine of {expr} as a |Float| in the range
  6582. [-inf, inf].
  6583. {expr} must evaluate to a |Float| or a |Number|.
  6584. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6585. Examples: >
  6586. :echo sinh(0.5)
  6587. < 0.521095 >
  6588. :echo sinh(-0.9)
  6589. < -1.026517
  6590. Can also be used as a |method|: >
  6591. Compute()->sinh()
  6592. sockconnect({mode}, {address} [, {opts}]) *sockconnect()*
  6593. Connect a socket to an address. If {mode} is "pipe" then
  6594. {address} should be the path of a named pipe. If {mode} is
  6595. "tcp" then {address} should be of the form "host:port" where
  6596. the host should be an ip adderess or host name, and port the
  6597. port number.
  6598. Returns a |channel| ID. Close the socket with |chanclose()|.
  6599. Use |chansend()| to send data over a bytes socket, and
  6600. |rpcrequest()| and |rpcnotify()| to communicate with a RPC
  6601. socket.
  6602. {opts} is an optional dictionary with these keys:
  6603. |on_data| : callback invoked when data was read from socket
  6604. data_buffered : read socket data in |channel-buffered| mode.
  6605. rpc : If set, |msgpack-rpc| will be used to communicate
  6606. over the socket.
  6607. Returns:
  6608. - The channel ID on success (greater than zero)
  6609. - 0 on invalid arguments or connection failure.
  6610. sort({list} [, {func} [, {dict}]]) *sort()* *E702*
  6611. Sort the items in {list} in-place. Returns {list}.
  6612. If you want a list to remain unmodified make a copy first: >
  6613. :let sortedlist = sort(copy(mylist))
  6614. < When {func} is omitted, is empty or zero, then sort() uses the
  6615. string representation of each item to sort on. Numbers sort
  6616. after Strings, |Lists| after Numbers. For sorting text in the
  6617. current buffer use |:sort|.
  6618. When {func} is given and it is '1' or 'i' then case is
  6619. ignored.
  6620. When {func} is given and it is 'l' then the current collation
  6621. locale is used for ordering. Implementation details: strcoll()
  6622. is used to compare strings. See |:language| check or set the
  6623. collation locale. |v:collate| can also be used to check the
  6624. current locale. Sorting using the locale typically ignores
  6625. case. Example: >
  6626. " ö is sorted similarly to o with English locale.
  6627. :language collate en_US.UTF8
  6628. :echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  6629. < ['n', 'o', 'O', 'ö', 'p', 'z'] ~
  6630. >
  6631. " ö is sorted after z with Swedish locale.
  6632. :language collate sv_SE.UTF8
  6633. :echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  6634. < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
  6635. This does not work properly on Mac.
  6636. When {func} is given and it is 'n' then all items will be
  6637. sorted numerical (Implementation detail: this uses the
  6638. strtod() function to parse numbers, Strings, Lists, Dicts and
  6639. Funcrefs will be considered as being 0).
  6640. When {func} is given and it is 'N' then all items will be
  6641. sorted numerical. This is like 'n' but a string containing
  6642. digits will be used as the number they represent.
  6643. When {func} is given and it is 'f' then all items will be
  6644. sorted numerical. All values must be a Number or a Float.
  6645. When {func} is a |Funcref| or a function name, this function
  6646. is called to compare items. The function is invoked with two
  6647. items as argument and must return zero if they are equal, 1 or
  6648. bigger if the first one sorts after the second one, -1 or
  6649. smaller if the first one sorts before the second one.
  6650. {dict} is for functions with the "dict" attribute. It will be
  6651. used to set the local variable "self". |Dictionary-function|
  6652. The sort is stable, items which compare equal (as number or as
  6653. string) will keep their relative position. E.g., when sorting
  6654. on numbers, text strings will sort next to each other, in the
  6655. same order as they were originally.
  6656. Can also be used as a |method|: >
  6657. mylist->sort()
  6658. < Also see |uniq()|.
  6659. Example: >
  6660. func MyCompare(i1, i2)
  6661. return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
  6662. endfunc
  6663. eval mylist->sort("MyCompare")
  6664. < A shorter compare version for this specific simple case, which
  6665. ignores overflow: >
  6666. func MyCompare(i1, i2)
  6667. return a:i1 - a:i2
  6668. endfunc
  6669. < For a simple expression you can use a lambda: >
  6670. eval mylist->sort({i1, i2 -> i1 - i2})
  6671. <
  6672. *soundfold()*
  6673. soundfold({word})
  6674. Return the sound-folded equivalent of {word}. Uses the first
  6675. language in 'spelllang' for the current window that supports
  6676. soundfolding. 'spell' must be set. When no sound folding is
  6677. possible the {word} is returned unmodified.
  6678. This can be used for making spelling suggestions. Note that
  6679. the method can be quite slow.
  6680. Can also be used as a |method|: >
  6681. GetWord()->soundfold()
  6682. <
  6683. *spellbadword()*
  6684. spellbadword([{sentence}])
  6685. Without argument: The result is the badly spelled word under
  6686. or after the cursor. The cursor is moved to the start of the
  6687. bad word. When no bad word is found in the cursor line the
  6688. result is an empty string and the cursor doesn't move.
  6689. With argument: The result is the first word in {sentence} that
  6690. is badly spelled. If there are no spelling mistakes the
  6691. result is an empty string.
  6692. The return value is a list with two items:
  6693. - The badly spelled word or an empty string.
  6694. - The type of the spelling error:
  6695. "bad" spelling mistake
  6696. "rare" rare word
  6697. "local" word only valid in another region
  6698. "caps" word should start with Capital
  6699. Example: >
  6700. echo spellbadword("the quik brown fox")
  6701. < ['quik', 'bad'] ~
  6702. The spelling information for the current window and the value
  6703. of 'spelllang' are used.
  6704. Can also be used as a |method|: >
  6705. GetText()->spellbadword()
  6706. <
  6707. *spellsuggest()*
  6708. spellsuggest({word} [, {max} [, {capital}]])
  6709. Return a |List| with spelling suggestions to replace {word}.
  6710. When {max} is given up to this number of suggestions are
  6711. returned. Otherwise up to 25 suggestions are returned.
  6712. When the {capital} argument is given and it's non-zero only
  6713. suggestions with a leading capital will be given. Use this
  6714. after a match with 'spellcapcheck'.
  6715. {word} can be a badly spelled word followed by other text.
  6716. This allows for joining two words that were split. The
  6717. suggestions also include the following text, thus you can
  6718. replace a line.
  6719. {word} may also be a good word. Similar words will then be
  6720. returned. {word} itself is not included in the suggestions,
  6721. although it may appear capitalized.
  6722. The spelling information for the current window is used. The
  6723. values of 'spelllang' and 'spellsuggest' are used.
  6724. Can also be used as a |method|: >
  6725. GetWord()->spellsuggest()
  6726. split({string} [, {pattern} [, {keepempty}]]) *split()*
  6727. Make a |List| out of {string}. When {pattern} is omitted or
  6728. empty each white-separated sequence of characters becomes an
  6729. item.
  6730. Otherwise the string is split where {pattern} matches,
  6731. removing the matched characters. 'ignorecase' is not used
  6732. here, add \c to ignore case. |/\c|
  6733. When the first or last item is empty it is omitted, unless the
  6734. {keepempty} argument is given and it's non-zero.
  6735. Other empty items are kept when {pattern} matches at least one
  6736. character or when {keepempty} is non-zero.
  6737. Example: >
  6738. :let words = split(getline('.'), '\W\+')
  6739. < To split a string in individual characters: >
  6740. :for c in split(mystring, '\zs')
  6741. < If you want to keep the separator you can also use '\zs' at
  6742. the end of the pattern: >
  6743. :echo split('abc:def:ghi', ':\zs')
  6744. < ['abc:', 'def:', 'ghi'] ~
  6745. Splitting a table where the first element can be empty: >
  6746. :let items = split(line, ':', 1)
  6747. < The opposite function is |join()|.
  6748. Can also be used as a |method|: >
  6749. GetString()->split()
  6750. sqrt({expr}) *sqrt()*
  6751. Return the non-negative square root of Float {expr} as a
  6752. |Float|.
  6753. {expr} must evaluate to a |Float| or a |Number|. When {expr}
  6754. is negative the result is NaN (Not a Number). Returns 0.0 if
  6755. {expr} is not a |Float| or a |Number|.
  6756. Examples: >
  6757. :echo sqrt(100)
  6758. < 10.0 >
  6759. :echo sqrt(-4.01)
  6760. < str2float("nan")
  6761. NaN may be different, it depends on system libraries.
  6762. Can also be used as a |method|: >
  6763. Compute()->sqrt()
  6764. srand([{expr}]) *srand()*
  6765. Initialize seed used by |rand()|:
  6766. - If {expr} is not given, seed values are initialized by
  6767. reading from /dev/urandom, if possible, or using time(NULL)
  6768. a.k.a. epoch time otherwise; this only has second accuracy.
  6769. - If {expr} is given it must be a Number. It is used to
  6770. initialize the seed values. This is useful for testing or
  6771. when a predictable sequence is intended.
  6772. Examples: >
  6773. :let seed = srand()
  6774. :let seed = srand(userinput)
  6775. :echo rand(seed)
  6776. <
  6777. Can also be used as a |method|: >
  6778. userinput->srand()
  6779. stdioopen({opts}) *stdioopen()*
  6780. With |--headless| this opens stdin and stdout as a |channel|.
  6781. May be called only once. See |channel-stdio|. stderr is not
  6782. handled by this function, see |v:stderr|.
  6783. Close the stdio handles with |chanclose()|. Use |chansend()|
  6784. to send data to stdout, and |rpcrequest()| and |rpcnotify()|
  6785. to communicate over RPC.
  6786. {opts} is a dictionary with these keys:
  6787. |on_stdin| : callback invoked when stdin is written to.
  6788. on_print : callback invoked when Nvim needs to print a
  6789. message, with the message (whose type is string)
  6790. as sole argument.
  6791. stdin_buffered : read stdin in |channel-buffered| mode.
  6792. rpc : If set, |msgpack-rpc| will be used to communicate
  6793. over stdio
  6794. Returns:
  6795. - |channel-id| on success (value is always 1)
  6796. - 0 on invalid arguments
  6797. stdpath({what}) *stdpath()* *E6100*
  6798. Returns |standard-path| locations of various default files and
  6799. directories.
  6800. {what} Type Description ~
  6801. cache String Cache directory: arbitrary temporary
  6802. storage for plugins, etc.
  6803. config String User configuration directory. |init.vim|
  6804. is stored here.
  6805. config_dirs List Other configuration directories.
  6806. data String User data directory.
  6807. data_dirs List Other data directories.
  6808. log String Logs directory (for use by plugins too).
  6809. run String Run directory: temporary, local storage
  6810. for sockets, named pipes, etc.
  6811. state String Session state directory: storage for file
  6812. drafts, swap, undo, |shada|.
  6813. Example: >
  6814. :echo stdpath("config")
  6815. str2float({string} [, {quoted}]) *str2float()*
  6816. Convert String {string} to a Float. This mostly works the
  6817. same as when using a floating point number in an expression,
  6818. see |floating-point-format|. But it's a bit more permissive.
  6819. E.g., "1e40" is accepted, while in an expression you need to
  6820. write "1.0e40". The hexadecimal form "0x123" is also
  6821. accepted, but not others, like binary or octal.
  6822. When {quoted} is present and non-zero then embedded single
  6823. quotes before the dot are ignored, thus "1'000.0" is a
  6824. thousand.
  6825. Text after the number is silently ignored.
  6826. The decimal point is always '.', no matter what the locale is
  6827. set to. A comma ends the number: "12,345.67" is converted to
  6828. 12.0. You can strip out thousands separators with
  6829. |substitute()|: >
  6830. let f = str2float(substitute(text, ',', '', 'g'))
  6831. <
  6832. Returns 0.0 if the conversion fails.
  6833. Can also be used as a |method|: >
  6834. let f = text->substitute(',', '', 'g')->str2float()
  6835. str2list({string} [, {utf8}]) *str2list()*
  6836. Return a list containing the number values which represent
  6837. each character in String {string}. Examples: >
  6838. str2list(" ") returns [32]
  6839. str2list("ABC") returns [65, 66, 67]
  6840. < |list2str()| does the opposite.
  6841. UTF-8 encoding is always used, {utf8} option has no effect,
  6842. and exists only for backwards-compatibility.
  6843. With UTF-8 composing characters are handled properly: >
  6844. str2list("á") returns [97, 769]
  6845. < Can also be used as a |method|: >
  6846. GetString()->str2list()
  6847. str2nr({string} [, {base}]) *str2nr()*
  6848. Convert string {string} to a number.
  6849. {base} is the conversion base, it can be 2, 8, 10 or 16.
  6850. When {quoted} is present and non-zero then embedded single
  6851. quotes are ignored, thus "1'000'000" is a million.
  6852. When {base} is omitted base 10 is used. This also means that
  6853. a leading zero doesn't cause octal conversion to be used, as
  6854. with the default String to Number conversion. Example: >
  6855. let nr = str2nr('0123')
  6856. <
  6857. When {base} is 16 a leading "0x" or "0X" is ignored. With a
  6858. different base the result will be zero. Similarly, when
  6859. {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
  6860. {base} is 2 a leading "0b" or "0B" is ignored.
  6861. Text after the number is silently ignored.
  6862. Returns 0 if {string} is empty or on error.
  6863. Can also be used as a |method|: >
  6864. GetText()->str2nr()
  6865. strcharpart({src}, {start} [, {len}]) *strcharpart()*
  6866. Like |strpart()| but using character index and length instead
  6867. of byte index and length. Composing characters are counted
  6868. separately.
  6869. When a character index is used where a character does not
  6870. exist it is assumed to be one character. For example: >
  6871. strcharpart('abc', -1, 2)
  6872. < results in 'a'.
  6873. Returns an empty string on error.
  6874. Can also be used as a |method|: >
  6875. GetText()->strcharpart(5)
  6876. strchars({string} [, {skipcc}]) *strchars()*
  6877. The result is a Number, which is the number of characters
  6878. in String {string}.
  6879. When {skipcc} is omitted or zero, composing characters are
  6880. counted separately.
  6881. When {skipcc} set to 1, Composing characters are ignored.
  6882. Returns zero on error.
  6883. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  6884. {skipcc} is only available after 7.4.755. For backward
  6885. compatibility, you can define a wrapper function: >
  6886. if has("patch-7.4.755")
  6887. function s:strchars(str, skipcc)
  6888. return strchars(a:str, a:skipcc)
  6889. endfunction
  6890. else
  6891. function s:strchars(str, skipcc)
  6892. if a:skipcc
  6893. return strlen(substitute(a:str, ".", "x", "g"))
  6894. else
  6895. return strchars(a:str)
  6896. endif
  6897. endfunction
  6898. endif
  6899. <
  6900. Can also be used as a |method|: >
  6901. GetText()->strchars()
  6902. strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
  6903. The result is a Number, which is the number of display cells
  6904. String {string} occupies on the screen when it starts at {col}
  6905. (first column is zero). When {col} is omitted zero is used.
  6906. Otherwise it is the screen column where to start. This
  6907. matters for Tab characters.
  6908. The option settings of the current window are used. This
  6909. matters for anything that's displayed differently, such as
  6910. 'tabstop' and 'display'.
  6911. When {string} contains characters with East Asian Width Class
  6912. Ambiguous, this function's return value depends on 'ambiwidth'.
  6913. Returns zero on error.
  6914. Also see |strlen()|, |strwidth()| and |strchars()|.
  6915. Can also be used as a |method|: >
  6916. GetText()->strdisplaywidth()
  6917. strftime({format} [, {time}]) *strftime()*
  6918. The result is a String, which is a formatted date and time, as
  6919. specified by the {format} string. The given {time} is used,
  6920. or the current time if no time is given. The accepted
  6921. {format} depends on your system, thus this is not portable!
  6922. See the manual page of the C function strftime() for the
  6923. format. The maximum length of the result is 80 characters.
  6924. See also |localtime()|, |getftime()| and |strptime()|.
  6925. The language can be changed with the |:language| command.
  6926. Examples: >
  6927. :echo strftime("%c") Sun Apr 27 11:49:23 1997
  6928. :echo strftime("%Y %b %d %X") 1997 Apr 27 11:53:25
  6929. :echo strftime("%y%m%d %T") 970427 11:53:55
  6930. :echo strftime("%H:%M") 11:55
  6931. :echo strftime("%c", getftime("file.c"))
  6932. Show mod time of file.c.
  6933. < Can also be used as a |method|: >
  6934. GetFormat()->strftime()
  6935. strgetchar({str}, {index}) *strgetchar()*
  6936. Get a Number corresponding to the character at {index} in
  6937. {str}. This uses a zero-based character index, not a byte
  6938. index. Composing characters are considered separate
  6939. characters here. Use |nr2char()| to convert the Number to a
  6940. String.
  6941. Returns -1 if {index} is invalid.
  6942. Also see |strcharpart()| and |strchars()|.
  6943. Can also be used as a |method|: >
  6944. GetText()->strgetchar(5)
  6945. stridx({haystack}, {needle} [, {start}]) *stridx()*
  6946. The result is a Number, which gives the byte index in
  6947. {haystack} of the first occurrence of the String {needle}.
  6948. If {start} is specified, the search starts at index {start}.
  6949. This can be used to find a second match: >
  6950. :let colon1 = stridx(line, ":")
  6951. :let colon2 = stridx(line, ":", colon1 + 1)
  6952. < The search is done case-sensitive.
  6953. For pattern searches use |match()|.
  6954. -1 is returned if the {needle} does not occur in {haystack}.
  6955. See also |strridx()|.
  6956. Examples: >
  6957. :echo stridx("An Example", "Example") 3
  6958. :echo stridx("Starting point", "Start") 0
  6959. :echo stridx("Starting point", "start") -1
  6960. < *strstr()* *strchr()*
  6961. stridx() works similar to the C function strstr(). When used
  6962. with a single character it works similar to strchr().
  6963. Can also be used as a |method|: >
  6964. GetHaystack()->stridx(needle)
  6965. *string()*
  6966. string({expr}) Return {expr} converted to a String. If {expr} is a Number,
  6967. Float, String, Blob or a composition of them, then the result
  6968. can be parsed back with |eval()|.
  6969. {expr} type result ~
  6970. String 'string'
  6971. Number 123
  6972. Float 123.123456 or 1.123456e8 or
  6973. `str2float('inf')`
  6974. Funcref `function('name')`
  6975. Blob 0z00112233.44556677.8899
  6976. List [item, item]
  6977. Dictionary {key: value, key: value}
  6978. Note that in String values the ' character is doubled.
  6979. Also see |strtrans()|.
  6980. Note 2: Output format is mostly compatible with YAML, except
  6981. for infinite and NaN floating-point values representations
  6982. which use |str2float()|. Strings are also dumped literally,
  6983. only single quote is escaped, which does not allow using YAML
  6984. for parsing back binary strings. |eval()| should always work for
  6985. strings and floats though and this is the only official
  6986. method, use |msgpackdump()| or |json_encode()| if you need to
  6987. share data with other application.
  6988. Can also be used as a |method|: >
  6989. mylist->string()
  6990. strlen({string}) *strlen()*
  6991. The result is a Number, which is the length of the String
  6992. {string} in bytes.
  6993. If the argument is a Number it is first converted to a String.
  6994. For other types an error is given and zero is returned.
  6995. If you want to count the number of multibyte characters use
  6996. |strchars()|.
  6997. Also see |len()|, |strdisplaywidth()| and |strwidth()|.
  6998. Can also be used as a |method|: >
  6999. GetString()->strlen()
  7000. strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
  7001. The result is a String, which is part of {src}, starting from
  7002. byte {start}, with the byte length {len}.
  7003. When {chars} is present and TRUE then {len} is the number of
  7004. characters positions (composing characters are not counted
  7005. separately, thus "1" means one base character and any
  7006. following composing characters).
  7007. To count {start} as characters instead of bytes use
  7008. |strcharpart()|.
  7009. When bytes are selected which do not exist, this doesn't
  7010. result in an error, the bytes are simply omitted.
  7011. If {len} is missing, the copy continues from {start} till the
  7012. end of the {src}. >
  7013. strpart("abcdefg", 3, 2) == "de"
  7014. strpart("abcdefg", -2, 4) == "ab"
  7015. strpart("abcdefg", 5, 4) == "fg"
  7016. strpart("abcdefg", 3) == "defg"
  7017. < Note: To get the first character, {start} must be 0. For
  7018. example, to get the character under the cursor: >
  7019. strpart(getline("."), col(".") - 1, 1, v:true)
  7020. <
  7021. Returns an empty string on error.
  7022. Can also be used as a |method|: >
  7023. GetText()->strpart(5)
  7024. strptime({format}, {timestring}) *strptime()*
  7025. The result is a Number, which is a unix timestamp representing
  7026. the date and time in {timestring}, which is expected to match
  7027. the format specified in {format}.
  7028. The accepted {format} depends on your system, thus this is not
  7029. portable! See the manual page of the C function strptime()
  7030. for the format. Especially avoid "%c". The value of $TZ also
  7031. matters.
  7032. If the {timestring} cannot be parsed with {format} zero is
  7033. returned. If you do not know the format of {timestring} you
  7034. can try different {format} values until you get a non-zero
  7035. result.
  7036. See also |strftime()|.
  7037. Examples: >
  7038. :echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
  7039. < 862156163 >
  7040. :echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
  7041. < Sun Apr 27 11:53:55 1997 >
  7042. :echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
  7043. < Sun Apr 27 12:53:55 1997
  7044. Can also be used as a |method|: >
  7045. GetFormat()->strptime(timestring)
  7046. <
  7047. strridx({haystack}, {needle} [, {start}]) *strridx()*
  7048. The result is a Number, which gives the byte index in
  7049. {haystack} of the last occurrence of the String {needle}.
  7050. When {start} is specified, matches beyond this index are
  7051. ignored. This can be used to find a match before a previous
  7052. match: >
  7053. :let lastcomma = strridx(line, ",")
  7054. :let comma2 = strridx(line, ",", lastcomma - 1)
  7055. < The search is done case-sensitive.
  7056. For pattern searches use |match()|.
  7057. -1 is returned if the {needle} does not occur in {haystack}.
  7058. If the {needle} is empty the length of {haystack} is returned.
  7059. See also |stridx()|. Examples: >
  7060. :echo strridx("an angry armadillo", "an") 3
  7061. < *strrchr()*
  7062. When used with a single character it works similar to the C
  7063. function strrchr().
  7064. Can also be used as a |method|: >
  7065. GetHaystack()->strridx(needle)
  7066. strtrans({string}) *strtrans()*
  7067. The result is a String, which is {string} with all unprintable
  7068. characters translated into printable characters |'isprint'|.
  7069. Like they are shown in a window. Example: >
  7070. echo strtrans(@a)
  7071. < This displays a newline in register a as "^@" instead of
  7072. starting a new line.
  7073. Returns an empty string on error.
  7074. Can also be used as a |method|: >
  7075. GetString()->strtrans()
  7076. strwidth({string}) *strwidth()*
  7077. The result is a Number, which is the number of display cells
  7078. String {string} occupies. A Tab character is counted as one
  7079. cell, alternatively use |strdisplaywidth()|.
  7080. When {string} contains characters with East Asian Width Class
  7081. Ambiguous, this function's return value depends on 'ambiwidth'.
  7082. Returns zero on error.
  7083. Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
  7084. Can also be used as a |method|: >
  7085. GetString()->strwidth()
  7086. submatch({nr} [, {list}]) *submatch()* *E935*
  7087. Only for an expression in a |:substitute| command or
  7088. substitute() function.
  7089. Returns the {nr}'th submatch of the matched text. When {nr}
  7090. is 0 the whole matched text is returned.
  7091. Note that a NL in the string can stand for a line break of a
  7092. multi-line match or a NUL character in the text.
  7093. Also see |sub-replace-expression|.
  7094. If {list} is present and non-zero then submatch() returns
  7095. a list of strings, similar to |getline()| with two arguments.
  7096. NL characters in the text represent NUL characters in the
  7097. text.
  7098. Only returns more than one item for |:substitute|, inside
  7099. |substitute()| this list will always contain one or zero
  7100. items, since there are no real line breaks.
  7101. When substitute() is used recursively only the submatches in
  7102. the current (deepest) call can be obtained.
  7103. Returns an empty string or list on error.
  7104. Examples: >
  7105. :s/\d\+/\=submatch(0) + 1/
  7106. :echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
  7107. < This finds the first number in the line and adds one to it.
  7108. A line break is included as a newline character.
  7109. Can also be used as a |method|: >
  7110. GetNr()->submatch()
  7111. substitute({string}, {pat}, {sub}, {flags}) *substitute()*
  7112. The result is a String, which is a copy of {string}, in which
  7113. the first match of {pat} is replaced with {sub}.
  7114. When {flags} is "g", all matches of {pat} in {string} are
  7115. replaced. Otherwise {flags} should be "".
  7116. This works like the ":substitute" command (without any flags).
  7117. But the matching with {pat} is always done like the 'magic'
  7118. option is set and 'cpoptions' is empty (to make scripts
  7119. portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
  7120. if you want to ignore or match case and ignore 'ignorecase'.
  7121. 'smartcase' is not used. See |string-match| for how {pat} is
  7122. used.
  7123. A "~" in {sub} is not replaced with the previous {sub}.
  7124. Note that some codes in {sub} have a special meaning
  7125. |sub-replace-special|. For example, to replace something with
  7126. "\n" (two characters), use "\\\\n" or '\\n'.
  7127. When {pat} does not match in {string}, {string} is returned
  7128. unmodified.
  7129. Example: >
  7130. :let &path = substitute(&path, ",\\=[^,]*$", "", "")
  7131. < This removes the last component of the 'path' option. >
  7132. :echo substitute("testing", ".*", "\\U\\0", "")
  7133. < results in "TESTING".
  7134. When {sub} starts with "\=", the remainder is interpreted as
  7135. an expression. See |sub-replace-expression|. Example: >
  7136. :echo substitute(s, '%\(\x\x\)',
  7137. \ '\=nr2char("0x" .. submatch(1))', 'g')
  7138. < When {sub} is a Funcref that function is called, with one
  7139. optional argument. Example: >
  7140. :echo substitute(s, '%\(\x\x\)', SubNr, 'g')
  7141. < The optional argument is a list which contains the whole
  7142. matched string and up to nine submatches, like what
  7143. |submatch()| returns. Example: >
  7144. :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
  7145. < Returns an empty string on error.
  7146. Can also be used as a |method|: >
  7147. GetString()->substitute(pat, sub, flags)
  7148. swapinfo({fname}) *swapinfo()*
  7149. The result is a dictionary, which holds information about the
  7150. swapfile {fname}. The available fields are:
  7151. version Vim version
  7152. user user name
  7153. host host name
  7154. fname original file name
  7155. pid PID of the Vim process that created the swap
  7156. file
  7157. mtime last modification time in seconds
  7158. inode Optional: INODE number of the file
  7159. dirty 1 if file was modified, 0 if not
  7160. In case of failure an "error" item is added with the reason:
  7161. Cannot open file: file not found or in accessible
  7162. Cannot read file: cannot read first block
  7163. Not a swap file: does not contain correct block ID
  7164. Magic number mismatch: Info in first block is invalid
  7165. Can also be used as a |method|: >
  7166. GetFilename()->swapinfo()
  7167. swapname({buf}) *swapname()*
  7168. The result is the swap file path of the buffer {buf}.
  7169. For the use of {buf}, see |bufname()| above.
  7170. If buffer {buf} is the current buffer, the result is equal to
  7171. |:swapname| (unless there is no swap file).
  7172. If buffer {buf} has no swap file, returns an empty string.
  7173. Can also be used as a |method|: >
  7174. GetBufname()->swapname()
  7175. synID({lnum}, {col}, {trans}) *synID()*
  7176. The result is a Number, which is the syntax ID at the position
  7177. {lnum} and {col} in the current window.
  7178. The syntax ID can be used with |synIDattr()| and
  7179. |synIDtrans()| to obtain syntax information about text.
  7180. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  7181. line. 'synmaxcol' applies, in a longer line zero is returned.
  7182. Note that when the position is after the last character,
  7183. that's where the cursor can be in Insert mode, synID() returns
  7184. zero. {lnum} is used like with |getline()|.
  7185. When {trans} is |TRUE|, transparent items are reduced to the
  7186. item that they reveal. This is useful when wanting to know
  7187. the effective color. When {trans} is |FALSE|, the transparent
  7188. item is returned. This is useful when wanting to know which
  7189. syntax item is effective (e.g. inside parens).
  7190. Warning: This function can be very slow. Best speed is
  7191. obtained by going through the file in forward direction.
  7192. Returns zero on error.
  7193. Example (echoes the name of the syntax item under the cursor): >
  7194. :echo synIDattr(synID(line("."), col("."), 1), "name")
  7195. <
  7196. synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
  7197. The result is a String, which is the {what} attribute of
  7198. syntax ID {synID}. This can be used to obtain information
  7199. about a syntax item.
  7200. {mode} can be "gui" or "cterm", to get the attributes
  7201. for that mode. When {mode} is omitted, or an invalid value is
  7202. used, the attributes for the currently active highlighting are
  7203. used (GUI or cterm).
  7204. Use synIDtrans() to follow linked highlight groups.
  7205. {what} result
  7206. "name" the name of the syntax item
  7207. "fg" foreground color (GUI: color name used to set
  7208. the color, cterm: color number as a string,
  7209. term: empty string)
  7210. "bg" background color (as with "fg")
  7211. "font" font name (only available in the GUI)
  7212. |highlight-font|
  7213. "sp" special color (as with "fg") |guisp|
  7214. "fg#" like "fg", but for the GUI and the GUI is
  7215. running the name in "#RRGGBB" form
  7216. "bg#" like "fg#" for "bg"
  7217. "sp#" like "fg#" for "sp"
  7218. "bold" "1" if bold
  7219. "italic" "1" if italic
  7220. "reverse" "1" if reverse
  7221. "inverse" "1" if inverse (= reverse)
  7222. "standout" "1" if standout
  7223. "underline" "1" if underlined
  7224. "undercurl" "1" if undercurled
  7225. "underdouble" "1" if double underlined
  7226. "underdotted" "1" if dotted underlined
  7227. "underdashed" "1" if dashed underlined
  7228. "strikethrough" "1" if struckthrough
  7229. "nocombine" "1" if nocombine
  7230. Returns an empty string on error.
  7231. Example (echoes the color of the syntax item under the
  7232. cursor): >
  7233. :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  7234. <
  7235. Can also be used as a |method|: >
  7236. :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  7237. synIDtrans({synID}) *synIDtrans()*
  7238. The result is a Number, which is the translated syntax ID of
  7239. {synID}. This is the syntax group ID of what is being used to
  7240. highlight the character. Highlight links given with
  7241. ":highlight link" are followed.
  7242. Returns zero on error.
  7243. Can also be used as a |method|: >
  7244. :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  7245. synconcealed({lnum}, {col}) *synconcealed()*
  7246. The result is a |List| with currently three items:
  7247. 1. The first item in the list is 0 if the character at the
  7248. position {lnum} and {col} is not part of a concealable
  7249. region, 1 if it is. {lnum} is used like with |getline()|.
  7250. 2. The second item in the list is a string. If the first item
  7251. is 1, the second item contains the text which will be
  7252. displayed in place of the concealed text, depending on the
  7253. current setting of 'conceallevel' and 'listchars'.
  7254. 3. The third and final item in the list is a number
  7255. representing the specific syntax region matched in the
  7256. line. When the character is not concealed the value is
  7257. zero. This allows detection of the beginning of a new
  7258. concealable region if there are two consecutive regions
  7259. with the same replacement character. For an example, if
  7260. the text is "123456" and both "23" and "45" are concealed
  7261. and replaced by the character "X", then:
  7262. call returns ~
  7263. synconcealed(lnum, 1) [0, '', 0]
  7264. synconcealed(lnum, 2) [1, 'X', 1]
  7265. synconcealed(lnum, 3) [1, 'X', 1]
  7266. synconcealed(lnum, 4) [1, 'X', 2]
  7267. synconcealed(lnum, 5) [1, 'X', 2]
  7268. synconcealed(lnum, 6) [0, '', 0]
  7269. synstack({lnum}, {col}) *synstack()*
  7270. Return a |List|, which is the stack of syntax items at the
  7271. position {lnum} and {col} in the current window. {lnum} is
  7272. used like with |getline()|. Each item in the List is an ID
  7273. like what |synID()| returns.
  7274. The first item in the List is the outer region, following are
  7275. items contained in that one. The last one is what |synID()|
  7276. returns, unless not the whole item is highlighted or it is a
  7277. transparent item.
  7278. This function is useful for debugging a syntax file.
  7279. Example that shows the syntax stack under the cursor: >
  7280. for id in synstack(line("."), col("."))
  7281. echo synIDattr(id, "name")
  7282. endfor
  7283. < When the position specified with {lnum} and {col} is invalid
  7284. an empty list is returned. The position just after the last
  7285. character in a line and the first column in an empty line are
  7286. valid positions.
  7287. system({cmd} [, {input}]) *system()* *E677*
  7288. Gets the output of {cmd} as a |string| (|systemlist()| returns
  7289. a |List|) and sets |v:shell_error| to the error code.
  7290. {cmd} is treated as in |jobstart()|:
  7291. If {cmd} is a List it runs directly (no 'shell').
  7292. If {cmd} is a String it runs in the 'shell', like this: >
  7293. :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  7294. < Not to be used for interactive commands.
  7295. Result is a String, filtered to avoid platform-specific quirks:
  7296. - <CR><NL> is replaced with <NL>
  7297. - NUL characters are replaced with SOH (0x01)
  7298. Example: >
  7299. :echo system(['ls', expand('%:h')])
  7300. < If {input} is a string it is written to a pipe and passed as
  7301. stdin to the command. The string is written as-is, line
  7302. separators are not changed.
  7303. If {input} is a |List| it is written to the pipe as
  7304. |writefile()| does with {binary} set to "b" (i.e. with
  7305. a newline between each list item, and newlines inside list
  7306. items converted to NULs).
  7307. When {input} is given and is a valid buffer id, the content of
  7308. the buffer is written to the file line by line, each line
  7309. terminated by NL (and NUL where the text has NL).
  7310. *E5677*
  7311. Note: system() cannot write to or read from backgrounded ("&")
  7312. shell commands, e.g.: >
  7313. :echo system("cat - &", "foo")
  7314. < which is equivalent to: >
  7315. $ echo foo | bash -c 'cat - &'
  7316. < The pipes are disconnected (unless overridden by shell
  7317. redirection syntax) before input can reach it. Use
  7318. |jobstart()| instead.
  7319. Note: Use |shellescape()| or |::S| with |expand()| or
  7320. |fnamemodify()| to escape special characters in a command
  7321. argument. 'shellquote' and 'shellxquote' must be properly
  7322. configured. Example: >
  7323. :echo system('ls '..shellescape(expand('%:h')))
  7324. :echo system('ls '..expand('%:h:S'))
  7325. < Unlike ":!cmd" there is no automatic check for changed files.
  7326. Use |:checktime| to force a check.
  7327. Can also be used as a |method|: >
  7328. :echo GetCmd()->system()
  7329. systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
  7330. Same as |system()|, but returns a |List| with lines (parts of
  7331. output separated by NL) with NULs transformed into NLs. Output
  7332. is the same as |readfile()| will output with {binary} argument
  7333. set to "b", except that a final newline is not preserved,
  7334. unless {keepempty} is non-zero.
  7335. Note that on MS-Windows you may get trailing CR characters.
  7336. To see the difference between "echo hello" and "echo -n hello"
  7337. use |system()| and |split()|: >
  7338. echo split(system('echo hello'), '\n', 1)
  7339. <
  7340. Returns an empty string on error.
  7341. Can also be used as a |method|: >
  7342. :echo GetCmd()->systemlist()
  7343. tabpagebuflist([{arg}]) *tabpagebuflist()*
  7344. The result is a |List|, where each item is the number of the
  7345. buffer associated with each window in the current tab page.
  7346. {arg} specifies the number of the tab page to be used. When
  7347. omitted the current tab page is used.
  7348. When {arg} is invalid the number zero is returned.
  7349. To get a list of all buffers in all tabs use this: >
  7350. let buflist = []
  7351. for i in range(tabpagenr('$'))
  7352. call extend(buflist, tabpagebuflist(i + 1))
  7353. endfor
  7354. < Note that a buffer may appear in more than one window.
  7355. Can also be used as a |method|: >
  7356. GetTabpage()->tabpagebuflist()
  7357. tabpagenr([{arg}]) *tabpagenr()*
  7358. The result is a Number, which is the number of the current
  7359. tab page. The first tab page has number 1.
  7360. The optional argument {arg} supports the following values:
  7361. $ the number of the last tab page (the tab page
  7362. count).
  7363. # the number of the last accessed tab page
  7364. (where |g<Tab>| goes to). If there is no
  7365. previous tab page, 0 is returned.
  7366. The number can be used with the |:tab| command.
  7367. Returns zero on error.
  7368. tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
  7369. Like |winnr()| but for tab page {tabarg}.
  7370. {tabarg} specifies the number of tab page to be used.
  7371. {arg} is used like with |winnr()|:
  7372. - When omitted the current window number is returned. This is
  7373. the window which will be used when going to this tab page.
  7374. - When "$" the number of windows is returned.
  7375. - When "#" the previous window nr is returned.
  7376. Useful examples: >
  7377. tabpagewinnr(1) " current window of tab page 1
  7378. tabpagewinnr(4, '$') " number of windows in tab page 4
  7379. < When {tabarg} is invalid zero is returned.
  7380. Can also be used as a |method|: >
  7381. GetTabpage()->tabpagewinnr()
  7382. <
  7383. *tagfiles()*
  7384. tagfiles() Returns a |List| with the file names used to search for tags
  7385. for the current buffer. This is the 'tags' option expanded.
  7386. taglist({expr} [, {filename}]) *taglist()*
  7387. Returns a |List| of tags matching the regular expression {expr}.
  7388. If {filename} is passed it is used to prioritize the results
  7389. in the same way that |:tselect| does. See |tag-priority|.
  7390. {filename} should be the full path of the file.
  7391. Each list item is a dictionary with at least the following
  7392. entries:
  7393. name Name of the tag.
  7394. filename Name of the file where the tag is
  7395. defined. It is either relative to the
  7396. current directory or a full path.
  7397. cmd Ex command used to locate the tag in
  7398. the file.
  7399. kind Type of the tag. The value for this
  7400. entry depends on the language specific
  7401. kind values. Only available when
  7402. using a tags file generated by
  7403. Universal/Exuberant ctags or hdrtag.
  7404. static A file specific tag. Refer to
  7405. |static-tag| for more information.
  7406. More entries may be present, depending on the content of the
  7407. tags file: access, implementation, inherits and signature.
  7408. Refer to the ctags documentation for information about these
  7409. fields. For C code the fields "struct", "class" and "enum"
  7410. may appear, they give the name of the entity the tag is
  7411. contained in.
  7412. The ex-command "cmd" can be either an ex search pattern, a
  7413. line number or a line number followed by a byte number.
  7414. If there are no matching tags, then an empty list is returned.
  7415. To get an exact tag match, the anchors '^' and '$' should be
  7416. used in {expr}. This also make the function work faster.
  7417. Refer to |tag-regexp| for more information about the tag
  7418. search regular expression pattern.
  7419. Refer to |'tags'| for information about how the tags file is
  7420. located by Vim. Refer to |tags-file-format| for the format of
  7421. the tags file generated by the different ctags tools.
  7422. Can also be used as a |method|: >
  7423. GetTagpattern()->taglist()
  7424. tempname() *tempname()* *temp-file-name*
  7425. The result is a String, which is the name of a file that
  7426. doesn't exist. It can be used for a temporary file. Example: >
  7427. :let tmpfile = tempname()
  7428. :exe "redir > " .. tmpfile
  7429. < For Unix, the file will be in a private directory |tempfile|.
  7430. For MS-Windows forward slashes are used when the 'shellslash'
  7431. option is set or when 'shellcmdflag' starts with '-'.
  7432. termopen({cmd} [, {opts}]) *termopen()*
  7433. Spawns {cmd} in a new pseudo-terminal session connected
  7434. to the current (unmodified) buffer. Parameters and behavior
  7435. are the same as |jobstart()| except "pty", "width", "height",
  7436. and "TERM" are ignored: "height" and "width" are taken from
  7437. the current window.
  7438. Returns the same values as |jobstart()|.
  7439. Terminal environment is initialized as in ||jobstart-env|,
  7440. except $TERM is set to "xterm-256color". Full behavior is
  7441. described in |terminal|.
  7442. tan({expr}) *tan()*
  7443. Return the tangent of {expr}, measured in radians, as a |Float|
  7444. in the range [-inf, inf].
  7445. {expr} must evaluate to a |Float| or a |Number|.
  7446. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  7447. Examples: >
  7448. :echo tan(10)
  7449. < 0.648361 >
  7450. :echo tan(-4.01)
  7451. < -1.181502
  7452. Can also be used as a |method|: >
  7453. Compute()->tan()
  7454. tanh({expr}) *tanh()*
  7455. Return the hyperbolic tangent of {expr} as a |Float| in the
  7456. range [-1, 1].
  7457. {expr} must evaluate to a |Float| or a |Number|.
  7458. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  7459. Examples: >
  7460. :echo tanh(0.5)
  7461. < 0.462117 >
  7462. :echo tanh(-1)
  7463. < -0.761594
  7464. Can also be used as a |method|: >
  7465. Compute()->tanh()
  7466. <
  7467. *timer_info()*
  7468. timer_info([{id}])
  7469. Return a list with information about timers.
  7470. When {id} is given only information about this timer is
  7471. returned. When timer {id} does not exist an empty list is
  7472. returned.
  7473. When {id} is omitted information about all timers is returned.
  7474. For each timer the information is stored in a |Dictionary| with
  7475. these items:
  7476. "id" the timer ID
  7477. "time" time the timer was started with
  7478. "repeat" number of times the timer will still fire;
  7479. -1 means forever
  7480. "callback" the callback
  7481. Can also be used as a |method|: >
  7482. GetTimer()->timer_info()
  7483. <
  7484. timer_pause({timer}, {paused}) *timer_pause()*
  7485. Pause or unpause a timer. A paused timer does not invoke its
  7486. callback when its time expires. Unpausing a timer may cause
  7487. the callback to be invoked almost immediately if enough time
  7488. has passed.
  7489. Pausing a timer is useful to avoid the callback to be called
  7490. for a short time.
  7491. If {paused} evaluates to a non-zero Number or a non-empty
  7492. String, then the timer is paused, otherwise it is unpaused.
  7493. See |non-zero-arg|.
  7494. Can also be used as a |method|: >
  7495. GetTimer()->timer_pause(1)
  7496. <
  7497. *timer_start()* *timer* *timers*
  7498. timer_start({time}, {callback} [, {options}])
  7499. Create a timer and return the timer ID.
  7500. {time} is the waiting time in milliseconds. This is the
  7501. minimum time before invoking the callback. When the system is
  7502. busy or Vim is not waiting for input the time will be longer.
  7503. {callback} is the function to call. It can be the name of a
  7504. function or a |Funcref|. It is called with one argument, which
  7505. is the timer ID. The callback is only invoked when Vim is
  7506. waiting for input.
  7507. {options} is a dictionary. Supported entries:
  7508. "repeat" Number of times to repeat the callback.
  7509. -1 means forever. Default is 1.
  7510. If the timer causes an error three times in a
  7511. row the repeat is cancelled.
  7512. Returns -1 on error.
  7513. Example: >
  7514. func MyHandler(timer)
  7515. echo 'Handler called'
  7516. endfunc
  7517. let timer = timer_start(500, 'MyHandler',
  7518. \ {'repeat': 3})
  7519. < This invokes MyHandler() three times at 500 msec intervals.
  7520. Can also be used as a |method|: >
  7521. GetMsec()->timer_start(callback)
  7522. < Not available in the |sandbox|.
  7523. timer_stop({timer}) *timer_stop()*
  7524. Stop a timer. The timer callback will no longer be invoked.
  7525. {timer} is an ID returned by timer_start(), thus it must be a
  7526. Number. If {timer} does not exist there is no error.
  7527. Can also be used as a |method|: >
  7528. GetTimer()->timer_stop()
  7529. <
  7530. timer_stopall() *timer_stopall()*
  7531. Stop all timers. The timer callbacks will no longer be
  7532. invoked. Useful if some timers is misbehaving. If there are
  7533. no timers there is no error.
  7534. tolower({expr}) *tolower()*
  7535. The result is a copy of the String given, with all uppercase
  7536. characters turned into lowercase (just like applying |gu| to
  7537. the string). Returns an empty string on error.
  7538. Can also be used as a |method|: >
  7539. GetText()->tolower()
  7540. toupper({expr}) *toupper()*
  7541. The result is a copy of the String given, with all lowercase
  7542. characters turned into uppercase (just like applying |gU| to
  7543. the string). Returns an empty string on error.
  7544. Can also be used as a |method|: >
  7545. GetText()->toupper()
  7546. tr({src}, {fromstr}, {tostr}) *tr()*
  7547. The result is a copy of the {src} string with all characters
  7548. which appear in {fromstr} replaced by the character in that
  7549. position in the {tostr} string. Thus the first character in
  7550. {fromstr} is translated into the first character in {tostr}
  7551. and so on. Exactly like the unix "tr" command.
  7552. This code also deals with multibyte characters properly.
  7553. Returns an empty string on error.
  7554. Examples: >
  7555. echo tr("hello there", "ht", "HT")
  7556. < returns "Hello THere" >
  7557. echo tr("<blob>", "<>", "{}")
  7558. < returns "{blob}"
  7559. Can also be used as a |method|: >
  7560. GetText()->tr(from, to)
  7561. trim({text} [, {mask} [, {dir}]]) *trim()*
  7562. Return {text} as a String where any character in {mask} is
  7563. removed from the beginning and/or end of {text}.
  7564. If {mask} is not given, {mask} is all characters up to 0x20,
  7565. which includes Tab, space, NL and CR, plus the non-breaking
  7566. space character 0xa0.
  7567. The optional {dir} argument specifies where to remove the
  7568. characters:
  7569. 0 remove from the beginning and end of {text}
  7570. 1 remove only at the beginning of {text}
  7571. 2 remove only at the end of {text}
  7572. When omitted both ends are trimmed.
  7573. This function deals with multibyte characters properly.
  7574. Returns an empty string on error.
  7575. Examples: >
  7576. echo trim(" some text ")
  7577. < returns "some text" >
  7578. echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  7579. < returns "RESERVE_TAIL" >
  7580. echo trim("rm<Xrm<>X>rrm", "rm<>")
  7581. < returns "Xrm<>X" (characters in the middle are not removed) >
  7582. echo trim(" vim ", " ", 2)
  7583. < returns " vim"
  7584. Can also be used as a |method|: >
  7585. GetText()->trim()
  7586. trunc({expr}) *trunc()*
  7587. Return the largest integral value with magnitude less than or
  7588. equal to {expr} as a |Float| (truncate towards zero).
  7589. {expr} must evaluate to a |Float| or a |Number|.
  7590. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  7591. Examples: >
  7592. echo trunc(1.456)
  7593. < 1.0 >
  7594. echo trunc(-5.456)
  7595. < -5.0 >
  7596. echo trunc(4.0)
  7597. < 4.0
  7598. Can also be used as a |method|: >
  7599. Compute()->trunc()
  7600. type({expr}) *type()*
  7601. The result is a Number representing the type of {expr}.
  7602. Instead of using the number directly, it is better to use the
  7603. v:t_ variable that has the value:
  7604. Number: 0 (|v:t_number|)
  7605. String: 1 (|v:t_string|)
  7606. Funcref: 2 (|v:t_func|)
  7607. List: 3 (|v:t_list|)
  7608. Dictionary: 4 (|v:t_dict|)
  7609. Float: 5 (|v:t_float|)
  7610. Boolean: 6 (|v:true| and |v:false|)
  7611. Null: 7 (|v:null|)
  7612. Blob: 10 (|v:t_blob|)
  7613. For backward compatibility, this method can be used: >
  7614. :if type(myvar) == type(0)
  7615. :if type(myvar) == type("")
  7616. :if type(myvar) == type(function("tr"))
  7617. :if type(myvar) == type([])
  7618. :if type(myvar) == type({})
  7619. :if type(myvar) == type(0.0)
  7620. :if type(myvar) == type(v:true)
  7621. < In place of checking for |v:null| type it is better to check
  7622. for |v:null| directly as it is the only value of this type: >
  7623. :if myvar is v:null
  7624. < To check if the v:t_ variables exist use this: >
  7625. :if exists('v:t_number')
  7626. < Can also be used as a |method|: >
  7627. mylist->type()
  7628. undofile({name}) *undofile()*
  7629. Return the name of the undo file that would be used for a file
  7630. with name {name} when writing. This uses the 'undodir'
  7631. option, finding directories that exist. It does not check if
  7632. the undo file exists.
  7633. {name} is always expanded to the full path, since that is what
  7634. is used internally.
  7635. If {name} is empty undofile() returns an empty string, since a
  7636. buffer without a file name will not write an undo file.
  7637. Useful in combination with |:wundo| and |:rundo|.
  7638. Can also be used as a |method|: >
  7639. GetFilename()->undofile()
  7640. undotree() *undotree()*
  7641. Return the current state of the undo tree in a dictionary with
  7642. the following items:
  7643. "seq_last" The highest undo sequence number used.
  7644. "seq_cur" The sequence number of the current position in
  7645. the undo tree. This differs from "seq_last"
  7646. when some changes were undone.
  7647. "time_cur" Time last used for |:earlier| and related
  7648. commands. Use |strftime()| to convert to
  7649. something readable.
  7650. "save_last" Number of the last file write. Zero when no
  7651. write yet.
  7652. "save_cur" Number of the current position in the undo
  7653. tree.
  7654. "synced" Non-zero when the last undo block was synced.
  7655. This happens when waiting from input from the
  7656. user. See |undo-blocks|.
  7657. "entries" A list of dictionaries with information about
  7658. undo blocks.
  7659. The first item in the "entries" list is the oldest undo item.
  7660. Each List item is a |Dictionary| with these items:
  7661. "seq" Undo sequence number. Same as what appears in
  7662. |:undolist|.
  7663. "time" Timestamp when the change happened. Use
  7664. |strftime()| to convert to something readable.
  7665. "newhead" Only appears in the item that is the last one
  7666. that was added. This marks the last change
  7667. and where further changes will be added.
  7668. "curhead" Only appears in the item that is the last one
  7669. that was undone. This marks the current
  7670. position in the undo tree, the block that will
  7671. be used by a redo command. When nothing was
  7672. undone after the last change this item will
  7673. not appear anywhere.
  7674. "save" Only appears on the last block before a file
  7675. write. The number is the write count. The
  7676. first write has number 1, the last one the
  7677. "save_last" mentioned above.
  7678. "alt" Alternate entry. This is again a List of undo
  7679. blocks. Each item may again have an "alt"
  7680. item.
  7681. uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
  7682. Remove second and succeeding copies of repeated adjacent
  7683. {list} items in-place. Returns {list}. If you want a list
  7684. to remain unmodified make a copy first: >
  7685. :let newlist = uniq(copy(mylist))
  7686. < The default compare function uses the string representation of
  7687. each item. For the use of {func} and {dict} see |sort()|.
  7688. Returns zero if {list} is not a |List|.
  7689. Can also be used as a |method|: >
  7690. mylist->uniq()
  7691. values({dict}) *values()*
  7692. Return a |List| with all the values of {dict}. The |List| is
  7693. in arbitrary order. Also see |items()| and |keys()|.
  7694. Returns zero if {dict} is not a |Dict|.
  7695. Can also be used as a |method|: >
  7696. mydict->values()
  7697. virtcol({expr}) *virtcol()*
  7698. The result is a Number, which is the screen column of the file
  7699. position given with {expr}. That is, the last screen position
  7700. occupied by the character at that position, when the screen
  7701. would be of unlimited width. When there is a <Tab> at the
  7702. position, the returned Number will be the column at the end of
  7703. the <Tab>. For example, for a <Tab> in column 1, with 'ts'
  7704. set to 8, it returns 8. |conceal| is ignored.
  7705. For the byte position use |col()|.
  7706. For the use of {expr} see |col()|.
  7707. When 'virtualedit' is used {expr} can be [lnum, col, off], where
  7708. "off" is the offset in screen columns from the start of the
  7709. character. E.g., a position within a <Tab> or after the last
  7710. character. When "off" is omitted zero is used.
  7711. When Virtual editing is active in the current mode, a position
  7712. beyond the end of the line can be returned. |'virtualedit'|
  7713. The accepted positions are:
  7714. . the cursor position
  7715. $ the end of the cursor line (the result is the
  7716. number of displayed characters in the cursor line
  7717. plus one)
  7718. 'x position of mark x (if the mark is not set, 0 is
  7719. returned)
  7720. v In Visual mode: the start of the Visual area (the
  7721. cursor is the end). When not in Visual mode
  7722. returns the cursor position. Differs from |'<| in
  7723. that it's updated right away.
  7724. Note that only marks in the current file can be used.
  7725. Examples: >
  7726. virtcol(".") with text "foo^Lbar", with cursor on the "^L", returns 5
  7727. virtcol("$") with text "foo^Lbar", returns 9
  7728. virtcol("'t") with text " there", with 't at 'h', returns 6
  7729. < The first column is 1. 0 is returned for an error.
  7730. A more advanced example that echoes the maximum length of
  7731. all lines: >
  7732. echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  7733. < Can also be used as a |method|: >
  7734. GetPos()->virtcol()
  7735. virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
  7736. The result is a Number, which is the byte index of the
  7737. character in window {winid} at buffer line {lnum} and virtual
  7738. column {col}.
  7739. If {col} is greater than the last virtual column in line
  7740. {lnum}, then the byte index of the character at the last
  7741. virtual column is returned.
  7742. The {winid} argument can be the window number or the
  7743. |window-ID|. If this is zero, then the current window is used.
  7744. Returns -1 if the window {winid} doesn't exist or the buffer
  7745. line {lnum} or virtual column {col} is invalid.
  7746. See also |screenpos()|, |virtcol()| and |col()|.
  7747. Can also be used as a |method|: >
  7748. GetWinid()->virtcol2col(lnum, col)
  7749. visualmode([{expr}]) *visualmode()*
  7750. The result is a String, which describes the last Visual mode
  7751. used in the current buffer. Initially it returns an empty
  7752. string, but once Visual mode has been used, it returns "v",
  7753. "V", or "<CTRL-V>" (a single CTRL-V character) for
  7754. character-wise, line-wise, or block-wise Visual mode
  7755. respectively.
  7756. Example: >
  7757. :exe "normal " .. visualmode()
  7758. < This enters the same Visual mode as before. It is also useful
  7759. in scripts if you wish to act differently depending on the
  7760. Visual mode that was used.
  7761. If Visual mode is active, use |mode()| to get the Visual mode
  7762. (e.g., in a |:vmap|).
  7763. If {expr} is supplied and it evaluates to a non-zero Number or
  7764. a non-empty String, then the Visual mode will be cleared and
  7765. the old value is returned. See |non-zero-arg|.
  7766. wait({timeout}, {condition} [, {interval}]) *wait()*
  7767. Waits until {condition} evaluates to |TRUE|, where {condition}
  7768. is a |Funcref| or |string| containing an expression.
  7769. {timeout} is the maximum waiting time in milliseconds, -1
  7770. means forever.
  7771. Condition is evaluated on user events, internal events, and
  7772. every {interval} milliseconds (default: 200).
  7773. Returns a status integer:
  7774. 0 if the condition was satisfied before timeout
  7775. -1 if the timeout was exceeded
  7776. -2 if the function was interrupted (by |CTRL-C|)
  7777. -3 if an error occurred
  7778. wildmenumode() *wildmenumode()*
  7779. Returns |TRUE| when the wildmenu is active and |FALSE|
  7780. otherwise. See 'wildmenu' and 'wildmode'.
  7781. This can be used in mappings to handle the 'wildcharm' option
  7782. gracefully. (Makes only sense with |mapmode-c| mappings).
  7783. For example to make <c-j> work like <down> in wildmode, use: >
  7784. :cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  7785. <
  7786. (Note, this needs the 'wildcharm' option set appropriately).
  7787. win_execute({id}, {command} [, {silent}]) *win_execute()*
  7788. Like `execute()` but in the context of window {id}.
  7789. The window will temporarily be made the current window,
  7790. without triggering autocommands or changing directory. When
  7791. executing {command} autocommands will be triggered, this may
  7792. have unexpected side effects. Use |:noautocmd| if needed.
  7793. Example: >
  7794. call win_execute(winid, 'syntax enable')
  7795. <
  7796. Can also be used as a |method|, the base is passed as the
  7797. second argument: >
  7798. GetCommand()->win_execute(winid)
  7799. win_findbuf({bufnr}) *win_findbuf()*
  7800. Returns a |List| with |window-ID|s for windows that contain
  7801. buffer {bufnr}. When there is none the list is empty.
  7802. Can also be used as a |method|: >
  7803. GetBufnr()->win_findbuf()
  7804. win_getid([{win} [, {tab}]]) *win_getid()*
  7805. Get the |window-ID| for the specified window.
  7806. When {win} is missing use the current window.
  7807. With {win} this is the window number. The top window has
  7808. number 1.
  7809. Without {tab} use the current tab, otherwise the tab with
  7810. number {tab}. The first tab has number one.
  7811. Return zero if the window cannot be found.
  7812. Can also be used as a |method|: >
  7813. GetWinnr()->win_getid()
  7814. win_gettype([{nr}]) *win_gettype()*
  7815. Return the type of the window:
  7816. "autocmd" autocommand window. Temporary window
  7817. used to execute autocommands.
  7818. "command" command-line window |cmdwin|
  7819. (empty) normal window
  7820. "loclist" |location-list-window|
  7821. "popup" floating window |api-floatwin|
  7822. "preview" preview window |preview-window|
  7823. "quickfix" |quickfix-window|
  7824. "unknown" window {nr} not found
  7825. When {nr} is omitted return the type of the current window.
  7826. When {nr} is given return the type of this window by number or
  7827. |window-ID|.
  7828. Also see the 'buftype' option.
  7829. Can also be used as a |method|: >
  7830. GetWinid()->win_gettype()
  7831. <
  7832. win_gotoid({expr}) *win_gotoid()*
  7833. Go to window with ID {expr}. This may also change the current
  7834. tabpage.
  7835. Return TRUE if successful, FALSE if the window cannot be found.
  7836. Can also be used as a |method|: >
  7837. GetWinid()->win_gotoid()
  7838. win_id2tabwin({expr}) *win_id2tabwin()*
  7839. Return a list with the tab number and window number of window
  7840. with ID {expr}: [tabnr, winnr].
  7841. Return [0, 0] if the window cannot be found.
  7842. Can also be used as a |method|: >
  7843. GetWinid()->win_id2tabwin()
  7844. win_id2win({expr}) *win_id2win()*
  7845. Return the window number of window with ID {expr}.
  7846. Return 0 if the window cannot be found in the current tabpage.
  7847. Can also be used as a |method|: >
  7848. GetWinid()->win_id2win()
  7849. win_move_separator({nr}, {offset}) *win_move_separator()*
  7850. Move window {nr}'s vertical separator (i.e., the right border)
  7851. by {offset} columns, as if being dragged by the mouse. {nr}
  7852. can be a window number or |window-ID|. A positive {offset}
  7853. moves right and a negative {offset} moves left. Moving a
  7854. window's vertical separator will change the width of the
  7855. window and the width of other windows adjacent to the vertical
  7856. separator. The magnitude of movement may be smaller than
  7857. specified (e.g., as a consequence of maintaining
  7858. 'winminwidth'). Returns TRUE if the window can be found and
  7859. FALSE otherwise.
  7860. This will fail for the rightmost window and a full-width
  7861. window, since it has no separator on the right.
  7862. Can also be used as a |method|: >
  7863. GetWinnr()->win_move_separator(offset)
  7864. win_move_statusline({nr}, {offset}) *win_move_statusline()*
  7865. Move window {nr}'s status line (i.e., the bottom border) by
  7866. {offset} rows, as if being dragged by the mouse. {nr} can be a
  7867. window number or |window-ID|. A positive {offset} moves down
  7868. and a negative {offset} moves up. Moving a window's status
  7869. line will change the height of the window and the height of
  7870. other windows adjacent to the status line. The magnitude of
  7871. movement may be smaller than specified (e.g., as a consequence
  7872. of maintaining 'winminheight'). Returns TRUE if the window can
  7873. be found and FALSE otherwise.
  7874. Can also be used as a |method|: >
  7875. GetWinnr()->win_move_statusline(offset)
  7876. win_screenpos({nr}) *win_screenpos()*
  7877. Return the screen position of window {nr} as a list with two
  7878. numbers: [row, col]. The first window always has position
  7879. [1, 1], unless there is a tabline, then it is [2, 1].
  7880. {nr} can be the window number or the |window-ID|. Use zero
  7881. for the current window.
  7882. Returns [0, 0] if the window cannot be found in the current
  7883. tabpage.
  7884. Can also be used as a |method|: >
  7885. GetWinid()->win_screenpos()
  7886. <
  7887. win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
  7888. Move the window {nr} to a new split of the window {target}.
  7889. This is similar to moving to {target}, creating a new window
  7890. using |:split| but having the same contents as window {nr}, and
  7891. then closing {nr}.
  7892. Both {nr} and {target} can be window numbers or |window-ID|s.
  7893. Both must be in the current tab page.
  7894. Returns zero for success, non-zero for failure.
  7895. {options} is a |Dictionary| with the following optional entries:
  7896. "vertical" When TRUE, the split is created vertically,
  7897. like with |:vsplit|.
  7898. "rightbelow" When TRUE, the split is made below or to the
  7899. right (if vertical). When FALSE, it is done
  7900. above or to the left (if vertical). When not
  7901. present, the values of 'splitbelow' and
  7902. 'splitright' are used.
  7903. Can also be used as a |method|: >
  7904. GetWinid()->win_splitmove(target)
  7905. <
  7906. *winbufnr()*
  7907. winbufnr({nr}) The result is a Number, which is the number of the buffer
  7908. associated with window {nr}. {nr} can be the window number or
  7909. the |window-ID|.
  7910. When {nr} is zero, the number of the buffer in the current
  7911. window is returned.
  7912. When window {nr} doesn't exist, -1 is returned.
  7913. Example: >
  7914. :echo "The file in the current window is " .. bufname(winbufnr(0))
  7915. <
  7916. Can also be used as a |method|: >
  7917. FindWindow()->winbufnr()->bufname()
  7918. <
  7919. *wincol()*
  7920. wincol() The result is a Number, which is the virtual column of the
  7921. cursor in the window. This is counting screen cells from the
  7922. left side of the window. The leftmost column is one.
  7923. *windowsversion()*
  7924. windowsversion()
  7925. The result is a String. For MS-Windows it indicates the OS
  7926. version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  7927. Windows XP is "5.1". For non-MS-Windows systems the result is
  7928. an empty string.
  7929. winheight({nr}) *winheight()*
  7930. The result is a Number, which is the height of window {nr}.
  7931. {nr} can be the window number or the |window-ID|.
  7932. When {nr} is zero, the height of the current window is
  7933. returned. When window {nr} doesn't exist, -1 is returned.
  7934. An existing window always has a height of zero or more.
  7935. This excludes any window toolbar line.
  7936. Examples: >
  7937. :echo "The current window has " .. winheight(0) .. " lines."
  7938. < Can also be used as a |method|: >
  7939. GetWinid()->winheight()
  7940. <
  7941. winlayout([{tabnr}]) *winlayout()*
  7942. The result is a nested List containing the layout of windows
  7943. in a tabpage.
  7944. Without {tabnr} use the current tabpage, otherwise the tabpage
  7945. with number {tabnr}. If the tabpage {tabnr} is not found,
  7946. returns an empty list.
  7947. For a leaf window, it returns:
  7948. ["leaf", {winid}]
  7949. For horizontally split windows, which form a column, it
  7950. returns:
  7951. ["col", [{nested list of windows}]]
  7952. For vertically split windows, which form a row, it returns:
  7953. ["row", [{nested list of windows}]]
  7954. Example: >
  7955. " Only one window in the tab page
  7956. :echo winlayout()
  7957. ['leaf', 1000]
  7958. " Two horizontally split windows
  7959. :echo winlayout()
  7960. ['col', [['leaf', 1000], ['leaf', 1001]]]
  7961. " The second tab page, with three horizontally split
  7962. " windows, with two vertically split windows in the
  7963. " middle window
  7964. :echo winlayout(2)
  7965. ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  7966. ['leaf', 1001]]], ['leaf', 1000]]]
  7967. <
  7968. Can also be used as a |method|: >
  7969. GetTabnr()->winlayout()
  7970. <
  7971. *winline()*
  7972. winline() The result is a Number, which is the screen line of the cursor
  7973. in the window. This is counting screen lines from the top of
  7974. the window. The first line is one.
  7975. If the cursor was moved the view on the file will be updated
  7976. first, this may cause a scroll.
  7977. *winnr()*
  7978. winnr([{arg}]) The result is a Number, which is the number of the current
  7979. window. The top window has number 1.
  7980. Returns zero for a popup window.
  7981. The optional argument {arg} supports the following values:
  7982. $ the number of the last window (the window
  7983. count).
  7984. # the number of the last accessed window (where
  7985. |CTRL-W_p| goes to). If there is no previous
  7986. window or it is in another tab page 0 is
  7987. returned.
  7988. {N}j the number of the Nth window below the
  7989. current window (where |CTRL-W_j| goes to).
  7990. {N}k the number of the Nth window above the current
  7991. window (where |CTRL-W_k| goes to).
  7992. {N}h the number of the Nth window left of the
  7993. current window (where |CTRL-W_h| goes to).
  7994. {N}l the number of the Nth window right of the
  7995. current window (where |CTRL-W_l| goes to).
  7996. The number can be used with |CTRL-W_w| and ":wincmd w"
  7997. |:wincmd|.
  7998. When {arg} is invalid an error is given and zero is returned.
  7999. Also see |tabpagewinnr()| and |win_getid()|.
  8000. Examples: >
  8001. let window_count = winnr('$')
  8002. let prev_window = winnr('#')
  8003. let wnum = winnr('3k')
  8004. < Can also be used as a |method|: >
  8005. GetWinval()->winnr()
  8006. <
  8007. *winrestcmd()*
  8008. winrestcmd() Returns a sequence of |:resize| commands that should restore
  8009. the current window sizes. Only works properly when no windows
  8010. are opened or closed and the current window and tab page is
  8011. unchanged.
  8012. Example: >
  8013. :let cmd = winrestcmd()
  8014. :call MessWithWindowSizes()
  8015. :exe cmd
  8016. <
  8017. *winrestview()*
  8018. winrestview({dict})
  8019. Uses the |Dictionary| returned by |winsaveview()| to restore
  8020. the view of the current window.
  8021. Note: The {dict} does not have to contain all values, that are
  8022. returned by |winsaveview()|. If values are missing, those
  8023. settings won't be restored. So you can use: >
  8024. :call winrestview({'curswant': 4})
  8025. <
  8026. This will only set the curswant value (the column the cursor
  8027. wants to move on vertical movements) of the cursor to column 5
  8028. (yes, that is 5), while all other settings will remain the
  8029. same. This is useful, if you set the cursor position manually.
  8030. If you have changed the values the result is unpredictable.
  8031. If the window size changed the result won't be the same.
  8032. Can also be used as a |method|: >
  8033. GetView()->winrestview()
  8034. <
  8035. *winsaveview()*
  8036. winsaveview() Returns a |Dictionary| that contains information to restore
  8037. the view of the current window. Use |winrestview()| to
  8038. restore the view.
  8039. This is useful if you have a mapping that jumps around in the
  8040. buffer and you want to go back to the original view.
  8041. This does not save fold information. Use the 'foldenable'
  8042. option to temporarily switch off folding, so that folds are
  8043. not opened when moving around. This may have side effects.
  8044. The return value includes:
  8045. lnum cursor line number
  8046. col cursor column (Note: the first column
  8047. zero, as opposed to what getpos()
  8048. returns)
  8049. coladd cursor column offset for 'virtualedit'
  8050. curswant column for vertical movement
  8051. topline first line in the window
  8052. topfill filler lines, only in diff mode
  8053. leftcol first column displayed; only used when
  8054. 'wrap' is off
  8055. skipcol columns skipped
  8056. Note that no option values are saved.
  8057. winwidth({nr}) *winwidth()*
  8058. The result is a Number, which is the width of window {nr}.
  8059. {nr} can be the window number or the |window-ID|.
  8060. When {nr} is zero, the width of the current window is
  8061. returned. When window {nr} doesn't exist, -1 is returned.
  8062. An existing window always has a width of zero or more.
  8063. Examples: >
  8064. :echo "The current window has " .. winwidth(0) .. " columns."
  8065. :if winwidth(0) <= 50
  8066. : 50 wincmd |
  8067. :endif
  8068. < For getting the terminal or screen size, see the 'columns'
  8069. option.
  8070. Can also be used as a |method|: >
  8071. GetWinid()->winwidth()
  8072. wordcount() *wordcount()*
  8073. The result is a dictionary of byte/chars/word statistics for
  8074. the current buffer. This is the same info as provided by
  8075. |g_CTRL-G|
  8076. The return value includes:
  8077. bytes Number of bytes in the buffer
  8078. chars Number of chars in the buffer
  8079. words Number of words in the buffer
  8080. cursor_bytes Number of bytes before cursor position
  8081. (not in Visual mode)
  8082. cursor_chars Number of chars before cursor position
  8083. (not in Visual mode)
  8084. cursor_words Number of words before cursor position
  8085. (not in Visual mode)
  8086. visual_bytes Number of bytes visually selected
  8087. (only in Visual mode)
  8088. visual_chars Number of chars visually selected
  8089. (only in Visual mode)
  8090. visual_words Number of words visually selected
  8091. (only in Visual mode)
  8092. *writefile()*
  8093. writefile({object}, {fname} [, {flags}])
  8094. When {object} is a |List| write it to file {fname}. Each list
  8095. item is separated with a NL. Each list item must be a String
  8096. or Number.
  8097. When {flags} contains "b" then binary mode is used: There will
  8098. not be a NL after the last list item. An empty item at the
  8099. end does cause the last line in the file to end in a NL.
  8100. When {object} is a |Blob| write the bytes to file {fname}
  8101. unmodified.
  8102. When {flags} contains "a" then append mode is used, lines are
  8103. appended to the file: >
  8104. :call writefile(["foo"], "event.log", "a")
  8105. :call writefile(["bar"], "event.log", "a")
  8106. <
  8107. When {flags} contains "S" fsync() call is not used, with "s"
  8108. it is used, 'fsync' option applies by default. No fsync()
  8109. means that writefile() will finish faster, but writes may be
  8110. left in OS buffers and not yet written to disk. Such changes
  8111. will disappear if system crashes before OS does writing.
  8112. All NL characters are replaced with a NUL character.
  8113. Inserting CR characters needs to be done before passing {list}
  8114. to writefile().
  8115. An existing file is overwritten, if possible.
  8116. When the write fails -1 is returned, otherwise 0. There is an
  8117. error message if the file can't be created or when writing
  8118. fails.
  8119. Also see |readfile()|.
  8120. To copy a file byte for byte: >
  8121. :let fl = readfile("foo", "b")
  8122. :call writefile(fl, "foocopy", "b")
  8123. < Can also be used as a |method|: >
  8124. GetText()->writefile("thefile")
  8125. xor({expr}, {expr}) *xor()*
  8126. Bitwise XOR on the two arguments. The arguments are converted
  8127. to a number. A List, Dict or Float argument causes an error.
  8128. Also see `and()` and `or()`.
  8129. Example: >
  8130. :let bits = xor(bits, 0x80)
  8131. <
  8132. Can also be used as a |method|: >
  8133. :let bits = bits->xor(0x80)
  8134. <
  8135. ==============================================================================
  8136. 3. Matching a pattern in a String *string-match*
  8137. This is common between several functions. A regexp pattern as explained at
  8138. |pattern| is normally used to find a match in the buffer lines. When a
  8139. pattern is used to find a match in a String, almost everything works in the
  8140. same way. The difference is that a String is handled like it is one line.
  8141. When it contains a "\n" character, this is not seen as a line break for the
  8142. pattern. It can be matched with a "\n" in the pattern, or with ".". Example:
  8143. >
  8144. :let a = "aaaa\nxxxx"
  8145. :echo matchstr(a, "..\n..")
  8146. aa
  8147. xx
  8148. :echo matchstr(a, "a.x")
  8149. a
  8150. x
  8151. Don't forget that "^" will only match at the first character of the String and
  8152. "$" at the last character of the string. They don't match after or before a
  8153. "\n".
  8154. vim:tw=78:ts=8:noet:ft=help:norl: