builtin.txt 442 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253
  1. *builtin.txt* Nvim
  2. NVIM REFERENCE MANUAL
  3. Builtin functions *vimscript-functions* *builtin-functions*
  4. For functions grouped by what they are used for see |function-list|.
  5. Type |gO| to see the table of contents.
  6. ==============================================================================
  7. 1. Details *builtin-function-details*
  8. abs({expr}) *abs()*
  9. Return the absolute value of {expr}. When {expr} evaluates to
  10. a |Float| abs() returns a |Float|. When {expr} can be
  11. converted to a |Number| abs() returns a |Number|. Otherwise
  12. abs() gives an error message and returns -1.
  13. Examples: >vim
  14. echo abs(1.456)
  15. < 1.456 >vim
  16. echo abs(-5.456)
  17. < 5.456 >vim
  18. echo abs(-4)
  19. < 4
  20. Parameters: ~
  21. • {expr} (`number`)
  22. Return: ~
  23. (`number`)
  24. acos({expr}) *acos()*
  25. Return the arc cosine of {expr} measured in radians, as a
  26. |Float| in the range of [0, pi].
  27. {expr} must evaluate to a |Float| or a |Number| in the range
  28. [-1, 1].
  29. Returns NaN if {expr} is outside the range [-1, 1]. Returns
  30. 0.0 if {expr} is not a |Float| or a |Number|.
  31. Examples: >vim
  32. echo acos(0)
  33. < 1.570796 >vim
  34. echo acos(-0.5)
  35. < 2.094395
  36. Parameters: ~
  37. • {expr} (`number`)
  38. Return: ~
  39. (`number`)
  40. add({object}, {expr}) *add()*
  41. Append the item {expr} to |List| or |Blob| {object}. Returns
  42. the resulting |List| or |Blob|. Examples: >vim
  43. let alist = add([1, 2, 3], item)
  44. call add(mylist, "woodstock")
  45. < Note that when {expr} is a |List| it is appended as a single
  46. item. Use |extend()| to concatenate |Lists|.
  47. When {object} is a |Blob| then {expr} must be a number.
  48. Use |insert()| to add an item at another position.
  49. Returns 1 if {object} is not a |List| or a |Blob|.
  50. Parameters: ~
  51. • {object} (`any`)
  52. • {expr} (`any`)
  53. Return: ~
  54. (`any`) Resulting |List| or |Blob|, or 1 if {object} is not
  55. a |List| or a |Blob|.
  56. and({expr}, {expr}) *and()*
  57. Bitwise AND on the two arguments. The arguments are converted
  58. to a number. A List, Dict or Float argument causes an error.
  59. Also see `or()` and `xor()`.
  60. Example: >vim
  61. let flag = and(bits, 0x80)
  62. <
  63. Parameters: ~
  64. • {expr} (`number`)
  65. • {expr1} (`number`)
  66. Return: ~
  67. (`integer`)
  68. api_info() *api_info()*
  69. Returns Dictionary of |api-metadata|.
  70. View it in a nice human-readable format: >vim
  71. lua vim.print(vim.fn.api_info())
  72. <
  73. Return: ~
  74. (`table`)
  75. append({lnum}, {text}) *append()*
  76. When {text} is a |List|: Append each item of the |List| as a
  77. text line below line {lnum} in the current buffer.
  78. Otherwise append {text} as one text line below line {lnum} in
  79. the current buffer.
  80. Any type of item is accepted and converted to a String.
  81. {lnum} can be zero to insert a line before the first one.
  82. {lnum} is used like with |getline()|.
  83. Returns 1 for failure ({lnum} out of range or out of memory),
  84. 0 for success. When {text} is an empty list zero is returned,
  85. no matter the value of {lnum}. Example: >vim
  86. let failed = append(line('$'), "# THE END")
  87. let failed = append(0, ["Chapter 1", "the beginning"])
  88. <
  89. Parameters: ~
  90. • {lnum} (`integer`)
  91. • {text} (`string|string[]`)
  92. Return: ~
  93. (`0|1`)
  94. appendbufline({buf}, {lnum}, {text}) *appendbufline()*
  95. Like |append()| but append the text in buffer {expr}.
  96. This function works only for loaded buffers. First call
  97. |bufload()| if needed.
  98. For the use of {buf}, see |bufname()|.
  99. {lnum} is the line number to append below. Note that using
  100. |line()| would use the current buffer, not the one appending
  101. to. Use "$" to append at the end of the buffer. Other string
  102. values are not supported.
  103. On success 0 is returned, on failure 1 is returned.
  104. If {buf} is not a valid buffer or {lnum} is not valid, an
  105. error message is given. Example: >vim
  106. let failed = appendbufline(13, 0, "# THE START")
  107. < However, when {text} is an empty list then no error is given
  108. for an invalid {lnum}, since {lnum} isn't actually used.
  109. Parameters: ~
  110. • {buf} (`integer|string`)
  111. • {lnum} (`integer`)
  112. • {text} (`string`)
  113. Return: ~
  114. (`0|1`)
  115. argc([{winid}]) *argc()*
  116. The result is the number of files in the argument list. See
  117. |arglist|.
  118. If {winid} is not supplied, the argument list of the current
  119. window is used.
  120. If {winid} is -1, the global argument list is used.
  121. Otherwise {winid} specifies the window of which the argument
  122. list is used: either the window number or the window ID.
  123. Returns -1 if the {winid} argument is invalid.
  124. Parameters: ~
  125. • {winid} (`integer?`)
  126. Return: ~
  127. (`integer`)
  128. argidx() *argidx()*
  129. The result is the current index in the argument list. 0 is
  130. the first file. argc() - 1 is the last one. See |arglist|.
  131. Return: ~
  132. (`integer`)
  133. arglistid([{winnr} [, {tabnr}]]) *arglistid()*
  134. Return the argument list ID. This is a number which
  135. identifies the argument list being used. Zero is used for the
  136. global argument list. See |arglist|.
  137. Returns -1 if the arguments are invalid.
  138. Without arguments use the current window.
  139. With {winnr} only use this window in the current tab page.
  140. With {winnr} and {tabnr} use the window in the specified tab
  141. page.
  142. {winnr} can be the window number or the |window-ID|.
  143. Parameters: ~
  144. • {winnr} (`integer?`)
  145. • {tabnr} (`integer?`)
  146. Return: ~
  147. (`integer`)
  148. argv([{nr} [, {winid}]]) *argv()*
  149. The result is the {nr}th file in the argument list. See
  150. |arglist|. "argv(0)" is the first one. Example: >vim
  151. let i = 0
  152. while i < argc()
  153. let f = escape(fnameescape(argv(i)), '.')
  154. exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
  155. let i = i + 1
  156. endwhile
  157. < Without the {nr} argument, or when {nr} is -1, a |List| with
  158. the whole |arglist| is returned.
  159. The {winid} argument specifies the window ID, see |argc()|.
  160. For the Vim command line arguments see |v:argv|.
  161. Returns an empty string if {nr}th argument is not present in
  162. the argument list. Returns an empty List if the {winid}
  163. argument is invalid.
  164. Parameters: ~
  165. • {nr} (`integer?`)
  166. • {winid} (`integer?`)
  167. Return: ~
  168. (`string|string[]`)
  169. asin({expr}) *asin()*
  170. Return the arc sine of {expr} measured in radians, as a |Float|
  171. in the range of [-pi/2, pi/2].
  172. {expr} must evaluate to a |Float| or a |Number| in the range
  173. [-1, 1].
  174. Returns NaN if {expr} is outside the range [-1, 1]. Returns
  175. 0.0 if {expr} is not a |Float| or a |Number|.
  176. Examples: >vim
  177. echo asin(0.8)
  178. < 0.927295 >vim
  179. echo asin(-0.5)
  180. < -0.523599
  181. Parameters: ~
  182. • {expr} (`any`)
  183. Return: ~
  184. (`number`)
  185. assert_beeps({cmd}) *assert_beeps()*
  186. Run {cmd} and add an error message to |v:errors| if it does
  187. NOT produce a beep or visual bell.
  188. Also see |assert_fails()|, |assert_nobeep()| and
  189. |assert-return|.
  190. Parameters: ~
  191. • {cmd} (`string`)
  192. Return: ~
  193. (`0|1`)
  194. assert_equal({expected}, {actual} [, {msg}]) *assert_equal()*
  195. When {expected} and {actual} are not equal an error message is
  196. added to |v:errors| and 1 is returned. Otherwise zero is
  197. returned. |assert-return|
  198. The error is in the form "Expected {expected} but got
  199. {actual}". When {msg} is present it is prefixed to that,
  200. along with the location of the assert when run from a script.
  201. There is no automatic conversion, the String "4" is different
  202. from the Number 4. And the number 4 is different from the
  203. Float 4.0. The value of 'ignorecase' is not used here, case
  204. always matters.
  205. Example: >vim
  206. call assert_equal('foo', 'bar', 'baz')
  207. < Will add the following to |v:errors|:
  208. test.vim line 12: baz: Expected 'foo' but got 'bar' ~
  209. Parameters: ~
  210. • {expected} (`any`)
  211. • {actual} (`any`)
  212. • {msg} (`any?`)
  213. Return: ~
  214. (`0|1`)
  215. assert_equalfile({fname_one}, {fname_two}) *assert_equalfile()*
  216. When the files {fname_one} and {fname_two} do not contain
  217. exactly the same text an error message is added to |v:errors|.
  218. Also see |assert-return|.
  219. When {fname_one} or {fname_two} does not exist the error will
  220. mention that.
  221. Parameters: ~
  222. • {fname_one} (`string`)
  223. • {fname_two} (`string`)
  224. Return: ~
  225. (`0|1`)
  226. assert_exception({error} [, {msg}]) *assert_exception()*
  227. When v:exception does not contain the string {error} an error
  228. message is added to |v:errors|. Also see |assert-return|.
  229. This can be used to assert that a command throws an exception.
  230. Using the error number, followed by a colon, avoids problems
  231. with translations: >vim
  232. try
  233. commandthatfails
  234. call assert_false(1, 'command should have failed')
  235. catch
  236. call assert_exception('E492:')
  237. endtry
  238. <
  239. Parameters: ~
  240. • {error} (`any`)
  241. • {msg} (`any?`)
  242. Return: ~
  243. (`0|1`)
  244. *assert_fails()*
  245. assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
  246. Run {cmd} and add an error message to |v:errors| if it does
  247. NOT produce an error or when {error} is not found in the
  248. error message. Also see |assert-return|.
  249. When {error} is a string it must be found literally in the
  250. first reported error. Most often this will be the error code,
  251. including the colon, e.g. "E123:". >vim
  252. call assert_fails('bad cmd', 'E987:')
  253. <
  254. When {error} is a |List| with one or two strings, these are
  255. used as patterns. The first pattern is matched against the
  256. first reported error: >vim
  257. call assert_fails('cmd', ['E987:.*expected bool'])
  258. < The second pattern, if present, is matched against the last
  259. reported error. To only match the last error use an empty
  260. string for the first error: >vim
  261. call assert_fails('cmd', ['', 'E987:'])
  262. <
  263. If {msg} is empty then it is not used. Do this to get the
  264. default message when passing the {lnum} argument.
  265. *E1115*
  266. When {lnum} is present and not negative, and the {error}
  267. argument is present and matches, then this is compared with
  268. the line number at which the error was reported. That can be
  269. the line number in a function or in a script.
  270. *E1116*
  271. When {context} is present it is used as a pattern and matched
  272. against the context (script name or function name) where
  273. {lnum} is located in.
  274. Note that beeping is not considered an error, and some failing
  275. commands only beep. Use |assert_beeps()| for those.
  276. Parameters: ~
  277. • {cmd} (`string`)
  278. • {error} (`any?`)
  279. • {msg} (`any?`)
  280. • {lnum} (`integer?`)
  281. • {context} (`any?`)
  282. Return: ~
  283. (`0|1`)
  284. assert_false({actual} [, {msg}]) *assert_false()*
  285. When {actual} is not false an error message is added to
  286. |v:errors|, like with |assert_equal()|.
  287. The error is in the form "Expected False but got {actual}".
  288. When {msg} is present it is prefixed to that, along with the
  289. location of the assert when run from a script.
  290. Also see |assert-return|.
  291. A value is false when it is zero. When {actual} is not a
  292. number the assert fails.
  293. Parameters: ~
  294. • {actual} (`any`)
  295. • {msg} (`any?`)
  296. Return: ~
  297. (`0|1`)
  298. assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
  299. This asserts number and |Float| values. When {actual} is lower
  300. than {lower} or higher than {upper} an error message is added
  301. to |v:errors|. Also see |assert-return|.
  302. The error is in the form "Expected range {lower} - {upper},
  303. but got {actual}". When {msg} is present it is prefixed to
  304. that.
  305. Parameters: ~
  306. • {lower} (`number`)
  307. • {upper} (`number`)
  308. • {actual} (`number`)
  309. • {msg} (`string?`)
  310. Return: ~
  311. (`0|1`)
  312. assert_match({pattern}, {actual} [, {msg}]) *assert_match()*
  313. When {pattern} does not match {actual} an error message is
  314. added to |v:errors|. Also see |assert-return|.
  315. The error is in the form "Pattern {pattern} does not match
  316. {actual}". When {msg} is present it is prefixed to that,
  317. along with the location of the assert when run from a script.
  318. {pattern} is used as with |expr-=~|: The matching is always done
  319. like 'magic' was set and 'cpoptions' is empty, no matter what
  320. the actual value of 'magic' or 'cpoptions' is.
  321. {actual} is used as a string, automatic conversion applies.
  322. Use "^" and "$" to match with the start and end of the text.
  323. Use both to match the whole text.
  324. Example: >vim
  325. call assert_match('^f.*o$', 'foobar')
  326. < Will result in a string to be added to |v:errors|:
  327. test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
  328. Parameters: ~
  329. • {pattern} (`string`)
  330. • {actual} (`string`)
  331. • {msg} (`string?`)
  332. Return: ~
  333. (`0|1`)
  334. assert_nobeep({cmd}) *assert_nobeep()*
  335. Run {cmd} and add an error message to |v:errors| if it
  336. produces a beep or visual bell.
  337. Also see |assert_beeps()|.
  338. Parameters: ~
  339. • {cmd} (`string`)
  340. Return: ~
  341. (`0|1`)
  342. assert_notequal({expected}, {actual} [, {msg}]) *assert_notequal()*
  343. The opposite of `assert_equal()`: add an error message to
  344. |v:errors| when {expected} and {actual} are equal.
  345. Also see |assert-return|.
  346. Parameters: ~
  347. • {expected} (`any`)
  348. • {actual} (`any`)
  349. • {msg} (`any?`)
  350. Return: ~
  351. (`0|1`)
  352. assert_notmatch({pattern}, {actual} [, {msg}]) *assert_notmatch()*
  353. The opposite of `assert_match()`: add an error message to
  354. |v:errors| when {pattern} matches {actual}.
  355. Also see |assert-return|.
  356. Parameters: ~
  357. • {pattern} (`string`)
  358. • {actual} (`string`)
  359. • {msg} (`string?`)
  360. Return: ~
  361. (`0|1`)
  362. assert_report({msg}) *assert_report()*
  363. Report a test failure directly, using String {msg}.
  364. Always returns one.
  365. Parameters: ~
  366. • {msg} (`string`)
  367. Return: ~
  368. (`0|1`)
  369. assert_true({actual} [, {msg}]) *assert_true()*
  370. When {actual} is not true an error message is added to
  371. |v:errors|, like with |assert_equal()|.
  372. Also see |assert-return|.
  373. A value is |TRUE| when it is a non-zero number or |v:true|.
  374. When {actual} is not a number or |v:true| the assert fails.
  375. When {msg} is given it is prefixed to the default message,
  376. along with the location of the assert when run from a script.
  377. Parameters: ~
  378. • {actual} (`any`)
  379. • {msg} (`string?`)
  380. Return: ~
  381. (`0|1`)
  382. atan({expr}) *atan()*
  383. Return the principal value of the arc tangent of {expr}, in
  384. the range [-pi/2, +pi/2] radians, as a |Float|.
  385. {expr} must evaluate to a |Float| or a |Number|.
  386. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  387. Examples: >vim
  388. echo atan(100)
  389. < 1.560797 >vim
  390. echo atan(-4.01)
  391. < -1.326405
  392. Parameters: ~
  393. • {expr} (`number`)
  394. Return: ~
  395. (`number`)
  396. atan2({expr1}, {expr2}) *atan2()*
  397. Return the arc tangent of {expr1} / {expr2}, measured in
  398. radians, as a |Float| in the range [-pi, pi].
  399. {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  400. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  401. |Number|.
  402. Examples: >vim
  403. echo atan2(-1, 1)
  404. < -0.785398 >vim
  405. echo atan2(1, -1)
  406. < 2.356194
  407. Parameters: ~
  408. • {expr1} (`number`)
  409. • {expr2} (`number`)
  410. Return: ~
  411. (`number`)
  412. blob2list({blob}) *blob2list()*
  413. Return a List containing the number value of each byte in Blob
  414. {blob}. Examples: >vim
  415. blob2list(0z0102.0304) " returns [1, 2, 3, 4]
  416. blob2list(0z) " returns []
  417. < Returns an empty List on error. |list2blob()| does the
  418. opposite.
  419. Parameters: ~
  420. • {blob} (`any`)
  421. Return: ~
  422. (`any[]`)
  423. browse({save}, {title}, {initdir}, {default}) *browse()*
  424. Put up a file requester. This only works when "has("browse")"
  425. returns |TRUE| (only in some GUI versions).
  426. The input fields are:
  427. {save} when |TRUE|, select file to write
  428. {title} title for the requester
  429. {initdir} directory to start browsing in
  430. {default} default file name
  431. An empty string is returned when the "Cancel" button is hit,
  432. something went wrong, or browsing is not possible.
  433. Parameters: ~
  434. • {save} (`any`)
  435. • {title} (`string`)
  436. • {initdir} (`string`)
  437. • {default} (`string`)
  438. Return: ~
  439. (`0|1`)
  440. browsedir({title}, {initdir}) *browsedir()*
  441. Put up a directory requester. This only works when
  442. "has("browse")" returns |TRUE| (only in some GUI versions).
  443. On systems where a directory browser is not supported a file
  444. browser is used. In that case: select a file in the directory
  445. to be used.
  446. The input fields are:
  447. {title} title for the requester
  448. {initdir} directory to start browsing in
  449. When the "Cancel" button is hit, something went wrong, or
  450. browsing is not possible, an empty string is returned.
  451. Parameters: ~
  452. • {title} (`string`)
  453. • {initdir} (`string`)
  454. Return: ~
  455. (`0|1`)
  456. bufadd({name}) *bufadd()*
  457. Add a buffer to the buffer list with name {name} (must be a
  458. String).
  459. If a buffer for file {name} already exists, return that buffer
  460. number. Otherwise return the buffer number of the newly
  461. created buffer. When {name} is an empty string then a new
  462. buffer is always created.
  463. The buffer will not have 'buflisted' set and not be loaded
  464. yet. To add some text to the buffer use this: >vim
  465. let bufnr = bufadd('someName')
  466. call bufload(bufnr)
  467. call setbufline(bufnr, 1, ['some', 'text'])
  468. < Returns 0 on error.
  469. Parameters: ~
  470. • {name} (`string`)
  471. Return: ~
  472. (`integer`)
  473. bufexists({buf}) *bufexists()*
  474. The result is a Number, which is |TRUE| if a buffer called
  475. {buf} exists.
  476. If the {buf} argument is a number, buffer numbers are used.
  477. Number zero is the alternate buffer for the current window.
  478. If the {buf} argument is a string it must match a buffer name
  479. exactly. The name can be:
  480. - Relative to the current directory.
  481. - A full path.
  482. - The name of a buffer with 'buftype' set to "nofile".
  483. - A URL name.
  484. Unlisted buffers will be found.
  485. Note that help files are listed by their short name in the
  486. output of |:buffers|, but bufexists() requires using their
  487. long name to be able to find them.
  488. bufexists() may report a buffer exists, but to use the name
  489. with a |:buffer| command you may need to use |expand()|. Esp
  490. for MS-Windows 8.3 names in the form "c:\DOCUME~1"
  491. Use "bufexists(0)" to test for the existence of an alternate
  492. file name.
  493. Parameters: ~
  494. • {buf} (`any`)
  495. Return: ~
  496. (`0|1`)
  497. buflisted({buf}) *buflisted()*
  498. The result is a Number, which is |TRUE| if a buffer called
  499. {buf} exists and is listed (has the 'buflisted' option set).
  500. The {buf} argument is used like with |bufexists()|.
  501. Parameters: ~
  502. • {buf} (`any`)
  503. Return: ~
  504. (`0|1`)
  505. bufload({buf}) *bufload()*
  506. Ensure the buffer {buf} is loaded. When the buffer name
  507. refers to an existing file then the file is read. Otherwise
  508. the buffer will be empty. If the buffer was already loaded
  509. then there is no change. If the buffer is not related to a
  510. file then no file is read (e.g., when 'buftype' is "nofile").
  511. If there is an existing swap file for the file of the buffer,
  512. there will be no dialog, the buffer will be loaded anyway.
  513. The {buf} argument is used like with |bufexists()|.
  514. Parameters: ~
  515. • {buf} (`any`)
  516. bufloaded({buf}) *bufloaded()*
  517. The result is a Number, which is |TRUE| if a buffer called
  518. {buf} exists and is loaded (shown in a window or hidden).
  519. The {buf} argument is used like with |bufexists()|.
  520. Parameters: ~
  521. • {buf} (`any`)
  522. Return: ~
  523. (`0|1`)
  524. bufname([{buf}]) *bufname()*
  525. The result is the name of a buffer. Mostly as it is displayed
  526. by the `:ls` command, but not using special names such as
  527. "[No Name]".
  528. If {buf} is omitted the current buffer is used.
  529. If {buf} is a Number, that buffer number's name is given.
  530. Number zero is the alternate buffer for the current window.
  531. If {buf} is a String, it is used as a |file-pattern| to match
  532. with the buffer names. This is always done like 'magic' is
  533. set and 'cpoptions' is empty. When there is more than one
  534. match an empty string is returned.
  535. "" or "%" can be used for the current buffer, "#" for the
  536. alternate buffer.
  537. A full match is preferred, otherwise a match at the start, end
  538. or middle of the buffer name is accepted. If you only want a
  539. full match then put "^" at the start and "$" at the end of the
  540. pattern.
  541. Listed buffers are found first. If there is a single match
  542. with a listed buffer, that one is returned. Next unlisted
  543. buffers are searched for.
  544. If the {buf} is a String, but you want to use it as a buffer
  545. number, force it to be a Number by adding zero to it: >vim
  546. echo bufname("3" + 0)
  547. < If the buffer doesn't exist, or doesn't have a name, an empty
  548. string is returned. >vim
  549. echo bufname("#") " alternate buffer name
  550. echo bufname(3) " name of buffer 3
  551. echo bufname("%") " name of current buffer
  552. echo bufname("file2") " name of buffer where "file2" matches.
  553. <
  554. Parameters: ~
  555. • {buf} (`integer|string?`)
  556. Return: ~
  557. (`string`)
  558. bufnr([{buf} [, {create}]]) *bufnr()*
  559. The result is the number of a buffer, as it is displayed by
  560. the `:ls` command. For the use of {buf}, see |bufname()|
  561. above.
  562. If the buffer doesn't exist, -1 is returned. Or, if the
  563. {create} argument is present and TRUE, a new, unlisted,
  564. buffer is created and its number is returned.
  565. bufnr("$") is the last buffer: >vim
  566. let last_buffer = bufnr("$")
  567. < The result is a Number, which is the highest buffer number
  568. of existing buffers. Note that not all buffers with a smaller
  569. number necessarily exist, because ":bwipeout" may have removed
  570. them. Use bufexists() to test for the existence of a buffer.
  571. Parameters: ~
  572. • {buf} (`integer|string?`)
  573. • {create} (`any?`)
  574. Return: ~
  575. (`integer`)
  576. bufwinid({buf}) *bufwinid()*
  577. The result is a Number, which is the |window-ID| of the first
  578. window associated with buffer {buf}. For the use of {buf},
  579. see |bufname()| above. If buffer {buf} doesn't exist or
  580. there is no such window, -1 is returned. Example: >vim
  581. echo "A window containing buffer 1 is " .. (bufwinid(1))
  582. <
  583. Only deals with the current tab page. See |win_findbuf()| for
  584. finding more.
  585. Parameters: ~
  586. • {buf} (`any`)
  587. Return: ~
  588. (`integer`)
  589. bufwinnr({buf}) *bufwinnr()*
  590. Like |bufwinid()| but return the window number instead of the
  591. |window-ID|.
  592. If buffer {buf} doesn't exist or there is no such window, -1
  593. is returned. Example: >vim
  594. echo "A window containing buffer 1 is " .. (bufwinnr(1))
  595. < The number can be used with |CTRL-W_w| and ":wincmd w"
  596. |:wincmd|.
  597. Parameters: ~
  598. • {buf} (`any`)
  599. Return: ~
  600. (`integer`)
  601. byte2line({byte}) *byte2line()*
  602. Return the line number that contains the character at byte
  603. count {byte} in the current buffer. This includes the
  604. end-of-line character, depending on the 'fileformat' option
  605. for the current buffer. The first character has byte count
  606. one.
  607. Also see |line2byte()|, |go| and |:goto|.
  608. Returns -1 if the {byte} value is invalid.
  609. Parameters: ~
  610. • {byte} (`any`)
  611. Return: ~
  612. (`integer`)
  613. byteidx({expr}, {nr} [, {utf16}]) *byteidx()*
  614. Return byte index of the {nr}th character in the String
  615. {expr}. Use zero for the first character, it then returns
  616. zero.
  617. If there are no multibyte characters the returned value is
  618. equal to {nr}.
  619. Composing characters are not counted separately, their byte
  620. length is added to the preceding base character. See
  621. |byteidxcomp()| below for counting composing characters
  622. separately.
  623. When {utf16} is present and TRUE, {nr} is used as the UTF-16
  624. index in the String {expr} instead of as the character index.
  625. The UTF-16 index is the index in the string when it is encoded
  626. with 16-bit words. If the specified UTF-16 index is in the
  627. middle of a character (e.g. in a 4-byte character), then the
  628. byte index of the first byte in the character is returned.
  629. Refer to |string-offset-encoding| for more information.
  630. Example : >vim
  631. echo matchstr(str, ".", byteidx(str, 3))
  632. < will display the fourth character. Another way to do the
  633. same: >vim
  634. let s = strpart(str, byteidx(str, 3))
  635. echo strpart(s, 0, byteidx(s, 1))
  636. < Also see |strgetchar()| and |strcharpart()|.
  637. If there are less than {nr} characters -1 is returned.
  638. If there are exactly {nr} characters the length of the string
  639. in bytes is returned.
  640. See |charidx()| and |utf16idx()| for getting the character and
  641. UTF-16 index respectively from the byte index.
  642. Examples: >vim
  643. echo byteidx('a😊😊', 2) " returns 5
  644. echo byteidx('a😊😊', 2, 1) " returns 1
  645. echo byteidx('a😊😊', 3, 1) " returns 5
  646. <
  647. Parameters: ~
  648. • {expr} (`any`)
  649. • {nr} (`integer`)
  650. • {utf16} (`any?`)
  651. Return: ~
  652. (`integer`)
  653. byteidxcomp({expr}, {nr} [, {utf16}]) *byteidxcomp()*
  654. Like byteidx(), except that a composing character is counted
  655. as a separate character. Example: >vim
  656. let s = 'e' .. nr2char(0x301)
  657. echo byteidx(s, 1)
  658. echo byteidxcomp(s, 1)
  659. echo byteidxcomp(s, 2)
  660. < The first and third echo result in 3 ('e' plus composing
  661. character is 3 bytes), the second echo results in 1 ('e' is
  662. one byte).
  663. Parameters: ~
  664. • {expr} (`any`)
  665. • {nr} (`integer`)
  666. • {utf16} (`any?`)
  667. Return: ~
  668. (`integer`)
  669. call({func}, {arglist} [, {dict}]) *call()* *E699*
  670. Call function {func} with the items in |List| {arglist} as
  671. arguments.
  672. {func} can either be a |Funcref| or the name of a function.
  673. a:firstline and a:lastline are set to the cursor line.
  674. Returns the return value of the called function.
  675. {dict} is for functions with the "dict" attribute. It will be
  676. used to set the local variable "self". |Dictionary-function|
  677. Parameters: ~
  678. • {func} (`any`)
  679. • {arglist} (`any`)
  680. • {dict} (`any?`)
  681. Return: ~
  682. (`any`)
  683. ceil({expr}) *ceil()*
  684. Return the smallest integral value greater than or equal to
  685. {expr} as a |Float| (round up).
  686. {expr} must evaluate to a |Float| or a |Number|.
  687. Examples: >vim
  688. echo ceil(1.456)
  689. < 2.0 >vim
  690. echo ceil(-5.456)
  691. < -5.0 >vim
  692. echo ceil(4.0)
  693. < 4.0
  694. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  695. Parameters: ~
  696. • {expr} (`number`)
  697. Return: ~
  698. (`number`)
  699. chanclose({id} [, {stream}]) *chanclose()*
  700. Close a channel or a specific stream associated with it.
  701. For a job, {stream} can be one of "stdin", "stdout",
  702. "stderr" or "rpc" (closes stdin/stdout for a job started
  703. with `"rpc":v:true`) If {stream} is omitted, all streams
  704. are closed. If the channel is a pty, this will then close the
  705. pty master, sending SIGHUP to the job process.
  706. For a socket, there is only one stream, and {stream} should be
  707. omitted.
  708. Parameters: ~
  709. • {id} (`integer`)
  710. • {stream} (`string?`)
  711. Return: ~
  712. (`0|1`)
  713. changenr() *changenr()*
  714. Return the number of the most recent change. This is the same
  715. number as what is displayed with |:undolist| and can be used
  716. with the |:undo| command.
  717. When a change was made it is the number of that change. After
  718. redo it is the number of the redone change. After undo it is
  719. one less than the number of the undone change.
  720. Returns 0 if the undo list is empty.
  721. Return: ~
  722. (`integer`)
  723. chansend({id}, {data}) *chansend()*
  724. Send data to channel {id}. For a job, it writes it to the
  725. stdin of the process. For the stdio channel |channel-stdio|,
  726. it writes to Nvim's stdout. Returns the number of bytes
  727. written if the write succeeded, 0 otherwise.
  728. See |channel-bytes| for more information.
  729. {data} may be a string, string convertible, |Blob|, or a list.
  730. If {data} is a list, the items will be joined by newlines; any
  731. newlines in an item will be sent as NUL. To send a final
  732. newline, include a final empty string. Example: >vim
  733. call chansend(id, ["abc", "123\n456", ""])
  734. < will send "abc<NL>123<NUL>456<NL>".
  735. chansend() writes raw data, not RPC messages. If the channel
  736. was created with `"rpc":v:true` then the channel expects RPC
  737. messages, use |rpcnotify()| and |rpcrequest()| instead.
  738. Parameters: ~
  739. • {id} (`number`)
  740. • {data} (`string|string[]`)
  741. Return: ~
  742. (`0|1`)
  743. char2nr({string} [, {utf8}]) *char2nr()*
  744. Return Number value of the first char in {string}.
  745. Examples: >vim
  746. echo char2nr(" ") " returns 32
  747. echo char2nr("ABC") " returns 65
  748. echo char2nr("á") " returns 225
  749. echo char2nr("á"[0]) " returns 195
  750. echo char2nr("\<M-x>") " returns 128
  751. < Non-ASCII characters are always treated as UTF-8 characters.
  752. {utf8} is ignored, it exists only for backwards-compatibility.
  753. A combining character is a separate character.
  754. |nr2char()| does the opposite.
  755. Returns 0 if {string} is not a |String|.
  756. Parameters: ~
  757. • {string} (`string`)
  758. • {utf8} (`any?`)
  759. Return: ~
  760. (`0|1`)
  761. charclass({string}) *charclass()*
  762. Return the character class of the first character in {string}.
  763. The character class is one of:
  764. 0 blank
  765. 1 punctuation
  766. 2 word character (depends on 'iskeyword')
  767. 3 emoji
  768. other specific Unicode class
  769. The class is used in patterns and word motions.
  770. Returns 0 if {string} is not a |String|.
  771. Parameters: ~
  772. • {string} (`string`)
  773. Return: ~
  774. (`0|1|2|3|'other'`)
  775. charcol({expr} [, {winid}]) *charcol()*
  776. Same as |col()| but returns the character index of the column
  777. position given with {expr} instead of the byte position.
  778. Example:
  779. With the cursor on '세' in line 5 with text "여보세요": >vim
  780. echo charcol('.') " returns 3
  781. echo col('.') " returns 7
  782. <
  783. Parameters: ~
  784. • {expr} (`string|any[]`)
  785. • {winid} (`integer?`)
  786. Return: ~
  787. (`integer`)
  788. charidx({string}, {idx} [, {countcc} [, {utf16}]]) *charidx()*
  789. Return the character index of the byte at {idx} in {string}.
  790. The index of the first character is zero.
  791. If there are no multibyte characters the returned value is
  792. equal to {idx}.
  793. When {countcc} is omitted or |FALSE|, then composing characters
  794. are not counted separately, their byte length is added to the
  795. preceding base character.
  796. When {countcc} is |TRUE|, then composing characters are
  797. counted as separate characters.
  798. When {utf16} is present and TRUE, {idx} is used as the UTF-16
  799. index in the String {expr} instead of as the byte index.
  800. Returns -1 if the arguments are invalid or if there are less
  801. than {idx} bytes. If there are exactly {idx} bytes the length
  802. of the string in characters is returned.
  803. An error is given and -1 is returned if the first argument is
  804. not a string, the second argument is not a number or when the
  805. third argument is present and is not zero or one.
  806. See |byteidx()| and |byteidxcomp()| for getting the byte index
  807. from the character index and |utf16idx()| for getting the
  808. UTF-16 index from the character index.
  809. Refer to |string-offset-encoding| for more information.
  810. Examples: >vim
  811. echo charidx('áb́ć', 3) " returns 1
  812. echo charidx('áb́ć', 6, 1) " returns 4
  813. echo charidx('áb́ć', 16) " returns -1
  814. echo charidx('a😊😊', 4, 0, 1) " returns 2
  815. <
  816. Parameters: ~
  817. • {string} (`string`)
  818. • {idx} (`integer`)
  819. • {countcc} (`boolean?`)
  820. • {utf16} (`boolean?`)
  821. Return: ~
  822. (`integer`)
  823. chdir({dir}) *chdir()*
  824. Change the current working directory to {dir}. The scope of
  825. the directory change depends on the directory of the current
  826. window:
  827. - If the current window has a window-local directory
  828. (|:lcd|), then changes the window local directory.
  829. - Otherwise, if the current tabpage has a local
  830. directory (|:tcd|) then changes the tabpage local
  831. directory.
  832. - Otherwise, changes the global directory.
  833. {dir} must be a String.
  834. If successful, returns the previous working directory. Pass
  835. this to another chdir() to restore the directory.
  836. On failure, returns an empty string.
  837. Example: >vim
  838. let save_dir = chdir(newdir)
  839. if save_dir != ""
  840. " ... do some work
  841. call chdir(save_dir)
  842. endif
  843. <
  844. Parameters: ~
  845. • {dir} (`string`)
  846. Return: ~
  847. (`string`)
  848. cindent({lnum}) *cindent()*
  849. Get the amount of indent for line {lnum} according the C
  850. indenting rules, as with 'cindent'.
  851. The indent is counted in spaces, the value of 'tabstop' is
  852. relevant. {lnum} is used just like in |getline()|.
  853. When {lnum} is invalid -1 is returned.
  854. See |C-indenting|.
  855. Parameters: ~
  856. • {lnum} (`integer`)
  857. Return: ~
  858. (`integer`)
  859. clearmatches([{win}]) *clearmatches()*
  860. Clears all matches previously defined for the current window
  861. by |matchadd()| and the |:match| commands.
  862. If {win} is specified, use the window with this number or
  863. window ID instead of the current window.
  864. Parameters: ~
  865. • {win} (`integer?`)
  866. col({expr} [, {winid}]) *col()*
  867. The result is a Number, which is the byte index of the column
  868. position given with {expr}.
  869. For accepted positions see |getpos()|.
  870. When {expr} is "$", it means the end of the cursor line, so
  871. the result is the number of bytes in the cursor line plus one.
  872. Additionally {expr} can be [lnum, col]: a |List| with the line
  873. and column number. Most useful when the column is "$", to get
  874. the last column of a specific line. When "lnum" or "col" is
  875. out of range then col() returns zero.
  876. With the optional {winid} argument the values are obtained for
  877. that window instead of the current window.
  878. To get the line number use |line()|. To get both use
  879. |getpos()|.
  880. For the screen column position use |virtcol()|. For the
  881. character position use |charcol()|.
  882. Note that only marks in the current file can be used.
  883. Examples: >vim
  884. echo col(".") " column of cursor
  885. echo col("$") " length of cursor line plus one
  886. echo col("'t") " column of mark t
  887. echo col("'" .. markname) " column of mark markname
  888. <
  889. The first column is 1. Returns 0 if {expr} is invalid or when
  890. the window with ID {winid} is not found.
  891. For an uppercase mark the column may actually be in another
  892. buffer.
  893. For the cursor position, when 'virtualedit' is active, the
  894. column is one higher if the cursor is after the end of the
  895. line. Also, when using a <Cmd> mapping the cursor isn't
  896. moved, this can be used to obtain the column in Insert mode: >vim
  897. imap <F2> <Cmd>echo col(".").."\n"<CR>
  898. <
  899. Parameters: ~
  900. • {expr} (`string|any[]`)
  901. • {winid} (`integer?`)
  902. Return: ~
  903. (`integer`)
  904. complete({startcol}, {matches}) *complete()* *E785*
  905. Set the matches for Insert mode completion.
  906. Can only be used in Insert mode. You need to use a mapping
  907. with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O
  908. or with an expression mapping.
  909. {startcol} is the byte offset in the line where the completed
  910. text start. The text up to the cursor is the original text
  911. that will be replaced by the matches. Use col('.') for an
  912. empty string. "col('.') - 1" will replace one character by a
  913. match.
  914. {matches} must be a |List|. Each |List| item is one match.
  915. See |complete-items| for the kind of items that are possible.
  916. "longest" in 'completeopt' is ignored.
  917. Note that the after calling this function you need to avoid
  918. inserting anything that would cause completion to stop.
  919. The match can be selected with CTRL-N and CTRL-P as usual with
  920. Insert mode completion. The popup menu will appear if
  921. specified, see |ins-completion-menu|.
  922. Example: >vim
  923. inoremap <F5> <C-R>=ListMonths()<CR>
  924. func ListMonths()
  925. call complete(col('.'), ['January', 'February', 'March',
  926. \ 'April', 'May', 'June', 'July', 'August', 'September',
  927. \ 'October', 'November', 'December'])
  928. return ''
  929. endfunc
  930. < This isn't very useful, but it shows how it works. Note that
  931. an empty string is returned to avoid a zero being inserted.
  932. Parameters: ~
  933. • {startcol} (`integer`)
  934. • {matches} (`any[]`)
  935. complete_add({expr}) *complete_add()*
  936. Add {expr} to the list of matches. Only to be used by the
  937. function specified with the 'completefunc' option.
  938. Returns 0 for failure (empty string or out of memory),
  939. 1 when the match was added, 2 when the match was already in
  940. the list.
  941. See |complete-functions| for an explanation of {expr}. It is
  942. the same as one item in the list that 'omnifunc' would return.
  943. Parameters: ~
  944. • {expr} (`any`)
  945. Return: ~
  946. (`0|1|2`)
  947. complete_check() *complete_check()*
  948. Check for a key typed while looking for completion matches.
  949. This is to be used when looking for matches takes some time.
  950. Returns |TRUE| when searching for matches is to be aborted,
  951. zero otherwise.
  952. Only to be used by the function specified with the
  953. 'completefunc' option.
  954. Return: ~
  955. (`0|1`)
  956. complete_info([{what}]) *complete_info()*
  957. Returns a |Dictionary| with information about Insert mode
  958. completion. See |ins-completion|.
  959. The items are:
  960. mode Current completion mode name string.
  961. See |complete_info_mode| for the values.
  962. pum_visible |TRUE| if popup menu is visible.
  963. See |pumvisible()|.
  964. items List of all completion candidates. Each item
  965. is a dictionary containing the entries "word",
  966. "abbr", "menu", "kind", "info" and "user_data".
  967. See |complete-items|.
  968. matches Same as "items", but only returns items that
  969. are matching current query. If both "matches"
  970. and "items" are in "what", the returned list
  971. will still be named "items", but each item
  972. will have an additional "match" field.
  973. selected Selected item index. First index is zero.
  974. Index is -1 if no item is selected (showing
  975. typed text only, or the last completion after
  976. no item is selected when using the <Up> or
  977. <Down> keys)
  978. inserted Inserted string. [NOT IMPLEMENTED YET]
  979. preview_winid Info floating preview window id.
  980. preview_bufnr Info floating preview buffer id.
  981. *complete_info_mode*
  982. mode values are:
  983. "" Not in completion mode
  984. "keyword" Keyword completion |i_CTRL-X_CTRL-N|
  985. "ctrl_x" Just pressed CTRL-X |i_CTRL-X|
  986. "scroll" Scrolling with |i_CTRL-X_CTRL-E| or
  987. |i_CTRL-X_CTRL-Y|
  988. "whole_line" Whole lines |i_CTRL-X_CTRL-L|
  989. "files" File names |i_CTRL-X_CTRL-F|
  990. "tags" Tags |i_CTRL-X_CTRL-]|
  991. "path_defines" Definition completion |i_CTRL-X_CTRL-D|
  992. "path_patterns" Include completion |i_CTRL-X_CTRL-I|
  993. "dictionary" Dictionary |i_CTRL-X_CTRL-K|
  994. "thesaurus" Thesaurus |i_CTRL-X_CTRL-T|
  995. "cmdline" Vim Command line |i_CTRL-X_CTRL-V|
  996. "function" User defined completion |i_CTRL-X_CTRL-U|
  997. "omni" Omni completion |i_CTRL-X_CTRL-O|
  998. "spell" Spelling suggestions |i_CTRL-X_s|
  999. "eval" |complete()| completion
  1000. "unknown" Other internal modes
  1001. If the optional {what} list argument is supplied, then only
  1002. the items listed in {what} are returned. Unsupported items in
  1003. {what} are silently ignored.
  1004. To get the position and size of the popup menu, see
  1005. |pum_getpos()|. It's also available in |v:event| during the
  1006. |CompleteChanged| event.
  1007. Returns an empty |Dictionary| on error.
  1008. Examples: >vim
  1009. " Get all items
  1010. call complete_info()
  1011. " Get only 'mode'
  1012. call complete_info(['mode'])
  1013. " Get only 'mode' and 'pum_visible'
  1014. call complete_info(['mode', 'pum_visible'])
  1015. <
  1016. Parameters: ~
  1017. • {what} (`any[]?`)
  1018. Return: ~
  1019. (`table`)
  1020. confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()*
  1021. confirm() offers the user a dialog, from which a choice can be
  1022. made. It returns the number of the choice. For the first
  1023. choice this is 1.
  1024. {msg} is displayed in a dialog with {choices} as the
  1025. alternatives. When {choices} is missing or empty, "&OK" is
  1026. used (and translated).
  1027. {msg} is a String, use '\n' to include a newline. Only on
  1028. some systems the string is wrapped when it doesn't fit.
  1029. {choices} is a String, with the individual choices separated
  1030. by '\n', e.g. >vim
  1031. confirm("Save changes?", "&Yes\n&No\n&Cancel")
  1032. < The letter after the '&' is the shortcut key for that choice.
  1033. Thus you can type 'c' to select "Cancel". The shortcut does
  1034. not need to be the first letter: >vim
  1035. confirm("file has been modified", "&Save\nSave &All")
  1036. < For the console, the first letter of each choice is used as
  1037. the default shortcut key. Case is ignored.
  1038. The optional {type} String argument gives the type of dialog.
  1039. It can be one of these values: "Error", "Question", "Info",
  1040. "Warning" or "Generic". Only the first character is relevant.
  1041. When {type} is omitted, "Generic" is used.
  1042. The optional {type} argument gives the type of dialog. This
  1043. is only used for the icon of the Win32 GUI. It can be one of
  1044. these values: "Error", "Question", "Info", "Warning" or
  1045. "Generic". Only the first character is relevant.
  1046. When {type} is omitted, "Generic" is used.
  1047. If the user aborts the dialog by pressing <Esc>, CTRL-C,
  1048. or another valid interrupt key, confirm() returns 0.
  1049. An example: >vim
  1050. let choice = confirm("What do you want?",
  1051. \ "&Apples\n&Oranges\n&Bananas", 2)
  1052. if choice == 0
  1053. echo "make up your mind!"
  1054. elseif choice == 3
  1055. echo "tasteful"
  1056. else
  1057. echo "I prefer bananas myself."
  1058. endif
  1059. < In a GUI dialog, buttons are used. The layout of the buttons
  1060. depends on the 'v' flag in 'guioptions'. If it is included,
  1061. the buttons are always put vertically. Otherwise, confirm()
  1062. tries to put the buttons in one horizontal line. If they
  1063. don't fit, a vertical layout is used anyway. For some systems
  1064. the horizontal layout is always used.
  1065. Parameters: ~
  1066. • {msg} (`string`)
  1067. • {choices} (`string?`)
  1068. • {default} (`integer?`)
  1069. • {type} (`string?`)
  1070. Return: ~
  1071. (`integer`)
  1072. copy({expr}) *copy()*
  1073. Make a copy of {expr}. For Numbers and Strings this isn't
  1074. different from using {expr} directly.
  1075. When {expr} is a |List| a shallow copy is created. This means
  1076. that the original |List| can be changed without changing the
  1077. copy, and vice versa. But the items are identical, thus
  1078. changing an item changes the contents of both |Lists|.
  1079. A |Dictionary| is copied in a similar way as a |List|.
  1080. Also see |deepcopy()|.
  1081. Parameters: ~
  1082. • {expr} (`T`)
  1083. Return: ~
  1084. (`T`)
  1085. cos({expr}) *cos()*
  1086. Return the cosine of {expr}, measured in radians, as a |Float|.
  1087. {expr} must evaluate to a |Float| or a |Number|.
  1088. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1089. Examples: >vim
  1090. echo cos(100)
  1091. < 0.862319 >vim
  1092. echo cos(-4.01)
  1093. < -0.646043
  1094. Parameters: ~
  1095. • {expr} (`number`)
  1096. Return: ~
  1097. (`number`)
  1098. cosh({expr}) *cosh()*
  1099. Return the hyperbolic cosine of {expr} as a |Float| in the range
  1100. [1, inf].
  1101. {expr} must evaluate to a |Float| or a |Number|.
  1102. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1103. Examples: >vim
  1104. echo cosh(0.5)
  1105. < 1.127626 >vim
  1106. echo cosh(-0.5)
  1107. < -1.127626
  1108. Parameters: ~
  1109. • {expr} (`number`)
  1110. Return: ~
  1111. (`number`)
  1112. count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E706*
  1113. Return the number of times an item with value {expr} appears
  1114. in |String|, |List| or |Dictionary| {comp}.
  1115. If {start} is given then start with the item with this index.
  1116. {start} can only be used with a |List|.
  1117. When {ic} is given and it's |TRUE| then case is ignored.
  1118. When {comp} is a string then the number of not overlapping
  1119. occurrences of {expr} is returned. Zero is returned when
  1120. {expr} is an empty string.
  1121. Parameters: ~
  1122. • {comp} (`string|table|any[]`)
  1123. • {expr} (`any`)
  1124. • {ic} (`boolean?`)
  1125. • {start} (`integer?`)
  1126. Return: ~
  1127. (`integer`)
  1128. ctxget([{index}]) *ctxget()*
  1129. Returns a |Dictionary| representing the |context| at {index}
  1130. from the top of the |context-stack| (see |context-dict|).
  1131. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1132. Parameters: ~
  1133. • {index} (`integer?`)
  1134. Return: ~
  1135. (`table`)
  1136. ctxpop() *ctxpop()*
  1137. Pops and restores the |context| at the top of the
  1138. |context-stack|.
  1139. Return: ~
  1140. (`any`)
  1141. ctxpush([{types}]) *ctxpush()*
  1142. Pushes the current editor state (|context|) on the
  1143. |context-stack|.
  1144. If {types} is given and is a |List| of |String|s, it specifies
  1145. which |context-types| to include in the pushed context.
  1146. Otherwise, all context types are included.
  1147. Parameters: ~
  1148. • {types} (`string[]?`)
  1149. Return: ~
  1150. (`any`)
  1151. ctxset({context} [, {index}]) *ctxset()*
  1152. Sets the |context| at {index} from the top of the
  1153. |context-stack| to that represented by {context}.
  1154. {context} is a Dictionary with context data (|context-dict|).
  1155. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1156. Parameters: ~
  1157. • {context} (`table`)
  1158. • {index} (`integer?`)
  1159. Return: ~
  1160. (`integer`)
  1161. ctxsize() *ctxsize()*
  1162. Returns the size of the |context-stack|.
  1163. Return: ~
  1164. (`any`)
  1165. cursor({lnum}, {col} [, {off}]) *cursor()*
  1166. cursor({list})
  1167. Positions the cursor at the column (byte count) {col} in the
  1168. line {lnum}. The first column is one.
  1169. When there is one argument {list} this is used as a |List|
  1170. with two, three or four item:
  1171. [{lnum}, {col}]
  1172. [{lnum}, {col}, {off}]
  1173. [{lnum}, {col}, {off}, {curswant}]
  1174. This is like the return value of |getpos()| or |getcurpos()|,
  1175. but without the first item.
  1176. To position the cursor using {col} as the character count, use
  1177. |setcursorcharpos()|.
  1178. Does not change the jumplist.
  1179. {lnum} is used like with |getline()|, except that if {lnum} is
  1180. zero, the cursor will stay in the current line.
  1181. If {lnum} is greater than the number of lines in the buffer,
  1182. the cursor will be positioned at the last line in the buffer.
  1183. If {col} is greater than the number of bytes in the line,
  1184. the cursor will be positioned at the last character in the
  1185. line.
  1186. If {col} is zero, the cursor will stay in the current column.
  1187. If {curswant} is given it is used to set the preferred column
  1188. for vertical movement. Otherwise {col} is used.
  1189. When 'virtualedit' is used {off} specifies the offset in
  1190. screen columns from the start of the character. E.g., a
  1191. position within a <Tab> or after the last character.
  1192. Returns 0 when the position could be set, -1 otherwise.
  1193. Parameters: ~
  1194. • {list} (`integer[]`)
  1195. Return: ~
  1196. (`any`)
  1197. debugbreak({pid}) *debugbreak()*
  1198. Specifically used to interrupt a program being debugged. It
  1199. will cause process {pid} to get a SIGTRAP. Behavior for other
  1200. processes is undefined. See |terminal-debug|.
  1201. (Sends a SIGINT to a process {pid} other than MS-Windows)
  1202. Returns |TRUE| if successfully interrupted the program.
  1203. Otherwise returns |FALSE|.
  1204. Parameters: ~
  1205. • {pid} (`integer`)
  1206. Return: ~
  1207. (`any`)
  1208. deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
  1209. Make a copy of {expr}. For Numbers and Strings this isn't
  1210. different from using {expr} directly.
  1211. When {expr} is a |List| a full copy is created. This means
  1212. that the original |List| can be changed without changing the
  1213. copy, and vice versa. When an item is a |List|, a copy for it
  1214. is made, recursively. Thus changing an item in the copy does
  1215. not change the contents of the original |List|.
  1216. When {noref} is omitted or zero a contained |List| or
  1217. |Dictionary| is only copied once. All references point to
  1218. this single copy. With {noref} set to 1 every occurrence of a
  1219. |List| or |Dictionary| results in a new copy. This also means
  1220. that a cyclic reference causes deepcopy() to fail.
  1221. *E724*
  1222. Nesting is possible up to 100 levels. When there is an item
  1223. that refers back to a higher level making a deep copy with
  1224. {noref} set to 1 will fail.
  1225. Also see |copy()|.
  1226. Parameters: ~
  1227. • {expr} (`T`)
  1228. • {noref} (`boolean?`)
  1229. Return: ~
  1230. (`T`)
  1231. delete({fname} [, {flags}]) *delete()*
  1232. Without {flags} or with {flags} empty: Deletes the file by the
  1233. name {fname}.
  1234. This also works when {fname} is a symbolic link. The symbolic
  1235. link itself is deleted, not what it points to.
  1236. When {flags} is "d": Deletes the directory by the name
  1237. {fname}. This fails when directory {fname} is not empty.
  1238. When {flags} is "rf": Deletes the directory by the name
  1239. {fname} and everything in it, recursively. BE CAREFUL!
  1240. Note: on MS-Windows it is not possible to delete a directory
  1241. that is being used.
  1242. The result is a Number, which is 0/false if the delete
  1243. operation was successful and -1/true when the deletion failed
  1244. or partly failed.
  1245. Parameters: ~
  1246. • {fname} (`string`)
  1247. • {flags} (`string?`)
  1248. Return: ~
  1249. (`integer`)
  1250. deletebufline({buf}, {first} [, {last}]) *deletebufline()*
  1251. Delete lines {first} to {last} (inclusive) from buffer {buf}.
  1252. If {last} is omitted then delete line {first} only.
  1253. On success 0 is returned, on failure 1 is returned.
  1254. This function works only for loaded buffers. First call
  1255. |bufload()| if needed.
  1256. For the use of {buf}, see |bufname()| above.
  1257. {first} and {last} are used like with |getline()|. Note that
  1258. when using |line()| this refers to the current buffer. Use "$"
  1259. to refer to the last line in buffer {buf}.
  1260. Parameters: ~
  1261. • {buf} (`integer|string`)
  1262. • {first} (`integer|string`)
  1263. • {last} (`integer|string?`)
  1264. Return: ~
  1265. (`any`)
  1266. dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
  1267. Adds a watcher to a dictionary. A dictionary watcher is
  1268. identified by three components:
  1269. - A dictionary({dict});
  1270. - A key pattern({pattern}).
  1271. - A function({callback}).
  1272. After this is called, every change on {dict} and on keys
  1273. matching {pattern} will result in {callback} being invoked.
  1274. For example, to watch all global variables: >vim
  1275. silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
  1276. function! OnDictChanged(d,k,z)
  1277. echomsg string(a:k) string(a:z)
  1278. endfunction
  1279. call dictwatcheradd(g:, '*', 'OnDictChanged')
  1280. <
  1281. For now {pattern} only accepts very simple patterns that can
  1282. contain a "*" at the end of the string, in which case it will
  1283. match every key that begins with the substring before the "*".
  1284. That means if "*" is not the last character of {pattern}, only
  1285. keys that are exactly equal as {pattern} will be matched.
  1286. The {callback} receives three arguments:
  1287. - The dictionary being watched.
  1288. - The key which changed.
  1289. - A dictionary containing the new and old values for the key.
  1290. The type of change can be determined by examining the keys
  1291. present on the third argument:
  1292. - If contains both `old` and `new`, the key was updated.
  1293. - If it contains only `new`, the key was added.
  1294. - If it contains only `old`, the key was deleted.
  1295. This function can be used by plugins to implement options with
  1296. validation and parsing logic.
  1297. Parameters: ~
  1298. • {dict} (`table`)
  1299. • {pattern} (`string`)
  1300. • {callback} (`function`)
  1301. Return: ~
  1302. (`any`)
  1303. dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()*
  1304. Removes a watcher added with |dictwatcheradd()|. All three
  1305. arguments must match the ones passed to |dictwatcheradd()| in
  1306. order for the watcher to be successfully deleted.
  1307. Parameters: ~
  1308. • {dict} (`any`)
  1309. • {pattern} (`string`)
  1310. • {callback} (`function`)
  1311. Return: ~
  1312. (`any`)
  1313. did_filetype() *did_filetype()*
  1314. Returns |TRUE| when autocommands are being executed and the
  1315. FileType event has been triggered at least once. Can be used
  1316. to avoid triggering the FileType event again in the scripts
  1317. that detect the file type. |FileType|
  1318. Returns |FALSE| when `:setf FALLBACK` was used.
  1319. When editing another file, the counter is reset, thus this
  1320. really checks if the FileType event has been triggered for the
  1321. current buffer. This allows an autocommand that starts
  1322. editing another buffer to set 'filetype' and load a syntax
  1323. file.
  1324. Return: ~
  1325. (`integer`)
  1326. diff_filler({lnum}) *diff_filler()*
  1327. Returns the number of filler lines above line {lnum}.
  1328. These are the lines that were inserted at this point in
  1329. another diff'ed window. These filler lines are shown in the
  1330. display but don't exist in the buffer.
  1331. {lnum} is used like with |getline()|. Thus "." is the current
  1332. line, "'m" mark m, etc.
  1333. Returns 0 if the current window is not in diff mode.
  1334. Parameters: ~
  1335. • {lnum} (`integer`)
  1336. Return: ~
  1337. (`integer`)
  1338. diff_hlID({lnum}, {col}) *diff_hlID()*
  1339. Returns the highlight ID for diff mode at line {lnum} column
  1340. {col} (byte index). When the current line does not have a
  1341. diff change zero is returned.
  1342. {lnum} is used like with |getline()|. Thus "." is the current
  1343. line, "'m" mark m, etc.
  1344. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  1345. line.
  1346. The highlight ID can be used with |synIDattr()| to obtain
  1347. syntax information about the highlighting.
  1348. Parameters: ~
  1349. • {lnum} (`integer`)
  1350. • {col} (`integer`)
  1351. Return: ~
  1352. (`any`)
  1353. digraph_get({chars}) *digraph_get()* *E1214*
  1354. Return the digraph of {chars}. This should be a string with
  1355. exactly two characters. If {chars} are not just two
  1356. characters, or the digraph of {chars} does not exist, an error
  1357. is given and an empty string is returned.
  1358. Also see |digraph_getlist()|.
  1359. Examples: >vim
  1360. " Get a built-in digraph
  1361. echo digraph_get('00') " Returns '∞'
  1362. " Get a user-defined digraph
  1363. call digraph_set('aa', 'あ')
  1364. echo digraph_get('aa') " Returns 'あ'
  1365. <
  1366. Parameters: ~
  1367. • {chars} (`string`)
  1368. Return: ~
  1369. (`string`)
  1370. digraph_getlist([{listall}]) *digraph_getlist()*
  1371. Return a list of digraphs. If the {listall} argument is given
  1372. and it is TRUE, return all digraphs, including the default
  1373. digraphs. Otherwise, return only user-defined digraphs.
  1374. Also see |digraph_get()|.
  1375. Examples: >vim
  1376. " Get user-defined digraphs
  1377. echo digraph_getlist()
  1378. " Get all the digraphs, including default digraphs
  1379. echo digraph_getlist(1)
  1380. <
  1381. Parameters: ~
  1382. • {listall} (`boolean?`)
  1383. Return: ~
  1384. (`string[][]`)
  1385. digraph_set({chars}, {digraph}) *digraph_set()*
  1386. Add digraph {chars} to the list. {chars} must be a string
  1387. with two characters. {digraph} is a string with one UTF-8
  1388. encoded character. *E1215*
  1389. Be careful, composing characters are NOT ignored. This
  1390. function is similar to |:digraphs| command, but useful to add
  1391. digraphs start with a white space.
  1392. The function result is v:true if |digraph| is registered. If
  1393. this fails an error message is given and v:false is returned.
  1394. If you want to define multiple digraphs at once, you can use
  1395. |digraph_setlist()|.
  1396. Example: >vim
  1397. call digraph_set(' ', 'あ')
  1398. <
  1399. Parameters: ~
  1400. • {chars} (`string`)
  1401. • {digraph} (`string`)
  1402. Return: ~
  1403. (`any`)
  1404. digraph_setlist({digraphlist}) *digraph_setlist()*
  1405. Similar to |digraph_set()| but this function can add multiple
  1406. digraphs at once. {digraphlist} is a list composed of lists,
  1407. where each list contains two strings with {chars} and
  1408. {digraph} as in |digraph_set()|. *E1216*
  1409. Example: >vim
  1410. call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
  1411. <
  1412. It is similar to the following: >vim
  1413. for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
  1414. call digraph_set(chars, digraph)
  1415. endfor
  1416. < Except that the function returns after the first error,
  1417. following digraphs will not be added.
  1418. Parameters: ~
  1419. • {digraphlist} (`table<integer,string[]>`)
  1420. Return: ~
  1421. (`any`)
  1422. empty({expr}) *empty()*
  1423. Return the Number 1 if {expr} is empty, zero otherwise.
  1424. - A |List| or |Dictionary| is empty when it does not have any
  1425. items.
  1426. - A |String| is empty when its length is zero.
  1427. - A |Number| and |Float| are empty when their value is zero.
  1428. - |v:false| and |v:null| are empty, |v:true| is not.
  1429. - A |Blob| is empty when its length is zero.
  1430. Parameters: ~
  1431. • {expr} (`any`)
  1432. Return: ~
  1433. (`integer`)
  1434. environ() *environ()*
  1435. Return all of environment variables as dictionary. You can
  1436. check if an environment variable exists like this: >vim
  1437. echo has_key(environ(), 'HOME')
  1438. < Note that the variable name may be CamelCase; to ignore case
  1439. use this: >vim
  1440. echo index(keys(environ()), 'HOME', 0, 1) != -1
  1441. <
  1442. Return: ~
  1443. (`any`)
  1444. escape({string}, {chars}) *escape()*
  1445. Escape the characters in {chars} that occur in {string} with a
  1446. backslash. Example: >vim
  1447. echo escape('c:\program files\vim', ' \')
  1448. < results in: >
  1449. c:\\program\ files\\vim
  1450. < Also see |shellescape()| and |fnameescape()|.
  1451. Parameters: ~
  1452. • {string} (`string`)
  1453. • {chars} (`string`)
  1454. Return: ~
  1455. (`string`)
  1456. eval({string}) *eval()*
  1457. Evaluate {string} and return the result. Especially useful to
  1458. turn the result of |string()| back into the original value.
  1459. This works for Numbers, Floats, Strings, Blobs and composites
  1460. of them. Also works for |Funcref|s that refer to existing
  1461. functions.
  1462. Parameters: ~
  1463. • {string} (`string`)
  1464. Return: ~
  1465. (`any`)
  1466. eventhandler() *eventhandler()*
  1467. Returns 1 when inside an event handler. That is that Vim got
  1468. interrupted while waiting for the user to type a character,
  1469. e.g., when dropping a file on Vim. This means interactive
  1470. commands cannot be used. Otherwise zero is returned.
  1471. Return: ~
  1472. (`any`)
  1473. executable({expr}) *executable()*
  1474. This function checks if an executable with the name {expr}
  1475. exists. {expr} must be the name of the program without any
  1476. arguments.
  1477. executable() uses the value of $PATH and/or the normal
  1478. searchpath for programs.
  1479. *PATHEXT*
  1480. On MS-Windows the ".exe", ".bat", etc. can optionally be
  1481. included. Then the extensions in $PATHEXT are tried. Thus if
  1482. "foo.exe" does not exist, "foo.exe.bat" can be found. If
  1483. $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot
  1484. by itself can be used in $PATHEXT to try using the name
  1485. without an extension. When 'shell' looks like a Unix shell,
  1486. then the name is also tried without adding an extension.
  1487. On MS-Windows it only checks if the file exists and is not a
  1488. directory, not if it's really executable.
  1489. On MS-Windows an executable in the same directory as the Vim
  1490. executable is always found (it's added to $PATH at |startup|).
  1491. *NoDefaultCurrentDirectoryInExePath*
  1492. On MS-Windows an executable in Vim's current working directory
  1493. is also normally found, but this can be disabled by setting
  1494. the $NoDefaultCurrentDirectoryInExePath environment variable.
  1495. The result is a Number:
  1496. 1 exists
  1497. 0 does not exist
  1498. |exepath()| can be used to get the full path of an executable.
  1499. Parameters: ~
  1500. • {expr} (`string`)
  1501. Return: ~
  1502. (`0|1`)
  1503. execute({command} [, {silent}]) *execute()*
  1504. Execute {command} and capture its output.
  1505. If {command} is a |String|, returns {command} output.
  1506. If {command} is a |List|, returns concatenated outputs.
  1507. Line continuations in {command} are not recognized.
  1508. Examples: >vim
  1509. echo execute('echon "foo"')
  1510. < foo >vim
  1511. echo execute(['echon "foo"', 'echon "bar"'])
  1512. < foobar
  1513. The optional {silent} argument can have these values:
  1514. "" no `:silent` used
  1515. "silent" `:silent` used
  1516. "silent!" `:silent!` used
  1517. The default is "silent". Note that with "silent!", unlike
  1518. `:redir`, error messages are dropped.
  1519. To get a list of lines use `split()` on the result: >vim
  1520. execute('args')->split("\n")
  1521. < This function is not available in the |sandbox|.
  1522. Note: If nested, an outer execute() will not observe output of
  1523. the inner calls.
  1524. Note: Text attributes (highlights) are not captured.
  1525. To execute a command in another window than the current one
  1526. use `win_execute()`.
  1527. Parameters: ~
  1528. • {command} (`string|string[]`)
  1529. • {silent} (`''|'silent'|'silent!'?`)
  1530. Return: ~
  1531. (`string`)
  1532. exepath({expr}) *exepath()*
  1533. Returns the full path of {expr} if it is an executable and
  1534. given as a (partial or full) path or is found in $PATH.
  1535. Returns empty string otherwise.
  1536. If {expr} starts with "./" the |current-directory| is used.
  1537. Parameters: ~
  1538. • {expr} (`string`)
  1539. Return: ~
  1540. (`string`)
  1541. exists({expr}) *exists()*
  1542. The result is a Number, which is |TRUE| if {expr} is
  1543. defined, zero otherwise.
  1544. For checking for a supported feature use |has()|.
  1545. For checking if a file exists use |filereadable()|.
  1546. The {expr} argument is a string, which contains one of these:
  1547. varname internal variable (see
  1548. dict.key |internal-variables|). Also works
  1549. list[i] for |curly-braces-names|, |Dictionary|
  1550. entries, |List| items, etc.
  1551. Beware that evaluating an index may
  1552. cause an error message for an invalid
  1553. expression. E.g.: >vim
  1554. let l = [1, 2, 3]
  1555. echo exists("l[5]")
  1556. < 0 >vim
  1557. echo exists("l[xx]")
  1558. < E121: Undefined variable: xx
  1559. 0
  1560. &option-name Vim option (only checks if it exists,
  1561. not if it really works)
  1562. +option-name Vim option that works.
  1563. $ENVNAME environment variable (could also be
  1564. done by comparing with an empty
  1565. string)
  1566. `*funcname` built-in function (see |functions|)
  1567. or user defined function (see
  1568. |user-function|). Also works for a
  1569. variable that is a Funcref.
  1570. :cmdname Ex command: built-in command, user
  1571. command or command modifier |:command|.
  1572. Returns:
  1573. 1 for match with start of a command
  1574. 2 full match with a command
  1575. 3 matches several user commands
  1576. To check for a supported command
  1577. always check the return value to be 2.
  1578. :2match The |:2match| command.
  1579. :3match The |:3match| command (but you
  1580. probably should not use it, it is
  1581. reserved for internal usage)
  1582. #event autocommand defined for this event
  1583. #event#pattern autocommand defined for this event and
  1584. pattern (the pattern is taken
  1585. literally and compared to the
  1586. autocommand patterns character by
  1587. character)
  1588. #group autocommand group exists
  1589. #group#event autocommand defined for this group and
  1590. event.
  1591. #group#event#pattern
  1592. autocommand defined for this group,
  1593. event and pattern.
  1594. ##event autocommand for this event is
  1595. supported.
  1596. Examples: >vim
  1597. echo exists("&mouse")
  1598. echo exists("$HOSTNAME")
  1599. echo exists("*strftime")
  1600. echo exists("*s:MyFunc")
  1601. echo exists("*MyFunc")
  1602. echo exists("*v:lua.Func")
  1603. echo exists("bufcount")
  1604. echo exists(":Make")
  1605. echo exists("#CursorHold")
  1606. echo exists("#BufReadPre#*.gz")
  1607. echo exists("#filetypeindent")
  1608. echo exists("#filetypeindent#FileType")
  1609. echo exists("#filetypeindent#FileType#*")
  1610. echo exists("##ColorScheme")
  1611. < There must be no space between the symbol (&/$/*/#) and the
  1612. name.
  1613. There must be no extra characters after the name, although in
  1614. a few cases this is ignored. That may become stricter in the
  1615. future, thus don't count on it!
  1616. Working example: >vim
  1617. echo exists(":make")
  1618. < NOT working example: >vim
  1619. echo exists(":make install")
  1620. < Note that the argument must be a string, not the name of the
  1621. variable itself. For example: >vim
  1622. echo exists(bufcount)
  1623. < This doesn't check for existence of the "bufcount" variable,
  1624. but gets the value of "bufcount", and checks if that exists.
  1625. Parameters: ~
  1626. • {expr} (`string`)
  1627. Return: ~
  1628. (`0|1`)
  1629. exp({expr}) *exp()*
  1630. Return the exponential of {expr} as a |Float| in the range
  1631. [0, inf].
  1632. {expr} must evaluate to a |Float| or a |Number|.
  1633. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1634. Examples: >vim
  1635. echo exp(2)
  1636. < 7.389056 >vim
  1637. echo exp(-1)
  1638. < 0.367879
  1639. Parameters: ~
  1640. • {expr} (`number`)
  1641. Return: ~
  1642. (`any`)
  1643. expand({string} [, {nosuf} [, {list}]]) *expand()*
  1644. Expand wildcards and the following special keywords in
  1645. {string}. 'wildignorecase' applies.
  1646. If {list} is given and it is |TRUE|, a List will be returned.
  1647. Otherwise the result is a String and when there are several
  1648. matches, they are separated by <NL> characters.
  1649. If the expansion fails, the result is an empty string. A name
  1650. for a non-existing file is not included, unless {string} does
  1651. not start with '%', '#' or '<', see below.
  1652. When {string} starts with '%', '#' or '<', the expansion is
  1653. done like for the |cmdline-special| variables with their
  1654. associated modifiers. Here is a short overview:
  1655. % current file name
  1656. # alternate file name
  1657. #n alternate file name n
  1658. <cfile> file name under the cursor
  1659. <afile> autocmd file name
  1660. <abuf> autocmd buffer number (as a String!)
  1661. <amatch> autocmd matched name
  1662. <cexpr> C expression under the cursor
  1663. <sfile> sourced script file or function name
  1664. <slnum> sourced script line number or function
  1665. line number
  1666. <sflnum> script file line number, also when in
  1667. a function
  1668. <SID> "<SNR>123_" where "123" is the
  1669. current script ID |<SID>|
  1670. <script> sourced script file, or script file
  1671. where the current function was defined
  1672. <stack> call stack
  1673. <cword> word under the cursor
  1674. <cWORD> WORD under the cursor
  1675. <client> the {clientid} of the last received
  1676. message
  1677. Modifiers:
  1678. :p expand to full path
  1679. :h head (last path component removed)
  1680. :t tail (last path component only)
  1681. :r root (one extension removed)
  1682. :e extension only
  1683. Example: >vim
  1684. let &tags = expand("%:p:h") .. "/tags"
  1685. < Note that when expanding a string that starts with '%', '#' or
  1686. '<', any following text is ignored. This does NOT work: >vim
  1687. let doesntwork = expand("%:h.bak")
  1688. < Use this: >vim
  1689. let doeswork = expand("%:h") .. ".bak"
  1690. < Also note that expanding "<cfile>" and others only returns the
  1691. referenced file name without further expansion. If "<cfile>"
  1692. is "~/.cshrc", you need to do another expand() to have the
  1693. "~/" expanded into the path of the home directory: >vim
  1694. echo expand(expand("<cfile>"))
  1695. <
  1696. There cannot be white space between the variables and the
  1697. following modifier. The |fnamemodify()| function can be used
  1698. to modify normal file names.
  1699. When using '%' or '#', and the current or alternate file name
  1700. is not defined, an empty string is used. Using "%:p" in a
  1701. buffer with no name, results in the current directory, with a
  1702. '/' added.
  1703. When 'verbose' is set then expanding '%', '#' and <> items
  1704. will result in an error message if the argument cannot be
  1705. expanded.
  1706. When {string} does not start with '%', '#' or '<', it is
  1707. expanded like a file name is expanded on the command line.
  1708. 'suffixes' and 'wildignore' are used, unless the optional
  1709. {nosuf} argument is given and it is |TRUE|.
  1710. Names for non-existing files are included. The "**" item can
  1711. be used to search in a directory tree. For example, to find
  1712. all "README" files in the current directory and below: >vim
  1713. echo expand("**/README")
  1714. <
  1715. expand() can also be used to expand variables and environment
  1716. variables that are only known in a shell. But this can be
  1717. slow, because a shell may be used to do the expansion. See
  1718. |expr-env-expand|.
  1719. The expanded variable is still handled like a list of file
  1720. names. When an environment variable cannot be expanded, it is
  1721. left unchanged. Thus ":echo expand('$FOOBAR')" results in
  1722. "$FOOBAR".
  1723. See |glob()| for finding existing files. See |system()| for
  1724. getting the raw output of an external command.
  1725. Parameters: ~
  1726. • {string} (`string`)
  1727. • {nosuf} (`boolean?`)
  1728. • {list} (`nil|false?`)
  1729. Return: ~
  1730. (`string`)
  1731. expandcmd({string} [, {options}]) *expandcmd()*
  1732. Expand special items in String {string} like what is done for
  1733. an Ex command such as `:edit`. This expands special keywords,
  1734. like with |expand()|, and environment variables, anywhere in
  1735. {string}. "~user" and "~/path" are only expanded at the
  1736. start.
  1737. The following items are supported in the {options} Dict
  1738. argument:
  1739. errmsg If set to TRUE, error messages are displayed
  1740. if an error is encountered during expansion.
  1741. By default, error messages are not displayed.
  1742. Returns the expanded string. If an error is encountered
  1743. during expansion, the unmodified {string} is returned.
  1744. Example: >vim
  1745. echo expandcmd('make %<.o')
  1746. < >
  1747. make /path/runtime/doc/builtin.o
  1748. < >vim
  1749. echo expandcmd('make %<.o', {'errmsg': v:true})
  1750. <
  1751. Parameters: ~
  1752. • {string} (`string`)
  1753. • {options} (`table?`)
  1754. Return: ~
  1755. (`any`)
  1756. extend({expr1}, {expr2} [, {expr3}]) *extend()*
  1757. {expr1} and {expr2} must be both |Lists| or both
  1758. |Dictionaries|.
  1759. If they are |Lists|: Append {expr2} to {expr1}.
  1760. If {expr3} is given insert the items of {expr2} before the
  1761. item with index {expr3} in {expr1}. When {expr3} is zero
  1762. insert before the first item. When {expr3} is equal to
  1763. len({expr1}) then {expr2} is appended.
  1764. Examples: >vim
  1765. echo sort(extend(mylist, [7, 5]))
  1766. call extend(mylist, [2, 3], 1)
  1767. < When {expr1} is the same List as {expr2} then the number of
  1768. items copied is equal to the original length of the List.
  1769. E.g., when {expr3} is 1 you get N new copies of the first item
  1770. (where N is the original length of the List).
  1771. Use |add()| to concatenate one item to a list. To concatenate
  1772. two lists into a new list use the + operator: >vim
  1773. let newlist = [1, 2, 3] + [4, 5]
  1774. <
  1775. If they are |Dictionaries|:
  1776. Add all entries from {expr2} to {expr1}.
  1777. If a key exists in both {expr1} and {expr2} then {expr3} is
  1778. used to decide what to do:
  1779. {expr3} = "keep": keep the value of {expr1}
  1780. {expr3} = "force": use the value of {expr2}
  1781. {expr3} = "error": give an error message *E737*
  1782. When {expr3} is omitted then "force" is assumed.
  1783. {expr1} is changed when {expr2} is not empty. If necessary
  1784. make a copy of {expr1} first.
  1785. {expr2} remains unchanged.
  1786. When {expr1} is locked and {expr2} is not empty the operation
  1787. fails.
  1788. Returns {expr1}. Returns 0 on error.
  1789. Parameters: ~
  1790. • {expr1} (`table`)
  1791. • {expr2} (`table`)
  1792. • {expr3} (`table?`)
  1793. Return: ~
  1794. (`any`)
  1795. extendnew({expr1}, {expr2} [, {expr3}]) *extendnew()*
  1796. Like |extend()| but instead of adding items to {expr1} a new
  1797. List or Dictionary is created and returned. {expr1} remains
  1798. unchanged.
  1799. Parameters: ~
  1800. • {expr1} (`table`)
  1801. • {expr2} (`table`)
  1802. • {expr3} (`table?`)
  1803. Return: ~
  1804. (`any`)
  1805. feedkeys({string} [, {mode}]) *feedkeys()*
  1806. Characters in {string} are queued for processing as if they
  1807. come from a mapping or were typed by the user.
  1808. By default the string is added to the end of the typeahead
  1809. buffer, thus if a mapping is still being executed the
  1810. characters come after them. Use the 'i' flag to insert before
  1811. other characters, they will be executed next, before any
  1812. characters from a mapping.
  1813. The function does not wait for processing of keys contained in
  1814. {string}.
  1815. To include special keys into {string}, use double-quotes
  1816. and "\..." notation |expr-quote|. For example,
  1817. feedkeys("\<CR>") simulates pressing of the <Enter> key. But
  1818. feedkeys('\<CR>') pushes 5 characters.
  1819. The |<Ignore>| keycode may be used to exit the
  1820. wait-for-character without doing anything.
  1821. {mode} is a String, which can contain these character flags:
  1822. 'm' Remap keys. This is default. If {mode} is absent,
  1823. keys are remapped.
  1824. 'n' Do not remap keys.
  1825. 't' Handle keys as if typed; otherwise they are handled as
  1826. if coming from a mapping. This matters for undo,
  1827. opening folds, etc.
  1828. 'L' Lowlevel input. Other flags are not used.
  1829. 'i' Insert the string instead of appending (see above).
  1830. 'x' Execute commands until typeahead is empty. This is
  1831. similar to using ":normal!". You can call feedkeys()
  1832. several times without 'x' and then one time with 'x'
  1833. (possibly with an empty {string}) to execute all the
  1834. typeahead. Note that when Vim ends in Insert mode it
  1835. will behave as if <Esc> is typed, to avoid getting
  1836. stuck, waiting for a character to be typed before the
  1837. script continues.
  1838. Note that if you manage to call feedkeys() while
  1839. executing commands, thus calling it recursively, then
  1840. all typeahead will be consumed by the last call.
  1841. '!' When used with 'x' will not end Insert mode. Can be
  1842. used in a test when a timer is set to exit Insert mode
  1843. a little later. Useful for testing CursorHoldI.
  1844. Return value is always 0.
  1845. Parameters: ~
  1846. • {string} (`string`)
  1847. • {mode} (`string?`)
  1848. Return: ~
  1849. (`any`)
  1850. filecopy({from}, {to}) *filecopy()*
  1851. Copy the file pointed to by the name {from} to {to}. The
  1852. result is a Number, which is |TRUE| if the file was copied
  1853. successfully, and |FALSE| when it failed.
  1854. If a file with name {to} already exists, it will fail.
  1855. Note that it does not handle directories (yet).
  1856. This function is not available in the |sandbox|.
  1857. Parameters: ~
  1858. • {from} (`string`)
  1859. • {to} (`string`)
  1860. Return: ~
  1861. (`0|1`)
  1862. filereadable({file}) *filereadable()*
  1863. The result is a Number, which is |TRUE| when a file with the
  1864. name {file} exists, and can be read. If {file} doesn't exist,
  1865. or is a directory, the result is |FALSE|. {file} is any
  1866. expression, which is used as a String.
  1867. If you don't care about the file being readable you can use
  1868. |glob()|.
  1869. {file} is used as-is, you may want to expand wildcards first: >vim
  1870. echo filereadable('~/.vimrc')
  1871. < >
  1872. 0
  1873. < >vim
  1874. echo filereadable(expand('~/.vimrc'))
  1875. < >
  1876. 1
  1877. <
  1878. Parameters: ~
  1879. • {file} (`string`)
  1880. Return: ~
  1881. (`0|1`)
  1882. filewritable({file}) *filewritable()*
  1883. The result is a Number, which is 1 when a file with the
  1884. name {file} exists, and can be written. If {file} doesn't
  1885. exist, or is not writable, the result is 0. If {file} is a
  1886. directory, and we can write to it, the result is 2.
  1887. Parameters: ~
  1888. • {file} (`string`)
  1889. Return: ~
  1890. (`0|1`)
  1891. filter({expr1}, {expr2}) *filter()*
  1892. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  1893. For each item in {expr1} evaluate {expr2} and when the result
  1894. is zero or false remove the item from the |List| or
  1895. |Dictionary|. Similarly for each byte in a |Blob| and each
  1896. character in a |String|.
  1897. {expr2} must be a |string| or |Funcref|.
  1898. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  1899. of the current item. For a |Dictionary| |v:key| has the key
  1900. of the current item and for a |List| |v:key| has the index of
  1901. the current item. For a |Blob| |v:key| has the index of the
  1902. current byte. For a |String| |v:key| has the index of the
  1903. current character.
  1904. Examples: >vim
  1905. call filter(mylist, 'v:val !~ "OLD"')
  1906. < Removes the items where "OLD" appears. >vim
  1907. call filter(mydict, 'v:key >= 8')
  1908. < Removes the items with a key below 8. >vim
  1909. call filter(var, 0)
  1910. < Removes all the items, thus clears the |List| or |Dictionary|.
  1911. Note that {expr2} is the result of expression and is then
  1912. used as an expression again. Often it is good to use a
  1913. |literal-string| to avoid having to double backslashes.
  1914. If {expr2} is a |Funcref| it must take two arguments:
  1915. 1. the key or the index of the current item.
  1916. 2. the value of the current item.
  1917. The function must return |TRUE| if the item should be kept.
  1918. Example that keeps the odd items of a list: >vim
  1919. func Odd(idx, val)
  1920. return a:idx % 2 == 1
  1921. endfunc
  1922. call filter(mylist, function('Odd'))
  1923. < It is shorter when using a |lambda|: >vim
  1924. call filter(myList, {idx, val -> idx * val <= 42})
  1925. < If you do not use "val" you can leave it out: >vim
  1926. call filter(myList, {idx -> idx % 2 == 1})
  1927. <
  1928. For a |List| and a |Dictionary| the operation is done
  1929. in-place. If you want it to remain unmodified make a copy
  1930. first: >vim
  1931. let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  1932. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  1933. or a new |Blob| or |String|.
  1934. When an error is encountered while evaluating {expr2} no
  1935. further items in {expr1} are processed.
  1936. When {expr2} is a Funcref errors inside a function are ignored,
  1937. unless it was defined with the "abort" flag.
  1938. Parameters: ~
  1939. • {expr1} (`string|table`)
  1940. • {expr2} (`string|function`)
  1941. Return: ~
  1942. (`any`)
  1943. finddir({name} [, {path} [, {count}]]) *finddir()*
  1944. Find directory {name} in {path}. Supports both downwards and
  1945. upwards recursive directory searches. See |file-searching|
  1946. for the syntax of {path}.
  1947. Returns the path of the first found match. When the found
  1948. directory is below the current directory a relative path is
  1949. returned. Otherwise a full path is returned.
  1950. If {path} is omitted or empty then 'path' is used.
  1951. If the optional {count} is given, find {count}'s occurrence of
  1952. {name} in {path} instead of the first one.
  1953. When {count} is negative return all the matches in a |List|.
  1954. Returns an empty string if the directory is not found.
  1955. This is quite similar to the ex-command `:find`.
  1956. Parameters: ~
  1957. • {name} (`string`)
  1958. • {path} (`string?`)
  1959. • {count} (`integer?`)
  1960. Return: ~
  1961. (`any`)
  1962. findfile({name} [, {path} [, {count}]]) *findfile()*
  1963. Just like |finddir()|, but find a file instead of a directory.
  1964. Uses 'suffixesadd'.
  1965. Example: >vim
  1966. echo findfile("tags.vim", ".;")
  1967. < Searches from the directory of the current file upwards until
  1968. it finds the file "tags.vim".
  1969. Parameters: ~
  1970. • {name} (`string`)
  1971. • {path} (`string?`)
  1972. • {count} (`any?`)
  1973. Return: ~
  1974. (`any`)
  1975. flatten({list} [, {maxdepth}]) *flatten()*
  1976. Flatten {list} up to {maxdepth} levels. Without {maxdepth}
  1977. the result is a |List| without nesting, as if {maxdepth} is
  1978. a very large number.
  1979. The {list} is changed in place, use |flattennew()| if you do
  1980. not want that.
  1981. *E900*
  1982. {maxdepth} means how deep in nested lists changes are made.
  1983. {list} is not modified when {maxdepth} is 0.
  1984. {maxdepth} must be positive number.
  1985. If there is an error the number zero is returned.
  1986. Example: >vim
  1987. echo flatten([1, [2, [3, 4]], 5])
  1988. < [1, 2, 3, 4, 5] >vim
  1989. echo flatten([1, [2, [3, 4]], 5], 1)
  1990. < [1, 2, [3, 4], 5]
  1991. Parameters: ~
  1992. • {list} (`any[]`)
  1993. • {maxdepth} (`integer?`)
  1994. Return: ~
  1995. (`any[]|0`)
  1996. flattennew({list} [, {maxdepth}]) *flattennew()*
  1997. Like |flatten()| but first make a copy of {list}.
  1998. Parameters: ~
  1999. • {list} (`any[]`)
  2000. • {maxdepth} (`integer?`)
  2001. Return: ~
  2002. (`any[]|0`)
  2003. float2nr({expr}) *float2nr()*
  2004. Convert {expr} to a Number by omitting the part after the
  2005. decimal point.
  2006. {expr} must evaluate to a |Float| or a |Number|.
  2007. Returns 0 if {expr} is not a |Float| or a |Number|.
  2008. When the value of {expr} is out of range for a |Number| the
  2009. result is truncated to 0x7fffffff or -0x7fffffff (or when
  2010. 64-bit Number support is enabled, 0x7fffffffffffffff or
  2011. -0x7fffffffffffffff). NaN results in -0x80000000 (or when
  2012. 64-bit Number support is enabled, -0x8000000000000000).
  2013. Examples: >vim
  2014. echo float2nr(3.95)
  2015. < 3 >vim
  2016. echo float2nr(-23.45)
  2017. < -23 >vim
  2018. echo float2nr(1.0e100)
  2019. < 2147483647 (or 9223372036854775807) >vim
  2020. echo float2nr(-1.0e150)
  2021. < -2147483647 (or -9223372036854775807) >vim
  2022. echo float2nr(1.0e-100)
  2023. < 0
  2024. Parameters: ~
  2025. • {expr} (`number`)
  2026. Return: ~
  2027. (`any`)
  2028. floor({expr}) *floor()*
  2029. Return the largest integral value less than or equal to
  2030. {expr} as a |Float| (round down).
  2031. {expr} must evaluate to a |Float| or a |Number|.
  2032. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  2033. Examples: >vim
  2034. echo floor(1.856)
  2035. < 1.0 >vim
  2036. echo floor(-5.456)
  2037. < -6.0 >vim
  2038. echo floor(4.0)
  2039. < 4.0
  2040. Parameters: ~
  2041. • {expr} (`number`)
  2042. Return: ~
  2043. (`any`)
  2044. fmod({expr1}, {expr2}) *fmod()*
  2045. Return the remainder of {expr1} / {expr2}, even if the
  2046. division is not representable. Returns {expr1} - i * {expr2}
  2047. for some integer i such that if {expr2} is non-zero, the
  2048. result has the same sign as {expr1} and magnitude less than
  2049. the magnitude of {expr2}. If {expr2} is zero, the value
  2050. returned is zero. The value returned is a |Float|.
  2051. {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  2052. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  2053. |Number|.
  2054. Examples: >vim
  2055. echo fmod(12.33, 1.22)
  2056. < 0.13 >vim
  2057. echo fmod(-12.33, 1.22)
  2058. < -0.13
  2059. Parameters: ~
  2060. • {expr1} (`number`)
  2061. • {expr2} (`number`)
  2062. Return: ~
  2063. (`any`)
  2064. fnameescape({string}) *fnameescape()*
  2065. Escape {string} for use as file name command argument. All
  2066. characters that have a special meaning, such as `'%'` and `'|'`
  2067. are escaped with a backslash.
  2068. For most systems the characters escaped are
  2069. " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
  2070. appears in a filename, it depends on the value of 'isfname'.
  2071. A leading '+' and '>' is also escaped (special after |:edit|
  2072. and |:write|). And a "-" by itself (special after |:cd|).
  2073. Returns an empty string on error.
  2074. Example: >vim
  2075. let fname = '+some str%nge|name'
  2076. exe "edit " .. fnameescape(fname)
  2077. < results in executing: >vim
  2078. edit \+some\ str\%nge\|name
  2079. <
  2080. Parameters: ~
  2081. • {string} (`string`)
  2082. Return: ~
  2083. (`string`)
  2084. fnamemodify({fname}, {mods}) *fnamemodify()*
  2085. Modify file name {fname} according to {mods}. {mods} is a
  2086. string of characters like it is used for file names on the
  2087. command line. See |filename-modifiers|.
  2088. Example: >vim
  2089. echo fnamemodify("main.c", ":p:h")
  2090. < results in: >
  2091. /home/user/vim/vim/src
  2092. < If {mods} is empty or an unsupported modifier is used then
  2093. {fname} is returned.
  2094. When {fname} is empty then with {mods} ":h" returns ".", so
  2095. that `:cd` can be used with it. This is different from
  2096. expand('%:h') without a buffer name, which returns an empty
  2097. string.
  2098. Note: Environment variables don't work in {fname}, use
  2099. |expand()| first then.
  2100. Parameters: ~
  2101. • {fname} (`string`)
  2102. • {mods} (`string`)
  2103. Return: ~
  2104. (`string`)
  2105. foldclosed({lnum}) *foldclosed()*
  2106. The result is a Number. If the line {lnum} is in a closed
  2107. fold, the result is the number of the first line in that fold.
  2108. If the line {lnum} is not in a closed fold, -1 is returned.
  2109. {lnum} is used like with |getline()|. Thus "." is the current
  2110. line, "'m" mark m, etc.
  2111. Parameters: ~
  2112. • {lnum} (`integer`)
  2113. Return: ~
  2114. (`integer`)
  2115. foldclosedend({lnum}) *foldclosedend()*
  2116. The result is a Number. If the line {lnum} is in a closed
  2117. fold, the result is the number of the last line in that fold.
  2118. If the line {lnum} is not in a closed fold, -1 is returned.
  2119. {lnum} is used like with |getline()|. Thus "." is the current
  2120. line, "'m" mark m, etc.
  2121. Parameters: ~
  2122. • {lnum} (`integer`)
  2123. Return: ~
  2124. (`integer`)
  2125. foldlevel({lnum}) *foldlevel()*
  2126. The result is a Number, which is the foldlevel of line {lnum}
  2127. in the current buffer. For nested folds the deepest level is
  2128. returned. If there is no fold at line {lnum}, zero is
  2129. returned. It doesn't matter if the folds are open or closed.
  2130. When used while updating folds (from 'foldexpr') -1 is
  2131. returned for lines where folds are still to be updated and the
  2132. foldlevel is unknown. As a special case the level of the
  2133. previous line is usually available.
  2134. {lnum} is used like with |getline()|. Thus "." is the current
  2135. line, "'m" mark m, etc.
  2136. Parameters: ~
  2137. • {lnum} (`integer`)
  2138. Return: ~
  2139. (`integer`)
  2140. foldtext() *foldtext()*
  2141. Returns a String, to be displayed for a closed fold. This is
  2142. the default function used for the 'foldtext' option and should
  2143. only be called from evaluating 'foldtext'. It uses the
  2144. |v:foldstart|, |v:foldend| and |v:folddashes| variables.
  2145. The returned string looks like this: >
  2146. +-- 45 lines: abcdef
  2147. < The number of leading dashes depends on the foldlevel. The
  2148. "45" is the number of lines in the fold. "abcdef" is the text
  2149. in the first non-blank line of the fold. Leading white space,
  2150. "//" or "/*" and the text from the 'foldmarker' and
  2151. 'commentstring' options is removed.
  2152. When used to draw the actual foldtext, the rest of the line
  2153. will be filled with the fold char from the 'fillchars'
  2154. setting.
  2155. Returns an empty string when there is no fold.
  2156. Return: ~
  2157. (`string`)
  2158. foldtextresult({lnum}) *foldtextresult()*
  2159. Returns the text that is displayed for the closed fold at line
  2160. {lnum}. Evaluates 'foldtext' in the appropriate context.
  2161. When there is no closed fold at {lnum} an empty string is
  2162. returned.
  2163. {lnum} is used like with |getline()|. Thus "." is the current
  2164. line, "'m" mark m, etc.
  2165. Useful when exporting folded text, e.g., to HTML.
  2166. Parameters: ~
  2167. • {lnum} (`integer`)
  2168. Return: ~
  2169. (`string`)
  2170. foreach({expr1}, {expr2}) *foreach()*
  2171. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  2172. For each item in {expr1} execute {expr2}. {expr1} is not
  2173. modified; its values may be, as with |:lockvar| 1. |E741|
  2174. See |map()| and |filter()| to modify {expr1}.
  2175. {expr2} must be a |string| or |Funcref|.
  2176. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  2177. of the current item. For a |Dictionary| |v:key| has the key
  2178. of the current item and for a |List| |v:key| has the index of
  2179. the current item. For a |Blob| |v:key| has the index of the
  2180. current byte. For a |String| |v:key| has the index of the
  2181. current character.
  2182. Examples: >vim
  2183. call foreach(mylist, 'let used[v:val] = v:true')
  2184. < This records the items that are in the {expr1} list.
  2185. Note that {expr2} is the result of expression and is then used
  2186. as a command. Often it is good to use a |literal-string| to
  2187. avoid having to double backslashes.
  2188. If {expr2} is a |Funcref| it must take two arguments:
  2189. 1. the key or the index of the current item.
  2190. 2. the value of the current item.
  2191. With a lambda you don't get an error if it only accepts one
  2192. argument.
  2193. If the function returns a value, it is ignored.
  2194. Returns {expr1} in all cases.
  2195. When an error is encountered while executing {expr2} no
  2196. further items in {expr1} are processed.
  2197. When {expr2} is a Funcref errors inside a function are ignored,
  2198. unless it was defined with the "abort" flag.
  2199. Parameters: ~
  2200. • {expr1} (`string|table`)
  2201. • {expr2} (`string|function`)
  2202. Return: ~
  2203. (`string|table`)
  2204. fullcommand({name}) *fullcommand()*
  2205. Get the full command name from a short abbreviated command
  2206. name; see |20.2| for details on command abbreviations.
  2207. The string argument {name} may start with a `:` and can
  2208. include a [range], these are skipped and not returned.
  2209. Returns an empty string if a command doesn't exist or if it's
  2210. ambiguous (for user-defined commands).
  2211. For example `fullcommand('s')`, `fullcommand('sub')`,
  2212. `fullcommand(':%substitute')` all return "substitute".
  2213. Parameters: ~
  2214. • {name} (`string`)
  2215. Return: ~
  2216. (`string`)
  2217. funcref({name} [, {arglist}] [, {dict}]) *funcref()*
  2218. Just like |function()|, but the returned Funcref will lookup
  2219. the function by reference, not by name. This matters when the
  2220. function {name} is redefined later.
  2221. Unlike |function()|, {name} must be an existing user function.
  2222. It only works for an autoloaded function if it has already
  2223. been loaded (to avoid mistakenly loading the autoload script
  2224. when only intending to use the function name, use |function()|
  2225. instead). {name} cannot be a builtin function.
  2226. Returns 0 on error.
  2227. Parameters: ~
  2228. • {name} (`string`)
  2229. • {arglist} (`any?`)
  2230. • {dict} (`any?`)
  2231. Return: ~
  2232. (`any`)
  2233. function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923*
  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.: >vim
  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: >vim
  2251. func Callback(arg1, arg2, name)
  2252. "...
  2253. endfunc
  2254. let Partial = function('Callback', ['one', 'two'])
  2255. "...
  2256. call Partial('name')
  2257. < Invokes the function as with: >vim
  2258. call Callback('one', 'two', 'name')
  2259. < With a |method|: >vim
  2260. func Callback(one, two, three)
  2261. "...
  2262. endfunc
  2263. let Partial = function('Callback', ['two'])
  2264. "...
  2265. eval 'one'->Partial('three')
  2266. < Invokes the function as with: >vim
  2267. call Callback('one', 'two', 'three')
  2268. < The function() call can be nested to add more arguments to the
  2269. Funcref. The extra arguments are appended to the list of
  2270. arguments. Example: >vim
  2271. func Callback(arg1, arg2, name)
  2272. "...
  2273. endfunc
  2274. let Func = function('Callback', ['one'])
  2275. let Func2 = function(Func, ['two'])
  2276. "...
  2277. call Func2('name')
  2278. < Invokes the function as with: >vim
  2279. call Callback('one', 'two', 'name')
  2280. < The Dictionary is only useful when calling a "dict" function.
  2281. In that case the {dict} is passed in as "self". Example: >vim
  2282. function Callback() dict
  2283. echo "called for " .. self.name
  2284. endfunction
  2285. "...
  2286. let context = {"name": "example"}
  2287. let Func = function('Callback', context)
  2288. "...
  2289. call Func() " will echo: called for example
  2290. < The use of function() is not needed when there are no extra
  2291. arguments, these two are equivalent, if Callback() is defined
  2292. as context.Callback(): >vim
  2293. let Func = function('Callback', context)
  2294. let Func = context.Callback
  2295. < The argument list and the Dictionary can be combined: >vim
  2296. function Callback(arg1, count) dict
  2297. "...
  2298. endfunction
  2299. let context = {"name": "example"}
  2300. let Func = function('Callback', ['one'], context)
  2301. "...
  2302. call Func(500)
  2303. < Invokes the function as with: >vim
  2304. call context.Callback('one', 500)
  2305. <
  2306. Returns 0 on error.
  2307. Parameters: ~
  2308. • {name} (`string`)
  2309. • {arglist} (`any?`)
  2310. • {dict} (`any?`)
  2311. Return: ~
  2312. (`any`)
  2313. garbagecollect([{atexit}]) *garbagecollect()*
  2314. Cleanup unused |Lists| and |Dictionaries| that have circular
  2315. references.
  2316. There is hardly ever a need to invoke this function, as it is
  2317. automatically done when Vim runs out of memory or is waiting
  2318. for the user to press a key after 'updatetime'. Items without
  2319. circular references are always freed when they become unused.
  2320. This is useful if you have deleted a very big |List| and/or
  2321. |Dictionary| with circular references in a script that runs
  2322. for a long time.
  2323. When the optional {atexit} argument is one, garbage
  2324. collection will also be done when exiting Vim, if it wasn't
  2325. done before. This is useful when checking for memory leaks.
  2326. The garbage collection is not done immediately but only when
  2327. it's safe to perform. This is when waiting for the user to
  2328. type a character.
  2329. Parameters: ~
  2330. • {atexit} (`boolean?`)
  2331. Return: ~
  2332. (`any`)
  2333. get({list}, {idx} [, {default}]) *get()* *get()-list*
  2334. Get item {idx} from |List| {list}. When this item is not
  2335. available return {default}. Return zero when {default} is
  2336. omitted.
  2337. Parameters: ~
  2338. • {list} (`any[]`)
  2339. • {idx} (`integer`)
  2340. • {default} (`any?`)
  2341. Return: ~
  2342. (`any`)
  2343. get({blob}, {idx} [, {default}]) *get()-blob*
  2344. Get byte {idx} from |Blob| {blob}. When this byte is not
  2345. available return {default}. Return -1 when {default} is
  2346. omitted.
  2347. Parameters: ~
  2348. • {blob} (`string`)
  2349. • {idx} (`integer`)
  2350. • {default} (`any?`)
  2351. Return: ~
  2352. (`any`)
  2353. get({dict}, {key} [, {default}]) *get()-dict*
  2354. Get item with key {key} from |Dictionary| {dict}. When this
  2355. item is not available return {default}. Return zero when
  2356. {default} is omitted. Useful example: >vim
  2357. let val = get(g:, 'var_name', 'default')
  2358. < This gets the value of g:var_name if it exists, and uses
  2359. "default" when it does not exist.
  2360. Parameters: ~
  2361. • {dict} (`table<string,any>`)
  2362. • {key} (`string`)
  2363. • {default} (`any?`)
  2364. Return: ~
  2365. (`any`)
  2366. get({func}, {what}) *get()-func*
  2367. Get item {what} from |Funcref| {func}. Possible values for
  2368. {what} are:
  2369. "name" The function name
  2370. "func" The function
  2371. "dict" The dictionary
  2372. "args" The list with arguments
  2373. "arity" A dictionary with information about the number of
  2374. arguments accepted by the function (minus the
  2375. {arglist}) with the following fields:
  2376. required the number of positional arguments
  2377. optional the number of optional arguments,
  2378. in addition to the required ones
  2379. varargs |TRUE| if the function accepts a
  2380. variable number of arguments |...|
  2381. Note: There is no error, if the {arglist} of
  2382. the Funcref contains more arguments than the
  2383. Funcref expects, it's not validated.
  2384. Returns zero on error.
  2385. Parameters: ~
  2386. • {func} (`function`)
  2387. • {what} (`string`)
  2388. Return: ~
  2389. (`any`)
  2390. getbufinfo([{buf}]) *getbufinfo()*
  2391. getbufinfo([{dict}])
  2392. Get information about buffers as a List of Dictionaries.
  2393. Without an argument information about all the buffers is
  2394. returned.
  2395. When the argument is a |Dictionary| only the buffers matching
  2396. the specified criteria are returned. The following keys can
  2397. be specified in {dict}:
  2398. buflisted include only listed buffers.
  2399. bufloaded include only loaded buffers.
  2400. bufmodified include only modified buffers.
  2401. Otherwise, {buf} specifies a particular buffer to return
  2402. information for. For the use of {buf}, see |bufname()|
  2403. above. If the buffer is found the returned List has one item.
  2404. Otherwise the result is an empty list.
  2405. Each returned List item is a dictionary with the following
  2406. entries:
  2407. bufnr Buffer number.
  2408. changed TRUE if the buffer is modified.
  2409. changedtick Number of changes made to the buffer.
  2410. command TRUE if the buffer belongs to the
  2411. command-line window |cmdwin|.
  2412. hidden TRUE if the buffer is hidden.
  2413. lastused Timestamp in seconds, like
  2414. |localtime()|, when the buffer was
  2415. last used.
  2416. listed TRUE if the buffer is listed.
  2417. lnum Line number used for the buffer when
  2418. opened in the current window.
  2419. Only valid if the buffer has been
  2420. displayed in the window in the past.
  2421. If you want the line number of the
  2422. last known cursor position in a given
  2423. window, use |line()|: >vim
  2424. echo line('.', {winid})
  2425. <
  2426. linecount Number of lines in the buffer (only
  2427. valid when loaded)
  2428. loaded TRUE if the buffer is loaded.
  2429. name Full path to the file in the buffer.
  2430. signs List of signs placed in the buffer.
  2431. Each list item is a dictionary with
  2432. the following fields:
  2433. id sign identifier
  2434. lnum line number
  2435. name sign name
  2436. variables A reference to the dictionary with
  2437. buffer-local variables.
  2438. windows List of |window-ID|s that display this
  2439. buffer
  2440. Examples: >vim
  2441. for buf in getbufinfo()
  2442. echo buf.name
  2443. endfor
  2444. for buf in getbufinfo({'buflisted':1})
  2445. if buf.changed
  2446. " ....
  2447. endif
  2448. endfor
  2449. <
  2450. To get buffer-local options use: >vim
  2451. getbufvar({bufnr}, '&option_name')
  2452. <
  2453. Parameters: ~
  2454. • {dict} (`vim.fn.getbufinfo.dict?`)
  2455. Return: ~
  2456. (`vim.fn.getbufinfo.ret.item[]`)
  2457. getbufline({buf}, {lnum} [, {end}]) *getbufline()*
  2458. Return a |List| with the lines starting from {lnum} to {end}
  2459. (inclusive) in the buffer {buf}. If {end} is omitted, a
  2460. |List| with only the line {lnum} is returned. See
  2461. `getbufoneline()` for only getting the line.
  2462. For the use of {buf}, see |bufname()| above.
  2463. For {lnum} and {end} "$" can be used for the last line of the
  2464. buffer. Otherwise a number must be used.
  2465. When {lnum} is smaller than 1 or bigger than the number of
  2466. lines in the buffer, an empty |List| is returned.
  2467. When {end} is greater than the number of lines in the buffer,
  2468. it is treated as {end} is set to the number of lines in the
  2469. buffer. When {end} is before {lnum} an empty |List| is
  2470. returned.
  2471. This function works only for loaded buffers. For unloaded and
  2472. non-existing buffers, an empty |List| is returned.
  2473. Example: >vim
  2474. let lines = getbufline(bufnr("myfile"), 1, "$")
  2475. <
  2476. Parameters: ~
  2477. • {buf} (`integer|string`)
  2478. • {lnum} (`integer`)
  2479. • {end} (`integer?`)
  2480. Return: ~
  2481. (`string[]`)
  2482. getbufoneline({buf}, {lnum}) *getbufoneline()*
  2483. Just like `getbufline()` but only get one line and return it
  2484. as a string.
  2485. Parameters: ~
  2486. • {buf} (`integer|string`)
  2487. • {lnum} (`integer`)
  2488. Return: ~
  2489. (`string`)
  2490. getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
  2491. The result is the value of option or local buffer variable
  2492. {varname} in buffer {buf}. Note that the name without "b:"
  2493. must be used.
  2494. The {varname} argument is a string.
  2495. When {varname} is empty returns a |Dictionary| with all the
  2496. buffer-local variables.
  2497. When {varname} is equal to "&" returns a |Dictionary| with all
  2498. the buffer-local options.
  2499. Otherwise, when {varname} starts with "&" returns the value of
  2500. a buffer-local option.
  2501. This also works for a global or buffer-local option, but it
  2502. doesn't work for a global variable, window-local variable or
  2503. window-local option.
  2504. For the use of {buf}, see |bufname()| above.
  2505. When the buffer or variable doesn't exist {def} or an empty
  2506. string is returned, there is no error message.
  2507. Examples: >vim
  2508. let bufmodified = getbufvar(1, "&mod")
  2509. echo "todo myvar = " .. getbufvar("todo", "myvar")
  2510. Parameters: ~
  2511. • {buf} (`integer|string`)
  2512. • {varname} (`string`)
  2513. • {def} (`any?`)
  2514. Return: ~
  2515. (`any`)
  2516. getcellwidths() *getcellwidths()*
  2517. Returns a |List| of cell widths of character ranges overridden
  2518. by |setcellwidths()|. The format is equal to the argument of
  2519. |setcellwidths()|. If no character ranges have their cell
  2520. widths overridden, an empty List is returned.
  2521. Return: ~
  2522. (`any`)
  2523. getchangelist([{buf}]) *getchangelist()*
  2524. Returns the |changelist| for the buffer {buf}. For the use
  2525. of {buf}, see |bufname()| above. If buffer {buf} doesn't
  2526. exist, an empty list is returned.
  2527. The returned list contains two entries: a list with the change
  2528. locations and the current position in the list. Each
  2529. entry in the change list is a dictionary with the following
  2530. entries:
  2531. col column number
  2532. coladd column offset for 'virtualedit'
  2533. lnum line number
  2534. If buffer {buf} is the current buffer, then the current
  2535. position refers to the position in the list. For other
  2536. buffers, it is set to the length of the list.
  2537. Parameters: ~
  2538. • {buf} (`integer|string?`)
  2539. Return: ~
  2540. (`table[]`)
  2541. getchar([{expr}]) *getchar()*
  2542. Get a single character from the user or input stream.
  2543. If {expr} is omitted, wait until a character is available.
  2544. If {expr} is 0, only get a character when one is available.
  2545. Return zero otherwise.
  2546. If {expr} is 1, only check if a character is available, it is
  2547. not consumed. Return zero if no character available.
  2548. If you prefer always getting a string use |getcharstr()|.
  2549. Without {expr} and when {expr} is 0 a whole character or
  2550. special key is returned. If it is a single character, the
  2551. result is a Number. Use |nr2char()| to convert it to a String.
  2552. Otherwise a String is returned with the encoded character.
  2553. For a special key it's a String with a sequence of bytes
  2554. starting with 0x80 (decimal: 128). This is the same value as
  2555. the String "\<Key>", e.g., "\<Left>". The returned value is
  2556. also a String when a modifier (shift, control, alt) was used
  2557. that is not included in the character.
  2558. When {expr} is 0 and Esc is typed, there will be a short delay
  2559. while Vim waits to see if this is the start of an escape
  2560. sequence.
  2561. When {expr} is 1 only the first byte is returned. For a
  2562. one-byte character it is the character itself as a number.
  2563. Use nr2char() to convert it to a String.
  2564. Use getcharmod() to obtain any additional modifiers.
  2565. When the user clicks a mouse button, the mouse event will be
  2566. returned. The position can then be found in |v:mouse_col|,
  2567. |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
  2568. |getmousepos()| can also be used. Mouse move events will be
  2569. ignored.
  2570. This example positions the mouse as it would normally happen: >vim
  2571. let c = getchar()
  2572. if c == "\<LeftMouse>" && v:mouse_win > 0
  2573. exe v:mouse_win .. "wincmd w"
  2574. exe v:mouse_lnum
  2575. exe "normal " .. v:mouse_col .. "|"
  2576. endif
  2577. <
  2578. There is no prompt, you will somehow have to make clear to the
  2579. user that a character has to be typed. The screen is not
  2580. redrawn, e.g. when resizing the window.
  2581. There is no mapping for the character.
  2582. Key codes are replaced, thus when the user presses the <Del>
  2583. key you get the code for the <Del> key, not the raw character
  2584. sequence. Examples: >vim
  2585. getchar() == "\<Del>"
  2586. getchar() == "\<S-Left>"
  2587. < This example redefines "f" to ignore case: >vim
  2588. nmap f :call FindChar()<CR>
  2589. function FindChar()
  2590. let c = nr2char(getchar())
  2591. while col('.') < col('$') - 1
  2592. normal l
  2593. if getline('.')[col('.') - 1] ==? c
  2594. break
  2595. endif
  2596. endwhile
  2597. endfunction
  2598. <
  2599. Parameters: ~
  2600. • {expr} (`0|1?`)
  2601. Return: ~
  2602. (`integer`)
  2603. getcharmod() *getcharmod()*
  2604. The result is a Number which is the state of the modifiers for
  2605. the last obtained character with getchar() or in another way.
  2606. These values are added together:
  2607. 2 shift
  2608. 4 control
  2609. 8 alt (meta)
  2610. 16 meta (when it's different from ALT)
  2611. 32 mouse double click
  2612. 64 mouse triple click
  2613. 96 mouse quadruple click (== 32 + 64)
  2614. 128 command (Mac) or super
  2615. Only the modifiers that have not been included in the
  2616. character itself are obtained. Thus Shift-a results in "A"
  2617. without a modifier. Returns 0 if no modifiers are used.
  2618. Return: ~
  2619. (`integer`)
  2620. getcharpos({expr}) *getcharpos()*
  2621. Get the position for String {expr}. Same as |getpos()| but the
  2622. column number in the returned List is a character index
  2623. instead of a byte index.
  2624. If |getpos()| returns a very large column number, equal to
  2625. |v:maxcol|, then getcharpos() will return the character index
  2626. of the last character.
  2627. Example:
  2628. With the cursor on '세' in line 5 with text "여보세요": >vim
  2629. getcharpos('.') returns [0, 5, 3, 0]
  2630. getpos('.') returns [0, 5, 7, 0]
  2631. <
  2632. Parameters: ~
  2633. • {expr} (`string`)
  2634. Return: ~
  2635. (`integer[]`)
  2636. getcharsearch() *getcharsearch()*
  2637. Return the current character search information as a {dict}
  2638. with the following entries:
  2639. char character previously used for a character
  2640. search (|t|, |f|, |T|, or |F|); empty string
  2641. if no character search has been performed
  2642. forward direction of character search; 1 for forward,
  2643. 0 for backward
  2644. until type of character search; 1 for a |t| or |T|
  2645. character search, 0 for an |f| or |F|
  2646. character search
  2647. This can be useful to always have |;| and |,| search
  2648. forward/backward regardless of the direction of the previous
  2649. character search: >vim
  2650. nnoremap <expr> ; getcharsearch().forward ? ';' : ','
  2651. nnoremap <expr> , getcharsearch().forward ? ',' : ';'
  2652. < Also see |setcharsearch()|.
  2653. Return: ~
  2654. (`table`)
  2655. getcharstr([{expr}]) *getcharstr()*
  2656. Get a single character from the user or input stream as a
  2657. string.
  2658. If {expr} is omitted, wait until a character is available.
  2659. If {expr} is 0 or false, only get a character when one is
  2660. available. Return an empty string otherwise.
  2661. If {expr} is 1 or true, only check if a character is
  2662. available, it is not consumed. Return an empty string
  2663. if no character is available.
  2664. Otherwise this works like |getchar()|, except that a number
  2665. result is converted to a string.
  2666. Parameters: ~
  2667. • {expr} (`0|1?`)
  2668. Return: ~
  2669. (`string`)
  2670. getcmdcomplpat() *getcmdcomplpat()*
  2671. Return completion pattern of the current command-line.
  2672. Only works when the command line is being edited, thus
  2673. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2674. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2675. |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
  2676. Returns an empty string when completion is not defined.
  2677. Return: ~
  2678. (`string`)
  2679. getcmdcompltype() *getcmdcompltype()*
  2680. Return the type of the current command-line completion.
  2681. Only works when the command line is being edited, thus
  2682. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2683. See |:command-completion| for the return string.
  2684. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2685. |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
  2686. Returns an empty string when completion is not defined.
  2687. Return: ~
  2688. (`string`)
  2689. getcmdline() *getcmdline()*
  2690. Return the current command-line input. Only works when the
  2691. command line is being edited, thus requires use of
  2692. |c_CTRL-\_e| or |c_CTRL-R_=|.
  2693. Example: >vim
  2694. cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
  2695. < Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
  2696. |getcmdprompt()| and |setcmdline()|.
  2697. Returns an empty string when entering a password or using
  2698. |inputsecret()|.
  2699. Return: ~
  2700. (`string`)
  2701. getcmdpos() *getcmdpos()*
  2702. Return the position of the cursor in the command line as a
  2703. byte count. The first column is 1.
  2704. Only works when editing the command line, thus requires use of
  2705. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2706. Returns 0 otherwise.
  2707. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2708. |getcmdprompt()| and |setcmdline()|.
  2709. Return: ~
  2710. (`integer`)
  2711. getcmdprompt() *getcmdprompt()*
  2712. Return the current command-line prompt when using functions
  2713. like |input()| or |confirm()|.
  2714. Only works when the command line is being edited, thus
  2715. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2716. Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
  2717. |setcmdpos()| and |setcmdline()|.
  2718. Return: ~
  2719. (`string`)
  2720. getcmdscreenpos() *getcmdscreenpos()*
  2721. Return the screen position of the cursor in the command line
  2722. as a byte count. The first column is 1.
  2723. Instead of |getcmdpos()|, it adds the prompt position.
  2724. Only works when editing the command line, thus requires use of
  2725. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2726. Returns 0 otherwise.
  2727. Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
  2728. |setcmdline()|.
  2729. Return: ~
  2730. (`integer`)
  2731. getcmdtype() *getcmdtype()*
  2732. Return the current command-line type. Possible return values
  2733. are:
  2734. : normal Ex command
  2735. > debug mode command |debug-mode|
  2736. / forward search command
  2737. ? backward search command
  2738. @ |input()| command
  2739. `-` |:insert| or |:append| command
  2740. = |i_CTRL-R_=|
  2741. Only works when editing the command line, thus requires use of
  2742. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2743. Returns an empty string otherwise.
  2744. Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  2745. Return: ~
  2746. (`':'|'>'|'/'|'?'|'@'|'-'|'='`)
  2747. getcmdwintype() *getcmdwintype()*
  2748. Return the current |command-line-window| type. Possible return
  2749. values are the same as |getcmdtype()|. Returns an empty string
  2750. when not in the command-line window.
  2751. Return: ~
  2752. (`':'|'>'|'/'|'?'|'@'|'-'|'='`)
  2753. getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
  2754. Return a list of command-line completion matches. The String
  2755. {type} argument specifies what for. The following completion
  2756. types are supported:
  2757. arglist file names in argument list
  2758. augroup autocmd groups
  2759. buffer buffer names
  2760. breakpoint |:breakadd| and |:breakdel| suboptions
  2761. cmdline |cmdline-completion| result
  2762. color color schemes
  2763. command Ex command
  2764. compiler compilers
  2765. custom,{func} custom completion, defined via {func}
  2766. customlist,{func} custom completion, defined via {func}
  2767. diff_buffer |:diffget| and |:diffput| completion
  2768. dir directory names
  2769. dir_in_path directory names in |'cdpath'|
  2770. environment environment variable names
  2771. event autocommand events
  2772. expression Vim expression
  2773. file file and directory names
  2774. file_in_path file and directory names in |'path'|
  2775. filetype filetype names |'filetype'|
  2776. function function name
  2777. help help subjects
  2778. highlight highlight groups
  2779. history |:history| suboptions
  2780. keymap keyboard mappings
  2781. locale locale names (as output of locale -a)
  2782. mapclear buffer argument
  2783. mapping mapping name
  2784. menu menus
  2785. messages |:messages| suboptions
  2786. option options
  2787. packadd optional package |pack-add| names
  2788. runtime |:runtime| completion
  2789. scriptnames sourced script names |:scriptnames|
  2790. shellcmd Shell command
  2791. shellcmdline Shell command line with filename arguments
  2792. sign |:sign| suboptions
  2793. syntax syntax file names |'syntax'|
  2794. syntime |:syntime| suboptions
  2795. tag tags
  2796. tag_listfiles tags, file names
  2797. user user names
  2798. var user variables
  2799. If {pat} is an empty string, then all the matches are
  2800. returned. Otherwise only items matching {pat} are returned.
  2801. See |wildcards| for the use of special characters in {pat}.
  2802. If the optional {filtered} flag is set to 1, then 'wildignore'
  2803. is applied to filter the results. Otherwise all the matches
  2804. are returned. The 'wildignorecase' option always applies.
  2805. If the 'wildoptions' option contains "fuzzy", then fuzzy
  2806. matching is used to get the completion matches. Otherwise
  2807. regular expression matching is used. Thus this function
  2808. follows the user preference, what happens on the command line.
  2809. If you do not want this you can make 'wildoptions' empty
  2810. before calling getcompletion() and restore it afterwards.
  2811. If {type} is "cmdline", then the |cmdline-completion| result is
  2812. returned. For example, to complete the possible values after
  2813. a ":call" command: >vim
  2814. echo getcompletion('call ', 'cmdline')
  2815. <
  2816. If there are no matches, an empty list is returned. An
  2817. invalid value for {type} produces an error.
  2818. Parameters: ~
  2819. • {pat} (`string`)
  2820. • {type} (`string`)
  2821. • {filtered} (`boolean?`)
  2822. Return: ~
  2823. (`string[]`)
  2824. getcurpos([{winid}]) *getcurpos()*
  2825. Get the position of the cursor. This is like getpos('.'), but
  2826. includes an extra "curswant" item in the list:
  2827. [0, lnum, col, off, curswant] ~
  2828. The "curswant" number is the preferred column when moving the
  2829. cursor vertically. After |$| command it will be a very large
  2830. number equal to |v:maxcol|. Also see |getcursorcharpos()| and
  2831. |getpos()|.
  2832. The first "bufnum" item is always zero. The byte position of
  2833. the cursor is returned in "col". To get the character
  2834. position, use |getcursorcharpos()|.
  2835. The optional {winid} argument can specify the window. It can
  2836. be the window number or the |window-ID|. The last known
  2837. cursor position is returned, this may be invalid for the
  2838. current value of the buffer if it is not the current window.
  2839. If {winid} is invalid a list with zeroes is returned.
  2840. This can be used to save and restore the cursor position: >vim
  2841. let save_cursor = getcurpos()
  2842. MoveTheCursorAround
  2843. call setpos('.', save_cursor)
  2844. < Note that this only works within the window. See
  2845. |winrestview()| for restoring more state.
  2846. Parameters: ~
  2847. • {winid} (`integer?`)
  2848. Return: ~
  2849. (`any`)
  2850. getcursorcharpos([{winid}]) *getcursorcharpos()*
  2851. Same as |getcurpos()| but the column number in the returned
  2852. List is a character index instead of a byte index.
  2853. Example:
  2854. With the cursor on '보' in line 3 with text "여보세요": >vim
  2855. getcursorcharpos() " returns [0, 3, 2, 0, 3]
  2856. getcurpos() " returns [0, 3, 4, 0, 3]
  2857. <
  2858. Parameters: ~
  2859. • {winid} (`integer?`)
  2860. Return: ~
  2861. (`any`)
  2862. getcwd([{winnr} [, {tabnr}]]) *getcwd()*
  2863. With no arguments, returns the name of the effective
  2864. |current-directory|. With {winnr} or {tabnr} the working
  2865. directory of that scope is returned, and 'autochdir' is
  2866. ignored.
  2867. Tabs and windows are identified by their respective numbers,
  2868. 0 means current tab or window. Missing tab number implies 0.
  2869. Thus the following are equivalent: >vim
  2870. getcwd(0)
  2871. getcwd(0, 0)
  2872. < If {winnr} is -1 it is ignored, only the tab is resolved.
  2873. {winnr} can be the window number or the |window-ID|.
  2874. If both {winnr} and {tabnr} are -1 the global working
  2875. directory is returned.
  2876. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  2877. Parameters: ~
  2878. • {winnr} (`integer?`)
  2879. • {tabnr} (`integer?`)
  2880. Return: ~
  2881. (`string`)
  2882. getenv({name}) *getenv()*
  2883. Return the value of environment variable {name}. The {name}
  2884. argument is a string, without a leading '$'. Example: >vim
  2885. myHome = getenv('HOME')
  2886. < When the variable does not exist |v:null| is returned. That
  2887. is different from a variable set to an empty string.
  2888. See also |expr-env|.
  2889. Parameters: ~
  2890. • {name} (`string`)
  2891. Return: ~
  2892. (`string`)
  2893. getfontname([{name}]) *getfontname()*
  2894. Without an argument returns the name of the normal font being
  2895. used. Like what is used for the Normal highlight group
  2896. |hl-Normal|.
  2897. With an argument a check is done whether String {name} is a
  2898. valid font name. If not then an empty string is returned.
  2899. Otherwise the actual font name is returned, or {name} if the
  2900. GUI does not support obtaining the real name.
  2901. Only works when the GUI is running, thus not in your vimrc or
  2902. gvimrc file. Use the |GUIEnter| autocommand to use this
  2903. function just after the GUI has started.
  2904. Parameters: ~
  2905. • {name} (`string?`)
  2906. Return: ~
  2907. (`string`)
  2908. getfperm({fname}) *getfperm()*
  2909. The result is a String, which is the read, write, and execute
  2910. permissions of the given file {fname}.
  2911. If {fname} does not exist or its directory cannot be read, an
  2912. empty string is returned.
  2913. The result is of the form "rwxrwxrwx", where each group of
  2914. "rwx" flags represent, in turn, the permissions of the owner
  2915. of the file, the group the file belongs to, and other users.
  2916. If a user does not have a given permission the flag for this
  2917. is replaced with the string "-". Examples: >vim
  2918. echo getfperm("/etc/passwd")
  2919. echo getfperm(expand("~/.config/nvim/init.vim"))
  2920. < This will hopefully (from a security point of view) display
  2921. the string "rw-r--r--" or even "rw-------".
  2922. For setting permissions use |setfperm()|.
  2923. Parameters: ~
  2924. • {fname} (`string`)
  2925. Return: ~
  2926. (`string`)
  2927. getfsize({fname}) *getfsize()*
  2928. The result is a Number, which is the size in bytes of the
  2929. given file {fname}.
  2930. If {fname} is a directory, 0 is returned.
  2931. If the file {fname} can't be found, -1 is returned.
  2932. If the size of {fname} is too big to fit in a Number then -2
  2933. is returned.
  2934. Parameters: ~
  2935. • {fname} (`string`)
  2936. Return: ~
  2937. (`integer`)
  2938. getftime({fname}) *getftime()*
  2939. The result is a Number, which is the last modification time of
  2940. the given file {fname}. The value is measured as seconds
  2941. since 1st Jan 1970, and may be passed to strftime(). See also
  2942. |localtime()| and |strftime()|.
  2943. If the file {fname} can't be found -1 is returned.
  2944. Parameters: ~
  2945. • {fname} (`string`)
  2946. Return: ~
  2947. (`integer`)
  2948. getftype({fname}) *getftype()*
  2949. The result is a String, which is a description of the kind of
  2950. file of the given file {fname}.
  2951. If {fname} does not exist an empty string is returned.
  2952. Here is a table over different kinds of files and their
  2953. results:
  2954. Normal file "file"
  2955. Directory "dir"
  2956. Symbolic link "link"
  2957. Block device "bdev"
  2958. Character device "cdev"
  2959. Socket "socket"
  2960. FIFO "fifo"
  2961. All other "other"
  2962. Example: >vim
  2963. getftype("/home")
  2964. < Note that a type such as "link" will only be returned on
  2965. systems that support it. On some systems only "dir" and
  2966. "file" are returned.
  2967. Parameters: ~
  2968. • {fname} (`string`)
  2969. Return: ~
  2970. (`'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'`)
  2971. getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
  2972. Returns the |jumplist| for the specified window.
  2973. Without arguments use the current window.
  2974. With {winnr} only use this window in the current tab page.
  2975. {winnr} can also be a |window-ID|.
  2976. With {winnr} and {tabnr} use the window in the specified tab
  2977. page. If {winnr} or {tabnr} is invalid, an empty list is
  2978. returned.
  2979. The returned list contains two entries: a list with the jump
  2980. locations and the last used jump position number in the list.
  2981. Each entry in the jump location list is a dictionary with
  2982. the following entries:
  2983. bufnr buffer number
  2984. col column number
  2985. coladd column offset for 'virtualedit'
  2986. filename filename if available
  2987. lnum line number
  2988. Parameters: ~
  2989. • {winnr} (`integer?`)
  2990. • {tabnr} (`integer?`)
  2991. Return: ~
  2992. (`vim.fn.getjumplist.ret`)
  2993. getline({lnum} [, {end}]) *getline()*
  2994. Without {end} the result is a String, which is line {lnum}
  2995. from the current buffer. Example: >vim
  2996. getline(1)
  2997. < When {lnum} is a String that doesn't start with a
  2998. digit, |line()| is called to translate the String into a Number.
  2999. To get the line under the cursor: >vim
  3000. getline(".")
  3001. < When {lnum} is a number smaller than 1 or bigger than the
  3002. number of lines in the buffer, an empty string is returned.
  3003. When {end} is given the result is a |List| where each item is
  3004. a line from the current buffer in the range {lnum} to {end},
  3005. including line {end}.
  3006. {end} is used in the same way as {lnum}.
  3007. Non-existing lines are silently omitted.
  3008. When {end} is before {lnum} an empty |List| is returned.
  3009. Example: >vim
  3010. let start = line('.')
  3011. let end = search("^$") - 1
  3012. let lines = getline(start, end)
  3013. < To get lines from another buffer see |getbufline()| and
  3014. |getbufoneline()|
  3015. Parameters: ~
  3016. • {lnum} (`integer|string`)
  3017. • {end} (`nil|false?`)
  3018. Return: ~
  3019. (`string`)
  3020. getloclist({nr} [, {what}]) *getloclist()*
  3021. Returns a |List| with all the entries in the location list for
  3022. window {nr}. {nr} can be the window number or the |window-ID|.
  3023. When {nr} is zero the current window is used.
  3024. For a location list window, the displayed location list is
  3025. returned. For an invalid window number {nr}, an empty list is
  3026. returned. Otherwise, same as |getqflist()|.
  3027. If the optional {what} dictionary argument is supplied, then
  3028. returns the items listed in {what} as a dictionary. Refer to
  3029. |getqflist()| for the supported items in {what}.
  3030. In addition to the items supported by |getqflist()| in {what},
  3031. the following item is supported by |getloclist()|:
  3032. filewinid id of the window used to display files
  3033. from the location list. This field is
  3034. applicable only when called from a
  3035. location list window. See
  3036. |location-list-file-window| for more
  3037. details.
  3038. Returns a |Dictionary| with default values if there is no
  3039. location list for the window {nr}.
  3040. Returns an empty Dictionary if window {nr} does not exist.
  3041. Examples (See also |getqflist-examples|): >vim
  3042. echo getloclist(3, {'all': 0})
  3043. echo getloclist(5, {'filewinid': 0})
  3044. <
  3045. Parameters: ~
  3046. • {nr} (`integer`)
  3047. • {what} (`table?`)
  3048. Return: ~
  3049. (`any`)
  3050. getmarklist([{buf}]) *getmarklist()*
  3051. Without the {buf} argument returns a |List| with information
  3052. about all the global marks. |mark|
  3053. If the optional {buf} argument is specified, returns the
  3054. local marks defined in buffer {buf}. For the use of {buf},
  3055. see |bufname()|. If {buf} is invalid, an empty list is
  3056. returned.
  3057. Each item in the returned List is a |Dict| with the following:
  3058. mark name of the mark prefixed by "'"
  3059. pos a |List| with the position of the mark:
  3060. [bufnum, lnum, col, off]
  3061. Refer to |getpos()| for more information.
  3062. file file name
  3063. Refer to |getpos()| for getting information about a specific
  3064. mark.
  3065. Parameters: ~
  3066. • {buf} (`integer??`)
  3067. Return: ~
  3068. (`vim.fn.getmarklist.ret.item[]`)
  3069. getmatches([{win}]) *getmatches()*
  3070. Returns a |List| with all matches previously defined for the
  3071. current window by |matchadd()| and the |:match| commands.
  3072. |getmatches()| is useful in combination with |setmatches()|,
  3073. as |setmatches()| can restore a list of matches saved by
  3074. |getmatches()|.
  3075. If {win} is specified, use the window with this number or
  3076. window ID instead of the current window. If {win} is invalid,
  3077. an empty list is returned.
  3078. Example: >vim
  3079. echo getmatches()
  3080. < >
  3081. [{"group": "MyGroup1", "pattern": "TODO",
  3082. "priority": 10, "id": 1}, {"group": "MyGroup2",
  3083. "pattern": "FIXME", "priority": 10, "id": 2}]
  3084. < >vim
  3085. let m = getmatches()
  3086. call clearmatches()
  3087. echo getmatches()
  3088. < >
  3089. []
  3090. < >vim
  3091. call setmatches(m)
  3092. echo getmatches()
  3093. < >
  3094. [{"group": "MyGroup1", "pattern": "TODO",
  3095. "priority": 10, "id": 1}, {"group": "MyGroup2",
  3096. "pattern": "FIXME", "priority": 10, "id": 2}]
  3097. < >vim
  3098. unlet m
  3099. <
  3100. Parameters: ~
  3101. • {win} (`integer?`)
  3102. Return: ~
  3103. (`any`)
  3104. getmousepos() *getmousepos()*
  3105. Returns a |Dictionary| with the last known position of the
  3106. mouse. This can be used in a mapping for a mouse click. The
  3107. items are:
  3108. screenrow screen row
  3109. screencol screen column
  3110. winid Window ID of the click
  3111. winrow row inside "winid"
  3112. wincol column inside "winid"
  3113. line text line inside "winid"
  3114. column text column inside "winid"
  3115. coladd offset (in screen columns) from the
  3116. start of the clicked char
  3117. All numbers are 1-based.
  3118. If not over a window, e.g. when in the command line, then only
  3119. "screenrow" and "screencol" are valid, the others are zero.
  3120. When on the status line below a window or the vertical
  3121. separator right of a window, the "line" and "column" values
  3122. are zero.
  3123. When the position is after the text then "column" is the
  3124. length of the text in bytes plus one.
  3125. If the mouse is over a focusable floating window then that
  3126. window is used.
  3127. When using |getchar()| the Vim variables |v:mouse_lnum|,
  3128. |v:mouse_col| and |v:mouse_winid| also provide these values.
  3129. Return: ~
  3130. (`vim.fn.getmousepos.ret`)
  3131. getpid() *getpid()*
  3132. Return a Number which is the process ID of the Vim process.
  3133. This is a unique number, until Vim exits.
  3134. Return: ~
  3135. (`integer`)
  3136. getpos({expr}) *getpos()*
  3137. Get the position for String {expr}.
  3138. The accepted values for {expr} are:
  3139. . The cursor position.
  3140. $ The last line in the current buffer.
  3141. 'x Position of mark x (if the mark is not set, 0 is
  3142. returned for all values).
  3143. w0 First line visible in current window (one if the
  3144. display isn't updated, e.g. in silent Ex mode).
  3145. w$ Last line visible in current window (this is one
  3146. less than "w0" if no lines are visible).
  3147. v When not in Visual mode, returns the cursor
  3148. position. In Visual mode, returns the other end
  3149. of the Visual area. A good way to think about
  3150. this is that in Visual mode "v" and "." complement
  3151. each other. While "." refers to the cursor
  3152. position, "v" refers to where |v_o| would move the
  3153. cursor. As a result, you can use "v" and "."
  3154. together to work on all of a selection in
  3155. characterwise Visual mode. If the cursor is at
  3156. the end of a characterwise Visual area, "v" refers
  3157. to the start of the same Visual area. And if the
  3158. cursor is at the start of a characterwise Visual
  3159. area, "v" refers to the end of the same Visual
  3160. area. "v" differs from |'<| and |'>| in that it's
  3161. updated right away.
  3162. Note that a mark in another file can be used. The line number
  3163. then applies to another buffer.
  3164. The result is a |List| with four numbers:
  3165. [bufnum, lnum, col, off]
  3166. "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  3167. is the buffer number of the mark.
  3168. "lnum" and "col" are the position in the buffer. The first
  3169. column is 1.
  3170. The "off" number is zero, unless 'virtualedit' is used. Then
  3171. it is the offset in screen columns from the start of the
  3172. character. E.g., a position within a <Tab> or after the last
  3173. character.
  3174. For getting the cursor position see |getcurpos()|.
  3175. The column number in the returned List is the byte position
  3176. within the line. To get the character position in the line,
  3177. use |getcharpos()|.
  3178. Note that for '< and '> Visual mode matters: when it is "V"
  3179. (visual line mode) the column of '< is zero and the column of
  3180. '> is a large number equal to |v:maxcol|.
  3181. A very large column number equal to |v:maxcol| can be returned,
  3182. in which case it means "after the end of the line".
  3183. If {expr} is invalid, returns a list with all zeros.
  3184. This can be used to save and restore the position of a mark: >vim
  3185. let save_a_mark = getpos("'a")
  3186. " ...
  3187. call setpos("'a", save_a_mark)
  3188. <
  3189. Also see |getcharpos()|, |getcurpos()| and |setpos()|.
  3190. Parameters: ~
  3191. • {expr} (`string`)
  3192. Return: ~
  3193. (`integer[]`)
  3194. getqflist([{what}]) *getqflist()*
  3195. Returns a |List| with all the current quickfix errors. Each
  3196. list item is a dictionary with these entries:
  3197. bufnr number of buffer that has the file name, use
  3198. bufname() to get the name
  3199. module module name
  3200. lnum line number in the buffer (first line is 1)
  3201. end_lnum
  3202. end of line number if the item is multiline
  3203. col column number (first column is 1)
  3204. end_col end of column number if the item has range
  3205. vcol |TRUE|: "col" is visual column
  3206. |FALSE|: "col" is byte index
  3207. nr error number
  3208. pattern search pattern used to locate the error
  3209. text description of the error
  3210. type type of the error, 'E', '1', etc.
  3211. valid |TRUE|: recognized error message
  3212. user_data
  3213. custom data associated with the item, can be
  3214. any type.
  3215. When there is no error list or it's empty, an empty list is
  3216. returned. Quickfix list entries with a non-existing buffer
  3217. number are returned with "bufnr" set to zero (Note: some
  3218. functions accept buffer number zero for the alternate buffer,
  3219. you may need to explicitly check for zero).
  3220. Useful application: Find pattern matches in multiple files and
  3221. do something with them: >vim
  3222. vimgrep /theword/jg *.c
  3223. for d in getqflist()
  3224. echo bufname(d.bufnr) ':' d.lnum '=' d.text
  3225. endfor
  3226. <
  3227. If the optional {what} dictionary argument is supplied, then
  3228. returns only the items listed in {what} as a dictionary. The
  3229. following string items are supported in {what}:
  3230. changedtick get the total number of changes made
  3231. to the list |quickfix-changedtick|
  3232. context get the |quickfix-context|
  3233. efm errorformat to use when parsing "lines". If
  3234. not present, then the 'errorformat' option
  3235. value is used.
  3236. id get information for the quickfix list with
  3237. |quickfix-ID|; zero means the id for the
  3238. current list or the list specified by "nr"
  3239. idx get information for the quickfix entry at this
  3240. index in the list specified by "id" or "nr".
  3241. If set to zero, then uses the current entry.
  3242. See |quickfix-index|
  3243. items quickfix list entries
  3244. lines parse a list of lines using 'efm' and return
  3245. the resulting entries. Only a |List| type is
  3246. accepted. The current quickfix list is not
  3247. modified. See |quickfix-parse|.
  3248. nr get information for this quickfix list; zero
  3249. means the current quickfix list and "$" means
  3250. the last quickfix list
  3251. qfbufnr number of the buffer displayed in the quickfix
  3252. window. Returns 0 if the quickfix buffer is
  3253. not present. See |quickfix-buffer|.
  3254. size number of entries in the quickfix list
  3255. title get the list title |quickfix-title|
  3256. winid get the quickfix |window-ID|
  3257. all all of the above quickfix properties
  3258. Non-string items in {what} are ignored. To get the value of a
  3259. particular item, set it to zero.
  3260. If "nr" is not present then the current quickfix list is used.
  3261. If both "nr" and a non-zero "id" are specified, then the list
  3262. specified by "id" is used.
  3263. To get the number of lists in the quickfix stack, set "nr" to
  3264. "$" in {what}. The "nr" value in the returned dictionary
  3265. contains the quickfix stack size.
  3266. When "lines" is specified, all the other items except "efm"
  3267. are ignored. The returned dictionary contains the entry
  3268. "items" with the list of entries.
  3269. The returned dictionary contains the following entries:
  3270. changedtick total number of changes made to the
  3271. list |quickfix-changedtick|
  3272. context quickfix list context. See |quickfix-context|
  3273. If not present, set to "".
  3274. id quickfix list ID |quickfix-ID|. If not
  3275. present, set to 0.
  3276. idx index of the quickfix entry in the list. If not
  3277. present, set to 0.
  3278. items quickfix list entries. If not present, set to
  3279. an empty list.
  3280. nr quickfix list number. If not present, set to 0
  3281. qfbufnr number of the buffer displayed in the quickfix
  3282. window. If not present, set to 0.
  3283. size number of entries in the quickfix list. If not
  3284. present, set to 0.
  3285. title quickfix list title text. If not present, set
  3286. to "".
  3287. winid quickfix |window-ID|. If not present, set to 0
  3288. Examples (See also |getqflist-examples|): >vim
  3289. echo getqflist({'all': 1})
  3290. echo getqflist({'nr': 2, 'title': 1})
  3291. echo getqflist({'lines' : ["F1:10:L10"]})
  3292. <
  3293. Parameters: ~
  3294. • {what} (`table?`)
  3295. Return: ~
  3296. (`any`)
  3297. getreg([{regname} [, 1 [, {list}]]]) *getreg()*
  3298. The result is a String, which is the contents of register
  3299. {regname}. Example: >vim
  3300. let cliptext = getreg('*')
  3301. < When register {regname} was not set the result is an empty
  3302. string.
  3303. The {regname} argument must be a string.
  3304. getreg('=') returns the last evaluated value of the expression
  3305. register. (For use in maps.)
  3306. getreg('=', 1) returns the expression itself, so that it can
  3307. be restored with |setreg()|. For other registers the extra
  3308. argument is ignored, thus you can always give it.
  3309. If {list} is present and |TRUE|, the result type is changed
  3310. to |List|. Each list item is one text line. Use it if you care
  3311. about zero bytes possibly present inside register: without
  3312. third argument both NLs and zero bytes are represented as NLs
  3313. (see |NL-used-for-Nul|).
  3314. When the register was not set an empty list is returned.
  3315. If {regname} is not specified, |v:register| is used.
  3316. Parameters: ~
  3317. • {regname} (`string?`)
  3318. • {list} (`nil|false?`)
  3319. Return: ~
  3320. (`string`)
  3321. getreginfo([{regname}]) *getreginfo()*
  3322. Returns detailed information about register {regname} as a
  3323. Dictionary with the following entries:
  3324. regcontents List of lines contained in register
  3325. {regname}, like
  3326. getreg({regname}, 1, 1).
  3327. regtype the type of register {regname}, as in
  3328. |getregtype()|.
  3329. isunnamed Boolean flag, v:true if this register
  3330. is currently pointed to by the unnamed
  3331. register.
  3332. points_to for the unnamed register, gives the
  3333. single letter name of the register
  3334. currently pointed to (see |quotequote|).
  3335. For example, after deleting a line
  3336. with `dd`, this field will be "1",
  3337. which is the register that got the
  3338. deleted text.
  3339. The {regname} argument is a string. If {regname} is invalid
  3340. or not set, an empty Dictionary will be returned.
  3341. If {regname} is not specified, |v:register| is used.
  3342. The returned Dictionary can be passed to |setreg()|.
  3343. Parameters: ~
  3344. • {regname} (`string?`)
  3345. Return: ~
  3346. (`table`)
  3347. getregion({pos1}, {pos2} [, {opts}]) *getregion()*
  3348. Returns the list of strings from {pos1} to {pos2} from a
  3349. buffer.
  3350. {pos1} and {pos2} must both be |List|s with four numbers.
  3351. See |getpos()| for the format of the list. It's possible
  3352. to specify positions from a different buffer, but please
  3353. note the limitations at |getregion-notes|.
  3354. The optional argument {opts} is a Dict and supports the
  3355. following items:
  3356. type Specify the region's selection type.
  3357. See |getregtype()| for possible values,
  3358. except that the width can be omitted
  3359. and an empty string cannot be used.
  3360. (default: "v")
  3361. exclusive If |TRUE|, use exclusive selection
  3362. for the end position.
  3363. (default: follow 'selection')
  3364. You can get the last selection type by |visualmode()|.
  3365. If Visual mode is active, use |mode()| to get the Visual mode
  3366. (e.g., in a |:vmap|).
  3367. This function is useful to get text starting and ending in
  3368. different columns, such as a |charwise-visual| selection.
  3369. *getregion-notes*
  3370. Note that:
  3371. - Order of {pos1} and {pos2} doesn't matter, it will always
  3372. return content from the upper left position to the lower
  3373. right position.
  3374. - If 'virtualedit' is enabled and the region is past the end
  3375. of the lines, resulting lines are padded with spaces.
  3376. - If the region is blockwise and it starts or ends in the
  3377. middle of a multi-cell character, it is not included but
  3378. its selected part is substituted with spaces.
  3379. - If {pos1} and {pos2} are not in the same buffer, an empty
  3380. list is returned.
  3381. - {pos1} and {pos2} must belong to a |bufloaded()| buffer.
  3382. - It is evaluated in current window context, which makes a
  3383. difference if the buffer is displayed in a window with
  3384. different 'virtualedit' or 'list' values.
  3385. Examples: >vim
  3386. xnoremap <CR>
  3387. \ <Cmd>echom getregion(
  3388. \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
  3389. <
  3390. Parameters: ~
  3391. • {pos1} (`table`)
  3392. • {pos2} (`table`)
  3393. • {opts} (`table?`)
  3394. Return: ~
  3395. (`string[]`)
  3396. getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
  3397. Same as |getregion()|, but returns a list of positions
  3398. describing the buffer text segments bound by {pos1} and
  3399. {pos2}.
  3400. The segments are a pair of positions for every line: >
  3401. [[{start_pos}, {end_pos}], ...]
  3402. <
  3403. The position is a |List| with four numbers:
  3404. [bufnum, lnum, col, off]
  3405. "bufnum" is the buffer number.
  3406. "lnum" and "col" are the position in the buffer. The first
  3407. column is 1.
  3408. If the "off" number of a starting position is non-zero, it is
  3409. the offset in screen columns from the start of the character.
  3410. E.g., a position within a <Tab> or after the last character.
  3411. If the "off" number of an ending position is non-zero, it is
  3412. the offset of the character's first cell not included in the
  3413. selection, otherwise all its cells are included.
  3414. Apart from the options supported by |getregion()|, {opts} also
  3415. supports the following:
  3416. eol If |TRUE|, indicate positions beyond
  3417. the end of a line with "col" values
  3418. one more than the length of the line.
  3419. If |FALSE|, positions are limited
  3420. within their lines, and if a line is
  3421. empty or the selection is entirely
  3422. beyond the end of a line, a "col"
  3423. value of 0 is used for both positions.
  3424. (default: |FALSE|)
  3425. Parameters: ~
  3426. • {pos1} (`table`)
  3427. • {pos2} (`table`)
  3428. • {opts} (`table?`)
  3429. Return: ~
  3430. (`integer[][][]`)
  3431. getregtype([{regname}]) *getregtype()*
  3432. The result is a String, which is type of register {regname}.
  3433. The value will be one of:
  3434. "v" for |charwise| text
  3435. "V" for |linewise| text
  3436. "<CTRL-V>{width}" for |blockwise-visual| text
  3437. "" for an empty or unknown register
  3438. <CTRL-V> is one character with value 0x16.
  3439. The {regname} argument is a string. If {regname} is not
  3440. specified, |v:register| is used.
  3441. Parameters: ~
  3442. • {regname} (`string?`)
  3443. Return: ~
  3444. (`string`)
  3445. getscriptinfo([{opts}]) *getscriptinfo()*
  3446. Returns a |List| with information about all the sourced Vim
  3447. scripts in the order they were sourced, like what
  3448. `:scriptnames` shows.
  3449. The optional Dict argument {opts} supports the following
  3450. optional items:
  3451. name Script name match pattern. If specified,
  3452. and "sid" is not specified, information about
  3453. scripts with a name that match the pattern
  3454. "name" are returned.
  3455. sid Script ID |<SID>|. If specified, only
  3456. information about the script with ID "sid" is
  3457. returned and "name" is ignored.
  3458. Each item in the returned List is a |Dict| with the following
  3459. items:
  3460. autoload Always set to FALSE.
  3461. functions List of script-local function names defined in
  3462. the script. Present only when a particular
  3463. script is specified using the "sid" item in
  3464. {opts}.
  3465. name Vim script file name.
  3466. sid Script ID |<SID>|.
  3467. variables A dictionary with the script-local variables.
  3468. Present only when a particular script is
  3469. specified using the "sid" item in {opts}.
  3470. Note that this is a copy, the value of
  3471. script-local variables cannot be changed using
  3472. this dictionary.
  3473. version Vim script version, always 1
  3474. Examples: >vim
  3475. echo getscriptinfo({'name': 'myscript'})
  3476. echo getscriptinfo({'sid': 15})[0].variables
  3477. <
  3478. Parameters: ~
  3479. • {opts} (`table?`)
  3480. Return: ~
  3481. (`vim.fn.getscriptinfo.ret[]`)
  3482. getstacktrace() *getstacktrace()*
  3483. Returns the current stack trace of Vim scripts.
  3484. Stack trace is a |List|, of which each item is a |Dictionary|
  3485. with the following items:
  3486. funcref The funcref if the stack is at a function,
  3487. otherwise this item is omitted.
  3488. event The string of the event description if the
  3489. stack is at an autocmd event, otherwise this
  3490. item is omitted.
  3491. lnum The line number in the script on the stack.
  3492. filepath The file path of the script on the stack.
  3493. Return: ~
  3494. (`table[]`)
  3495. gettabinfo([{tabnr}]) *gettabinfo()*
  3496. If {tabnr} is not specified, then information about all the
  3497. tab pages is returned as a |List|. Each List item is a
  3498. |Dictionary|. Otherwise, {tabnr} specifies the tab page
  3499. number and information about that one is returned. If the tab
  3500. page does not exist an empty List is returned.
  3501. Each List item is a |Dictionary| with the following entries:
  3502. tabnr tab page number.
  3503. variables a reference to the dictionary with
  3504. tabpage-local variables
  3505. windows List of |window-ID|s in the tab page.
  3506. Parameters: ~
  3507. • {tabnr} (`integer?`)
  3508. Return: ~
  3509. (`any`)
  3510. gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
  3511. Get the value of a tab-local variable {varname} in tab page
  3512. {tabnr}. |t:var|
  3513. Tabs are numbered starting with one.
  3514. The {varname} argument is a string. When {varname} is empty a
  3515. dictionary with all tab-local variables is returned.
  3516. Note that the name without "t:" must be used.
  3517. When the tab or variable doesn't exist {def} or an empty
  3518. string is returned, there is no error message.
  3519. Parameters: ~
  3520. • {tabnr} (`integer`)
  3521. • {varname} (`string`)
  3522. • {def} (`any?`)
  3523. Return: ~
  3524. (`any`)
  3525. gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
  3526. Get the value of window-local variable {varname} in window
  3527. {winnr} in tab page {tabnr}.
  3528. The {varname} argument is a string. When {varname} is empty a
  3529. dictionary with all window-local variables is returned.
  3530. When {varname} is equal to "&" get the values of all
  3531. window-local options in a |Dictionary|.
  3532. Otherwise, when {varname} starts with "&" get the value of a
  3533. window-local option.
  3534. Note that {varname} must be the name without "w:".
  3535. Tabs are numbered starting with one. For the current tabpage
  3536. use |getwinvar()|.
  3537. {winnr} can be the window number or the |window-ID|.
  3538. When {winnr} is zero the current window is used.
  3539. This also works for a global option, buffer-local option and
  3540. window-local option, but it doesn't work for a global variable
  3541. or buffer-local variable.
  3542. When the tab, window or variable doesn't exist {def} or an
  3543. empty string is returned, there is no error message.
  3544. Examples: >vim
  3545. let list_is_on = gettabwinvar(1, 2, '&list')
  3546. echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
  3547. <
  3548. To obtain all window-local variables use: >vim
  3549. gettabwinvar({tabnr}, {winnr}, '&')
  3550. <
  3551. Parameters: ~
  3552. • {tabnr} (`integer`)
  3553. • {winnr} (`integer`)
  3554. • {varname} (`string`)
  3555. • {def} (`any?`)
  3556. Return: ~
  3557. (`any`)
  3558. gettagstack([{winnr}]) *gettagstack()*
  3559. The result is a Dict, which is the tag stack of window {winnr}.
  3560. {winnr} can be the window number or the |window-ID|.
  3561. When {winnr} is not specified, the current window is used.
  3562. When window {winnr} doesn't exist, an empty Dict is returned.
  3563. The returned dictionary contains the following entries:
  3564. curidx Current index in the stack. When at
  3565. top of the stack, set to (length + 1).
  3566. Index of bottom of the stack is 1.
  3567. items List of items in the stack. Each item
  3568. is a dictionary containing the
  3569. entries described below.
  3570. length Number of entries in the stack.
  3571. Each item in the stack is a dictionary with the following
  3572. entries:
  3573. bufnr buffer number of the current jump
  3574. from cursor position before the tag jump.
  3575. See |getpos()| for the format of the
  3576. returned list.
  3577. matchnr current matching tag number. Used when
  3578. multiple matching tags are found for a
  3579. name.
  3580. tagname name of the tag
  3581. See |tagstack| for more information about the tag stack.
  3582. Parameters: ~
  3583. • {winnr} (`integer?`)
  3584. Return: ~
  3585. (`any`)
  3586. gettext({text}) *gettext()*
  3587. Translate String {text} if possible.
  3588. This is mainly for use in the distributed Vim scripts. When
  3589. generating message translations the {text} is extracted by
  3590. xgettext, the translator can add the translated message in the
  3591. .po file and Vim will lookup the translation when gettext() is
  3592. called.
  3593. For {text} double quoted strings are preferred, because
  3594. xgettext does not understand escaping in single quoted
  3595. strings.
  3596. Parameters: ~
  3597. • {text} (`string`)
  3598. Return: ~
  3599. (`string`)
  3600. getwininfo([{winid}]) *getwininfo()*
  3601. Returns information about windows as a |List| with Dictionaries.
  3602. If {winid} is given Information about the window with that ID
  3603. is returned, as a |List| with one item. If the window does not
  3604. exist the result is an empty list.
  3605. Without {winid} information about all the windows in all the
  3606. tab pages is returned.
  3607. Each List item is a |Dictionary| with the following entries:
  3608. botline last complete displayed buffer line
  3609. bufnr number of buffer in the window
  3610. height window height (excluding winbar)
  3611. leftcol first column displayed; only used when
  3612. 'wrap' is off
  3613. loclist 1 if showing a location list
  3614. quickfix 1 if quickfix or location list window
  3615. terminal 1 if a terminal window
  3616. tabnr tab page number
  3617. topline first displayed buffer line
  3618. variables a reference to the dictionary with
  3619. window-local variables
  3620. width window width
  3621. winbar 1 if the window has a toolbar, 0
  3622. otherwise
  3623. wincol leftmost screen column of the window;
  3624. "col" from |win_screenpos()|
  3625. textoff number of columns occupied by any
  3626. 'foldcolumn', 'signcolumn' and line
  3627. number in front of the text
  3628. winid |window-ID|
  3629. winnr window number
  3630. winrow topmost screen line of the window;
  3631. "row" from |win_screenpos()|
  3632. Parameters: ~
  3633. • {winid} (`integer?`)
  3634. Return: ~
  3635. (`vim.fn.getwininfo.ret.item[]`)
  3636. getwinpos([{timeout}]) *getwinpos()*
  3637. The result is a |List| with two numbers, the result of
  3638. |getwinposx()| and |getwinposy()| combined:
  3639. [x-pos, y-pos]
  3640. {timeout} can be used to specify how long to wait in msec for
  3641. a response from the terminal. When omitted 100 msec is used.
  3642. Use a longer time for a remote terminal.
  3643. When using a value less than 10 and no response is received
  3644. within that time, a previously reported position is returned,
  3645. if available. This can be used to poll for the position and
  3646. do some work in the meantime: >vim
  3647. while 1
  3648. let res = getwinpos(1)
  3649. if res[0] >= 0
  3650. break
  3651. endif
  3652. " Do some work here
  3653. endwhile
  3654. <
  3655. Parameters: ~
  3656. • {timeout} (`integer?`)
  3657. Return: ~
  3658. (`any`)
  3659. getwinposx() *getwinposx()*
  3660. The result is a Number, which is the X coordinate in pixels of
  3661. the left hand side of the GUI Vim window. The result will be
  3662. -1 if the information is not available.
  3663. The value can be used with `:winpos`.
  3664. Return: ~
  3665. (`integer`)
  3666. getwinposy() *getwinposy()*
  3667. The result is a Number, which is the Y coordinate in pixels of
  3668. the top of the GUI Vim window. The result will be -1 if the
  3669. information is not available.
  3670. The value can be used with `:winpos`.
  3671. Return: ~
  3672. (`integer`)
  3673. getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
  3674. Like |gettabwinvar()| for the current tabpage.
  3675. Examples: >vim
  3676. let list_is_on = getwinvar(2, '&list')
  3677. echo "myvar = " .. getwinvar(1, 'myvar')
  3678. Parameters: ~
  3679. • {winnr} (`integer`)
  3680. • {varname} (`string`)
  3681. • {def} (`any?`)
  3682. Return: ~
  3683. (`any`)
  3684. glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
  3685. Expand the file wildcards in {expr}. See |wildcards| for the
  3686. use of special characters.
  3687. Unless the optional {nosuf} argument is given and is |TRUE|,
  3688. the 'suffixes' and 'wildignore' options apply: Names matching
  3689. one of the patterns in 'wildignore' will be skipped and
  3690. 'suffixes' affect the ordering of matches.
  3691. 'wildignorecase' always applies.
  3692. When {list} is present and it is |TRUE| the result is a |List|
  3693. with all matching files. The advantage of using a List is,
  3694. you also get filenames containing newlines correctly.
  3695. Otherwise the result is a String and when there are several
  3696. matches, they are separated by <NL> characters.
  3697. If the expansion fails, the result is an empty String or List.
  3698. You can also use |readdir()| if you need to do complicated
  3699. things, such as limiting the number of matches.
  3700. A name for a non-existing file is not included. A symbolic
  3701. link is only included if it points to an existing file.
  3702. However, when the {alllinks} argument is present and it is
  3703. |TRUE| then all symbolic links are included.
  3704. For most systems backticks can be used to get files names from
  3705. any external command. Example: >vim
  3706. let tagfiles = glob("`find . -name tags -print`")
  3707. let &tags = substitute(tagfiles, "\n", ",", "g")
  3708. < The result of the program inside the backticks should be one
  3709. item per line. Spaces inside an item are allowed.
  3710. See |expand()| for expanding special Vim variables. See
  3711. |system()| for getting the raw output of an external command.
  3712. Parameters: ~
  3713. • {expr} (`string`)
  3714. • {nosuf} (`boolean?`)
  3715. • {list} (`boolean?`)
  3716. • {alllinks} (`boolean?`)
  3717. Return: ~
  3718. (`any`)
  3719. glob2regpat({string}) *glob2regpat()*
  3720. Convert a file pattern, as used by glob(), into a search
  3721. pattern. The result can be used to match with a string that
  3722. is a file name. E.g. >vim
  3723. if filename =~ glob2regpat('Make*.mak')
  3724. " ...
  3725. endif
  3726. < This is equivalent to: >vim
  3727. if filename =~ '^Make.*\.mak$'
  3728. " ...
  3729. endif
  3730. < When {string} is an empty string the result is "^$", match an
  3731. empty string.
  3732. Note that the result depends on the system. On MS-Windows
  3733. a backslash usually means a path separator.
  3734. Parameters: ~
  3735. • {string} (`string`)
  3736. Return: ~
  3737. (`string`)
  3738. globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()*
  3739. Perform glob() for String {expr} on all directories in {path}
  3740. and concatenate the results. Example: >vim
  3741. echo globpath(&rtp, "syntax/c.vim")
  3742. <
  3743. {path} is a comma-separated list of directory names. Each
  3744. directory name is prepended to {expr} and expanded like with
  3745. |glob()|. A path separator is inserted when needed.
  3746. To add a comma inside a directory name escape it with a
  3747. backslash. Note that on MS-Windows a directory may have a
  3748. trailing backslash, remove it if you put a comma after it.
  3749. If the expansion fails for one of the directories, there is no
  3750. error message.
  3751. Unless the optional {nosuf} argument is given and is |TRUE|,
  3752. the 'suffixes' and 'wildignore' options apply: Names matching
  3753. one of the patterns in 'wildignore' will be skipped and
  3754. 'suffixes' affect the ordering of matches.
  3755. When {list} is present and it is |TRUE| the result is a |List|
  3756. with all matching files. The advantage of using a List is, you
  3757. also get filenames containing newlines correctly. Otherwise
  3758. the result is a String and when there are several matches,
  3759. they are separated by <NL> characters. Example: >vim
  3760. echo globpath(&rtp, "syntax/c.vim", 0, 1)
  3761. <
  3762. {allinks} is used as with |glob()|.
  3763. The "**" item can be used to search in a directory tree.
  3764. For example, to find all "README.txt" files in the directories
  3765. in 'runtimepath' and below: >vim
  3766. echo globpath(&rtp, "**/README.txt")
  3767. < Upwards search and limiting the depth of "**" is not
  3768. supported, thus using 'path' will not always work properly.
  3769. Parameters: ~
  3770. • {path} (`string`)
  3771. • {expr} (`string`)
  3772. • {nosuf} (`boolean?`)
  3773. • {list} (`boolean?`)
  3774. • {allinks} (`boolean?`)
  3775. Return: ~
  3776. (`any`)
  3777. has({feature}) *has()*
  3778. Returns 1 if {feature} is supported, 0 otherwise. The
  3779. {feature} argument is a feature name like "nvim-0.2.1" or
  3780. "win32", see below. See also |exists()|.
  3781. To get the system name use |vim.uv|.os_uname() in Lua: >lua
  3782. print(vim.uv.os_uname().sysname)
  3783. < If the code has a syntax error then Vimscript may skip the
  3784. rest of the line. Put |:if| and |:endif| on separate lines to
  3785. avoid the syntax error: >vim
  3786. if has('feature')
  3787. let x = this_breaks_without_the_feature()
  3788. endif
  3789. <
  3790. Vim's compile-time feature-names (prefixed with "+") are not
  3791. recognized because Nvim is always compiled with all possible
  3792. features. |feature-compile|
  3793. Feature names can be:
  3794. 1. Nvim version. For example the "nvim-0.2.1" feature means
  3795. that Nvim is version 0.2.1 or later: >vim
  3796. if has("nvim-0.2.1")
  3797. " ...
  3798. endif
  3799. < 2. Runtime condition or other pseudo-feature. For example the
  3800. "win32" feature checks if the current system is Windows: >vim
  3801. if has("win32")
  3802. " ...
  3803. endif
  3804. < *feature-list*
  3805. List of supported pseudo-feature names:
  3806. acl |ACL| support.
  3807. bsd BSD system (not macOS, use "mac" for that).
  3808. clipboard |clipboard| provider is available.
  3809. fname_case Case in file names matters (for Darwin and MS-Windows
  3810. this is not present).
  3811. gui_running Nvim has a GUI.
  3812. iconv Can use |iconv()| for conversion.
  3813. linux Linux system.
  3814. mac MacOS system.
  3815. nvim This is Nvim.
  3816. python3 Legacy Vim |python3| interface. |has-python|
  3817. pythonx Legacy Vim |python_x| interface. |has-pythonx|
  3818. sun SunOS system.
  3819. ttyin input is a terminal (tty).
  3820. ttyout output is a terminal (tty).
  3821. unix Unix system.
  3822. *vim_starting* True during |startup|.
  3823. win32 Windows system (32 or 64 bit).
  3824. win64 Windows system (64 bit).
  3825. wsl WSL (Windows Subsystem for Linux) system.
  3826. *has-patch*
  3827. 3. Vim patch. For example the "patch123" feature means that
  3828. Vim patch 123 at the current |v:version| was included: >vim
  3829. if v:version > 602 || v:version == 602 && has("patch148")
  3830. " ...
  3831. endif
  3832. < 4. Vim version. For example the "patch-7.4.237" feature means
  3833. that Nvim is Vim-compatible to version 7.4.237 or later. >vim
  3834. if has("patch-7.4.237")
  3835. " ...
  3836. endif
  3837. <
  3838. Parameters: ~
  3839. • {feature} (`string`)
  3840. Return: ~
  3841. (`0|1`)
  3842. has_key({dict}, {key}) *has_key()*
  3843. The result is a Number, which is TRUE if |Dictionary| {dict}
  3844. has an entry with key {key}. FALSE otherwise. The {key}
  3845. argument is a string.
  3846. Parameters: ~
  3847. • {dict} (`table`)
  3848. • {key} (`string`)
  3849. Return: ~
  3850. (`0|1`)
  3851. haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
  3852. The result is a Number, which is 1 when the window has set a
  3853. local path via |:lcd| or when {winnr} is -1 and the tabpage
  3854. has set a local path via |:tcd|, otherwise 0.
  3855. Tabs and windows are identified by their respective numbers,
  3856. 0 means current tab or window. Missing argument implies 0.
  3857. Thus the following are equivalent: >vim
  3858. echo haslocaldir()
  3859. echo haslocaldir(0)
  3860. echo haslocaldir(0, 0)
  3861. < With {winnr} use that window in the current tabpage.
  3862. With {winnr} and {tabnr} use the window in that tabpage.
  3863. {winnr} can be the window number or the |window-ID|.
  3864. If {winnr} is -1 it is ignored, only the tab is resolved.
  3865. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  3866. Parameters: ~
  3867. • {winnr} (`integer?`)
  3868. • {tabnr} (`integer?`)
  3869. Return: ~
  3870. (`0|1`)
  3871. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
  3872. The result is a Number, which is TRUE if there is a mapping
  3873. that contains {what} in somewhere in the rhs (what it is
  3874. mapped to) and this mapping exists in one of the modes
  3875. indicated by {mode}.
  3876. The arguments {what} and {mode} are strings.
  3877. When {abbr} is there and it is |TRUE| use abbreviations
  3878. instead of mappings. Don't forget to specify Insert and/or
  3879. Command-line mode.
  3880. Both the global mappings and the mappings local to the current
  3881. buffer are checked for a match.
  3882. If no matching mapping is found FALSE is returned.
  3883. The following characters are recognized in {mode}:
  3884. n Normal mode
  3885. v Visual and Select mode
  3886. x Visual mode
  3887. s Select mode
  3888. o Operator-pending mode
  3889. i Insert mode
  3890. l Language-Argument ("r", "f", "t", etc.)
  3891. c Command-line mode
  3892. When {mode} is omitted, "nvo" is used.
  3893. This function is useful to check if a mapping already exists
  3894. to a function in a Vim script. Example: >vim
  3895. if !hasmapto('\ABCdoit')
  3896. map <Leader>d \ABCdoit
  3897. endif
  3898. < This installs the mapping to "\ABCdoit" only if there isn't
  3899. already a mapping to "\ABCdoit".
  3900. Parameters: ~
  3901. • {what} (`any`)
  3902. • {mode} (`string?`)
  3903. • {abbr} (`boolean?`)
  3904. Return: ~
  3905. (`0|1`)
  3906. histadd({history}, {item}) *histadd()*
  3907. Add the String {item} to the history {history} which can be
  3908. one of: *hist-names*
  3909. "cmd" or ":" command line history
  3910. "search" or "/" search pattern history
  3911. "expr" or "=" typed expression history
  3912. "input" or "@" input line history
  3913. "debug" or ">" debug command history
  3914. empty the current or last used history
  3915. The {history} string does not need to be the whole name, one
  3916. character is sufficient.
  3917. If {item} does already exist in the history, it will be
  3918. shifted to become the newest entry.
  3919. The result is a Number: TRUE if the operation was successful,
  3920. otherwise FALSE is returned.
  3921. Example: >vim
  3922. call histadd("input", strftime("%Y %b %d"))
  3923. let date=input("Enter date: ")
  3924. < This function is not available in the |sandbox|.
  3925. Parameters: ~
  3926. • {history} (`string`)
  3927. • {item} (`any`)
  3928. Return: ~
  3929. (`0|1`)
  3930. histdel({history} [, {item}]) *histdel()*
  3931. Clear {history}, i.e. delete all its entries. See |hist-names|
  3932. for the possible values of {history}.
  3933. If the parameter {item} evaluates to a String, it is used as a
  3934. regular expression. All entries matching that expression will
  3935. be removed from the history (if there are any).
  3936. Upper/lowercase must match, unless "\c" is used |/\c|.
  3937. If {item} evaluates to a Number, it will be interpreted as
  3938. an index, see |:history-indexing|. The respective entry will
  3939. be removed if it exists.
  3940. The result is TRUE for a successful operation, otherwise FALSE
  3941. is returned.
  3942. Examples:
  3943. Clear expression register history: >vim
  3944. call histdel("expr")
  3945. <
  3946. Remove all entries starting with "*" from the search history: >vim
  3947. call histdel("/", '^\*')
  3948. <
  3949. The following three are equivalent: >vim
  3950. call histdel("search", histnr("search"))
  3951. call histdel("search", -1)
  3952. call histdel("search", '^' .. histget("search", -1) .. '$')
  3953. <
  3954. To delete the last search pattern and use the last-but-one for
  3955. the "n" command and 'hlsearch': >vim
  3956. call histdel("search", -1)
  3957. let @/ = histget("search", -1)
  3958. <
  3959. Parameters: ~
  3960. • {history} (`string`)
  3961. • {item} (`any?`)
  3962. Return: ~
  3963. (`0|1`)
  3964. histget({history} [, {index}]) *histget()*
  3965. The result is a String, the entry with Number {index} from
  3966. {history}. See |hist-names| for the possible values of
  3967. {history}, and |:history-indexing| for {index}. If there is
  3968. no such entry, an empty String is returned. When {index} is
  3969. omitted, the most recent item from the history is used.
  3970. Examples:
  3971. Redo the second last search from history. >vim
  3972. execute '/' .. histget("search", -2)
  3973. < Define an Ex command ":H {num}" that supports re-execution of
  3974. the {num}th entry from the output of |:history|. >vim
  3975. command -nargs=1 H execute histget("cmd", 0+<args>)
  3976. <
  3977. Parameters: ~
  3978. • {history} (`string`)
  3979. • {index} (`integer|string?`)
  3980. Return: ~
  3981. (`string`)
  3982. histnr({history}) *histnr()*
  3983. The result is the Number of the current entry in {history}.
  3984. See |hist-names| for the possible values of {history}.
  3985. If an error occurred, -1 is returned.
  3986. Example: >vim
  3987. let inp_index = histnr("expr")
  3988. <
  3989. Parameters: ~
  3990. • {history} (`string`)
  3991. Return: ~
  3992. (`integer`)
  3993. hlID({name}) *hlID()*
  3994. The result is a Number, which is the ID of the highlight group
  3995. with name {name}. When the highlight group doesn't exist,
  3996. zero is returned.
  3997. This can be used to retrieve information about the highlight
  3998. group. For example, to get the background color of the
  3999. "Comment" group: >vim
  4000. echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  4001. <
  4002. Parameters: ~
  4003. • {name} (`string`)
  4004. Return: ~
  4005. (`integer`)
  4006. hlexists({name}) *hlexists()*
  4007. The result is a Number, which is TRUE if a highlight group
  4008. called {name} exists. This is when the group has been
  4009. defined in some way. Not necessarily when highlighting has
  4010. been defined for it, it may also have been used for a syntax
  4011. item.
  4012. Parameters: ~
  4013. • {name} (`string`)
  4014. Return: ~
  4015. (`0|1`)
  4016. hostname() *hostname()*
  4017. The result is a String, which is the name of the machine on
  4018. which Vim is currently running. Machine names greater than
  4019. 256 characters long are truncated.
  4020. Return: ~
  4021. (`string`)
  4022. iconv({string}, {from}, {to}) *iconv()*
  4023. The result is a String, which is the text {string} converted
  4024. from encoding {from} to encoding {to}.
  4025. When the conversion completely fails an empty string is
  4026. returned. When some characters could not be converted they
  4027. are replaced with "?".
  4028. The encoding names are whatever the iconv() library function
  4029. can accept, see ":!man 3 iconv".
  4030. Note that Vim uses UTF-8 for all Unicode encodings, conversion
  4031. from/to UCS-2 is automatically changed to use UTF-8. You
  4032. cannot use UCS-2 in a string anyway, because of the NUL bytes.
  4033. Parameters: ~
  4034. • {string} (`string`)
  4035. • {from} (`string`)
  4036. • {to} (`string`)
  4037. Return: ~
  4038. (`string`)
  4039. id({expr}) *id()*
  4040. Returns a |String| which is a unique identifier of the
  4041. container type (|List|, |Dict|, |Blob| and |Partial|). It is
  4042. guaranteed that for the mentioned types `id(v1) ==# id(v2)`
  4043. returns true iff `type(v1) == type(v2) && v1 is v2`.
  4044. Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
  4045. `v:_null_blob` have the same `id()` with different types
  4046. because they are internally represented as NULL pointers.
  4047. `id()` returns a hexadecimal representation of the pointers to
  4048. the containers (i.e. like `0x994a40`), same as `printf("%p",
  4049. {expr})`, but it is advised against counting on the exact
  4050. format of the return value.
  4051. It is not guaranteed that `id(no_longer_existing_container)`
  4052. will not be equal to some other `id()`: new containers may
  4053. reuse identifiers of the garbage-collected ones.
  4054. Parameters: ~
  4055. • {expr} (`any`)
  4056. Return: ~
  4057. (`string`)
  4058. indent({lnum}) *indent()*
  4059. The result is a Number, which is indent of line {lnum} in the
  4060. current buffer. The indent is counted in spaces, the value
  4061. of 'tabstop' is relevant. {lnum} is used just like in
  4062. |getline()|.
  4063. When {lnum} is invalid -1 is returned.
  4064. Parameters: ~
  4065. • {lnum} (`integer|string`)
  4066. Return: ~
  4067. (`integer`)
  4068. index({object}, {expr} [, {start} [, {ic}]]) *index()*
  4069. Find {expr} in {object} and return its index. See
  4070. |indexof()| for using a lambda to select the item.
  4071. If {object} is a |List| return the lowest index where the item
  4072. has a value equal to {expr}. There is no automatic
  4073. conversion, so the String "4" is different from the Number 4.
  4074. And the Number 4 is different from the Float 4.0. The value
  4075. of 'ignorecase' is not used here, case matters as indicated by
  4076. the {ic} argument.
  4077. If {object} is a |Blob| return the lowest index where the byte
  4078. value is equal to {expr}.
  4079. If {start} is given then start looking at the item with index
  4080. {start} (may be negative for an item relative to the end).
  4081. When {ic} is given and it is |TRUE|, ignore case. Otherwise
  4082. case must match.
  4083. -1 is returned when {expr} is not found in {object}.
  4084. Example: >vim
  4085. let idx = index(words, "the")
  4086. if index(numbers, 123) >= 0
  4087. " ...
  4088. endif
  4089. <
  4090. Parameters: ~
  4091. • {object} (`any`)
  4092. • {expr} (`any`)
  4093. • {start} (`integer?`)
  4094. • {ic} (`boolean?`)
  4095. Return: ~
  4096. (`integer`)
  4097. indexof({object}, {expr} [, {opts}]) *indexof()*
  4098. Returns the index of an item in {object} where {expr} is
  4099. v:true. {object} must be a |List| or a |Blob|.
  4100. If {object} is a |List|, evaluate {expr} for each item in the
  4101. List until the expression is v:true and return the index of
  4102. this item.
  4103. If {object} is a |Blob| evaluate {expr} for each byte in the
  4104. Blob until the expression is v:true and return the index of
  4105. this byte.
  4106. {expr} must be a |string| or |Funcref|.
  4107. If {expr} is a |string|: If {object} is a |List|, inside
  4108. {expr} |v:key| has the index of the current List item and
  4109. |v:val| has the value of the item. If {object} is a |Blob|,
  4110. inside {expr} |v:key| has the index of the current byte and
  4111. |v:val| has the byte value.
  4112. If {expr} is a |Funcref| it must take two arguments:
  4113. 1. the key or the index of the current item.
  4114. 2. the value of the current item.
  4115. The function must return |TRUE| if the item is found and the
  4116. search should stop.
  4117. The optional argument {opts} is a Dict and supports the
  4118. following items:
  4119. startidx start evaluating {expr} at the item with this
  4120. index; may be negative for an item relative to
  4121. the end
  4122. Returns -1 when {expr} evaluates to v:false for all the items.
  4123. Example: >vim
  4124. let l = [#{n: 10}, #{n: 20}, #{n: 30}]
  4125. echo indexof(l, "v:val.n == 20")
  4126. echo indexof(l, {i, v -> v.n == 30})
  4127. echo indexof(l, "v:val.n == 20", #{startidx: 1})
  4128. <
  4129. Parameters: ~
  4130. • {object} (`any`)
  4131. • {expr} (`any`)
  4132. • {opts} (`table?`)
  4133. Return: ~
  4134. (`integer`)
  4135. input({prompt} [, {text} [, {completion}]]) *input()*
  4136. Parameters: ~
  4137. • {prompt} (`string`)
  4138. • {text} (`string?`)
  4139. • {completion} (`string?`)
  4140. Return: ~
  4141. (`string`)
  4142. input({opts})
  4143. The result is a String, which is whatever the user typed on
  4144. the command-line. The {prompt} argument is either a prompt
  4145. string, or a blank string (for no prompt). A '\n' can be used
  4146. in the prompt to start a new line.
  4147. In the second form it accepts a single dictionary with the
  4148. following keys, any of which may be omitted:
  4149. Key Default Description ~
  4150. prompt "" Same as {prompt} in the first form.
  4151. default "" Same as {text} in the first form.
  4152. completion nothing Same as {completion} in the first form.
  4153. cancelreturn "" The value returned when the dialog is
  4154. cancelled.
  4155. highlight nothing Highlight handler: |Funcref|.
  4156. The highlighting set with |:echohl| is used for the prompt.
  4157. The input is entered just like a command-line, with the same
  4158. editing commands and mappings. There is a separate history
  4159. for lines typed for input().
  4160. Example: >vim
  4161. if input("Coffee or beer? ") == "beer"
  4162. echo "Cheers!"
  4163. endif
  4164. <
  4165. If the optional {text} argument is present and not empty, this
  4166. is used for the default reply, as if the user typed this.
  4167. Example: >vim
  4168. let color = input("Color? ", "white")
  4169. < The optional {completion} argument specifies the type of
  4170. completion supported for the input. Without it completion is
  4171. not performed. The supported completion types are the same as
  4172. that can be supplied to a user-defined command using the
  4173. "-complete=" argument. Refer to |:command-completion| for
  4174. more information. Example: >vim
  4175. let fname = input("File: ", "", "file")
  4176. < *input()-highlight* *E5400* *E5402*
  4177. The optional `highlight` key allows specifying function which
  4178. will be used for highlighting user input. This function
  4179. receives user input as its only argument and must return
  4180. a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
  4181. where
  4182. hl_start_col is the first highlighted column,
  4183. hl_end_col is the last highlighted column (+ 1!),
  4184. hl_group is |:hi| group used for highlighting.
  4185. *E5403* *E5404* *E5405* *E5406*
  4186. Both hl_start_col and hl_end_col + 1 must point to the start
  4187. of the multibyte character (highlighting must not break
  4188. multibyte characters), hl_end_col + 1 may be equal to the
  4189. input length. Start column must be in range [0, len(input)),
  4190. end column must be in range (hl_start_col, len(input)],
  4191. sections must be ordered so that next hl_start_col is greater
  4192. then or equal to previous hl_end_col.
  4193. Example (try some input with parentheses): >vim
  4194. highlight RBP1 guibg=Red ctermbg=red
  4195. highlight RBP2 guibg=Yellow ctermbg=yellow
  4196. highlight RBP3 guibg=Green ctermbg=green
  4197. highlight RBP4 guibg=Blue ctermbg=blue
  4198. let g:rainbow_levels = 4
  4199. function! RainbowParens(cmdline)
  4200. let ret = []
  4201. let i = 0
  4202. let lvl = 0
  4203. while i < len(a:cmdline)
  4204. if a:cmdline[i] is# '('
  4205. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4206. let lvl += 1
  4207. elseif a:cmdline[i] is# ')'
  4208. let lvl -= 1
  4209. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4210. endif
  4211. let i += 1
  4212. endwhile
  4213. return ret
  4214. endfunction
  4215. call input({'prompt':'>','highlight':'RainbowParens'})
  4216. <
  4217. Highlight function is called at least once for each new
  4218. displayed input string, before command-line is redrawn. It is
  4219. expected that function is pure for the duration of one input()
  4220. call, i.e. it produces the same output for the same input, so
  4221. output may be memoized. Function is run like under |:silent|
  4222. modifier. If the function causes any errors, it will be
  4223. skipped for the duration of the current input() call.
  4224. Highlighting is disabled if command-line contains arabic
  4225. characters.
  4226. NOTE: This function must not be used in a startup file, for
  4227. the versions that only run in GUI mode (e.g., the Win32 GUI).
  4228. Note: When input() is called from within a mapping it will
  4229. consume remaining characters from that mapping, because a
  4230. mapping is handled like the characters were typed.
  4231. Use |inputsave()| before input() and |inputrestore()|
  4232. after input() to avoid that. Another solution is to avoid
  4233. that further characters follow in the mapping, e.g., by using
  4234. |:execute| or |:normal|.
  4235. Example with a mapping: >vim
  4236. nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
  4237. function GetFoo()
  4238. call inputsave()
  4239. let g:Foo = input("enter search pattern: ")
  4240. call inputrestore()
  4241. endfunction
  4242. <
  4243. Parameters: ~
  4244. • {opts} (`table`)
  4245. Return: ~
  4246. (`string`)
  4247. inputlist({textlist}) *inputlist()*
  4248. {textlist} must be a |List| of strings. This |List| is
  4249. displayed, one string per line. The user will be prompted to
  4250. enter a number, which is returned.
  4251. The user can also select an item by clicking on it with the
  4252. mouse, if the mouse is enabled in the command line ('mouse' is
  4253. "a" or includes "c"). For the first string 0 is returned.
  4254. When clicking above the first item a negative number is
  4255. returned. When clicking on the prompt one more than the
  4256. length of {textlist} is returned.
  4257. Make sure {textlist} has less than 'lines' entries, otherwise
  4258. it won't work. It's a good idea to put the entry number at
  4259. the start of the string. And put a prompt in the first item.
  4260. Example: >vim
  4261. let color = inputlist(['Select color:', '1. red',
  4262. \ '2. green', '3. blue'])
  4263. Parameters: ~
  4264. • {textlist} (`string[]`)
  4265. Return: ~
  4266. (`any`)
  4267. inputrestore() *inputrestore()*
  4268. Restore typeahead that was saved with a previous |inputsave()|.
  4269. Should be called the same number of times inputsave() is
  4270. called. Calling it more often is harmless though.
  4271. Returns TRUE when there is nothing to restore, FALSE otherwise.
  4272. Return: ~
  4273. (`integer`)
  4274. inputsave() *inputsave()*
  4275. Preserve typeahead (also from mappings) and clear it, so that
  4276. a following prompt gets input from the user. Should be
  4277. followed by a matching inputrestore() after the prompt. Can
  4278. be used several times, in which case there must be just as
  4279. many inputrestore() calls.
  4280. Returns TRUE when out of memory, FALSE otherwise.
  4281. Return: ~
  4282. (`integer`)
  4283. inputsecret({prompt} [, {text}]) *inputsecret()*
  4284. This function acts much like the |input()| function with but
  4285. two exceptions:
  4286. a) the user's response will be displayed as a sequence of
  4287. asterisks ("*") thereby keeping the entry secret, and
  4288. b) the user's response will not be recorded on the input
  4289. |history| stack.
  4290. The result is a String, which is whatever the user actually
  4291. typed on the command-line in response to the issued prompt.
  4292. NOTE: Command-line completion is not supported.
  4293. Parameters: ~
  4294. • {prompt} (`string`)
  4295. • {text} (`string?`)
  4296. Return: ~
  4297. (`string`)
  4298. insert({object}, {item} [, {idx}]) *insert()*
  4299. When {object} is a |List| or a |Blob| insert {item} at the start
  4300. of it.
  4301. If {idx} is specified insert {item} before the item with index
  4302. {idx}. If {idx} is zero it goes before the first item, just
  4303. like omitting {idx}. A negative {idx} is also possible, see
  4304. |list-index|. -1 inserts just before the last item.
  4305. Returns the resulting |List| or |Blob|. Examples: >vim
  4306. let mylist = insert([2, 3, 5], 1)
  4307. call insert(mylist, 4, -1)
  4308. call insert(mylist, 6, len(mylist))
  4309. < The last example can be done simpler with |add()|.
  4310. Note that when {item} is a |List| it is inserted as a single
  4311. item. Use |extend()| to concatenate |Lists|.
  4312. Parameters: ~
  4313. • {object} (`any`)
  4314. • {item} (`any`)
  4315. • {idx} (`integer?`)
  4316. Return: ~
  4317. (`any`)
  4318. interrupt() *interrupt()*
  4319. Interrupt script execution. It works more or less like the
  4320. user typing CTRL-C, most commands won't execute and control
  4321. returns to the user. This is useful to abort execution
  4322. from lower down, e.g. in an autocommand. Example: >vim
  4323. function s:check_typoname(file)
  4324. if fnamemodify(a:file, ':t') == '['
  4325. echomsg 'Maybe typo'
  4326. call interrupt()
  4327. endif
  4328. endfunction
  4329. au BufWritePre * call s:check_typoname(expand('<amatch>'))
  4330. <
  4331. Return: ~
  4332. (`any`)
  4333. invert({expr}) *invert()*
  4334. Bitwise invert. The argument is converted to a number. A
  4335. List, Dict or Float argument causes an error. Example: >vim
  4336. let bits = invert(bits)
  4337. <
  4338. Parameters: ~
  4339. • {expr} (`integer`)
  4340. Return: ~
  4341. (`integer`)
  4342. isabsolutepath({path}) *isabsolutepath()*
  4343. The result is a Number, which is |TRUE| when {path} is an
  4344. absolute path.
  4345. On Unix, a path is considered absolute when it starts with '/'.
  4346. On MS-Windows, it is considered absolute when it starts with an
  4347. optional drive prefix and is followed by a '\' or '/'. UNC paths
  4348. are always absolute.
  4349. Example: >vim
  4350. echo isabsolutepath('/usr/share/') " 1
  4351. echo isabsolutepath('./foobar') " 0
  4352. echo isabsolutepath('C:\Windows') " 1
  4353. echo isabsolutepath('foobar') " 0
  4354. echo isabsolutepath('\\remote\file') " 1
  4355. <
  4356. Parameters: ~
  4357. • {path} (`string`)
  4358. Return: ~
  4359. (`0|1`)
  4360. isdirectory({directory}) *isdirectory()*
  4361. The result is a Number, which is |TRUE| when a directory
  4362. with the name {directory} exists. If {directory} doesn't
  4363. exist, or isn't a directory, the result is |FALSE|. {directory}
  4364. is any expression, which is used as a String.
  4365. Parameters: ~
  4366. • {directory} (`string`)
  4367. Return: ~
  4368. (`0|1`)
  4369. isinf({expr}) *isinf()*
  4370. Return 1 if {expr} is a positive infinity, or -1 a negative
  4371. infinity, otherwise 0. >vim
  4372. echo isinf(1.0 / 0.0)
  4373. < 1 >vim
  4374. echo isinf(-1.0 / 0.0)
  4375. < -1
  4376. Parameters: ~
  4377. • {expr} (`number`)
  4378. Return: ~
  4379. (`1|0|-1`)
  4380. islocked({expr}) *islocked()* *E786*
  4381. The result is a Number, which is |TRUE| when {expr} is the
  4382. name of a locked variable.
  4383. The string argument {expr} must be the name of a variable,
  4384. |List| item or |Dictionary| entry, not the variable itself!
  4385. Example: >vim
  4386. let alist = [0, ['a', 'b'], 2, 3]
  4387. lockvar 1 alist
  4388. echo islocked('alist') " 1
  4389. echo islocked('alist[1]') " 0
  4390. < When {expr} is a variable that does not exist you get an error
  4391. message. Use |exists()| to check for existence.
  4392. Parameters: ~
  4393. • {expr} (`any`)
  4394. Return: ~
  4395. (`0|1`)
  4396. isnan({expr}) *isnan()*
  4397. Return |TRUE| if {expr} is a float with value NaN. >vim
  4398. echo isnan(0.0 / 0.0)
  4399. < 1
  4400. Parameters: ~
  4401. • {expr} (`number`)
  4402. Return: ~
  4403. (`0|1`)
  4404. items({dict}) *items()*
  4405. Return a |List| with all the key-value pairs of {dict}. Each
  4406. |List| item is a list with two items: the key of a {dict}
  4407. entry and the value of this entry. The |List| is in arbitrary
  4408. order. Also see |keys()| and |values()|.
  4409. Example: >vim
  4410. for [key, value] in items(mydict)
  4411. echo key .. ': ' .. value
  4412. endfor
  4413. <
  4414. A List or a String argument is also supported. In these
  4415. cases, items() returns a List with the index and the value at
  4416. the index.
  4417. Parameters: ~
  4418. • {dict} (`table`)
  4419. Return: ~
  4420. (`any`)
  4421. jobpid({job}) *jobpid()*
  4422. Return the PID (process id) of |job-id| {job}.
  4423. Parameters: ~
  4424. • {job} (`integer`)
  4425. Return: ~
  4426. (`integer`)
  4427. jobresize({job}, {width}, {height}) *jobresize()*
  4428. Resize the pseudo terminal window of |job-id| {job} to {width}
  4429. columns and {height} rows.
  4430. Fails if the job was not started with `"pty":v:true`.
  4431. Parameters: ~
  4432. • {job} (`integer`)
  4433. • {width} (`integer`)
  4434. • {height} (`integer`)
  4435. Return: ~
  4436. (`any`)
  4437. jobstart({cmd} [, {opts}]) *jobstart()*
  4438. Note: Prefer |vim.system()| in Lua (unless using `rpc`, `pty`, or `term`).
  4439. Spawns {cmd} as a job.
  4440. If {cmd} is a List it runs directly (no 'shell').
  4441. If {cmd} is a String it runs in the 'shell', like this: >vim
  4442. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  4443. < (See |shell-unquoting| for details.)
  4444. Example: start a job and handle its output: >vim
  4445. call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}})
  4446. <
  4447. Example: start a job in a |terminal| connected to the current buffer: >vim
  4448. call jobstart(['nvim', '-h'], {'term':v:true})
  4449. <
  4450. Returns |job-id| on success, 0 on invalid arguments (or job
  4451. table is full), -1 if {cmd}[0] or 'shell' is not executable.
  4452. The returned job-id is a valid |channel-id| representing the
  4453. job's stdio streams. Use |chansend()| (or |rpcnotify()| and
  4454. |rpcrequest()| if "rpc" was enabled) to send data to stdin and
  4455. |chanclose()| to close the streams without stopping the job.
  4456. See |job-control| and |RPC|.
  4457. NOTE: on Windows if {cmd} is a List:
  4458. - cmd[0] must be an executable (not a "built-in"). If it is
  4459. in $PATH it can be called by name, without an extension: >vim
  4460. call jobstart(['ping', 'neovim.io'])
  4461. < If it is a full or partial path, extension is required: >vim
  4462. call jobstart(['System32\ping.exe', 'neovim.io'])
  4463. < - {cmd} is collapsed to a string of quoted args as expected
  4464. by CommandLineToArgvW https://msdn.microsoft.com/bb776391
  4465. unless cmd[0] is some form of "cmd.exe".
  4466. *jobstart-env*
  4467. The job environment is initialized as follows:
  4468. $NVIM is set to |v:servername| of the parent Nvim
  4469. $NVIM_LISTEN_ADDRESS is unset
  4470. $NVIM_LOG_FILE is unset
  4471. $VIM is unset
  4472. $VIMRUNTIME is unset
  4473. You can set these with the `env` option.
  4474. *jobstart-options*
  4475. {opts} is a dictionary with these keys:
  4476. clear_env: (boolean) `env` defines the job environment
  4477. exactly, instead of merging current environment.
  4478. cwd: (string, default=|current-directory|) Working
  4479. directory of the job.
  4480. detach: (boolean) Detach the job process: it will not be
  4481. killed when Nvim exits. If the process exits
  4482. before Nvim, `on_exit` will be invoked.
  4483. env: (dict) Map of environment variable name:value
  4484. pairs extending (or replace with "clear_env")
  4485. the current environment. |jobstart-env|
  4486. height: (number) Height of the `pty` terminal.
  4487. |on_exit|: (function) Callback invoked when the job exits.
  4488. |on_stdout|: (function) Callback invoked when the job emits
  4489. stdout data.
  4490. |on_stderr|: (function) Callback invoked when the job emits
  4491. stderr data.
  4492. overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
  4493. stdio passed to the child process. Only on
  4494. MS-Windows; ignored on other platforms.
  4495. pty: (boolean) Connect the job to a new pseudo
  4496. terminal, and its streams to the master file
  4497. descriptor. `on_stdout` receives all output,
  4498. `on_stderr` is ignored. |terminal-start|
  4499. rpc: (boolean) Use |msgpack-rpc| to communicate with
  4500. the job over stdio. Then `on_stdout` is ignored,
  4501. but `on_stderr` can still be used.
  4502. stderr_buffered: (boolean) Collect data until EOF (stream closed)
  4503. before invoking `on_stderr`. |channel-buffered|
  4504. stdout_buffered: (boolean) Collect data until EOF (stream
  4505. closed) before invoking `on_stdout`. |channel-buffered|
  4506. stdin: (string) Either "pipe" (default) to connect the
  4507. job's stdin to a channel or "null" to disconnect
  4508. stdin.
  4509. term: (boolean) Spawns {cmd} in a new pseudo-terminal session
  4510. connected to the current (unmodified) buffer. Implies "pty".
  4511. Default "height" and "width" are set to the current window
  4512. dimensions. |jobstart()|. Defaults $TERM to "xterm-256color".
  4513. width: (number) Width of the `pty` terminal.
  4514. {opts} is passed as |self| dictionary to the callback; the
  4515. caller may set other keys to pass application-specific data.
  4516. Returns:
  4517. - |channel-id| on success
  4518. - 0 on invalid arguments
  4519. - -1 if {cmd}[0] is not executable.
  4520. See also |job-control|, |channel|, |msgpack-rpc|.
  4521. Parameters: ~
  4522. • {cmd} (`string|string[]`)
  4523. • {opts} (`table?`)
  4524. Return: ~
  4525. (`integer`)
  4526. jobstop({id}) *jobstop()*
  4527. Stop |job-id| {id} by sending SIGTERM to the job process. If
  4528. the process does not terminate after a timeout then SIGKILL
  4529. will be sent. When the job terminates its |on_exit| handler
  4530. (if any) will be invoked.
  4531. See |job-control|.
  4532. Returns 1 for valid job id, 0 for invalid id, including jobs have
  4533. exited or stopped.
  4534. Parameters: ~
  4535. • {id} (`integer`)
  4536. Return: ~
  4537. (`integer`)
  4538. jobwait({jobs} [, {timeout}]) *jobwait()*
  4539. Waits for jobs and their |on_exit| handlers to complete.
  4540. {jobs} is a List of |job-id|s to wait for.
  4541. {timeout} is the maximum waiting time in milliseconds. If
  4542. omitted or -1, wait forever.
  4543. Timeout of 0 can be used to check the status of a job: >vim
  4544. let running = jobwait([{job-id}], 0)[0] == -1
  4545. <
  4546. During jobwait() callbacks for jobs not in the {jobs} list may
  4547. be invoked. The screen will not redraw unless |:redraw| is
  4548. invoked by a callback.
  4549. Returns a list of len({jobs}) integers, where each integer is
  4550. the status of the corresponding job:
  4551. Exit-code, if the job exited
  4552. -1 if the timeout was exceeded
  4553. -2 if the job was interrupted (by |CTRL-C|)
  4554. -3 if the job-id is invalid
  4555. Parameters: ~
  4556. • {jobs} (`integer[]`)
  4557. • {timeout} (`integer?`)
  4558. Return: ~
  4559. (`integer[]`)
  4560. join({list} [, {sep}]) *join()*
  4561. Join the items in {list} together into one String.
  4562. When {sep} is specified it is put in between the items. If
  4563. {sep} is omitted a single space is used.
  4564. Note that {sep} is not added at the end. You might want to
  4565. add it there too: >vim
  4566. let lines = join(mylist, "\n") .. "\n"
  4567. < String items are used as-is. |Lists| and |Dictionaries| are
  4568. converted into a string like with |string()|.
  4569. The opposite function is |split()|.
  4570. Parameters: ~
  4571. • {list} (`any[]`)
  4572. • {sep} (`string?`)
  4573. Return: ~
  4574. (`string`)
  4575. json_decode({expr}) *json_decode()*
  4576. Convert {expr} from JSON object. Accepts |readfile()|-style
  4577. list as the input, as well as regular string. May output any
  4578. Vim value. In the following cases it will output
  4579. |msgpack-special-dict|:
  4580. 1. Dictionary contains duplicate key.
  4581. 2. String contains NUL byte. Two special dictionaries: for
  4582. dictionary and for string will be emitted in case string
  4583. with NUL byte was a dictionary key.
  4584. Note: function treats its input as UTF-8 always. The JSON
  4585. standard allows only a few encodings, of which UTF-8 is
  4586. recommended and the only one required to be supported.
  4587. Non-UTF-8 characters are an error.
  4588. Parameters: ~
  4589. • {expr} (`any`)
  4590. Return: ~
  4591. (`any`)
  4592. json_encode({expr}) *json_encode()*
  4593. Convert {expr} into a JSON string. Accepts
  4594. |msgpack-special-dict| as the input. Will not convert
  4595. |Funcref|s, mappings with non-string keys (can be created as
  4596. |msgpack-special-dict|), values with self-referencing
  4597. containers, strings which contain non-UTF-8 characters,
  4598. pseudo-UTF-8 strings which contain codepoints reserved for
  4599. surrogate pairs (such strings are not valid UTF-8 strings).
  4600. Non-printable characters are converted into "\u1234" escapes
  4601. or special escapes like "\t", other are dumped as-is.
  4602. |Blob|s are converted to arrays of the individual bytes.
  4603. Parameters: ~
  4604. • {expr} (`any`)
  4605. Return: ~
  4606. (`string`)
  4607. keys({dict}) *keys()*
  4608. Return a |List| with all the keys of {dict}. The |List| is in
  4609. arbitrary order. Also see |items()| and |values()|.
  4610. Parameters: ~
  4611. • {dict} (`table`)
  4612. Return: ~
  4613. (`string[]`)
  4614. keytrans({string}) *keytrans()*
  4615. Turn the internal byte representation of keys into a form that
  4616. can be used for |:map|. E.g. >vim
  4617. let xx = "\<C-Home>"
  4618. echo keytrans(xx)
  4619. < <C-Home>
  4620. Parameters: ~
  4621. • {string} (`string`)
  4622. Return: ~
  4623. (`string`)
  4624. len({expr}) *len()* *E701*
  4625. The result is a Number, which is the length of the argument.
  4626. When {expr} is a String or a Number the length in bytes is
  4627. used, as with |strlen()|.
  4628. When {expr} is a |List| the number of items in the |List| is
  4629. returned.
  4630. When {expr} is a |Blob| the number of bytes is returned.
  4631. When {expr} is a |Dictionary| the number of entries in the
  4632. |Dictionary| is returned.
  4633. Otherwise an error is given and returns zero.
  4634. Parameters: ~
  4635. • {expr} (`any[]`)
  4636. Return: ~
  4637. (`integer`)
  4638. libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E368*
  4639. Call function {funcname} in the run-time library {libname}
  4640. with single argument {argument}.
  4641. This is useful to call functions in a library that you
  4642. especially made to be used with Vim. Since only one argument
  4643. is possible, calling standard library functions is rather
  4644. limited.
  4645. The result is the String returned by the function. If the
  4646. function returns NULL, this will appear as an empty string ""
  4647. to Vim.
  4648. If the function returns a number, use libcallnr()!
  4649. If {argument} is a number, it is passed to the function as an
  4650. int; if {argument} is a string, it is passed as a
  4651. null-terminated string.
  4652. libcall() allows you to write your own 'plug-in' extensions to
  4653. Vim without having to recompile the program. It is NOT a
  4654. means to call system functions! If you try to do so Vim will
  4655. very probably crash.
  4656. For Win32, the functions you write must be placed in a DLL
  4657. and use the normal C calling convention (NOT Pascal which is
  4658. used in Windows System DLLs). The function must take exactly
  4659. one parameter, either a character pointer or a long integer,
  4660. and must return a character pointer or NULL. The character
  4661. pointer returned must point to memory that will remain valid
  4662. after the function has returned (e.g. in static data in the
  4663. DLL). If it points to allocated memory, that memory will
  4664. leak away. Using a static buffer in the function should work,
  4665. it's then freed when the DLL is unloaded.
  4666. WARNING: If the function returns a non-valid pointer, Vim may
  4667. crash! This also happens if the function returns a number,
  4668. because Vim thinks it's a pointer.
  4669. For Win32 systems, {libname} should be the filename of the DLL
  4670. without the ".DLL" suffix. A full path is only required if
  4671. the DLL is not in the usual places.
  4672. For Unix: When compiling your own plugins, remember that the
  4673. object code must be compiled as position-independent ('PIC').
  4674. Examples: >vim
  4675. echo libcall("libc.so", "getenv", "HOME")
  4676. Parameters: ~
  4677. • {libname} (`string`)
  4678. • {funcname} (`string`)
  4679. • {argument} (`any`)
  4680. Return: ~
  4681. (`any`)
  4682. libcallnr({libname}, {funcname}, {argument}) *libcallnr()*
  4683. Just like |libcall()|, but used for a function that returns an
  4684. int instead of a string.
  4685. Examples: >vim
  4686. echo libcallnr("/usr/lib/libc.so", "getpid", "")
  4687. call libcallnr("libc.so", "printf", "Hello World!\n")
  4688. call libcallnr("libc.so", "sleep", 10)
  4689. <
  4690. Parameters: ~
  4691. • {libname} (`string`)
  4692. • {funcname} (`string`)
  4693. • {argument} (`any`)
  4694. Return: ~
  4695. (`any`)
  4696. line({expr} [, {winid}]) *line()*
  4697. See |getpos()| for accepted positions.
  4698. To get the column number use |col()|. To get both use
  4699. |getpos()|.
  4700. With the optional {winid} argument the values are obtained for
  4701. that window instead of the current window.
  4702. Returns 0 for invalid values of {expr} and {winid}.
  4703. Examples: >vim
  4704. echo line(".") " line number of the cursor
  4705. echo line(".", winid) " idem, in window "winid"
  4706. echo line("'t") " line number of mark t
  4707. echo line("'" .. marker) " line number of mark marker
  4708. <
  4709. To jump to the last known position when opening a file see
  4710. |last-position-jump|.
  4711. Parameters: ~
  4712. • {expr} (`string|integer[]`)
  4713. • {winid} (`integer?`)
  4714. Return: ~
  4715. (`integer`)
  4716. line2byte({lnum}) *line2byte()*
  4717. Return the byte count from the start of the buffer for line
  4718. {lnum}. This includes the end-of-line character, depending on
  4719. the 'fileformat' option for the current buffer. The first
  4720. line returns 1. UTF-8 encoding is used, 'fileencoding' is
  4721. ignored. This can also be used to get the byte count for the
  4722. line just below the last line: >vim
  4723. echo line2byte(line("$") + 1)
  4724. < This is the buffer size plus one. If 'fileencoding' is empty
  4725. it is the file size plus one. {lnum} is used like with
  4726. |getline()|. When {lnum} is invalid -1 is returned.
  4727. Also see |byte2line()|, |go| and |:goto|.
  4728. Parameters: ~
  4729. • {lnum} (`integer`)
  4730. Return: ~
  4731. (`integer`)
  4732. lispindent({lnum}) *lispindent()*
  4733. Get the amount of indent for line {lnum} according the lisp
  4734. indenting rules, as with 'lisp'.
  4735. The indent is counted in spaces, the value of 'tabstop' is
  4736. relevant. {lnum} is used just like in |getline()|.
  4737. When {lnum} is invalid, -1 is returned.
  4738. Parameters: ~
  4739. • {lnum} (`integer`)
  4740. Return: ~
  4741. (`integer`)
  4742. list2blob({list}) *list2blob()*
  4743. Return a Blob concatenating all the number values in {list}.
  4744. Examples: >vim
  4745. echo list2blob([1, 2, 3, 4]) " returns 0z01020304
  4746. echo list2blob([]) " returns 0z
  4747. < Returns an empty Blob on error. If one of the numbers is
  4748. negative or more than 255 error *E1239* is given.
  4749. |blob2list()| does the opposite.
  4750. Parameters: ~
  4751. • {list} (`any[]`)
  4752. Return: ~
  4753. (`string`)
  4754. list2str({list} [, {utf8}]) *list2str()*
  4755. Convert each number in {list} to a character string can
  4756. concatenate them all. Examples: >vim
  4757. echo list2str([32]) " returns " "
  4758. echo list2str([65, 66, 67]) " returns "ABC"
  4759. < The same can be done (slowly) with: >vim
  4760. echo join(map(list, {nr, val -> nr2char(val)}), '')
  4761. < |str2list()| does the opposite.
  4762. UTF-8 encoding is always used, {utf8} option has no effect,
  4763. and exists only for backwards-compatibility.
  4764. With UTF-8 composing characters work as expected: >vim
  4765. echo list2str([97, 769]) " returns "á"
  4766. <
  4767. Returns an empty string on error.
  4768. Parameters: ~
  4769. • {list} (`any[]`)
  4770. • {utf8} (`boolean?`)
  4771. Return: ~
  4772. (`string`)
  4773. localtime() *localtime()*
  4774. Return the current time, measured as seconds since 1st Jan
  4775. 1970. See also |strftime()|, |strptime()| and |getftime()|.
  4776. Return: ~
  4777. (`integer`)
  4778. log({expr}) *log()*
  4779. Return the natural logarithm (base e) of {expr} as a |Float|.
  4780. {expr} must evaluate to a |Float| or a |Number| in the range
  4781. (0, inf].
  4782. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4783. Examples: >vim
  4784. echo log(10)
  4785. < 2.302585 >vim
  4786. echo log(exp(5))
  4787. < 5.0
  4788. Parameters: ~
  4789. • {expr} (`number`)
  4790. Return: ~
  4791. (`number`)
  4792. log10({expr}) *log10()*
  4793. Return the logarithm of Float {expr} to base 10 as a |Float|.
  4794. {expr} must evaluate to a |Float| or a |Number|.
  4795. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4796. Examples: >vim
  4797. echo log10(1000)
  4798. < 3.0 >vim
  4799. echo log10(0.01)
  4800. < -2.0
  4801. Parameters: ~
  4802. • {expr} (`number`)
  4803. Return: ~
  4804. (`number`)
  4805. luaeval({expr} [, {expr}]) *luaeval()*
  4806. Evaluate Lua expression {expr} and return its result converted
  4807. to Vim data structures. See |lua-eval| for more details.
  4808. Parameters: ~
  4809. • {expr} (`string`)
  4810. • {expr1} (`any[]?`)
  4811. Return: ~
  4812. (`any`)
  4813. map({expr1}, {expr2}) *map()*
  4814. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  4815. When {expr1} is a |List| or |Dictionary|, replace each
  4816. item in {expr1} with the result of evaluating {expr2}.
  4817. For a |Blob| each byte is replaced.
  4818. For a |String|, each character, including composing
  4819. characters, is replaced.
  4820. If the item type changes you may want to use |mapnew()| to
  4821. create a new List or Dictionary.
  4822. {expr2} must be a |String| or |Funcref|.
  4823. If {expr2} is a |String|, inside {expr2} |v:val| has the value
  4824. of the current item. For a |Dictionary| |v:key| has the key
  4825. of the current item and for a |List| |v:key| has the index of
  4826. the current item. For a |Blob| |v:key| has the index of the
  4827. current byte. For a |String| |v:key| has the index of the
  4828. current character.
  4829. Example: >vim
  4830. call map(mylist, '"> " .. v:val .. " <"')
  4831. < This puts "> " before and " <" after each item in "mylist".
  4832. Note that {expr2} is the result of an expression and is then
  4833. used as an expression again. Often it is good to use a
  4834. |literal-string| to avoid having to double backslashes. You
  4835. still have to double ' quotes
  4836. If {expr2} is a |Funcref| it is called with two arguments:
  4837. 1. The key or the index of the current item.
  4838. 2. the value of the current item.
  4839. The function must return the new value of the item. Example
  4840. that changes each value by "key-value": >vim
  4841. func KeyValue(key, val)
  4842. return a:key .. '-' .. a:val
  4843. endfunc
  4844. call map(myDict, function('KeyValue'))
  4845. < It is shorter when using a |lambda|: >vim
  4846. call map(myDict, {key, val -> key .. '-' .. val})
  4847. < If you do not use "val" you can leave it out: >vim
  4848. call map(myDict, {key -> 'item: ' .. key})
  4849. < If you do not use "key" you can use a short name: >vim
  4850. call map(myDict, {_, val -> 'item: ' .. val})
  4851. <
  4852. The operation is done in-place for a |List| and |Dictionary|.
  4853. If you want it to remain unmodified make a copy first: >vim
  4854. let tlist = map(copy(mylist), ' v:val .. "\t"')
  4855. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  4856. or a new |Blob| or |String|.
  4857. When an error is encountered while evaluating {expr2} no
  4858. further items in {expr1} are processed.
  4859. When {expr2} is a Funcref errors inside a function are ignored,
  4860. unless it was defined with the "abort" flag.
  4861. Parameters: ~
  4862. • {expr1} (`string|table|any[]`)
  4863. • {expr2} (`string|function`)
  4864. Return: ~
  4865. (`any`)
  4866. maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
  4867. When {dict} is omitted or zero: Return the rhs of mapping
  4868. {name} in mode {mode}. The returned String has special
  4869. characters translated like in the output of the ":map" command
  4870. listing. When {dict} is TRUE a dictionary is returned, see
  4871. below. To get a list of all mappings see |maplist()|.
  4872. When there is no mapping for {name}, an empty String is
  4873. returned if {dict} is FALSE, otherwise returns an empty Dict.
  4874. When the mapping for {name} is empty, then "<Nop>" is
  4875. returned.
  4876. The {name} can have special key names, like in the ":map"
  4877. command.
  4878. {mode} can be one of these strings:
  4879. "n" Normal
  4880. "v" Visual (including Select)
  4881. "o" Operator-pending
  4882. "i" Insert
  4883. "c" Cmd-line
  4884. "s" Select
  4885. "x" Visual
  4886. "l" langmap |language-mapping|
  4887. "t" Terminal
  4888. "" Normal, Visual and Operator-pending
  4889. When {mode} is omitted, the modes for "" are used.
  4890. When {abbr} is there and it is |TRUE| use abbreviations
  4891. instead of mappings.
  4892. When {dict} is there and it is |TRUE| return a dictionary
  4893. containing all the information of the mapping with the
  4894. following items: *mapping-dict*
  4895. "lhs" The {lhs} of the mapping as it would be typed
  4896. "lhsraw" The {lhs} of the mapping as raw bytes
  4897. "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
  4898. form, only present when it differs from "lhsraw"
  4899. "rhs" The {rhs} of the mapping as typed.
  4900. "callback" Lua function, if RHS was defined as such.
  4901. "silent" 1 for a |:map-silent| mapping, else 0.
  4902. "noremap" 1 if the {rhs} of the mapping is not remappable.
  4903. "script" 1 if mapping was defined with <script>.
  4904. "expr" 1 for an expression mapping (|:map-<expr>|).
  4905. "buffer" 1 for a buffer local mapping (|:map-local|).
  4906. "mode" Modes for which the mapping is defined. In
  4907. addition to the modes mentioned above, these
  4908. characters will be used:
  4909. " " Normal, Visual and Operator-pending
  4910. "!" Insert and Commandline mode
  4911. (|mapmode-ic|)
  4912. "sid" The script local ID, used for <sid> mappings
  4913. (|<SID>|). Negative for special contexts.
  4914. "scriptversion" The version of the script, always 1.
  4915. "lnum" The line number in "sid", zero if unknown.
  4916. "nowait" Do not wait for other, longer mappings.
  4917. (|:map-<nowait>|).
  4918. "abbr" True if this is an |abbreviation|.
  4919. "mode_bits" Nvim's internal binary representation of "mode".
  4920. |mapset()| ignores this; only "mode" is used.
  4921. See |maplist()| for usage examples. The values
  4922. are from src/nvim/state_defs.h and may change in
  4923. the future.
  4924. The dictionary can be used to restore a mapping with
  4925. |mapset()|.
  4926. The mappings local to the current buffer are checked first,
  4927. then the global mappings.
  4928. This function can be used to map a key even when it's already
  4929. mapped, and have it do the original mapping too. Sketch: >vim
  4930. exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
  4931. <
  4932. Parameters: ~
  4933. • {name} (`string`)
  4934. • {mode} (`string?`)
  4935. • {abbr} (`boolean?`)
  4936. • {dict} (`false?`)
  4937. Return: ~
  4938. (`string`)
  4939. mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
  4940. Check if there is a mapping that matches with {name} in mode
  4941. {mode}. See |maparg()| for {mode} and special names in
  4942. {name}.
  4943. When {abbr} is there and it is non-zero use abbreviations
  4944. instead of mappings.
  4945. A match happens with a mapping that starts with {name} and
  4946. with a mapping which is equal to the start of {name}.
  4947. matches mapping "a" "ab" "abc" ~
  4948. mapcheck("a") yes yes yes
  4949. mapcheck("abc") yes yes yes
  4950. mapcheck("ax") yes no no
  4951. mapcheck("b") no no no
  4952. The difference with maparg() is that mapcheck() finds a
  4953. mapping that matches with {name}, while maparg() only finds a
  4954. mapping for {name} exactly.
  4955. When there is no mapping that starts with {name}, an empty
  4956. String is returned. If there is one, the RHS of that mapping
  4957. is returned. If there are several mappings that start with
  4958. {name}, the RHS of one of them is returned. This will be
  4959. "<Nop>" if the RHS is empty.
  4960. The mappings local to the current buffer are checked first,
  4961. then the global mappings.
  4962. This function can be used to check if a mapping can be added
  4963. without being ambiguous. Example: >vim
  4964. if mapcheck("_vv") == ""
  4965. map _vv :set guifont=7x13<CR>
  4966. endif
  4967. < This avoids adding the "_vv" mapping when there already is a
  4968. mapping for "_v" or for "_vvv".
  4969. Parameters: ~
  4970. • {name} (`string`)
  4971. • {mode} (`string?`)
  4972. • {abbr} (`boolean?`)
  4973. Return: ~
  4974. (`any`)
  4975. maplist([{abbr}]) *maplist()*
  4976. Returns a |List| of all mappings. Each List item is a |Dict|,
  4977. the same as what is returned by |maparg()|, see
  4978. |mapping-dict|. When {abbr} is there and it is |TRUE| use
  4979. abbreviations instead of mappings.
  4980. Example to show all mappings with "MultiMatch" in rhs: >vim
  4981. echo maplist()->filter({_, m ->
  4982. \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
  4983. \ })
  4984. < It can be tricky to find mappings for particular |:map-modes|.
  4985. |mapping-dict|'s "mode_bits" can simplify this. For example,
  4986. the mode_bits for Normal, Insert or Command-line modes are
  4987. 0x19. To find all the mappings available in those modes you
  4988. can do: >vim
  4989. let saved_maps = []
  4990. for m in maplist()
  4991. if and(m.mode_bits, 0x19) != 0
  4992. eval saved_maps->add(m)
  4993. endif
  4994. endfor
  4995. echo saved_maps->mapnew({_, m -> m.lhs})
  4996. < The values of the mode_bits are defined in Nvim's
  4997. src/nvim/state_defs.h file and they can be discovered at
  4998. runtime using |:map-commands| and "maplist()". Example: >vim
  4999. omap xyzzy <Nop>
  5000. let op_bit = maplist()->filter(
  5001. \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
  5002. ounmap xyzzy
  5003. echo printf("Operator-pending mode bit: 0x%x", op_bit)
  5004. <
  5005. Parameters: ~
  5006. • {abbr} (`0|1?`)
  5007. Return: ~
  5008. (`table[]`)
  5009. mapnew({expr1}, {expr2}) *mapnew()*
  5010. Like |map()| but instead of replacing items in {expr1} a new
  5011. List or Dictionary is created and returned. {expr1} remains
  5012. unchanged. Items can still be changed by {expr2}, if you
  5013. don't want that use |deepcopy()| first.
  5014. Parameters: ~
  5015. • {expr1} (`any`)
  5016. • {expr2} (`any`)
  5017. Return: ~
  5018. (`any`)
  5019. mapset({mode}, {abbr}, {dict}) *mapset()*
  5020. mapset({dict})
  5021. Restore a mapping from a dictionary, possibly returned by
  5022. |maparg()| or |maplist()|. A buffer mapping, when dict.buffer
  5023. is true, is set on the current buffer; it is up to the caller
  5024. to ensure that the intended buffer is the current buffer. This
  5025. feature allows copying mappings from one buffer to another.
  5026. The dict.mode value may restore a single mapping that covers
  5027. more than one mode, like with mode values of '!', ' ', "nox",
  5028. or 'v'. *E1276*
  5029. In the first form, {mode} and {abbr} should be the same as
  5030. for the call to |maparg()|. *E460*
  5031. {mode} is used to define the mode in which the mapping is set,
  5032. not the "mode" entry in {dict}.
  5033. Example for saving and restoring a mapping: >vim
  5034. let save_map = maparg('K', 'n', 0, 1)
  5035. nnoremap K somethingelse
  5036. " ...
  5037. call mapset('n', 0, save_map)
  5038. < Note that if you are going to replace a map in several modes,
  5039. e.g. with `:map!`, you need to save/restore the mapping for
  5040. all of them, when they might differ.
  5041. In the second form, with {dict} as the only argument, mode
  5042. and abbr are taken from the dict.
  5043. Example: >vim
  5044. let save_maps = maplist()->filter(
  5045. \ {_, m -> m.lhs == 'K'})
  5046. nnoremap K somethingelse
  5047. cnoremap K somethingelse2
  5048. " ...
  5049. unmap K
  5050. for d in save_maps
  5051. call mapset(d)
  5052. endfor
  5053. <
  5054. Parameters: ~
  5055. • {dict} (`boolean`)
  5056. Return: ~
  5057. (`any`)
  5058. match({expr}, {pat} [, {start} [, {count}]]) *match()*
  5059. When {expr} is a |List| then this returns the index of the
  5060. first item where {pat} matches. Each item is used as a
  5061. String, |Lists| and |Dictionaries| are used as echoed.
  5062. Otherwise, {expr} is used as a String. The result is a
  5063. Number, which gives the index (byte offset) in {expr} where
  5064. {pat} matches.
  5065. A match at the first character or |List| item returns zero.
  5066. If there is no match -1 is returned.
  5067. For getting submatches see |matchlist()|.
  5068. Example: >vim
  5069. echo match("testing", "ing") " results in 4
  5070. echo match([1, 'x'], '\a') " results in 1
  5071. < See |string-match| for how {pat} is used.
  5072. *strpbrk()*
  5073. Vim doesn't have a strpbrk() function. But you can do: >vim
  5074. let sepidx = match(line, '[.,;: \t]')
  5075. < *strcasestr()*
  5076. Vim doesn't have a strcasestr() function. But you can add
  5077. "\c" to the pattern to ignore case: >vim
  5078. let idx = match(haystack, '\cneedle')
  5079. <
  5080. If {start} is given, the search starts from byte index
  5081. {start} in a String or item {start} in a |List|.
  5082. The result, however, is still the index counted from the
  5083. first character/item. Example: >vim
  5084. echo match("testing", "ing", 2)
  5085. < result is again "4". >vim
  5086. echo match("testing", "ing", 4)
  5087. < result is again "4". >vim
  5088. echo match("testing", "t", 2)
  5089. < result is "3".
  5090. For a String, if {start} > 0 then it is like the string starts
  5091. {start} bytes later, thus "^" will match at {start}. Except
  5092. when {count} is given, then it's like matches before the
  5093. {start} byte are ignored (this is a bit complicated to keep it
  5094. backwards compatible).
  5095. For a String, if {start} < 0, it will be set to 0. For a list
  5096. the index is counted from the end.
  5097. If {start} is out of range ({start} > strlen({expr}) for a
  5098. String or {start} > len({expr}) for a |List|) -1 is returned.
  5099. When {count} is given use the {count}th match. When a match
  5100. is found in a String the search for the next one starts one
  5101. character further. Thus this example results in 1: >vim
  5102. echo match("testing", "..", 0, 2)
  5103. < In a |List| the search continues in the next item.
  5104. Note that when {count} is added the way {start} works changes,
  5105. see above.
  5106. *match-pattern*
  5107. See |pattern| for the patterns that are accepted.
  5108. The 'ignorecase' option is used to set the ignore-caseness of
  5109. the pattern. 'smartcase' is NOT used. The matching is always
  5110. done like 'magic' is set and 'cpoptions' is empty.
  5111. Note that a match at the start is preferred, thus when the
  5112. pattern is using "*" (any number of matches) it tends to find
  5113. zero matches at the start instead of a number of matches
  5114. further down in the text.
  5115. Parameters: ~
  5116. • {expr} (`string|any[]`)
  5117. • {pat} (`string`)
  5118. • {start} (`integer?`)
  5119. • {count} (`integer?`)
  5120. Return: ~
  5121. (`any`)
  5122. *matchadd()* *E798* *E799* *E801* *E957*
  5123. matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
  5124. Defines a pattern to be highlighted in the current window (a
  5125. "match"). It will be highlighted with {group}. Returns an
  5126. identification number (ID), which can be used to delete the
  5127. match using |matchdelete()|. The ID is bound to the window.
  5128. Matching is case sensitive and magic, unless case sensitivity
  5129. or magicness are explicitly overridden in {pattern}. The
  5130. 'magic', 'smartcase' and 'ignorecase' options are not used.
  5131. The "Conceal" value is special, it causes the match to be
  5132. concealed.
  5133. The optional {priority} argument assigns a priority to the
  5134. match. A match with a high priority will have its
  5135. highlighting overrule that of a match with a lower priority.
  5136. A priority is specified as an integer (negative numbers are no
  5137. exception). If the {priority} argument is not specified, the
  5138. default priority is 10. The priority of 'hlsearch' is zero,
  5139. hence all matches with a priority greater than zero will
  5140. overrule it. Syntax highlighting (see 'syntax') is a separate
  5141. mechanism, and regardless of the chosen priority a match will
  5142. always overrule syntax highlighting.
  5143. The optional {id} argument allows the request for a specific
  5144. match ID. If a specified ID is already taken, an error
  5145. message will appear and the match will not be added. An ID
  5146. is specified as a positive integer (zero excluded). IDs 1, 2
  5147. and 3 are reserved for |:match|, |:2match| and |:3match|,
  5148. respectively. 3 is reserved for use by the |matchparen|
  5149. plugin.
  5150. If the {id} argument is not specified or -1, |matchadd()|
  5151. automatically chooses a free ID, which is at least 1000.
  5152. The optional {dict} argument allows for further custom
  5153. values. Currently this is used to specify a match specific
  5154. conceal character that will be shown for |hl-Conceal|
  5155. highlighted matches. The dict can have the following members:
  5156. conceal Special character to show instead of the
  5157. match (only for |hl-Conceal| highlighted
  5158. matches, see |:syn-cchar|)
  5159. window Instead of the current window use the
  5160. window with this number or window ID.
  5161. The number of matches is not limited, as it is the case with
  5162. the |:match| commands.
  5163. Returns -1 on error.
  5164. Example: >vim
  5165. highlight MyGroup ctermbg=green guibg=green
  5166. let m = matchadd("MyGroup", "TODO")
  5167. < Deletion of the pattern: >vim
  5168. call matchdelete(m)
  5169. < A list of matches defined by |matchadd()| and |:match| are
  5170. available from |getmatches()|. All matches can be deleted in
  5171. one operation by |clearmatches()|.
  5172. Parameters: ~
  5173. • {group} (`integer|string`)
  5174. • {pattern} (`string`)
  5175. • {priority} (`integer?`)
  5176. • {id} (`integer?`)
  5177. • {dict} (`string?`)
  5178. Return: ~
  5179. (`any`)
  5180. matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
  5181. Same as |matchadd()|, but requires a list of positions {pos}
  5182. instead of a pattern. This command is faster than |matchadd()|
  5183. because it does not handle regular expressions and it sets
  5184. buffer line boundaries to redraw screen. It is supposed to be
  5185. used when fast match additions and deletions are required, for
  5186. example to highlight matching parentheses.
  5187. *E5030* *E5031*
  5188. {pos} is a list of positions. Each position can be one of
  5189. these:
  5190. - A number. This whole line will be highlighted. The first
  5191. line has number 1.
  5192. - A list with one number, e.g., [23]. The whole line with this
  5193. number will be highlighted.
  5194. - A list with two numbers, e.g., [23, 11]. The first number is
  5195. the line number, the second one is the column number (first
  5196. column is 1, the value must correspond to the byte index as
  5197. |col()| would return). The character at this position will
  5198. be highlighted.
  5199. - A list with three numbers, e.g., [23, 11, 3]. As above, but
  5200. the third number gives the length of the highlight in bytes.
  5201. Entries with zero and negative line numbers are silently
  5202. ignored, as well as entries with negative column numbers and
  5203. lengths.
  5204. Returns -1 on error.
  5205. Example: >vim
  5206. highlight MyGroup ctermbg=green guibg=green
  5207. let m = matchaddpos("MyGroup", [[23, 24], 34])
  5208. < Deletion of the pattern: >vim
  5209. call matchdelete(m)
  5210. < Matches added by |matchaddpos()| are returned by
  5211. |getmatches()|.
  5212. Parameters: ~
  5213. • {group} (`integer|string`)
  5214. • {pos} (`any[]`)
  5215. • {priority} (`integer?`)
  5216. • {id} (`integer?`)
  5217. • {dict} (`string?`)
  5218. Return: ~
  5219. (`any`)
  5220. matcharg({nr}) *matcharg()*
  5221. Selects the {nr} match item, as set with a |:match|,
  5222. |:2match| or |:3match| command.
  5223. Return a |List| with two elements:
  5224. The name of the highlight group used
  5225. The pattern used.
  5226. When {nr} is not 1, 2 or 3 returns an empty |List|.
  5227. When there is no match item set returns ['', ''].
  5228. This is useful to save and restore a |:match|.
  5229. Highlighting matches using the |:match| commands are limited
  5230. to three matches. |matchadd()| does not have this limitation.
  5231. Parameters: ~
  5232. • {nr} (`integer`)
  5233. Return: ~
  5234. (`any`)
  5235. matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
  5236. Returns the |List| of matches in lines from {lnum} to {end} in
  5237. buffer {buf} where {pat} matches.
  5238. {lnum} and {end} can either be a line number or the string "$"
  5239. to refer to the last line in {buf}.
  5240. The {dict} argument supports following items:
  5241. submatches include submatch information (|/\(|)
  5242. For each match, a |Dict| with the following items is returned:
  5243. byteidx starting byte index of the match
  5244. lnum line number where there is a match
  5245. text matched string
  5246. Note that there can be multiple matches in a single line.
  5247. This function works only for loaded buffers. First call
  5248. |bufload()| if needed.
  5249. See |match-pattern| for information about the effect of some
  5250. option settings on the pattern.
  5251. When {buf} is not a valid buffer, the buffer is not loaded or
  5252. {lnum} or {end} is not valid then an error is given and an
  5253. empty |List| is returned.
  5254. Examples: >vim
  5255. " Assuming line 3 in buffer 5 contains "a"
  5256. echo matchbufline(5, '\<\k\+\>', 3, 3)
  5257. < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
  5258. " Assuming line 4 in buffer 10 contains "tik tok"
  5259. echo matchbufline(10, '\<\k\+\>', 1, 4)
  5260. < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
  5261. If {submatch} is present and is v:true, then submatches like
  5262. "\1", "\2", etc. are also returned. Example: >vim
  5263. " Assuming line 2 in buffer 2 contains "acd"
  5264. echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
  5265. \ {'submatches': v:true})
  5266. < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5267. The "submatches" List always contains 9 items. If a submatch
  5268. is not found, then an empty string is returned for that
  5269. submatch.
  5270. Parameters: ~
  5271. • {buf} (`string|integer`)
  5272. • {pat} (`string`)
  5273. • {lnum} (`string|integer`)
  5274. • {end} (`string|integer`)
  5275. • {dict} (`table?`)
  5276. Return: ~
  5277. (`any`)
  5278. matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
  5279. Deletes a match with ID {id} previously defined by |matchadd()|
  5280. or one of the |:match| commands. Returns 0 if successful,
  5281. otherwise -1. See example for |matchadd()|. All matches can
  5282. be deleted in one operation by |clearmatches()|.
  5283. If {win} is specified, use the window with this number or
  5284. window ID instead of the current window.
  5285. Parameters: ~
  5286. • {id} (`integer`)
  5287. • {win} (`integer?`)
  5288. Return: ~
  5289. (`any`)
  5290. matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
  5291. Same as |match()|, but return the index of first character
  5292. after the match. Example: >vim
  5293. echo matchend("testing", "ing")
  5294. < results in "7".
  5295. *strspn()* *strcspn()*
  5296. Vim doesn't have a strspn() or strcspn() function, but you can
  5297. do it with matchend(): >vim
  5298. let span = matchend(line, '[a-zA-Z]')
  5299. let span = matchend(line, '[^a-zA-Z]')
  5300. < Except that -1 is returned when there are no matches.
  5301. The {start}, if given, has the same meaning as for |match()|. >vim
  5302. echo matchend("testing", "ing", 2)
  5303. < results in "7". >vim
  5304. echo matchend("testing", "ing", 5)
  5305. < result is "-1".
  5306. When {expr} is a |List| the result is equal to |match()|.
  5307. Parameters: ~
  5308. • {expr} (`any`)
  5309. • {pat} (`string`)
  5310. • {start} (`integer?`)
  5311. • {count} (`integer?`)
  5312. Return: ~
  5313. (`any`)
  5314. matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
  5315. If {list} is a list of strings, then returns a |List| with all
  5316. the strings in {list} that fuzzy match {str}. The strings in
  5317. the returned list are sorted based on the matching score.
  5318. The optional {dict} argument always supports the following
  5319. items:
  5320. matchseq When this item is present return only matches
  5321. that contain the characters in {str} in the
  5322. given sequence.
  5323. limit Maximum number of matches in {list} to be
  5324. returned. Zero means no limit.
  5325. If {list} is a list of dictionaries, then the optional {dict}
  5326. argument supports the following additional items:
  5327. key Key of the item which is fuzzy matched against
  5328. {str}. The value of this item should be a
  5329. string.
  5330. text_cb |Funcref| that will be called for every item
  5331. in {list} to get the text for fuzzy matching.
  5332. This should accept a dictionary item as the
  5333. argument and return the text for that item to
  5334. use for fuzzy matching.
  5335. {str} is treated as a literal string and regular expression
  5336. matching is NOT supported. The maximum supported {str} length
  5337. is 256.
  5338. When {str} has multiple words each separated by white space,
  5339. then the list of strings that have all the words is returned.
  5340. If there are no matching strings or there is an error, then an
  5341. empty list is returned. If length of {str} is greater than
  5342. 256, then returns an empty list.
  5343. When {limit} is given, matchfuzzy() will find up to this
  5344. number of matches in {list} and return them in sorted order.
  5345. Refer to |fuzzy-matching| for more information about fuzzy
  5346. matching strings.
  5347. Example: >vim
  5348. echo matchfuzzy(["clay", "crow"], "cay")
  5349. < results in ["clay"]. >vim
  5350. echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
  5351. < results in a list of buffer names fuzzy matching "ndl". >vim
  5352. echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
  5353. < results in a list of buffer information dicts with buffer
  5354. names fuzzy matching "ndl". >vim
  5355. echo getbufinfo()->matchfuzzy("spl",
  5356. \ {'text_cb' : {v -> v.name}})
  5357. < results in a list of buffer information dicts with buffer
  5358. names fuzzy matching "spl". >vim
  5359. echo v:oldfiles->matchfuzzy("test")
  5360. < results in a list of file names fuzzy matching "test". >vim
  5361. let l = readfile("buffer.c")->matchfuzzy("str")
  5362. < results in a list of lines in "buffer.c" fuzzy matching "str". >vim
  5363. echo ['one two', 'two one']->matchfuzzy('two one')
  5364. < results in `['two one', 'one two']` . >vim
  5365. echo ['one two', 'two one']->matchfuzzy('two one',
  5366. \ {'matchseq': 1})
  5367. < results in `['two one']`.
  5368. Parameters: ~
  5369. • {list} (`any[]`)
  5370. • {str} (`string`)
  5371. • {dict} (`string?`)
  5372. Return: ~
  5373. (`any`)
  5374. matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
  5375. Same as |matchfuzzy()|, but returns the list of matched
  5376. strings, the list of character positions where characters
  5377. in {str} matches and a list of matching scores. You can
  5378. use |byteidx()| to convert a character position to a byte
  5379. position.
  5380. If {str} matches multiple times in a string, then only the
  5381. positions for the best match is returned.
  5382. If there are no matching strings or there is an error, then a
  5383. list with three empty list items is returned.
  5384. Example: >vim
  5385. echo matchfuzzypos(['testing'], 'tsg')
  5386. < results in [["testing"], [[0, 2, 6]], [99]] >vim
  5387. echo matchfuzzypos(['clay', 'lacy'], 'la')
  5388. < results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
  5389. echo [{'text': 'hello', 'id' : 10}]
  5390. \ ->matchfuzzypos('ll', {'key' : 'text'})
  5391. < results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
  5392. Parameters: ~
  5393. • {list} (`any[]`)
  5394. • {str} (`string`)
  5395. • {dict} (`string?`)
  5396. Return: ~
  5397. (`any`)
  5398. matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
  5399. Same as |match()|, but return a |List|. The first item in the
  5400. list is the matched string, same as what matchstr() would
  5401. return. Following items are submatches, like "\1", "\2", etc.
  5402. in |:substitute|. When an optional submatch didn't match an
  5403. empty string is used. Example: >vim
  5404. echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
  5405. < Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
  5406. When there is no match an empty list is returned.
  5407. You can pass in a List, but that is not very useful.
  5408. Parameters: ~
  5409. • {expr} (`any`)
  5410. • {pat} (`string`)
  5411. • {start} (`integer?`)
  5412. • {count} (`integer?`)
  5413. Return: ~
  5414. (`any`)
  5415. matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
  5416. Same as |match()|, but return the matched string. Example: >vim
  5417. echo matchstr("testing", "ing")
  5418. < results in "ing".
  5419. When there is no match "" is returned.
  5420. The {start}, if given, has the same meaning as for |match()|. >vim
  5421. echo matchstr("testing", "ing", 2)
  5422. < results in "ing". >vim
  5423. echo matchstr("testing", "ing", 5)
  5424. < result is "".
  5425. When {expr} is a |List| then the matching item is returned.
  5426. The type isn't changed, it's not necessarily a String.
  5427. Parameters: ~
  5428. • {expr} (`any`)
  5429. • {pat} (`string`)
  5430. • {start} (`integer?`)
  5431. • {count} (`integer?`)
  5432. Return: ~
  5433. (`any`)
  5434. matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
  5435. Returns the |List| of matches in {list} where {pat} matches.
  5436. {list} is a |List| of strings. {pat} is matched against each
  5437. string in {list}.
  5438. The {dict} argument supports following items:
  5439. submatches include submatch information (|/\(|)
  5440. For each match, a |Dict| with the following items is returned:
  5441. byteidx starting byte index of the match.
  5442. idx index in {list} of the match.
  5443. text matched string
  5444. submatches a List of submatches. Present only if
  5445. "submatches" is set to v:true in {dict}.
  5446. See |match-pattern| for information about the effect of some
  5447. option settings on the pattern.
  5448. Example: >vim
  5449. echo matchstrlist(['tik tok'], '\<\k\+\>')
  5450. < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
  5451. echo matchstrlist(['a', 'b'], '\<\k\+\>')
  5452. < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
  5453. If "submatches" is present and is v:true, then submatches like
  5454. "\1", "\2", etc. are also returned. Example: >vim
  5455. echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
  5456. \ #{submatches: v:true})
  5457. < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5458. The "submatches" List always contains 9 items. If a submatch
  5459. is not found, then an empty string is returned for that
  5460. submatch.
  5461. Parameters: ~
  5462. • {list} (`string[]`)
  5463. • {pat} (`string`)
  5464. • {dict} (`table?`)
  5465. Return: ~
  5466. (`any`)
  5467. matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
  5468. Same as |matchstr()|, but return the matched string, the start
  5469. position and the end position of the match. Example: >vim
  5470. echo matchstrpos("testing", "ing")
  5471. < results in ["ing", 4, 7].
  5472. When there is no match ["", -1, -1] is returned.
  5473. The {start}, if given, has the same meaning as for |match()|. >vim
  5474. echo matchstrpos("testing", "ing", 2)
  5475. < results in ["ing", 4, 7]. >vim
  5476. echo matchstrpos("testing", "ing", 5)
  5477. < result is ["", -1, -1].
  5478. When {expr} is a |List| then the matching item, the index
  5479. of first item where {pat} matches, the start position and the
  5480. end position of the match are returned. >vim
  5481. echo matchstrpos([1, '__x'], '\a')
  5482. < result is ["x", 1, 2, 3].
  5483. The type isn't changed, it's not necessarily a String.
  5484. Parameters: ~
  5485. • {expr} (`any`)
  5486. • {pat} (`string`)
  5487. • {start} (`integer?`)
  5488. • {count} (`integer?`)
  5489. Return: ~
  5490. (`any`)
  5491. max({expr}) *max()*
  5492. Return the maximum value of all items in {expr}. Example: >vim
  5493. echo max([apples, pears, oranges])
  5494. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5495. it returns the maximum of all values in the Dictionary.
  5496. If {expr} is neither a List nor a Dictionary, or one of the
  5497. items in {expr} cannot be used as a Number this results in
  5498. an error. An empty |List| or |Dictionary| results in zero.
  5499. Parameters: ~
  5500. • {expr} (`any`)
  5501. Return: ~
  5502. (`number`)
  5503. menu_get({path} [, {modes}]) *menu_get()*
  5504. Returns a |List| of |Dictionaries| describing |menus| (defined
  5505. by |:menu|, |:amenu|, …), including |hidden-menus|.
  5506. {path} matches a menu by name, or all menus if {path} is an
  5507. empty string. Example: >vim
  5508. echo menu_get('File','')
  5509. echo menu_get('')
  5510. <
  5511. {modes} is a string of zero or more modes (see |maparg()| or
  5512. |creating-menus| for the list of modes). "a" means "all".
  5513. Example: >vim
  5514. nnoremenu &Test.Test inormal
  5515. inoremenu Test.Test insert
  5516. vnoremenu Test.Test x
  5517. echo menu_get("")
  5518. < returns something like this: >
  5519. [ {
  5520. "hidden": 0,
  5521. "name": "Test",
  5522. "priority": 500,
  5523. "shortcut": 84,
  5524. "submenus": [ {
  5525. "hidden": 0,
  5526. "mappings": {
  5527. i": {
  5528. "enabled": 1,
  5529. "noremap": 1,
  5530. "rhs": "insert",
  5531. "sid": 1,
  5532. "silent": 0
  5533. },
  5534. n": { ... },
  5535. s": { ... },
  5536. v": { ... }
  5537. },
  5538. "name": "Test",
  5539. "priority": 500,
  5540. "shortcut": 0
  5541. } ]
  5542. } ]
  5543. <
  5544. Parameters: ~
  5545. • {path} (`string`)
  5546. • {modes} (`string?`)
  5547. Return: ~
  5548. (`any`)
  5549. menu_info({name} [, {mode}]) *menu_info()*
  5550. Return information about the specified menu {name} in
  5551. mode {mode}. The menu name should be specified without the
  5552. shortcut character ('&'). If {name} is "", then the top-level
  5553. menu names are returned.
  5554. {mode} can be one of these strings:
  5555. "n" Normal
  5556. "v" Visual (including Select)
  5557. "o" Operator-pending
  5558. "i" Insert
  5559. "c" Cmd-line
  5560. "s" Select
  5561. "x" Visual
  5562. "t" Terminal-Job
  5563. "" Normal, Visual and Operator-pending
  5564. "!" Insert and Cmd-line
  5565. When {mode} is omitted, the modes for "" are used.
  5566. Returns a |Dictionary| containing the following items:
  5567. accel menu item accelerator text |menu-text|
  5568. display display name (name without '&')
  5569. enabled v:true if this menu item is enabled
  5570. Refer to |:menu-enable|
  5571. icon name of the icon file (for toolbar)
  5572. |toolbar-icon|
  5573. iconidx index of a built-in icon
  5574. modes modes for which the menu is defined. In
  5575. addition to the modes mentioned above, these
  5576. characters will be used:
  5577. " " Normal, Visual and Operator-pending
  5578. name menu item name.
  5579. noremenu v:true if the {rhs} of the menu item is not
  5580. remappable else v:false.
  5581. priority menu order priority |menu-priority|
  5582. rhs right-hand-side of the menu item. The returned
  5583. string has special characters translated like
  5584. in the output of the ":menu" command listing.
  5585. When the {rhs} of a menu item is empty, then
  5586. "<Nop>" is returned.
  5587. script v:true if script-local remapping of {rhs} is
  5588. allowed else v:false. See |:menu-script|.
  5589. shortcut shortcut key (character after '&' in
  5590. the menu name) |menu-shortcut|
  5591. silent v:true if the menu item is created
  5592. with <silent> argument |:menu-silent|
  5593. submenus |List| containing the names of
  5594. all the submenus. Present only if the menu
  5595. item has submenus.
  5596. Returns an empty dictionary if the menu item is not found.
  5597. Examples: >vim
  5598. echo menu_info('Edit.Cut')
  5599. echo menu_info('File.Save', 'n')
  5600. " Display the entire menu hierarchy in a buffer
  5601. func ShowMenu(name, pfx)
  5602. let m = menu_info(a:name)
  5603. call append(line('$'), a:pfx .. m.display)
  5604. for child in m->get('submenus', [])
  5605. call ShowMenu(a:name .. '.' .. escape(child, '.'),
  5606. \ a:pfx .. ' ')
  5607. endfor
  5608. endfunc
  5609. new
  5610. for topmenu in menu_info('').submenus
  5611. call ShowMenu(topmenu, '')
  5612. endfor
  5613. <
  5614. Parameters: ~
  5615. • {name} (`string`)
  5616. • {mode} (`string?`)
  5617. Return: ~
  5618. (`any`)
  5619. min({expr}) *min()*
  5620. Return the minimum value of all items in {expr}. Example: >vim
  5621. echo min([apples, pears, oranges])
  5622. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5623. it returns the minimum of all values in the Dictionary.
  5624. If {expr} is neither a List nor a Dictionary, or one of the
  5625. items in {expr} cannot be used as a Number this results in
  5626. an error. An empty |List| or |Dictionary| results in zero.
  5627. Parameters: ~
  5628. • {expr} (`any`)
  5629. Return: ~
  5630. (`number`)
  5631. mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
  5632. Create directory {name}.
  5633. When {flags} is present it must be a string. An empty string
  5634. has no effect.
  5635. {flags} can contain these character flags:
  5636. "p" intermediate directories will be created as necessary
  5637. "D" {name} will be deleted at the end of the current
  5638. function, but not recursively |:defer|
  5639. "R" {name} will be deleted recursively at the end of the
  5640. current function |:defer|
  5641. Note that when {name} has more than one part and "p" is used
  5642. some directories may already exist. Only the first one that
  5643. is created and what it contains is scheduled to be deleted.
  5644. E.g. when using: >vim
  5645. call mkdir('subdir/tmp/autoload', 'pR')
  5646. < and "subdir" already exists then "subdir/tmp" will be
  5647. scheduled for deletion, like with: >vim
  5648. defer delete('subdir/tmp', 'rf')
  5649. <
  5650. If {prot} is given it is used to set the protection bits of
  5651. the new directory. The default is 0o755 (rwxr-xr-x: r/w for
  5652. the user, readable for others). Use 0o700 to make it
  5653. unreadable for others.
  5654. {prot} is applied for all parts of {name}. Thus if you create
  5655. /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
  5656. call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
  5657. < This function is not available in the |sandbox|.
  5658. If you try to create an existing directory with {flags} set to
  5659. "p" mkdir() will silently exit.
  5660. The function result is a Number, which is TRUE if the call was
  5661. successful or FALSE if the directory creation failed or partly
  5662. failed.
  5663. Parameters: ~
  5664. • {name} (`string`)
  5665. • {flags} (`string?`)
  5666. • {prot} (`string?`)
  5667. Return: ~
  5668. (`integer`)
  5669. mode([{expr}]) *mode()*
  5670. Return a string that indicates the current mode.
  5671. If {expr} is supplied and it evaluates to a non-zero Number or
  5672. a non-empty String (|non-zero-arg|), then the full mode is
  5673. returned, otherwise only the first letter is returned.
  5674. Also see |state()|.
  5675. n Normal
  5676. no Operator-pending
  5677. nov Operator-pending (forced charwise |o_v|)
  5678. noV Operator-pending (forced linewise |o_V|)
  5679. noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
  5680. CTRL-V is one character
  5681. niI Normal using |i_CTRL-O| in |Insert-mode|
  5682. niR Normal using |i_CTRL-O| in |Replace-mode|
  5683. niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
  5684. nt Normal in |terminal-emulator| (insert goes to
  5685. Terminal mode)
  5686. ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
  5687. v Visual by character
  5688. vs Visual by character using |v_CTRL-O| in Select mode
  5689. V Visual by line
  5690. Vs Visual by line using |v_CTRL-O| in Select mode
  5691. CTRL-V Visual blockwise
  5692. CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
  5693. s Select by character
  5694. S Select by line
  5695. CTRL-S Select blockwise
  5696. i Insert
  5697. ic Insert mode completion |compl-generic|
  5698. ix Insert mode |i_CTRL-X| completion
  5699. R Replace |R|
  5700. Rc Replace mode completion |compl-generic|
  5701. Rx Replace mode |i_CTRL-X| completion
  5702. Rv Virtual Replace |gR|
  5703. Rvc Virtual Replace mode completion |compl-generic|
  5704. Rvx Virtual Replace mode |i_CTRL-X| completion
  5705. c Command-line editing
  5706. cr Command-line editing overstrike mode |c_<Insert>|
  5707. cv Vim Ex mode |gQ|
  5708. cvr Vim Ex mode while in overstrike mode |c_<Insert>|
  5709. r Hit-enter prompt
  5710. rm The -- more -- prompt
  5711. r? A |:confirm| query of some sort
  5712. ! Shell or external command is executing
  5713. t Terminal mode: keys go to the job
  5714. This is useful in the 'statusline' option or RPC calls. In
  5715. most other places it always returns "c" or "n".
  5716. Note that in the future more modes and more specific modes may
  5717. be added. It's better not to compare the whole string but only
  5718. the leading character(s).
  5719. Also see |visualmode()|.
  5720. Parameters: ~
  5721. • {expr} (`any?`)
  5722. Return: ~
  5723. (`any`)
  5724. msgpackdump({list} [, {type}]) *msgpackdump()*
  5725. Convert a list of Vimscript objects to msgpack. Returned value is a
  5726. |readfile()|-style list. When {type} contains "B", a |Blob| is
  5727. returned instead. Example: >vim
  5728. call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
  5729. < or, using a |Blob|: >vim
  5730. call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
  5731. <
  5732. This will write the single 0x80 byte to a `fname.mpack` file
  5733. (dictionary with zero items is represented by 0x80 byte in
  5734. messagepack).
  5735. Limitations: *E5004* *E5005*
  5736. 1. |Funcref|s cannot be dumped.
  5737. 2. Containers that reference themselves cannot be dumped.
  5738. 3. Dictionary keys are always dumped as STR strings.
  5739. 4. Other strings and |Blob|s are always dumped as BIN strings.
  5740. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
  5741. Parameters: ~
  5742. • {list} (`any`)
  5743. • {type} (`any?`)
  5744. Return: ~
  5745. (`any`)
  5746. msgpackparse({data}) *msgpackparse()*
  5747. Convert a |readfile()|-style list or a |Blob| to a list of
  5748. Vimscript objects.
  5749. Example: >vim
  5750. let fname = expand('~/.config/nvim/shada/main.shada')
  5751. let mpack = readfile(fname, 'b')
  5752. let shada_objects = msgpackparse(mpack)
  5753. < This will read ~/.config/nvim/shada/main.shada file to
  5754. `shada_objects` list.
  5755. Limitations:
  5756. 1. Mapping ordering is not preserved unless messagepack
  5757. mapping is dumped using generic mapping
  5758. (|msgpack-special-map|).
  5759. 2. Since the parser aims to preserve all data untouched
  5760. (except for 1.) some strings are parsed to
  5761. |msgpack-special-dict| format which is not convenient to
  5762. use.
  5763. *msgpack-special-dict*
  5764. Some messagepack strings may be parsed to special
  5765. dictionaries. Special dictionaries are dictionaries which
  5766. 1. Contain exactly two keys: `_TYPE` and `_VAL`.
  5767. 2. `_TYPE` key is one of the types found in |v:msgpack_types|
  5768. variable.
  5769. 3. Value for `_VAL` has the following format (Key column
  5770. contains name of the key from |v:msgpack_types|):
  5771. Key Value ~
  5772. nil Zero, ignored when dumping. Not returned by
  5773. |msgpackparse()| since |v:null| was introduced.
  5774. boolean One or zero. When dumping it is only checked that
  5775. value is a |Number|. Not returned by |msgpackparse()|
  5776. since |v:true| and |v:false| were introduced.
  5777. integer |List| with four numbers: sign (-1 or 1), highest two
  5778. bits, number with bits from 62nd to 31st, lowest 31
  5779. bits. I.e. to get actual number one will need to use
  5780. code like >
  5781. _VAL[0] * ((_VAL[1] << 62)
  5782. & (_VAL[2] << 31)
  5783. & _VAL[3])
  5784. < Special dictionary with this type will appear in
  5785. |msgpackparse()| output under one of the following
  5786. circumstances:
  5787. 1. |Number| is 32-bit and value is either above
  5788. INT32_MAX or below INT32_MIN.
  5789. 2. |Number| is 64-bit and value is above INT64_MAX. It
  5790. cannot possibly be below INT64_MIN because msgpack
  5791. C parser does not support such values.
  5792. float |Float|. This value cannot possibly appear in
  5793. |msgpackparse()| output.
  5794. string |String|, or |Blob| if binary string contains zero
  5795. byte. This value cannot appear in |msgpackparse()|
  5796. output since blobs were introduced.
  5797. array |List|. This value cannot appear in |msgpackparse()|
  5798. output.
  5799. *msgpack-special-map*
  5800. map |List| of |List|s with two items (key and value) each.
  5801. This value will appear in |msgpackparse()| output if
  5802. parsed mapping contains one of the following keys:
  5803. 1. Any key that is not a string (including keys which
  5804. are binary strings).
  5805. 2. String with NUL byte inside.
  5806. 3. Duplicate key.
  5807. ext |List| with two values: first is a signed integer
  5808. representing extension type. Second is
  5809. |readfile()|-style list of strings.
  5810. Parameters: ~
  5811. • {data} (`any`)
  5812. Return: ~
  5813. (`any`)
  5814. nextnonblank({lnum}) *nextnonblank()*
  5815. Return the line number of the first line at or below {lnum}
  5816. that is not blank. Example: >vim
  5817. if getline(nextnonblank(1)) =~ "Java" | endif
  5818. < When {lnum} is invalid or there is no non-blank line at or
  5819. below it, zero is returned.
  5820. {lnum} is used like with |getline()|.
  5821. See also |prevnonblank()|.
  5822. Parameters: ~
  5823. • {lnum} (`integer`)
  5824. Return: ~
  5825. (`integer`)
  5826. nr2char({expr} [, {utf8}]) *nr2char()*
  5827. Return a string with a single character, which has the number
  5828. value {expr}. Examples: >vim
  5829. echo nr2char(64) " returns '@'
  5830. echo nr2char(32) " returns ' '
  5831. < Example for "utf-8": >vim
  5832. echo nr2char(300) " returns I with bow character
  5833. <
  5834. UTF-8 encoding is always used, {utf8} option has no effect,
  5835. and exists only for backwards-compatibility.
  5836. Note that a NUL character in the file is specified with
  5837. nr2char(10), because NULs are represented with newline
  5838. characters. nr2char(0) is a real NUL and terminates the
  5839. string, thus results in an empty string.
  5840. Parameters: ~
  5841. • {expr} (`integer`)
  5842. • {utf8} (`boolean?`)
  5843. Return: ~
  5844. (`string`)
  5845. nvim_...({...}) *nvim_...()* *E5555* *eval-api*
  5846. Call nvim |api| functions. The type checking of arguments will
  5847. be stricter than for most other builtins. For instance,
  5848. if Integer is expected, a |Number| must be passed in, a
  5849. |String| will not be autoconverted.
  5850. Buffer numbers, as returned by |bufnr()| could be used as
  5851. first argument to nvim_buf_... functions. All functions
  5852. expecting an object (buffer, window or tabpage) can
  5853. also take the numerical value 0 to indicate the current
  5854. (focused) object.
  5855. Parameters: ~
  5856. • {...} (`any`)
  5857. Return: ~
  5858. (`any`)
  5859. or({expr}, {expr}) *or()*
  5860. Bitwise OR on the two arguments. The arguments are converted
  5861. to a number. A List, Dict or Float argument causes an error.
  5862. Also see `and()` and `xor()`.
  5863. Example: >vim
  5864. let bits = or(bits, 0x80)
  5865. < Rationale: The reason this is a function and not using the "|"
  5866. character like many languages, is that Vi has always used "|"
  5867. to separate commands. In many places it would not be clear if
  5868. "|" is an operator or a command separator.
  5869. Parameters: ~
  5870. • {expr} (`number`)
  5871. • {expr1} (`number`)
  5872. Return: ~
  5873. (`any`)
  5874. pathshorten({path} [, {len}]) *pathshorten()*
  5875. Shorten directory names in the path {path} and return the
  5876. result. The tail, the file name, is kept as-is. The other
  5877. components in the path are reduced to {len} letters in length.
  5878. If {len} is omitted or smaller than 1 then 1 is used (single
  5879. letters). Leading '~' and '.' characters are kept. Examples: >vim
  5880. echo pathshorten('~/.config/nvim/autoload/file1.vim')
  5881. < ~/.c/n/a/file1.vim ~
  5882. >vim
  5883. echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
  5884. < ~/.co/nv/au/file2.vim ~
  5885. It doesn't matter if the path exists or not.
  5886. Returns an empty string on error.
  5887. Parameters: ~
  5888. • {path} (`string`)
  5889. • {len} (`integer?`)
  5890. Return: ~
  5891. (`string`)
  5892. perleval({expr}) *perleval()*
  5893. Evaluate |perl| expression {expr} and return its result
  5894. converted to Vim data structures.
  5895. Numbers and strings are returned as they are (strings are
  5896. copied though).
  5897. Lists are represented as Vim |List| type.
  5898. Dictionaries are represented as Vim |Dictionary| type,
  5899. non-string keys result in error.
  5900. Note: If you want an array or hash, {expr} must return a
  5901. reference to it.
  5902. Example: >vim
  5903. echo perleval('[1 .. 4]')
  5904. < [1, 2, 3, 4]
  5905. Parameters: ~
  5906. • {expr} (`any`)
  5907. Return: ~
  5908. (`any`)
  5909. pow({x}, {y}) *pow()*
  5910. Return the power of {x} to the exponent {y} as a |Float|.
  5911. {x} and {y} must evaluate to a |Float| or a |Number|.
  5912. Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
  5913. Examples: >vim
  5914. echo pow(3, 3)
  5915. < 27.0 >vim
  5916. echo pow(2, 16)
  5917. < 65536.0 >vim
  5918. echo pow(32, 0.20)
  5919. < 2.0
  5920. Parameters: ~
  5921. • {x} (`number`)
  5922. • {y} (`number`)
  5923. Return: ~
  5924. (`number`)
  5925. prevnonblank({lnum}) *prevnonblank()*
  5926. Return the line number of the first line at or above {lnum}
  5927. that is not blank. Example: >vim
  5928. let ind = indent(prevnonblank(v:lnum - 1))
  5929. < When {lnum} is invalid or there is no non-blank line at or
  5930. above it, zero is returned.
  5931. {lnum} is used like with |getline()|.
  5932. Also see |nextnonblank()|.
  5933. Parameters: ~
  5934. • {lnum} (`integer`)
  5935. Return: ~
  5936. (`integer`)
  5937. printf({fmt}, {expr1} ...) *printf()*
  5938. Return a String with {fmt}, where "%" items are replaced by
  5939. the formatted form of their respective arguments. Example: >vim
  5940. echo printf("%4d: E%d %.30s", lnum, errno, msg)
  5941. < May result in:
  5942. " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
  5943. When used as a |method| the base is passed as the second
  5944. argument: >vim
  5945. Compute()->printf("result: %d")
  5946. <
  5947. You can use `call()` to pass the items as a list.
  5948. Often used items are:
  5949. %s string
  5950. %6S string right-aligned in 6 display cells
  5951. %6s string right-aligned in 6 bytes
  5952. %.9s string truncated to 9 bytes
  5953. %c single byte
  5954. %d decimal number
  5955. %5d decimal number padded with spaces to 5 characters
  5956. %b binary number
  5957. %08b binary number padded with zeros to at least 8 characters
  5958. %B binary number using upper case letters
  5959. %x hex number
  5960. %04x hex number padded with zeros to at least 4 characters
  5961. %X hex number using upper case letters
  5962. %o octal number
  5963. %f floating point number as 12.23, inf, -inf or nan
  5964. %F floating point number as 12.23, INF, -INF or NAN
  5965. %e floating point number as 1.23e3, inf, -inf or nan
  5966. %E floating point number as 1.23E3, INF, -INF or NAN
  5967. %g floating point number, as %f or %e depending on value
  5968. %G floating point number, as %F or %E depending on value
  5969. %% the % character itself
  5970. %p representation of the pointer to the container
  5971. Conversion specifications start with '%' and end with the
  5972. conversion type. All other characters are copied unchanged to
  5973. the result.
  5974. The "%" starts a conversion specification. The following
  5975. arguments appear in sequence:
  5976. % [pos-argument] [flags] [field-width] [.precision] type
  5977. pos-argument
  5978. At most one positional argument specifier. These
  5979. take the form {n$}, where n is >= 1.
  5980. flags
  5981. Zero or more of the following flags:
  5982. # The value should be converted to an "alternate
  5983. form". For c, d, and s conversions, this option
  5984. has no effect. For o conversions, the precision
  5985. of the number is increased to force the first
  5986. character of the output string to a zero (except
  5987. if a zero value is printed with an explicit
  5988. precision of zero).
  5989. For x and X conversions, a non-zero result has
  5990. the string "0x" (or "0X" for X conversions)
  5991. prepended to it.
  5992. 0 (zero) Zero padding. For all conversions the converted
  5993. value is padded on the left with zeros rather
  5994. than blanks. If a precision is given with a
  5995. numeric conversion (d, o, x, and X), the 0 flag
  5996. is ignored.
  5997. - A negative field width flag; the converted value
  5998. is to be left adjusted on the field boundary.
  5999. The converted value is padded on the right with
  6000. blanks, rather than on the left with blanks or
  6001. zeros. A - overrides a 0 if both are given.
  6002. ' ' (space) A blank should be left before a positive
  6003. number produced by a signed conversion (d).
  6004. + A sign must always be placed before a number
  6005. produced by a signed conversion. A + overrides
  6006. a space if both are used.
  6007. field-width
  6008. An optional decimal digit string specifying a minimum
  6009. field width. If the converted value has fewer bytes
  6010. than the field width, it will be padded with spaces on
  6011. the left (or right, if the left-adjustment flag has
  6012. been given) to fill out the field width. For the S
  6013. conversion the count is in cells.
  6014. .precision
  6015. An optional precision, in the form of a period '.'
  6016. followed by an optional digit string. If the digit
  6017. string is omitted, the precision is taken as zero.
  6018. This gives the minimum number of digits to appear for
  6019. d, o, x, and X conversions, the maximum number of
  6020. bytes to be printed from a string for s conversions,
  6021. or the maximum number of cells to be printed from a
  6022. string for S conversions.
  6023. For floating point it is the number of digits after
  6024. the decimal point.
  6025. type
  6026. A character that specifies the type of conversion to
  6027. be applied, see below.
  6028. A field width or precision, or both, may be indicated by an
  6029. asterisk "*" instead of a digit string. In this case, a
  6030. Number argument supplies the field width or precision. A
  6031. negative field width is treated as a left adjustment flag
  6032. followed by a positive field width; a negative precision is
  6033. treated as though it were missing. Example: >vim
  6034. echo printf("%d: %.*s", nr, width, line)
  6035. < This limits the length of the text used from "line" to
  6036. "width" bytes.
  6037. If the argument to be formatted is specified using a
  6038. positional argument specifier, and a '*' is used to indicate
  6039. that a number argument is to be used to specify the width or
  6040. precision, the argument(s) to be used must also be specified
  6041. using a {n$} positional argument specifier. See |printf-$|.
  6042. The conversion specifiers and their meanings are:
  6043. *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
  6044. dbBoxX The Number argument is converted to signed decimal (d),
  6045. unsigned binary (b and B), unsigned octal (o), or
  6046. unsigned hexadecimal (x and X) notation. The letters
  6047. "abcdef" are used for x conversions; the letters
  6048. "ABCDEF" are used for X conversions. The precision, if
  6049. any, gives the minimum number of digits that must
  6050. appear; if the converted value requires fewer digits, it
  6051. is padded on the left with zeros. In no case does a
  6052. non-existent or small field width cause truncation of a
  6053. numeric field; if the result of a conversion is wider
  6054. than the field width, the field is expanded to contain
  6055. the conversion result.
  6056. The 'h' modifier indicates the argument is 16 bits.
  6057. The 'l' modifier indicates the argument is a long
  6058. integer. The size will be 32 bits or 64 bits
  6059. depending on your platform.
  6060. The "ll" modifier indicates the argument is 64 bits.
  6061. The b and B conversion specifiers never take a width
  6062. modifier and always assume their argument is a 64 bit
  6063. integer.
  6064. Generally, these modifiers are not useful. They are
  6065. ignored when type is known from the argument.
  6066. i alias for d
  6067. D alias for ld
  6068. U alias for lu
  6069. O alias for lo
  6070. *printf-c*
  6071. c The Number argument is converted to a byte, and the
  6072. resulting character is written.
  6073. *printf-s*
  6074. s The text of the String argument is used. If a
  6075. precision is specified, no more bytes than the number
  6076. specified are used.
  6077. If the argument is not a String type, it is
  6078. automatically converted to text with the same format
  6079. as ":echo".
  6080. *printf-S*
  6081. S The text of the String argument is used. If a
  6082. precision is specified, no more display cells than the
  6083. number specified are used.
  6084. *printf-f* *E807*
  6085. f F The Float argument is converted into a string of the
  6086. form 123.456. The precision specifies the number of
  6087. digits after the decimal point. When the precision is
  6088. zero the decimal point is omitted. When the precision
  6089. is not specified 6 is used. A really big number
  6090. (out of range or dividing by zero) results in "inf"
  6091. or "-inf" with %f (INF or -INF with %F).
  6092. "0.0 / 0.0" results in "nan" with %f (NAN with %F).
  6093. Example: >vim
  6094. echo printf("%.2f", 12.115)
  6095. < 12.12
  6096. Note that roundoff depends on the system libraries.
  6097. Use |round()| when in doubt.
  6098. *printf-e* *printf-E*
  6099. e E The Float argument is converted into a string of the
  6100. form 1.234e+03 or 1.234E+03 when using 'E'. The
  6101. precision specifies the number of digits after the
  6102. decimal point, like with 'f'.
  6103. *printf-g* *printf-G*
  6104. g G The Float argument is converted like with 'f' if the
  6105. value is between 0.001 (inclusive) and 10000000.0
  6106. (exclusive). Otherwise 'e' is used for 'g' and 'E'
  6107. for 'G'. When no precision is specified superfluous
  6108. zeroes and '+' signs are removed, except for the zero
  6109. immediately after the decimal point. Thus 10000000.0
  6110. results in 1.0e7.
  6111. *printf-%*
  6112. % A '%' is written. No argument is converted. The
  6113. complete conversion specification is "%%".
  6114. When a Number argument is expected a String argument is also
  6115. accepted and automatically converted.
  6116. When a Float or String argument is expected a Number argument
  6117. is also accepted and automatically converted.
  6118. Any other argument type results in an error message.
  6119. *E766* *E767*
  6120. The number of {exprN} arguments must exactly match the number
  6121. of "%" items. If there are not sufficient or too many
  6122. arguments an error is given. Up to 18 arguments can be used.
  6123. *printf-$*
  6124. In certain languages, error and informative messages are
  6125. more readable when the order of words is different from the
  6126. corresponding message in English. To accommodate translations
  6127. having a different word order, positional arguments may be
  6128. used to indicate this. For instance: >vim
  6129. #, c-format
  6130. msgid "%s returning %s"
  6131. msgstr "waarde %2$s komt terug van %1$s"
  6132. <
  6133. In this example, the sentence has its 2 string arguments
  6134. reversed in the output. >vim
  6135. echo printf(
  6136. "In The Netherlands, vim's creator's name is: %1$s %2$s",
  6137. "Bram", "Moolenaar")
  6138. < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim
  6139. echo printf(
  6140. "In Belgium, vim's creator's name is: %2$s %1$s",
  6141. "Bram", "Moolenaar")
  6142. < In Belgium, vim's creator's name is: Moolenaar Bram
  6143. Width (and precision) can be specified using the '*' specifier.
  6144. In this case, you must specify the field width position in the
  6145. argument list. >vim
  6146. echo printf("%1$*2$.*3$d", 1, 2, 3)
  6147. < 001 >vim
  6148. echo printf("%2$*3$.*1$d", 1, 2, 3)
  6149. < 2 >vim
  6150. echo printf("%3$*1$.*2$d", 1, 2, 3)
  6151. < 03 >vim
  6152. echo printf("%1$*2$.*3$g", 1.4142, 2, 3)
  6153. < 1.414
  6154. You can mix specifying the width and/or precision directly
  6155. and via positional arguments: >vim
  6156. echo printf("%1$4.*2$f", 1.4142135, 6)
  6157. < 1.414214 >vim
  6158. echo printf("%1$*2$.4f", 1.4142135, 6)
  6159. < 1.4142 >vim
  6160. echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
  6161. < 1.41
  6162. You will get an overflow error |E1510|, when the field-width
  6163. or precision will result in a string longer than 6400 chars.
  6164. *E1500*
  6165. You cannot mix positional and non-positional arguments: >vim
  6166. echo printf("%s%1$s", "One", "Two")
  6167. < E1500: Cannot mix positional and non-positional arguments:
  6168. %s%1$s
  6169. *E1501*
  6170. You cannot skip a positional argument in a format string: >vim
  6171. echo printf("%3$s%1$s", "One", "Two", "Three")
  6172. < E1501: format argument 2 unused in $-style format:
  6173. %3$s%1$s
  6174. *E1502*
  6175. You can re-use a [field-width] (or [precision]) argument: >vim
  6176. echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
  6177. < 1 at width 2 is: 01
  6178. However, you can't use it as a different type: >vim
  6179. echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
  6180. < E1502: Positional argument 2 used as field width reused as
  6181. different type: long int/int
  6182. *E1503*
  6183. When a positional argument is used, but not the correct number
  6184. or arguments is given, an error is raised: >vim
  6185. echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
  6186. < E1503: Positional argument 3 out of bounds: %1$d at width
  6187. %2$d is: %01$*2$.*3$d
  6188. Only the first error is reported: >vim
  6189. echo printf("%01$*2$.*3$d %4$d", 1, 2)
  6190. < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
  6191. %4$d
  6192. *E1504*
  6193. A positional argument can be used more than once: >vim
  6194. echo printf("%1$s %2$s %1$s", "One", "Two")
  6195. < One Two One
  6196. However, you can't use a different type the second time: >vim
  6197. echo printf("%1$s %2$s %1$d", "One", "Two")
  6198. < E1504: Positional argument 1 type used inconsistently:
  6199. int/string
  6200. *E1505*
  6201. Various other errors that lead to a format string being
  6202. wrongly formatted lead to: >vim
  6203. echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
  6204. < E1505: Invalid format specifier: %1$d at width %2$d is:
  6205. %01$*2$.3$d
  6206. *E1507*
  6207. This internal error indicates that the logic to parse a
  6208. positional format argument ran into a problem that couldn't be
  6209. otherwise reported. Please file a bug against Vim if you run
  6210. into this, copying the exact format string and parameters that
  6211. were used.
  6212. Parameters: ~
  6213. • {fmt} (`string`)
  6214. • {expr1} (`any?`)
  6215. Return: ~
  6216. (`string`)
  6217. prompt_getprompt({buf}) *prompt_getprompt()*
  6218. Returns the effective prompt text for buffer {buf}. {buf} can
  6219. be a buffer name or number. See |prompt-buffer|.
  6220. If the buffer doesn't exist or isn't a prompt buffer, an empty
  6221. string is returned.
  6222. Parameters: ~
  6223. • {buf} (`integer|string`)
  6224. Return: ~
  6225. (`any`)
  6226. prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
  6227. Set prompt callback for buffer {buf} to {expr}. When {expr}
  6228. is an empty string the callback is removed. This has only
  6229. effect if {buf} has 'buftype' set to "prompt".
  6230. The callback is invoked when pressing Enter. The current
  6231. buffer will always be the prompt buffer. A new line for a
  6232. prompt is added before invoking the callback, thus the prompt
  6233. for which the callback was invoked will be in the last but one
  6234. line.
  6235. If the callback wants to add text to the buffer, it must
  6236. insert it above the last line, since that is where the current
  6237. prompt is. This can also be done asynchronously.
  6238. The callback is invoked with one argument, which is the text
  6239. that was entered at the prompt. This can be an empty string
  6240. if the user only typed Enter.
  6241. Example: >vim
  6242. func s:TextEntered(text)
  6243. if a:text == 'exit' || a:text == 'quit'
  6244. stopinsert
  6245. " Reset 'modified' to allow the buffer to be closed.
  6246. " We assume there is nothing useful to be saved.
  6247. set nomodified
  6248. close
  6249. else
  6250. " Do something useful with "a:text". In this example
  6251. " we just repeat it.
  6252. call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
  6253. endif
  6254. endfunc
  6255. call prompt_setcallback(bufnr(), function('s:TextEntered'))
  6256. Parameters: ~
  6257. • {buf} (`integer|string`)
  6258. • {expr} (`string|function`)
  6259. Return: ~
  6260. (`any`)
  6261. prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
  6262. Set a callback for buffer {buf} to {expr}. When {expr} is an
  6263. empty string the callback is removed. This has only effect if
  6264. {buf} has 'buftype' set to "prompt".
  6265. This callback will be invoked when pressing CTRL-C in Insert
  6266. mode. Without setting a callback Vim will exit Insert mode,
  6267. as in any buffer.
  6268. Parameters: ~
  6269. • {buf} (`integer|string`)
  6270. • {expr} (`string|function`)
  6271. Return: ~
  6272. (`any`)
  6273. prompt_setprompt({buf}, {text}) *prompt_setprompt()*
  6274. Set prompt for buffer {buf} to {text}. You most likely want
  6275. {text} to end in a space.
  6276. The result is only visible if {buf} has 'buftype' set to
  6277. "prompt". Example: >vim
  6278. call prompt_setprompt(bufnr(''), 'command: ')
  6279. <
  6280. Parameters: ~
  6281. • {buf} (`integer|string`)
  6282. • {text} (`string`)
  6283. Return: ~
  6284. (`any`)
  6285. pum_getpos() *pum_getpos()*
  6286. If the popup menu (see |ins-completion-menu|) is not visible,
  6287. returns an empty |Dictionary|, otherwise, returns a
  6288. |Dictionary| with the following keys:
  6289. height nr of items visible
  6290. width screen cells
  6291. row top screen row (0 first row)
  6292. col leftmost screen column (0 first col)
  6293. size total nr of items
  6294. scrollbar |TRUE| if scrollbar is visible
  6295. The values are the same as in |v:event| during |CompleteChanged|.
  6296. Return: ~
  6297. (`any`)
  6298. pumvisible() *pumvisible()*
  6299. Returns non-zero when the popup menu is visible, zero
  6300. otherwise. See |ins-completion-menu|.
  6301. This can be used to avoid some things that would remove the
  6302. popup menu.
  6303. Return: ~
  6304. (`any`)
  6305. py3eval({expr}) *py3eval()*
  6306. Evaluate Python expression {expr} and return its result
  6307. converted to Vim data structures.
  6308. Numbers and strings are returned as they are (strings are
  6309. copied though, Unicode strings are additionally converted to
  6310. UTF-8).
  6311. Lists are represented as Vim |List| type.
  6312. Dictionaries are represented as Vim |Dictionary| type with
  6313. keys converted to strings.
  6314. Parameters: ~
  6315. • {expr} (`any`)
  6316. Return: ~
  6317. (`any`)
  6318. pyeval({expr}) *pyeval()* *E858* *E859*
  6319. Evaluate Python expression {expr} and return its result
  6320. converted to Vim data structures.
  6321. Numbers and strings are returned as they are (strings are
  6322. copied though).
  6323. Lists are represented as Vim |List| type.
  6324. Dictionaries are represented as Vim |Dictionary| type,
  6325. non-string keys result in error.
  6326. Parameters: ~
  6327. • {expr} (`any`)
  6328. Return: ~
  6329. (`any`)
  6330. pyxeval({expr}) *pyxeval()*
  6331. Evaluate Python expression {expr} and return its result
  6332. converted to Vim data structures.
  6333. Uses Python 2 or 3, see |python_x| and 'pyxversion'.
  6334. See also: |pyeval()|, |py3eval()|
  6335. Parameters: ~
  6336. • {expr} (`any`)
  6337. Return: ~
  6338. (`any`)
  6339. rand([{expr}]) *rand()*
  6340. Return a pseudo-random Number generated with an xoshiro128**
  6341. algorithm using seed {expr}. The returned number is 32 bits,
  6342. also on 64 bits systems, for consistency.
  6343. {expr} can be initialized by |srand()| and will be updated by
  6344. rand(). If {expr} is omitted, an internal seed value is used
  6345. and updated.
  6346. Returns -1 if {expr} is invalid.
  6347. Examples: >vim
  6348. echo rand()
  6349. let seed = srand()
  6350. echo rand(seed)
  6351. echo rand(seed) % 16 " random number 0 - 15
  6352. <
  6353. Parameters: ~
  6354. • {expr} (`number?`)
  6355. Return: ~
  6356. (`any`)
  6357. range({expr} [, {max} [, {stride}]]) *range()* *E726* *E727*
  6358. Returns a |List| with Numbers:
  6359. - If only {expr} is specified: [0, 1, ..., {expr} - 1]
  6360. - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
  6361. - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
  6362. {max}] (increasing {expr} with {stride} each time, not
  6363. producing a value past {max}).
  6364. When the maximum is one before the start the result is an
  6365. empty list. When the maximum is more than one before the
  6366. start this is an error.
  6367. Examples: >vim
  6368. echo range(4) " [0, 1, 2, 3]
  6369. echo range(2, 4) " [2, 3, 4]
  6370. echo range(2, 9, 3) " [2, 5, 8]
  6371. echo range(2, -2, -1) " [2, 1, 0, -1, -2]
  6372. echo range(0) " []
  6373. echo range(2, 0) " error!
  6374. <
  6375. Parameters: ~
  6376. • {expr} (`any`)
  6377. • {max} (`integer?`)
  6378. • {stride} (`integer?`)
  6379. Return: ~
  6380. (`any`)
  6381. readblob({fname} [, {offset} [, {size}]]) *readblob()*
  6382. Read file {fname} in binary mode and return a |Blob|.
  6383. If {offset} is specified, read the file from the specified
  6384. offset. If it is a negative value, it is used as an offset
  6385. from the end of the file. E.g., to read the last 12 bytes: >vim
  6386. echo readblob('file.bin', -12)
  6387. < If {size} is specified, only the specified size will be read.
  6388. E.g. to read the first 100 bytes of a file: >vim
  6389. echo readblob('file.bin', 0, 100)
  6390. < If {size} is -1 or omitted, the whole data starting from
  6391. {offset} will be read.
  6392. This can be also used to read the data from a character device
  6393. on Unix when {size} is explicitly set. Only if the device
  6394. supports seeking {offset} can be used. Otherwise it should be
  6395. zero. E.g. to read 10 bytes from a serial console: >vim
  6396. echo readblob('/dev/ttyS0', 0, 10)
  6397. < When the file can't be opened an error message is given and
  6398. the result is an empty |Blob|.
  6399. When the offset is beyond the end of the file the result is an
  6400. empty blob.
  6401. When trying to read more bytes than are available the result
  6402. is truncated.
  6403. Also see |readfile()| and |writefile()|.
  6404. Parameters: ~
  6405. • {fname} (`string`)
  6406. • {offset} (`integer?`)
  6407. • {size} (`integer?`)
  6408. Return: ~
  6409. (`any`)
  6410. readdir({directory} [, {expr}]) *readdir()*
  6411. Return a list with file and directory names in {directory}.
  6412. You can also use |glob()| if you don't need to do complicated
  6413. things, such as limiting the number of matches.
  6414. When {expr} is omitted all entries are included.
  6415. When {expr} is given, it is evaluated to check what to do:
  6416. If {expr} results in -1 then no further entries will
  6417. be handled.
  6418. If {expr} results in 0 then this entry will not be
  6419. added to the list.
  6420. If {expr} results in 1 then this entry will be added
  6421. to the list.
  6422. Each time {expr} is evaluated |v:val| is set to the entry name.
  6423. When {expr} is a function the name is passed as the argument.
  6424. For example, to get a list of files ending in ".txt": >vim
  6425. echo readdir(dirname, {n -> n =~ '.txt$'})
  6426. < To skip hidden and backup files: >vim
  6427. echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
  6428. < If you want to get a directory tree: >vim
  6429. function! s:tree(dir)
  6430. return {a:dir : map(readdir(a:dir),
  6431. \ {_, x -> isdirectory(x) ?
  6432. \ {x : s:tree(a:dir .. '/' .. x)} : x})}
  6433. endfunction
  6434. echo s:tree(".")
  6435. <
  6436. Returns an empty List on error.
  6437. Parameters: ~
  6438. • {directory} (`string`)
  6439. • {expr} (`integer?`)
  6440. Return: ~
  6441. (`any`)
  6442. readfile({fname} [, {type} [, {max}]]) *readfile()*
  6443. Read file {fname} and return a |List|, each line of the file
  6444. as an item. Lines are broken at NL characters. Macintosh
  6445. files separated with CR will result in a single long line
  6446. (unless a NL appears somewhere).
  6447. All NUL characters are replaced with a NL character.
  6448. When {type} contains "b" binary mode is used:
  6449. - When the last line ends in a NL an extra empty list item is
  6450. added.
  6451. - No CR characters are removed.
  6452. Otherwise:
  6453. - CR characters that appear before a NL are removed.
  6454. - Whether the last line ends in a NL or not does not matter.
  6455. - Any UTF-8 byte order mark is removed from the text.
  6456. When {max} is given this specifies the maximum number of lines
  6457. to be read. Useful if you only want to check the first ten
  6458. lines of a file: >vim
  6459. for line in readfile(fname, '', 10)
  6460. if line =~ 'Date' | echo line | endif
  6461. endfor
  6462. < When {max} is negative -{max} lines from the end of the file
  6463. are returned, or as many as there are.
  6464. When {max} is zero the result is an empty list.
  6465. Note that without {max} the whole file is read into memory.
  6466. Also note that there is no recognition of encoding. Read a
  6467. file into a buffer if you need to.
  6468. Deprecated (use |readblob()| instead): When {type} contains
  6469. "B" a |Blob| is returned with the binary data of the file
  6470. unmodified.
  6471. When the file can't be opened an error message is given and
  6472. the result is an empty list.
  6473. Also see |writefile()|.
  6474. Parameters: ~
  6475. • {fname} (`string`)
  6476. • {type} (`string?`)
  6477. • {max} (`integer?`)
  6478. Return: ~
  6479. (`any`)
  6480. reduce({object}, {func} [, {initial}]) *reduce()* *E998*
  6481. {func} is called for every item in {object}, which can be a
  6482. |String|, |List| or a |Blob|. {func} is called with two
  6483. arguments: the result so far and current item. After
  6484. processing all items the result is returned.
  6485. {initial} is the initial result. When omitted, the first item
  6486. in {object} is used and {func} is first called for the second
  6487. item. If {initial} is not given and {object} is empty no
  6488. result can be computed, an E998 error is given.
  6489. Examples: >vim
  6490. echo reduce([1, 3, 5], { acc, val -> acc + val })
  6491. echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
  6492. echo reduce(0z1122, { acc, val -> 2 * acc + val })
  6493. echo reduce('xyz', { acc, val -> acc .. ',' .. val })
  6494. <
  6495. Parameters: ~
  6496. • {object} (`any`)
  6497. • {func} (`fun(accumulator: T, current: any): any`)
  6498. • {initial} (`any?`)
  6499. Return: ~
  6500. (`T`)
  6501. reg_executing() *reg_executing()*
  6502. Returns the single letter name of the register being executed.
  6503. Returns an empty string when no register is being executed.
  6504. See |@|.
  6505. Return: ~
  6506. (`any`)
  6507. reg_recorded() *reg_recorded()*
  6508. Returns the single letter name of the last recorded register.
  6509. Returns an empty string when nothing was recorded yet.
  6510. See |q| and |Q|.
  6511. Return: ~
  6512. (`any`)
  6513. reg_recording() *reg_recording()*
  6514. Returns the single letter name of the register being recorded.
  6515. Returns an empty string when not recording. See |q|.
  6516. Return: ~
  6517. (`any`)
  6518. reltime() *reltime()*
  6519. reltime({start})
  6520. reltime({start}, {end})
  6521. Return an item that represents a time value. The item is a
  6522. list with items that depend on the system.
  6523. The item can be passed to |reltimestr()| to convert it to a
  6524. string or |reltimefloat()| to convert to a Float.
  6525. Without an argument it returns the current "relative time", an
  6526. implementation-defined value meaningful only when used as an
  6527. argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
  6528. With one argument it returns the time passed since the time
  6529. specified in the argument.
  6530. With two arguments it returns the time passed between {start}
  6531. and {end}.
  6532. The {start} and {end} arguments must be values returned by
  6533. reltime(). Returns zero on error.
  6534. Note: |localtime()| returns the current (non-relative) time.
  6535. Parameters: ~
  6536. • {start} (`any?`)
  6537. • {end} (`any?`)
  6538. Return: ~
  6539. (`any`)
  6540. reltimefloat({time}) *reltimefloat()*
  6541. Return a Float that represents the time value of {time}.
  6542. Unit of time is seconds.
  6543. Example:
  6544. let start = reltime()
  6545. call MyFunction()
  6546. let seconds = reltimefloat(reltime(start))
  6547. See the note of reltimestr() about overhead.
  6548. Also see |profiling|.
  6549. If there is an error an empty string is returned
  6550. Parameters: ~
  6551. • {time} (`any`)
  6552. Return: ~
  6553. (`any`)
  6554. reltimestr({time}) *reltimestr()*
  6555. Return a String that represents the time value of {time}.
  6556. This is the number of seconds, a dot and the number of
  6557. microseconds. Example: >vim
  6558. let start = reltime()
  6559. call MyFunction()
  6560. echo reltimestr(reltime(start))
  6561. < Note that overhead for the commands will be added to the time.
  6562. Leading spaces are used to make the string align nicely. You
  6563. can use split() to remove it. >vim
  6564. echo split(reltimestr(reltime(start)))[0]
  6565. < Also see |profiling|.
  6566. If there is an error an empty string is returned
  6567. Parameters: ~
  6568. • {time} (`any`)
  6569. Return: ~
  6570. (`any`)
  6571. remove({list}, {idx}) *remove()*
  6572. remove({list}, {idx}, {end})
  6573. Without {end}: Remove the item at {idx} from |List| {list} and
  6574. return the item.
  6575. With {end}: Remove items from {idx} to {end} (inclusive) and
  6576. return a |List| with these items. When {idx} points to the same
  6577. item as {end} a list with one item is returned. When {end}
  6578. points to an item before {idx} this is an error.
  6579. See |list-index| for possible values of {idx} and {end}.
  6580. Returns zero on error.
  6581. Example: >vim
  6582. echo "last item: " .. remove(mylist, -1)
  6583. call remove(mylist, 0, 9)
  6584. <
  6585. Use |delete()| to remove a file.
  6586. Parameters: ~
  6587. • {list} (`any[]`)
  6588. • {idx} (`integer`)
  6589. • {end} (`integer?`)
  6590. Return: ~
  6591. (`any`)
  6592. remove({blob}, {idx})
  6593. remove({blob}, {idx}, {end})
  6594. Without {end}: Remove the byte at {idx} from |Blob| {blob} and
  6595. return the byte.
  6596. With {end}: Remove bytes from {idx} to {end} (inclusive) and
  6597. return a |Blob| with these bytes. When {idx} points to the same
  6598. byte as {end} a |Blob| with one byte is returned. When {end}
  6599. points to a byte before {idx} this is an error.
  6600. Returns zero on error.
  6601. Example: >vim
  6602. echo "last byte: " .. remove(myblob, -1)
  6603. call remove(mylist, 0, 9)
  6604. <
  6605. Parameters: ~
  6606. • {blob} (`any`)
  6607. • {idx} (`integer`)
  6608. • {end} (`integer?`)
  6609. Return: ~
  6610. (`any`)
  6611. remove({dict}, {key})
  6612. Remove the entry from {dict} with key {key} and return it.
  6613. Example: >vim
  6614. echo "removed " .. remove(dict, "one")
  6615. < If there is no {key} in {dict} this is an error.
  6616. Returns zero on error.
  6617. Parameters: ~
  6618. • {dict} (`any`)
  6619. • {key} (`string`)
  6620. Return: ~
  6621. (`any`)
  6622. rename({from}, {to}) *rename()*
  6623. Rename the file by the name {from} to the name {to}. This
  6624. should also work to move files across file systems. The
  6625. result is a Number, which is 0 if the file was renamed
  6626. successfully, and non-zero when the renaming failed.
  6627. NOTE: If {to} exists it is overwritten without warning.
  6628. This function is not available in the |sandbox|.
  6629. Parameters: ~
  6630. • {from} (`string`)
  6631. • {to} (`string`)
  6632. Return: ~
  6633. (`integer`)
  6634. repeat({expr}, {count}) *repeat()*
  6635. Repeat {expr} {count} times and return the concatenated
  6636. result. Example: >vim
  6637. let separator = repeat('-', 80)
  6638. < When {count} is zero or negative the result is empty.
  6639. When {expr} is a |List| or a |Blob| the result is {expr}
  6640. concatenated {count} times. Example: >vim
  6641. let longlist = repeat(['a', 'b'], 3)
  6642. < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
  6643. Parameters: ~
  6644. • {expr} (`any`)
  6645. • {count} (`integer`)
  6646. Return: ~
  6647. (`any`)
  6648. resolve({filename}) *resolve()* *E655*
  6649. On MS-Windows, when {filename} is a shortcut (a .lnk file),
  6650. returns the path the shortcut points to in a simplified form.
  6651. On Unix, repeat resolving symbolic links in all path
  6652. components of {filename} and return the simplified result.
  6653. To cope with link cycles, resolving of symbolic links is
  6654. stopped after 100 iterations.
  6655. On other systems, return the simplified {filename}.
  6656. The simplification step is done as by |simplify()|.
  6657. resolve() keeps a leading path component specifying the
  6658. current directory (provided the result is still a relative
  6659. path name) and also keeps a trailing path separator.
  6660. Parameters: ~
  6661. • {filename} (`string`)
  6662. Return: ~
  6663. (`string`)
  6664. reverse({object}) *reverse()*
  6665. Reverse the order of items in {object}. {object} can be a
  6666. |List|, a |Blob| or a |String|. For a List and a Blob the
  6667. items are reversed in-place and {object} is returned.
  6668. For a String a new String is returned.
  6669. Returns zero if {object} is not a List, Blob or a String.
  6670. If you want a List or Blob to remain unmodified make a copy
  6671. first: >vim
  6672. let revlist = reverse(copy(mylist))
  6673. <
  6674. Parameters: ~
  6675. • {object} (`T[]`)
  6676. Return: ~
  6677. (`T[]`)
  6678. round({expr}) *round()*
  6679. Round off {expr} to the nearest integral value and return it
  6680. as a |Float|. If {expr} lies halfway between two integral
  6681. values, then use the larger one (away from zero).
  6682. {expr} must evaluate to a |Float| or a |Number|.
  6683. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6684. Examples: >vim
  6685. echo round(0.456)
  6686. < 0.0 >vim
  6687. echo round(4.5)
  6688. < 5.0 >vim
  6689. echo round(-4.5)
  6690. < -5.0
  6691. Parameters: ~
  6692. • {expr} (`number`)
  6693. Return: ~
  6694. (`number`)
  6695. rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()*
  6696. Sends {event} to {channel} via |RPC| and returns immediately.
  6697. If {channel} is 0, the event is broadcast to all channels.
  6698. Example: >vim
  6699. au VimLeave call rpcnotify(0, "leaving")
  6700. <
  6701. Parameters: ~
  6702. • {channel} (`integer`)
  6703. • {event} (`string`)
  6704. • {...} (`any`)
  6705. Return: ~
  6706. (`integer`)
  6707. rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()*
  6708. Sends a request to {channel} to invoke {method} via
  6709. |RPC| and blocks until a response is received.
  6710. Example: >vim
  6711. let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
  6712. <
  6713. Parameters: ~
  6714. • {channel} (`integer`)
  6715. • {method} (`string`)
  6716. • {...} (`any`)
  6717. Return: ~
  6718. (`any`)
  6719. rubyeval({expr}) *rubyeval()*
  6720. Evaluate Ruby expression {expr} and return its result
  6721. converted to Vim data structures.
  6722. Numbers, floats and strings are returned as they are (strings
  6723. are copied though).
  6724. Arrays are represented as Vim |List| type.
  6725. Hashes are represented as Vim |Dictionary| type.
  6726. Other objects are represented as strings resulted from their
  6727. "Object#to_s" method.
  6728. Parameters: ~
  6729. • {expr} (`any`)
  6730. Return: ~
  6731. (`any`)
  6732. screenattr({row}, {col}) *screenattr()*
  6733. Like |screenchar()|, but return the attribute. This is a rather
  6734. arbitrary number that can only be used to compare to the
  6735. attribute at other positions.
  6736. Returns -1 when row or col is out of range.
  6737. Parameters: ~
  6738. • {row} (`integer`)
  6739. • {col} (`integer`)
  6740. Return: ~
  6741. (`integer`)
  6742. screenchar({row}, {col}) *screenchar()*
  6743. The result is a Number, which is the character at position
  6744. [row, col] on the screen. This works for every possible
  6745. screen position, also status lines, window separators and the
  6746. command line. The top left position is row one, column one
  6747. The character excludes composing characters. For double-byte
  6748. encodings it may only be the first byte.
  6749. This is mainly to be used for testing.
  6750. Returns -1 when row or col is out of range.
  6751. Parameters: ~
  6752. • {row} (`integer`)
  6753. • {col} (`integer`)
  6754. Return: ~
  6755. (`integer`)
  6756. screenchars({row}, {col}) *screenchars()*
  6757. The result is a |List| of Numbers. The first number is the same
  6758. as what |screenchar()| returns. Further numbers are
  6759. composing characters on top of the base character.
  6760. This is mainly to be used for testing.
  6761. Returns an empty List when row or col is out of range.
  6762. Parameters: ~
  6763. • {row} (`integer`)
  6764. • {col} (`integer`)
  6765. Return: ~
  6766. (`integer[]`)
  6767. screencol() *screencol()*
  6768. The result is a Number, which is the current screen column of
  6769. the cursor. The leftmost column has number 1.
  6770. This function is mainly used for testing.
  6771. Note: Always returns the current screen column, thus if used
  6772. in a command (e.g. ":echo screencol()") it will return the
  6773. column inside the command line, which is 1 when the command is
  6774. executed. To get the cursor position in the file use one of
  6775. the following mappings: >vim
  6776. nnoremap <expr> GG ":echom " .. screencol() .. "\n"
  6777. nnoremap <silent> GG :echom screencol()<CR>
  6778. noremap GG <Cmd>echom screencol()<CR>
  6779. <
  6780. Return: ~
  6781. (`integer[]`)
  6782. screenpos({winid}, {lnum}, {col}) *screenpos()*
  6783. The result is a Dict with the screen position of the text
  6784. character in window {winid} at buffer line {lnum} and column
  6785. {col}. {col} is a one-based byte index.
  6786. The Dict has these members:
  6787. row screen row
  6788. col first screen column
  6789. endcol last screen column
  6790. curscol cursor screen column
  6791. If the specified position is not visible, all values are zero.
  6792. The "endcol" value differs from "col" when the character
  6793. occupies more than one screen cell. E.g. for a Tab "col" can
  6794. be 1 and "endcol" can be 8.
  6795. The "curscol" value is where the cursor would be placed. For
  6796. a Tab it would be the same as "endcol", while for a double
  6797. width character it would be the same as "col".
  6798. The |conceal| feature is ignored here, the column numbers are
  6799. as if 'conceallevel' is zero. You can set the cursor to the
  6800. right position and use |screencol()| to get the value with
  6801. |conceal| taken into account.
  6802. If the position is in a closed fold the screen position of the
  6803. first character is returned, {col} is not used.
  6804. Returns an empty Dict if {winid} is invalid.
  6805. Parameters: ~
  6806. • {winid} (`integer`)
  6807. • {lnum} (`integer`)
  6808. • {col} (`integer`)
  6809. Return: ~
  6810. (`any`)
  6811. screenrow() *screenrow()*
  6812. The result is a Number, which is the current screen row of the
  6813. cursor. The top line has number one.
  6814. This function is mainly used for testing.
  6815. Alternatively you can use |winline()|.
  6816. Note: Same restrictions as with |screencol()|.
  6817. Return: ~
  6818. (`integer`)
  6819. screenstring({row}, {col}) *screenstring()*
  6820. The result is a String that contains the base character and
  6821. any composing characters at position [row, col] on the screen.
  6822. This is like |screenchars()| but returning a String with the
  6823. characters.
  6824. This is mainly to be used for testing.
  6825. Returns an empty String when row or col is out of range.
  6826. Parameters: ~
  6827. • {row} (`integer`)
  6828. • {col} (`integer`)
  6829. Return: ~
  6830. (`string`)
  6831. search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
  6832. Search for regexp pattern {pattern}. The search starts at the
  6833. cursor position (you can use |cursor()| to set it).
  6834. When a match has been found its line number is returned.
  6835. If there is no match a 0 is returned and the cursor doesn't
  6836. move. No error message is given.
  6837. To get the matched string, use |matchbufline()|.
  6838. {flags} is a String, which can contain these character flags:
  6839. 'b' search Backward instead of forward
  6840. 'c' accept a match at the Cursor position
  6841. 'e' move to the End of the match
  6842. 'n' do Not move the cursor
  6843. 'p' return number of matching sub-Pattern (see below)
  6844. 's' Set the ' mark at the previous location of the cursor
  6845. 'w' Wrap around the end of the file
  6846. 'W' don't Wrap around the end of the file
  6847. 'z' start searching at the cursor column instead of Zero
  6848. If neither 'w' or 'W' is given, the 'wrapscan' option applies.
  6849. If the 's' flag is supplied, the ' mark is set, only if the
  6850. cursor is moved. The 's' flag cannot be combined with the 'n'
  6851. flag.
  6852. 'ignorecase', 'smartcase' and 'magic' are used.
  6853. When the 'z' flag is not given, forward searching always
  6854. starts in column zero and then matches before the cursor are
  6855. skipped. When the 'c' flag is present in 'cpo' the next
  6856. search starts after the match. Without the 'c' flag the next
  6857. search starts one column after the start of the match. This
  6858. matters for overlapping matches. See |cpo-c|. You can also
  6859. insert "\ze" to change where the match ends, see |/\ze|.
  6860. When searching backwards and the 'z' flag is given then the
  6861. search starts in column zero, thus no match in the current
  6862. line will be found (unless wrapping around the end of the
  6863. file).
  6864. When the {stopline} argument is given then the search stops
  6865. after searching this line. This is useful to restrict the
  6866. search to a range of lines. Examples: >vim
  6867. let match = search('(', 'b', line("w0"))
  6868. let end = search('END', '', line("w$"))
  6869. < When {stopline} is used and it is not zero this also implies
  6870. that the search does not wrap around the end of the file.
  6871. A zero value is equal to not giving the argument.
  6872. When the {timeout} argument is given the search stops when
  6873. more than this many milliseconds have passed. Thus when
  6874. {timeout} is 500 the search stops after half a second.
  6875. The value must not be negative. A zero value is like not
  6876. giving the argument.
  6877. Note: the timeout is only considered when searching, not
  6878. while evaluating the {skip} expression.
  6879. If the {skip} expression is given it is evaluated with the
  6880. cursor positioned on the start of a match. If it evaluates to
  6881. non-zero this match is skipped. This can be used, for
  6882. example, to skip a match in a comment or a string.
  6883. {skip} can be a string, which is evaluated as an expression, a
  6884. function reference or a lambda.
  6885. When {skip} is omitted or empty, every match is accepted.
  6886. When evaluating {skip} causes an error the search is aborted
  6887. and -1 returned.
  6888. *search()-sub-match*
  6889. With the 'p' flag the returned value is one more than the
  6890. first sub-match in \(\). One if none of them matched but the
  6891. whole pattern did match.
  6892. To get the column number too use |searchpos()|.
  6893. The cursor will be positioned at the match, unless the 'n'
  6894. flag is used.
  6895. Example (goes over all files in the argument list): >vim
  6896. let n = 1
  6897. while n <= argc() " loop over all files in arglist
  6898. exe "argument " .. n
  6899. " start at the last char in the file and wrap for the
  6900. " first search to find match at start of file
  6901. normal G$
  6902. let flags = "w"
  6903. while search("foo", flags) > 0
  6904. s/foo/bar/g
  6905. let flags = "W"
  6906. endwhile
  6907. update " write the file if modified
  6908. let n = n + 1
  6909. endwhile
  6910. <
  6911. Example for using some flags: >vim
  6912. echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
  6913. < This will search for the keywords "if", "else", and "endif"
  6914. under or after the cursor. Because of the 'p' flag, it
  6915. returns 1, 2, or 3 depending on which keyword is found, or 0
  6916. if the search fails. With the cursor on the first word of the
  6917. line:
  6918. if (foo == 0) | let foo = foo + 1 | endif ~
  6919. the function returns 1. Without the 'c' flag, the function
  6920. finds the "endif" and returns 3. The same thing happens
  6921. without the 'e' flag if the cursor is on the "f" of "if".
  6922. The 'n' flag tells the function not to move the cursor.
  6923. Parameters: ~
  6924. • {pattern} (`string`)
  6925. • {flags} (`string?`)
  6926. • {stopline} (`integer?`)
  6927. • {timeout} (`integer?`)
  6928. • {skip} (`string|function?`)
  6929. Return: ~
  6930. (`any`)
  6931. searchcount([{options}]) *searchcount()*
  6932. Get or update the last search count, like what is displayed
  6933. without the "S" flag in 'shortmess'. This works even if
  6934. 'shortmess' does contain the "S" flag.
  6935. This returns a |Dictionary|. The dictionary is empty if the
  6936. previous pattern was not set and "pattern" was not specified.
  6937. key type meaning ~
  6938. current |Number| current position of match;
  6939. 0 if the cursor position is
  6940. before the first match
  6941. exact_match |Boolean| 1 if "current" is matched on
  6942. "pos", otherwise 0
  6943. total |Number| total count of matches found
  6944. incomplete |Number| 0: search was fully completed
  6945. 1: recomputing was timed out
  6946. 2: max count exceeded
  6947. For {options} see further down.
  6948. To get the last search count when |n| or |N| was pressed, call
  6949. this function with `recompute: 0` . This sometimes returns
  6950. wrong information because |n| and |N|'s maximum count is 99.
  6951. If it exceeded 99 the result must be max count + 1 (100). If
  6952. you want to get correct information, specify `recompute: 1`: >vim
  6953. " result == maxcount + 1 (100) when many matches
  6954. let result = searchcount(#{recompute: 0})
  6955. " Below returns correct result (recompute defaults
  6956. " to 1)
  6957. let result = searchcount()
  6958. <
  6959. The function is useful to add the count to 'statusline': >vim
  6960. function! LastSearchCount() abort
  6961. let result = searchcount(#{recompute: 0})
  6962. if empty(result)
  6963. return ''
  6964. endif
  6965. if result.incomplete ==# 1 " timed out
  6966. return printf(' /%s [?/??]', @/)
  6967. elseif result.incomplete ==# 2 " max count exceeded
  6968. if result.total > result.maxcount &&
  6969. \ result.current > result.maxcount
  6970. return printf(' /%s [>%d/>%d]', @/,
  6971. \ result.current, result.total)
  6972. elseif result.total > result.maxcount
  6973. return printf(' /%s [%d/>%d]', @/,
  6974. \ result.current, result.total)
  6975. endif
  6976. endif
  6977. return printf(' /%s [%d/%d]', @/,
  6978. \ result.current, result.total)
  6979. endfunction
  6980. let &statusline ..= '%{LastSearchCount()}'
  6981. " Or if you want to show the count only when
  6982. " 'hlsearch' was on
  6983. " let &statusline ..=
  6984. " \ '%{v:hlsearch ? LastSearchCount() : ""}'
  6985. <
  6986. You can also update the search count, which can be useful in a
  6987. |CursorMoved| or |CursorMovedI| autocommand: >vim
  6988. autocmd CursorMoved,CursorMovedI *
  6989. \ let s:searchcount_timer = timer_start(
  6990. \ 200, function('s:update_searchcount'))
  6991. function! s:update_searchcount(timer) abort
  6992. if a:timer ==# s:searchcount_timer
  6993. call searchcount(#{
  6994. \ recompute: 1, maxcount: 0, timeout: 100})
  6995. redrawstatus
  6996. endif
  6997. endfunction
  6998. <
  6999. This can also be used to count matched texts with specified
  7000. pattern in the current buffer using "pattern": >vim
  7001. " Count '\<foo\>' in this buffer
  7002. " (Note that it also updates search count)
  7003. let result = searchcount(#{pattern: '\<foo\>'})
  7004. " To restore old search count by old pattern,
  7005. " search again
  7006. call searchcount()
  7007. <
  7008. {options} must be a |Dictionary|. It can contain:
  7009. key type meaning ~
  7010. recompute |Boolean| if |TRUE|, recompute the count
  7011. like |n| or |N| was executed.
  7012. otherwise returns the last
  7013. computed result (when |n| or
  7014. |N| was used when "S" is not
  7015. in 'shortmess', or this
  7016. function was called).
  7017. (default: |TRUE|)
  7018. pattern |String| recompute if this was given
  7019. and different with |@/|.
  7020. this works as same as the
  7021. below command is executed
  7022. before calling this function >vim
  7023. let @/ = pattern
  7024. < (default: |@/|)
  7025. timeout |Number| 0 or negative number is no
  7026. timeout. timeout milliseconds
  7027. for recomputing the result
  7028. (default: 0)
  7029. maxcount |Number| 0 or negative number is no
  7030. limit. max count of matched
  7031. text while recomputing the
  7032. result. if search exceeded
  7033. total count, "total" value
  7034. becomes `maxcount + 1`
  7035. (default: 0)
  7036. pos |List| `[lnum, col, off]` value
  7037. when recomputing the result.
  7038. this changes "current" result
  7039. value. see |cursor()|, |getpos()|
  7040. (default: cursor's position)
  7041. Parameters: ~
  7042. • {options} (`table?`)
  7043. Return: ~
  7044. (`any`)
  7045. searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
  7046. Search for the declaration of {name}.
  7047. With a non-zero {global} argument it works like |gD|, find
  7048. first match in the file. Otherwise it works like |gd|, find
  7049. first match in the function.
  7050. With a non-zero {thisblock} argument matches in a {} block
  7051. that ends before the cursor position are ignored. Avoids
  7052. finding variable declarations only valid in another scope.
  7053. Moves the cursor to the found match.
  7054. Returns zero for success, non-zero for failure.
  7055. Example: >vim
  7056. if searchdecl('myvar') == 0
  7057. echo getline('.')
  7058. endif
  7059. <
  7060. Parameters: ~
  7061. • {name} (`string`)
  7062. • {global} (`boolean?`)
  7063. • {thisblock} (`boolean?`)
  7064. Return: ~
  7065. (`any`)
  7066. *searchpair()*
  7067. searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7068. Search for the match of a nested start-end pair. This can be
  7069. used to find the "endif" that matches an "if", while other
  7070. if/endif pairs in between are ignored.
  7071. The search starts at the cursor. The default is to search
  7072. forward, include 'b' in {flags} to search backward.
  7073. If a match is found, the cursor is positioned at it and the
  7074. line number is returned. If no match is found 0 or -1 is
  7075. returned and the cursor doesn't move. No error message is
  7076. given.
  7077. {start}, {middle} and {end} are patterns, see |pattern|. They
  7078. must not contain \( \) pairs. Use of \%( \) is allowed. When
  7079. {middle} is not empty, it is found when searching from either
  7080. direction, but only when not in a nested start-end pair. A
  7081. typical use is: >vim
  7082. echo searchpair('\<if\>', '\<else\>', '\<endif\>')
  7083. < By leaving {middle} empty the "else" is skipped.
  7084. {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
  7085. |search()|. Additionally:
  7086. 'r' Repeat until no more matches found; will find the
  7087. outer pair. Implies the 'W' flag.
  7088. 'm' Return number of matches instead of line number with
  7089. the match; will be > 1 when 'r' is used.
  7090. Note: it's nearly always a good idea to use the 'W' flag, to
  7091. avoid wrapping around the end of the file.
  7092. When a match for {start}, {middle} or {end} is found, the
  7093. {skip} expression is evaluated with the cursor positioned on
  7094. the start of the match. It should return non-zero if this
  7095. match is to be skipped. E.g., because it is inside a comment
  7096. or a string.
  7097. When {skip} is omitted or empty, every match is accepted.
  7098. When evaluating {skip} causes an error the search is aborted
  7099. and -1 returned.
  7100. {skip} can be a string, a lambda, a funcref or a partial.
  7101. Anything else makes the function fail.
  7102. For {stopline} and {timeout} see |search()|.
  7103. The value of 'ignorecase' is used. 'magic' is ignored, the
  7104. patterns are used like it's on.
  7105. The search starts exactly at the cursor. A match with
  7106. {start}, {middle} or {end} at the next character, in the
  7107. direction of searching, is the first one found. Example: >vim
  7108. if 1
  7109. if 2
  7110. endif 2
  7111. endif 1
  7112. < When starting at the "if 2", with the cursor on the "i", and
  7113. searching forwards, the "endif 2" is found. When starting on
  7114. the character just before the "if 2", the "endif 1" will be
  7115. found. That's because the "if 2" will be found first, and
  7116. then this is considered to be a nested if/endif from "if 2" to
  7117. "endif 2".
  7118. When searching backwards and {end} is more than one character,
  7119. it may be useful to put "\zs" at the end of the pattern, so
  7120. that when the cursor is inside a match with the end it finds
  7121. the matching start.
  7122. Example, to find the "endif" command in a Vim script: >vim
  7123. echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
  7124. \ 'getline(".") =~ "^\\s*\""')
  7125. < The cursor must be at or after the "if" for which a match is
  7126. to be found. Note that single-quote strings are used to avoid
  7127. having to double the backslashes. The skip expression only
  7128. catches comments at the start of a line, not after a command.
  7129. Also, a word "en" or "if" halfway through a line is considered
  7130. a match.
  7131. Another example, to search for the matching "{" of a "}": >vim
  7132. echo searchpair('{', '', '}', 'bW')
  7133. < This works when the cursor is at or before the "}" for which a
  7134. match is to be found. To reject matches that syntax
  7135. highlighting recognized as strings: >vim
  7136. echo searchpair('{', '', '}', 'bW',
  7137. \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
  7138. <
  7139. Parameters: ~
  7140. • {start} (`string`)
  7141. • {middle} (`string`)
  7142. • {end} (`string`)
  7143. • {flags} (`string?`)
  7144. • {skip} (`string|function?`)
  7145. • {stopline} (`integer?`)
  7146. • {timeout} (`integer?`)
  7147. Return: ~
  7148. (`integer`)
  7149. *searchpairpos()*
  7150. searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7151. Same as |searchpair()|, but returns a |List| with the line and
  7152. column position of the match. The first element of the |List|
  7153. is the line number and the second element is the byte index of
  7154. the column position of the match. If no match is found,
  7155. returns [0, 0]. >vim
  7156. let [lnum,col] = searchpairpos('{', '', '}', 'n')
  7157. <
  7158. See |match-parens| for a bigger and more useful example.
  7159. Parameters: ~
  7160. • {start} (`string`)
  7161. • {middle} (`string`)
  7162. • {end} (`string`)
  7163. • {flags} (`string?`)
  7164. • {skip} (`string|function?`)
  7165. • {stopline} (`integer?`)
  7166. • {timeout} (`integer?`)
  7167. Return: ~
  7168. (`[integer, integer]`)
  7169. *searchpos()*
  7170. searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  7171. Same as |search()|, but returns a |List| with the line and
  7172. column position of the match. The first element of the |List|
  7173. is the line number and the second element is the byte index of
  7174. the column position of the match. If no match is found,
  7175. returns [0, 0].
  7176. Example: >vim
  7177. let [lnum, col] = searchpos('mypattern', 'n')
  7178. < When the 'p' flag is given then there is an extra item with
  7179. the sub-pattern match number |search()-sub-match|. Example: >vim
  7180. let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
  7181. < In this example "submatch" is 2 when a lowercase letter is
  7182. found |/\l|, 3 when an uppercase letter is found |/\u|.
  7183. Parameters: ~
  7184. • {pattern} (`string`)
  7185. • {flags} (`string?`)
  7186. • {stopline} (`integer?`)
  7187. • {timeout} (`integer?`)
  7188. • {skip} (`string|function?`)
  7189. Return: ~
  7190. (`any`)
  7191. serverlist() *serverlist()*
  7192. Returns a list of server addresses, or empty if all servers
  7193. were stopped. |serverstart()| |serverstop()|
  7194. Example: >vim
  7195. echo serverlist()
  7196. <
  7197. Return: ~
  7198. (`string[]`)
  7199. serverstart([{address}]) *serverstart()*
  7200. Opens a socket or named pipe at {address} and listens for
  7201. |RPC| messages. Clients can send |API| commands to the
  7202. returned address to control Nvim.
  7203. Returns the address string (which may differ from the
  7204. {address} argument, see below).
  7205. - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
  7206. where the last ":" separates host and port (empty or zero
  7207. assigns a random port).
  7208. - Else {address} is the path to a named pipe (except on Windows).
  7209. - If {address} has no slashes ("/") it is treated as the
  7210. "name" part of a generated path in this format: >vim
  7211. stdpath("run").."/{name}.{pid}.{counter}"
  7212. < - If {address} is omitted the name is "nvim". >vim
  7213. echo serverstart()
  7214. < >
  7215. => /tmp/nvim.bram/oknANW/nvim.15430.5
  7216. <
  7217. Example bash command to list all Nvim servers: >bash
  7218. ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
  7219. < Example named pipe: >vim
  7220. if has('win32')
  7221. echo serverstart('\\.\pipe\nvim-pipe-1234')
  7222. else
  7223. echo serverstart('nvim.sock')
  7224. endif
  7225. <
  7226. Example TCP/IP address: >vim
  7227. echo serverstart('::1:12345')
  7228. <
  7229. Parameters: ~
  7230. • {address} (`string?`)
  7231. Return: ~
  7232. (`string`)
  7233. serverstop({address}) *serverstop()*
  7234. Closes the pipe or socket at {address}.
  7235. Returns TRUE if {address} is valid, else FALSE.
  7236. If |v:servername| is stopped it is set to the next available
  7237. address in |serverlist()|.
  7238. Parameters: ~
  7239. • {address} (`string`)
  7240. Return: ~
  7241. (`integer`)
  7242. setbufline({buf}, {lnum}, {text}) *setbufline()*
  7243. Set line {lnum} to {text} in buffer {buf}. This works like
  7244. |setline()| for the specified buffer.
  7245. This function works only for loaded buffers. First call
  7246. |bufload()| if needed.
  7247. To insert lines use |appendbufline()|.
  7248. {text} can be a string to set one line, or a List of strings
  7249. to set multiple lines. If the List extends below the last
  7250. line then those lines are added. If the List is empty then
  7251. nothing is changed and zero is returned.
  7252. For the use of {buf}, see |bufname()| above.
  7253. {lnum} is used like with |setline()|.
  7254. Use "$" to refer to the last line in buffer {buf}.
  7255. When {lnum} is just below the last line the {text} will be
  7256. added below the last line.
  7257. On success 0 is returned, on failure 1 is returned.
  7258. If {buf} is not a valid buffer or {lnum} is not valid, an
  7259. error message is given.
  7260. Parameters: ~
  7261. • {buf} (`integer|string`)
  7262. • {lnum} (`integer`)
  7263. • {text} (`string|string[]`)
  7264. Return: ~
  7265. (`integer`)
  7266. setbufvar({buf}, {varname}, {val}) *setbufvar()*
  7267. Set option or local variable {varname} in buffer {buf} to
  7268. {val}.
  7269. This also works for a global or local window option, but it
  7270. doesn't work for a global or local window variable.
  7271. For a local window option the global value is unchanged.
  7272. For the use of {buf}, see |bufname()| above.
  7273. The {varname} argument is a string.
  7274. Note that the variable name without "b:" must be used.
  7275. Examples: >vim
  7276. call setbufvar(1, "&mod", 1)
  7277. call setbufvar("todo", "myvar", "foobar")
  7278. < This function is not available in the |sandbox|.
  7279. Parameters: ~
  7280. • {buf} (`integer|string`)
  7281. • {varname} (`string`)
  7282. • {val} (`any`)
  7283. Return: ~
  7284. (`any`)
  7285. setcellwidths({list}) *setcellwidths()*
  7286. Specify overrides for cell widths of character ranges. This
  7287. tells Vim how wide characters are when displayed in the
  7288. terminal, counted in screen cells. The values override
  7289. 'ambiwidth'. Example: >vim
  7290. call setcellwidths([
  7291. \ [0x111, 0x111, 1],
  7292. \ [0x2194, 0x2199, 2],
  7293. \ ])
  7294. < The {list} argument is a List of Lists with each three
  7295. numbers: [{low}, {high}, {width}]. *E1109* *E1110*
  7296. {low} and {high} can be the same, in which case this refers to
  7297. one character. Otherwise it is the range of characters from
  7298. {low} to {high} (inclusive). *E1111* *E1114*
  7299. Only characters with value 0x80 and higher can be used.
  7300. {width} must be either 1 or 2, indicating the character width
  7301. in screen cells. *E1112*
  7302. An error is given if the argument is invalid, also when a
  7303. range overlaps with another. *E1113*
  7304. If the new value causes 'fillchars' or 'listchars' to become
  7305. invalid it is rejected and an error is given.
  7306. To clear the overrides pass an empty {list}: >vim
  7307. call setcellwidths([])
  7308. < You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
  7309. the effect for known emoji characters. Move the cursor
  7310. through the text to check if the cell widths of your terminal
  7311. match with what Vim knows about each emoji. If it doesn't
  7312. look right you need to adjust the {list} argument.
  7313. Parameters: ~
  7314. • {list} (`any[]`)
  7315. Return: ~
  7316. (`any`)
  7317. setcharpos({expr}, {list}) *setcharpos()*
  7318. Same as |setpos()| but uses the specified column number as the
  7319. character index instead of the byte index in the line.
  7320. Example:
  7321. With the text "여보세요" in line 8: >vim
  7322. call setcharpos('.', [0, 8, 4, 0])
  7323. < positions the cursor on the fourth character '요'. >vim
  7324. call setpos('.', [0, 8, 4, 0])
  7325. < positions the cursor on the second character '보'.
  7326. Parameters: ~
  7327. • {expr} (`string`)
  7328. • {list} (`integer[]`)
  7329. Return: ~
  7330. (`any`)
  7331. setcharsearch({dict}) *setcharsearch()*
  7332. Set the current character search information to {dict},
  7333. which contains one or more of the following entries:
  7334. char character which will be used for a subsequent
  7335. |,| or |;| command; an empty string clears the
  7336. character search
  7337. forward direction of character search; 1 for forward,
  7338. 0 for backward
  7339. until type of character search; 1 for a |t| or |T|
  7340. character search, 0 for an |f| or |F|
  7341. character search
  7342. This can be useful to save/restore a user's character search
  7343. from a script: >vim
  7344. let prevsearch = getcharsearch()
  7345. " Perform a command which clobbers user's search
  7346. call setcharsearch(prevsearch)
  7347. < Also see |getcharsearch()|.
  7348. Parameters: ~
  7349. • {dict} (`string`)
  7350. Return: ~
  7351. (`any`)
  7352. setcmdline({str} [, {pos}]) *setcmdline()*
  7353. Set the command line to {str} and set the cursor position to
  7354. {pos}.
  7355. If {pos} is omitted, the cursor is positioned after the text.
  7356. Returns 0 when successful, 1 when not editing the command
  7357. line.
  7358. Parameters: ~
  7359. • {str} (`string`)
  7360. • {pos} (`integer?`)
  7361. Return: ~
  7362. (`integer`)
  7363. setcmdpos({pos}) *setcmdpos()*
  7364. Set the cursor position in the command line to byte position
  7365. {pos}. The first position is 1.
  7366. Use |getcmdpos()| to obtain the current position.
  7367. Only works while editing the command line, thus you must use
  7368. |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
  7369. |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
  7370. set after the command line is set to the expression. For
  7371. |c_CTRL-R_=| it is set after evaluating the expression but
  7372. before inserting the resulting text.
  7373. When the number is too big the cursor is put at the end of the
  7374. line. A number smaller than one has undefined results.
  7375. Returns 0 when successful, 1 when not editing the command
  7376. line.
  7377. Parameters: ~
  7378. • {pos} (`integer`)
  7379. Return: ~
  7380. (`any`)
  7381. setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()*
  7382. setcursorcharpos({list})
  7383. Same as |cursor()| but uses the specified column number as the
  7384. character index instead of the byte index in the line.
  7385. Example:
  7386. With the text "여보세요" in line 4: >vim
  7387. call setcursorcharpos(4, 3)
  7388. < positions the cursor on the third character '세'. >vim
  7389. call cursor(4, 3)
  7390. < positions the cursor on the first character '여'.
  7391. Parameters: ~
  7392. • {list} (`integer[]`)
  7393. Return: ~
  7394. (`any`)
  7395. setenv({name}, {val}) *setenv()*
  7396. Set environment variable {name} to {val}. Example: >vim
  7397. call setenv('HOME', '/home/myhome')
  7398. < When {val} is |v:null| the environment variable is deleted.
  7399. See also |expr-env|.
  7400. Parameters: ~
  7401. • {name} (`string`)
  7402. • {val} (`string`)
  7403. Return: ~
  7404. (`any`)
  7405. setfperm({fname}, {mode}) *setfperm()* *chmod*
  7406. Set the file permissions for {fname} to {mode}.
  7407. {mode} must be a string with 9 characters. It is of the form
  7408. "rwxrwxrwx", where each group of "rwx" flags represent, in
  7409. turn, the permissions of the owner of the file, the group the
  7410. file belongs to, and other users. A '-' character means the
  7411. permission is off, any other character means on. Multi-byte
  7412. characters are not supported.
  7413. For example "rw-r-----" means read-write for the user,
  7414. readable by the group, not accessible by others. "xx-x-----"
  7415. would do the same thing.
  7416. Returns non-zero for success, zero for failure.
  7417. To read permissions see |getfperm()|.
  7418. Parameters: ~
  7419. • {fname} (`string`)
  7420. • {mode} (`string`)
  7421. Return: ~
  7422. (`any`)
  7423. setline({lnum}, {text}) *setline()*
  7424. Set line {lnum} of the current buffer to {text}. To insert
  7425. lines use |append()|. To set lines in another buffer use
  7426. |setbufline()|.
  7427. {lnum} is used like with |getline()|.
  7428. When {lnum} is just below the last line the {text} will be
  7429. added below the last line.
  7430. {text} can be any type or a List of any type, each item is
  7431. converted to a String. When {text} is an empty List then
  7432. nothing is changed and FALSE is returned.
  7433. If this succeeds, FALSE is returned. If this fails (most likely
  7434. because {lnum} is invalid) TRUE is returned.
  7435. Example: >vim
  7436. call setline(5, strftime("%c"))
  7437. < When {text} is a |List| then line {lnum} and following lines
  7438. will be set to the items in the list. Example: >vim
  7439. call setline(5, ['aaa', 'bbb', 'ccc'])
  7440. < This is equivalent to: >vim
  7441. for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
  7442. call setline(n, l)
  7443. endfor
  7444. < Note: The '[ and '] marks are not set.
  7445. Parameters: ~
  7446. • {lnum} (`integer`)
  7447. • {text} (`any`)
  7448. Return: ~
  7449. (`any`)
  7450. setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
  7451. Create or replace or add to the location list for window {nr}.
  7452. {nr} can be the window number or the |window-ID|.
  7453. When {nr} is zero the current window is used.
  7454. For a location list window, the displayed location list is
  7455. modified. For an invalid window number {nr}, -1 is returned.
  7456. Otherwise, same as |setqflist()|.
  7457. Also see |location-list|.
  7458. For {action} see |setqflist-action|.
  7459. If the optional {what} dictionary argument is supplied, then
  7460. only the items listed in {what} are set. Refer to |setqflist()|
  7461. for the list of supported keys in {what}.
  7462. Parameters: ~
  7463. • {nr} (`integer`)
  7464. • {list} (`any`)
  7465. • {action} (`string?`)
  7466. • {what} (`table?`)
  7467. Return: ~
  7468. (`any`)
  7469. setmatches({list} [, {win}]) *setmatches()*
  7470. Restores a list of matches saved by |getmatches()| for the
  7471. current window. Returns 0 if successful, otherwise -1. All
  7472. current matches are cleared before the list is restored. See
  7473. example for |getmatches()|.
  7474. If {win} is specified, use the window with this number or
  7475. window ID instead of the current window.
  7476. Parameters: ~
  7477. • {list} (`any`)
  7478. • {win} (`integer?`)
  7479. Return: ~
  7480. (`any`)
  7481. setpos({expr}, {list}) *setpos()*
  7482. Set the position for String {expr}. Possible values:
  7483. . the cursor
  7484. 'x mark x
  7485. {list} must be a |List| with four or five numbers:
  7486. [bufnum, lnum, col, off]
  7487. [bufnum, lnum, col, off, curswant]
  7488. "bufnum" is the buffer number. Zero can be used for the
  7489. current buffer. When setting an uppercase mark "bufnum" is
  7490. used for the mark position. For other marks it specifies the
  7491. buffer to set the mark in. You can use the |bufnr()| function
  7492. to turn a file name into a buffer number.
  7493. For setting the cursor and the ' mark "bufnum" is ignored,
  7494. since these are associated with a window, not a buffer.
  7495. Does not change the jumplist.
  7496. "lnum" and "col" are the position in the buffer. The first
  7497. column is 1. Use a zero "lnum" to delete a mark. If "col" is
  7498. smaller than 1 then 1 is used. To use the character count
  7499. instead of the byte count, use |setcharpos()|.
  7500. The "off" number is only used when 'virtualedit' is set. Then
  7501. it is the offset in screen columns from the start of the
  7502. character. E.g., a position within a <Tab> or after the last
  7503. character.
  7504. The "curswant" number is only used when setting the cursor
  7505. position. It sets the preferred column for when moving the
  7506. cursor vertically. When the "curswant" number is missing the
  7507. preferred column is not set. When it is present and setting a
  7508. mark position it is not used.
  7509. Note that for '< and '> changing the line number may result in
  7510. the marks to be effectively be swapped, so that '< is always
  7511. before '>.
  7512. Returns 0 when the position could be set, -1 otherwise.
  7513. An error message is given if {expr} is invalid.
  7514. Also see |setcharpos()|, |getpos()| and |getcurpos()|.
  7515. This does not restore the preferred column for moving
  7516. vertically; if you set the cursor position with this, |j| and
  7517. |k| motions will jump to previous columns! Use |cursor()| to
  7518. also set the preferred column. Also see the "curswant" key in
  7519. |winrestview()|.
  7520. Parameters: ~
  7521. • {expr} (`string`)
  7522. • {list} (`integer[]`)
  7523. Return: ~
  7524. (`any`)
  7525. setqflist({list} [, {action} [, {what}]]) *setqflist()*
  7526. Create or replace or add to the quickfix list.
  7527. If the optional {what} dictionary argument is supplied, then
  7528. only the items listed in {what} are set. The first {list}
  7529. argument is ignored. See below for the supported items in
  7530. {what}.
  7531. *setqflist-what*
  7532. When {what} is not present, the items in {list} are used. Each
  7533. item must be a dictionary. Non-dictionary items in {list} are
  7534. ignored. Each dictionary item can contain the following
  7535. entries:
  7536. bufnr buffer number; must be the number of a valid
  7537. buffer
  7538. filename name of a file; only used when "bufnr" is not
  7539. present or it is invalid.
  7540. module name of a module; if given it will be used in
  7541. quickfix error window instead of the filename.
  7542. lnum line number in the file
  7543. end_lnum end of lines, if the item spans multiple lines
  7544. pattern search pattern used to locate the error
  7545. col column number
  7546. vcol when non-zero: "col" is visual column
  7547. when zero: "col" is byte index
  7548. end_col end column, if the item spans multiple columns
  7549. nr error number
  7550. text description of the error
  7551. type single-character error type, 'E', 'W', etc.
  7552. valid recognized error message
  7553. user_data
  7554. custom data associated with the item, can be
  7555. any type.
  7556. The "col", "vcol", "nr", "type" and "text" entries are
  7557. optional. Either "lnum" or "pattern" entry can be used to
  7558. locate a matching error line.
  7559. If the "filename" and "bufnr" entries are not present or
  7560. neither the "lnum" or "pattern" entries are present, then the
  7561. item will not be handled as an error line.
  7562. If both "pattern" and "lnum" are present then "pattern" will
  7563. be used.
  7564. If the "valid" entry is not supplied, then the valid flag is
  7565. set when "bufnr" is a valid buffer or "filename" exists.
  7566. If you supply an empty {list}, the quickfix list will be
  7567. cleared.
  7568. Note that the list is not exactly the same as what
  7569. |getqflist()| returns.
  7570. {action} values: *setqflist-action* *E927*
  7571. 'a' The items from {list} are added to the existing
  7572. quickfix list. If there is no existing list, then a
  7573. new list is created.
  7574. 'r' The items from the current quickfix list are replaced
  7575. with the items from {list}. This can also be used to
  7576. clear the list: >vim
  7577. call setqflist([], 'r')
  7578. <
  7579. 'u' Like 'r', but tries to preserve the current selection
  7580. in the quickfix list.
  7581. 'f' All the quickfix lists in the quickfix stack are
  7582. freed.
  7583. If {action} is not present or is set to ' ', then a new list
  7584. is created. The new quickfix list is added after the current
  7585. quickfix list in the stack and all the following lists are
  7586. freed. To add a new quickfix list at the end of the stack,
  7587. set "nr" in {what} to "$".
  7588. The following items can be specified in dictionary {what}:
  7589. context quickfix list context. See |quickfix-context|
  7590. efm errorformat to use when parsing text from
  7591. "lines". If this is not present, then the
  7592. 'errorformat' option value is used.
  7593. See |quickfix-parse|
  7594. id quickfix list identifier |quickfix-ID|
  7595. idx index of the current entry in the quickfix
  7596. list specified by "id" or "nr". If set to '$',
  7597. then the last entry in the list is set as the
  7598. current entry. See |quickfix-index|
  7599. items list of quickfix entries. Same as the {list}
  7600. argument.
  7601. lines use 'errorformat' to parse a list of lines and
  7602. add the resulting entries to the quickfix list
  7603. {nr} or {id}. Only a |List| value is supported.
  7604. See |quickfix-parse|
  7605. nr list number in the quickfix stack; zero
  7606. means the current quickfix list and "$" means
  7607. the last quickfix list.
  7608. quickfixtextfunc
  7609. function to get the text to display in the
  7610. quickfix window. The value can be the name of
  7611. a function or a funcref or a lambda. Refer to
  7612. |quickfix-window-function| for an explanation
  7613. of how to write the function and an example.
  7614. title quickfix list title text. See |quickfix-title|
  7615. Unsupported keys in {what} are ignored.
  7616. If the "nr" item is not present, then the current quickfix list
  7617. is modified. When creating a new quickfix list, "nr" can be
  7618. set to a value one greater than the quickfix stack size.
  7619. When modifying a quickfix list, to guarantee that the correct
  7620. list is modified, "id" should be used instead of "nr" to
  7621. specify the list.
  7622. Examples (See also |setqflist-examples|): >vim
  7623. call setqflist([], 'r', {'title': 'My search'})
  7624. call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
  7625. call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
  7626. <
  7627. Returns zero for success, -1 for failure.
  7628. This function can be used to create a quickfix list
  7629. independent of the 'errorformat' setting. Use a command like
  7630. `:cc 1` to jump to the first position.
  7631. Parameters: ~
  7632. • {list} (`vim.quickfix.entry[]`)
  7633. • {action} (`string?`)
  7634. • {what} (`vim.fn.setqflist.what?`)
  7635. Return: ~
  7636. (`integer`)
  7637. setreg({regname}, {value} [, {options}]) *setreg()*
  7638. Set the register {regname} to {value}.
  7639. If {regname} is "" or "@", the unnamed register '"' is used.
  7640. The {regname} argument is a string.
  7641. {value} may be any value returned by |getreg()| or
  7642. |getreginfo()|, including a |List| or |Dict|.
  7643. If {options} contains "a" or {regname} is upper case,
  7644. then the value is appended.
  7645. {options} can also contain a register type specification:
  7646. "c" or "v" |charwise| mode
  7647. "l" or "V" |linewise| mode
  7648. "b" or "<CTRL-V>" |blockwise-visual| mode
  7649. If a number immediately follows "b" or "<CTRL-V>" then this is
  7650. used as the width of the selection - if it is not specified
  7651. then the width of the block is set to the number of characters
  7652. in the longest line (counting a <Tab> as 1 character).
  7653. If {options} contains "u" or '"', then the unnamed register is
  7654. set to point to register {regname}.
  7655. If {options} contains no register settings, then the default
  7656. is to use character mode unless {value} ends in a <NL> for
  7657. string {value} and linewise mode for list {value}. Blockwise
  7658. mode is never selected automatically.
  7659. Returns zero for success, non-zero for failure.
  7660. *E883*
  7661. Note: you may not use |List| containing more than one item to
  7662. set search and expression registers. Lists containing no
  7663. items act like empty strings.
  7664. Examples: >vim
  7665. call setreg(v:register, @*)
  7666. call setreg('*', @%, 'ac')
  7667. call setreg('a', "1\n2\n3", 'b5')
  7668. call setreg('"', { 'points_to': 'a'})
  7669. < This example shows using the functions to save and restore a
  7670. register: >vim
  7671. let var_a = getreginfo()
  7672. call setreg('a', var_a)
  7673. < or: >vim
  7674. let var_a = getreg('a', 1, 1)
  7675. let var_amode = getregtype('a')
  7676. " ....
  7677. call setreg('a', var_a, var_amode)
  7678. < Note: you may not reliably restore register value
  7679. without using the third argument to |getreg()| as without it
  7680. newlines are represented as newlines AND Nul bytes are
  7681. represented as newlines as well, see |NL-used-for-Nul|.
  7682. You can also change the type of a register by appending
  7683. nothing: >vim
  7684. call setreg('a', '', 'al')
  7685. Parameters: ~
  7686. • {regname} (`string`)
  7687. • {value} (`any`)
  7688. • {options} (`string?`)
  7689. Return: ~
  7690. (`any`)
  7691. settabvar({tabnr}, {varname}, {val}) *settabvar()*
  7692. Set tab-local variable {varname} to {val} in tab page {tabnr}.
  7693. |t:var|
  7694. The {varname} argument is a string.
  7695. Note that the variable name without "t:" must be used.
  7696. Tabs are numbered starting with one.
  7697. This function is not available in the |sandbox|.
  7698. Parameters: ~
  7699. • {tabnr} (`integer`)
  7700. • {varname} (`string`)
  7701. • {val} (`any`)
  7702. Return: ~
  7703. (`any`)
  7704. settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
  7705. Set option or local variable {varname} in window {winnr} to
  7706. {val}.
  7707. Tabs are numbered starting with one. For the current tabpage
  7708. use |setwinvar()|.
  7709. {winnr} can be the window number or the |window-ID|.
  7710. When {winnr} is zero the current window is used.
  7711. This also works for a global or local buffer option, but it
  7712. doesn't work for a global or local buffer variable.
  7713. For a local buffer option the global value is unchanged.
  7714. Note that the variable name without "w:" must be used.
  7715. Examples: >vim
  7716. call settabwinvar(1, 1, "&list", 0)
  7717. call settabwinvar(3, 2, "myvar", "foobar")
  7718. < This function is not available in the |sandbox|.
  7719. Parameters: ~
  7720. • {tabnr} (`integer`)
  7721. • {winnr} (`integer`)
  7722. • {varname} (`string`)
  7723. • {val} (`any`)
  7724. Return: ~
  7725. (`any`)
  7726. settagstack({nr}, {dict} [, {action}]) *settagstack()*
  7727. Modify the tag stack of the window {nr} using {dict}.
  7728. {nr} can be the window number or the |window-ID|.
  7729. For a list of supported items in {dict}, refer to
  7730. |gettagstack()|. "curidx" takes effect before changing the tag
  7731. stack.
  7732. *E962*
  7733. How the tag stack is modified depends on the {action}
  7734. argument:
  7735. - If {action} is not present or is set to 'r', then the tag
  7736. stack is replaced.
  7737. - If {action} is set to 'a', then new entries from {dict} are
  7738. pushed (added) onto the tag stack.
  7739. - If {action} is set to 't', then all the entries from the
  7740. current entry in the tag stack or "curidx" in {dict} are
  7741. removed and then new entries are pushed to the stack.
  7742. The current index is set to one after the length of the tag
  7743. stack after the modification.
  7744. Returns zero for success, -1 for failure.
  7745. Examples (for more examples see |tagstack-examples|):
  7746. Empty the tag stack of window 3: >vim
  7747. call settagstack(3, {'items' : []})
  7748. < Save and restore the tag stack: >vim
  7749. let stack = gettagstack(1003)
  7750. " do something else
  7751. call settagstack(1003, stack)
  7752. unlet stack
  7753. <
  7754. Parameters: ~
  7755. • {nr} (`integer`)
  7756. • {dict} (`any`)
  7757. • {action} (`string?`)
  7758. Return: ~
  7759. (`any`)
  7760. setwinvar({nr}, {varname}, {val}) *setwinvar()*
  7761. Like |settabwinvar()| for the current tab page.
  7762. Examples: >vim
  7763. call setwinvar(1, "&list", 0)
  7764. call setwinvar(2, "myvar", "foobar")
  7765. Parameters: ~
  7766. • {nr} (`integer`)
  7767. • {varname} (`string`)
  7768. • {val} (`any`)
  7769. Return: ~
  7770. (`any`)
  7771. sha256({string}) *sha256()*
  7772. Returns a String with 64 hex characters, which is the SHA256
  7773. checksum of {string}.
  7774. Parameters: ~
  7775. • {string} (`string`)
  7776. Return: ~
  7777. (`string`)
  7778. shellescape({string} [, {special}]) *shellescape()*
  7779. Escape {string} for use as a shell command argument.
  7780. On Windows when 'shellslash' is not set, encloses {string} in
  7781. double-quotes and doubles all double-quotes within {string}.
  7782. Otherwise encloses {string} in single-quotes and replaces all
  7783. "'" with "'\''".
  7784. The {special} argument adds additional escaping of keywords
  7785. used in Vim commands. If it is a |non-zero-arg|:
  7786. - Special items such as "!", "%", "#" and "<cword>" (as listed
  7787. in |expand()|) will be preceded by a backslash.
  7788. The backslash will be removed again by the |:!| command.
  7789. - The <NL> character is escaped.
  7790. If 'shell' contains "csh" in the tail:
  7791. - The "!" character will be escaped. This is because csh and
  7792. tcsh use "!" for history replacement even in single-quotes.
  7793. - The <NL> character is escaped (twice if {special} is
  7794. a |non-zero-arg|).
  7795. If 'shell' contains "fish" in the tail, the "\" character will
  7796. be escaped because in fish it is used as an escape character
  7797. inside single quotes.
  7798. Example of use with a |:!| command: >vim
  7799. exe '!dir ' .. shellescape(expand('<cfile>'), 1)
  7800. < This results in a directory listing for the file under the
  7801. cursor. Example of use with |system()|: >vim
  7802. call system("chmod +w -- " .. shellescape(expand("%")))
  7803. < See also |::S|.
  7804. Parameters: ~
  7805. • {string} (`string`)
  7806. • {special} (`boolean?`)
  7807. Return: ~
  7808. (`string`)
  7809. shiftwidth([{col}]) *shiftwidth()*
  7810. Returns the effective value of 'shiftwidth'. This is the
  7811. 'shiftwidth' value unless it is zero, in which case it is the
  7812. 'tabstop' value. To be backwards compatible in indent
  7813. plugins, use this: >vim
  7814. if exists('*shiftwidth')
  7815. func s:sw()
  7816. return shiftwidth()
  7817. endfunc
  7818. else
  7819. func s:sw()
  7820. return &sw
  7821. endfunc
  7822. endif
  7823. < And then use s:sw() instead of &sw.
  7824. When there is one argument {col} this is used as column number
  7825. for which to return the 'shiftwidth' value. This matters for the
  7826. 'vartabstop' feature. If no {col} argument is given, column 1
  7827. will be assumed.
  7828. Parameters: ~
  7829. • {col} (`integer?`)
  7830. Return: ~
  7831. (`integer`)
  7832. sign_define({name} [, {dict}]) *sign_define()*
  7833. sign_define({list})
  7834. Define a new sign named {name} or modify the attributes of an
  7835. existing sign. This is similar to the |:sign-define| command.
  7836. Prefix {name} with a unique text to avoid name collisions.
  7837. There is no {group} like with placing signs.
  7838. The {name} can be a String or a Number. The optional {dict}
  7839. argument specifies the sign attributes. The following values
  7840. are supported:
  7841. icon full path to the bitmap file for the sign.
  7842. linehl highlight group used for the whole line the
  7843. sign is placed in.
  7844. priority default priority value of the sign
  7845. numhl highlight group used for the line number where
  7846. the sign is placed.
  7847. text text that is displayed when there is no icon
  7848. or the GUI is not being used.
  7849. texthl highlight group used for the text item
  7850. culhl highlight group used for the text item when
  7851. the cursor is on the same line as the sign and
  7852. 'cursorline' is enabled.
  7853. If the sign named {name} already exists, then the attributes
  7854. of the sign are updated.
  7855. The one argument {list} can be used to define a list of signs.
  7856. Each list item is a dictionary with the above items in {dict}
  7857. and a "name" item for the sign name.
  7858. Returns 0 on success and -1 on failure. When the one argument
  7859. {list} is used, then returns a List of values one for each
  7860. defined sign.
  7861. Examples: >vim
  7862. call sign_define("mySign", {
  7863. \ "text" : "=>",
  7864. \ "texthl" : "Error",
  7865. \ "linehl" : "Search"})
  7866. call sign_define([
  7867. \ {'name' : 'sign1',
  7868. \ 'text' : '=>'},
  7869. \ {'name' : 'sign2',
  7870. \ 'text' : '!!'}
  7871. \ ])
  7872. <
  7873. Parameters: ~
  7874. • {list} (`vim.fn.sign_define.dict[]`)
  7875. Return: ~
  7876. (`(0|-1)[]`)
  7877. sign_getdefined([{name}]) *sign_getdefined()*
  7878. Get a list of defined signs and their attributes.
  7879. This is similar to the |:sign-list| command.
  7880. If the {name} is not supplied, then a list of all the defined
  7881. signs is returned. Otherwise the attribute of the specified
  7882. sign is returned.
  7883. Each list item in the returned value is a dictionary with the
  7884. following entries:
  7885. icon full path to the bitmap file of the sign
  7886. linehl highlight group used for the whole line the
  7887. sign is placed in; not present if not set.
  7888. name name of the sign
  7889. priority default priority value of the sign
  7890. numhl highlight group used for the line number where
  7891. the sign is placed; not present if not set.
  7892. text text that is displayed when there is no icon
  7893. or the GUI is not being used.
  7894. texthl highlight group used for the text item; not
  7895. present if not set.
  7896. culhl highlight group used for the text item when
  7897. the cursor is on the same line as the sign and
  7898. 'cursorline' is enabled; not present if not
  7899. set.
  7900. Returns an empty List if there are no signs and when {name} is
  7901. not found.
  7902. Examples: >vim
  7903. " Get a list of all the defined signs
  7904. echo sign_getdefined()
  7905. " Get the attribute of the sign named mySign
  7906. echo sign_getdefined("mySign")
  7907. <
  7908. Parameters: ~
  7909. • {name} (`string?`)
  7910. Return: ~
  7911. (`vim.fn.sign_getdefined.ret.item[]`)
  7912. sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
  7913. Return a list of signs placed in a buffer or all the buffers.
  7914. This is similar to the |:sign-place-list| command.
  7915. If the optional buffer name {buf} is specified, then only the
  7916. list of signs placed in that buffer is returned. For the use
  7917. of {buf}, see |bufname()|. The optional {dict} can contain
  7918. the following entries:
  7919. group select only signs in this group
  7920. id select sign with this identifier
  7921. lnum select signs placed in this line. For the use
  7922. of {lnum}, see |line()|.
  7923. If {group} is "*", then signs in all the groups including the
  7924. global group are returned. If {group} is not supplied or is an
  7925. empty string, then only signs in the global group are
  7926. returned. If no arguments are supplied, then signs in the
  7927. global group placed in all the buffers are returned.
  7928. See |sign-group|.
  7929. Each list item in the returned value is a dictionary with the
  7930. following entries:
  7931. bufnr number of the buffer with the sign
  7932. signs list of signs placed in {bufnr}. Each list
  7933. item is a dictionary with the below listed
  7934. entries
  7935. The dictionary for each sign contains the following entries:
  7936. group sign group. Set to '' for the global group.
  7937. id identifier of the sign
  7938. lnum line number where the sign is placed
  7939. name name of the defined sign
  7940. priority sign priority
  7941. The returned signs in a buffer are ordered by their line
  7942. number and priority.
  7943. Returns an empty list on failure or if there are no placed
  7944. signs.
  7945. Examples: >vim
  7946. " Get a List of signs placed in eval.c in the
  7947. " global group
  7948. echo sign_getplaced("eval.c")
  7949. " Get a List of signs in group 'g1' placed in eval.c
  7950. echo sign_getplaced("eval.c", {'group' : 'g1'})
  7951. " Get a List of signs placed at line 10 in eval.c
  7952. echo sign_getplaced("eval.c", {'lnum' : 10})
  7953. " Get sign with identifier 10 placed in a.py
  7954. echo sign_getplaced("a.py", {'id' : 10})
  7955. " Get sign with id 20 in group 'g1' placed in a.py
  7956. echo sign_getplaced("a.py", {'group' : 'g1',
  7957. \ 'id' : 20})
  7958. " Get a List of all the placed signs
  7959. echo sign_getplaced()
  7960. <
  7961. Parameters: ~
  7962. • {buf} (`integer|string?`)
  7963. • {dict} (`vim.fn.sign_getplaced.dict?`)
  7964. Return: ~
  7965. (`vim.fn.sign_getplaced.ret.item[]`)
  7966. sign_jump({id}, {group}, {buf}) *sign_jump()*
  7967. Open the buffer {buf} or jump to the window that contains
  7968. {buf} and position the cursor at sign {id} in group {group}.
  7969. This is similar to the |:sign-jump| command.
  7970. If {group} is an empty string, then the global group is used.
  7971. For the use of {buf}, see |bufname()|.
  7972. Returns the line number of the sign. Returns -1 if the
  7973. arguments are invalid.
  7974. Example: >vim
  7975. " Jump to sign 10 in the current buffer
  7976. call sign_jump(10, '', '')
  7977. <
  7978. Parameters: ~
  7979. • {id} (`integer`)
  7980. • {group} (`string`)
  7981. • {buf} (`integer|string`)
  7982. Return: ~
  7983. (`integer`)
  7984. sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()*
  7985. Place the sign defined as {name} at line {lnum} in file or
  7986. buffer {buf} and assign {id} and {group} to sign. This is
  7987. similar to the |:sign-place| command.
  7988. If the sign identifier {id} is zero, then a new identifier is
  7989. allocated. Otherwise the specified number is used. {group} is
  7990. the sign group name. To use the global sign group, use an
  7991. empty string. {group} functions as a namespace for {id}, thus
  7992. two groups can use the same IDs. Refer to |sign-identifier|
  7993. and |sign-group| for more information.
  7994. {name} refers to a defined sign.
  7995. {buf} refers to a buffer name or number. For the accepted
  7996. values, see |bufname()|.
  7997. The optional {dict} argument supports the following entries:
  7998. lnum line number in the file or buffer
  7999. {buf} where the sign is to be placed.
  8000. For the accepted values, see |line()|.
  8001. priority priority of the sign. See
  8002. |sign-priority| for more information.
  8003. If the optional {dict} is not specified, then it modifies the
  8004. placed sign {id} in group {group} to use the defined sign
  8005. {name}.
  8006. Returns the sign identifier on success and -1 on failure.
  8007. Examples: >vim
  8008. " Place a sign named sign1 with id 5 at line 20 in
  8009. " buffer json.c
  8010. call sign_place(5, '', 'sign1', 'json.c',
  8011. \ {'lnum' : 20})
  8012. " Updates sign 5 in buffer json.c to use sign2
  8013. call sign_place(5, '', 'sign2', 'json.c')
  8014. " Place a sign named sign3 at line 30 in
  8015. " buffer json.c with a new identifier
  8016. let id = sign_place(0, '', 'sign3', 'json.c',
  8017. \ {'lnum' : 30})
  8018. " Place a sign named sign4 with id 10 in group 'g3'
  8019. " at line 40 in buffer json.c with priority 90
  8020. call sign_place(10, 'g3', 'sign4', 'json.c',
  8021. \ {'lnum' : 40, 'priority' : 90})
  8022. <
  8023. Parameters: ~
  8024. • {id} (`integer`)
  8025. • {group} (`string`)
  8026. • {name} (`string`)
  8027. • {buf} (`integer|string`)
  8028. • {dict} (`vim.fn.sign_place.dict?`)
  8029. Return: ~
  8030. (`integer`)
  8031. sign_placelist({list}) *sign_placelist()*
  8032. Place one or more signs. This is similar to the
  8033. |sign_place()| function. The {list} argument specifies the
  8034. List of signs to place. Each list item is a dict with the
  8035. following sign attributes:
  8036. buffer Buffer name or number. For the accepted
  8037. values, see |bufname()|.
  8038. group Sign group. {group} functions as a namespace
  8039. for {id}, thus two groups can use the same
  8040. IDs. If not specified or set to an empty
  8041. string, then the global group is used. See
  8042. |sign-group| for more information.
  8043. id Sign identifier. If not specified or zero,
  8044. then a new unique identifier is allocated.
  8045. Otherwise the specified number is used. See
  8046. |sign-identifier| for more information.
  8047. lnum Line number in the buffer where the sign is to
  8048. be placed. For the accepted values, see
  8049. |line()|.
  8050. name Name of the sign to place. See |sign_define()|
  8051. for more information.
  8052. priority Priority of the sign. When multiple signs are
  8053. placed on a line, the sign with the highest
  8054. priority is used. If not specified, the
  8055. default value of 10 is used, unless specified
  8056. otherwise by the sign definition. See
  8057. |sign-priority| for more information.
  8058. If {id} refers to an existing sign, then the existing sign is
  8059. modified to use the specified {name} and/or {priority}.
  8060. Returns a List of sign identifiers. If failed to place a
  8061. sign, the corresponding list item is set to -1.
  8062. Examples: >vim
  8063. " Place sign s1 with id 5 at line 20 and id 10 at line
  8064. " 30 in buffer a.c
  8065. let [n1, n2] = sign_placelist([
  8066. \ {'id' : 5,
  8067. \ 'name' : 's1',
  8068. \ 'buffer' : 'a.c',
  8069. \ 'lnum' : 20},
  8070. \ {'id' : 10,
  8071. \ 'name' : 's1',
  8072. \ 'buffer' : 'a.c',
  8073. \ 'lnum' : 30}
  8074. \ ])
  8075. " Place sign s1 in buffer a.c at line 40 and 50
  8076. " with auto-generated identifiers
  8077. let [n1, n2] = sign_placelist([
  8078. \ {'name' : 's1',
  8079. \ 'buffer' : 'a.c',
  8080. \ 'lnum' : 40},
  8081. \ {'name' : 's1',
  8082. \ 'buffer' : 'a.c',
  8083. \ 'lnum' : 50}
  8084. \ ])
  8085. <
  8086. Parameters: ~
  8087. • {list} (`vim.fn.sign_placelist.list.item[]`)
  8088. Return: ~
  8089. (`integer[]`)
  8090. sign_undefine([{name}]) *sign_undefine()*
  8091. sign_undefine({list})
  8092. Deletes a previously defined sign {name}. This is similar to
  8093. the |:sign-undefine| command. If {name} is not supplied, then
  8094. deletes all the defined signs.
  8095. The one argument {list} can be used to undefine a list of
  8096. signs. Each list item is the name of a sign.
  8097. Returns 0 on success and -1 on failure. For the one argument
  8098. {list} call, returns a list of values one for each undefined
  8099. sign.
  8100. Examples: >vim
  8101. " Delete a sign named mySign
  8102. call sign_undefine("mySign")
  8103. " Delete signs 'sign1' and 'sign2'
  8104. call sign_undefine(["sign1", "sign2"])
  8105. " Delete all the signs
  8106. call sign_undefine()
  8107. <
  8108. Parameters: ~
  8109. • {list} (`string[]?`)
  8110. Return: ~
  8111. (`integer[]`)
  8112. sign_unplace({group} [, {dict}]) *sign_unplace()*
  8113. Remove a previously placed sign in one or more buffers. This
  8114. is similar to the |:sign-unplace| command.
  8115. {group} is the sign group name. To use the global sign group,
  8116. use an empty string. If {group} is set to "*", then all the
  8117. groups including the global group are used.
  8118. The signs in {group} are selected based on the entries in
  8119. {dict}. The following optional entries in {dict} are
  8120. supported:
  8121. buffer buffer name or number. See |bufname()|.
  8122. id sign identifier
  8123. If {dict} is not supplied, then all the signs in {group} are
  8124. removed.
  8125. Returns 0 on success and -1 on failure.
  8126. Examples: >vim
  8127. " Remove sign 10 from buffer a.vim
  8128. call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
  8129. " Remove sign 20 in group 'g1' from buffer 3
  8130. call sign_unplace('g1', {'buffer' : 3, 'id' : 20})
  8131. " Remove all the signs in group 'g2' from buffer 10
  8132. call sign_unplace('g2', {'buffer' : 10})
  8133. " Remove sign 30 in group 'g3' from all the buffers
  8134. call sign_unplace('g3', {'id' : 30})
  8135. " Remove all the signs placed in buffer 5
  8136. call sign_unplace('*', {'buffer' : 5})
  8137. " Remove the signs in group 'g4' from all the buffers
  8138. call sign_unplace('g4')
  8139. " Remove sign 40 from all the buffers
  8140. call sign_unplace('*', {'id' : 40})
  8141. " Remove all the placed signs from all the buffers
  8142. call sign_unplace('*')
  8143. Parameters: ~
  8144. • {group} (`string`)
  8145. • {dict} (`vim.fn.sign_unplace.dict?`)
  8146. Return: ~
  8147. (`0|-1`)
  8148. sign_unplacelist({list}) *sign_unplacelist()*
  8149. Remove previously placed signs from one or more buffers. This
  8150. is similar to the |sign_unplace()| function.
  8151. The {list} argument specifies the List of signs to remove.
  8152. Each list item is a dict with the following sign attributes:
  8153. buffer buffer name or number. For the accepted
  8154. values, see |bufname()|. If not specified,
  8155. then the specified sign is removed from all
  8156. the buffers.
  8157. group sign group name. If not specified or set to an
  8158. empty string, then the global sign group is
  8159. used. If set to "*", then all the groups
  8160. including the global group are used.
  8161. id sign identifier. If not specified, then all
  8162. the signs in the specified group are removed.
  8163. Returns a List where an entry is set to 0 if the corresponding
  8164. sign was successfully removed or -1 on failure.
  8165. Example: >vim
  8166. " Remove sign with id 10 from buffer a.vim and sign
  8167. " with id 20 from buffer b.vim
  8168. call sign_unplacelist([
  8169. \ {'id' : 10, 'buffer' : "a.vim"},
  8170. \ {'id' : 20, 'buffer' : 'b.vim'},
  8171. \ ])
  8172. <
  8173. Parameters: ~
  8174. • {list} (`vim.fn.sign_unplacelist.list.item`)
  8175. Return: ~
  8176. (`(0|-1)[]`)
  8177. simplify({filename}) *simplify()*
  8178. Simplify the file name as much as possible without changing
  8179. the meaning. Shortcuts (on MS-Windows) or symbolic links (on
  8180. Unix) are not resolved. If the first path component in
  8181. {filename} designates the current directory, this will be
  8182. valid for the result as well. A trailing path separator is
  8183. not removed either. On Unix "//path" is unchanged, but
  8184. "///path" is simplified to "/path" (this follows the Posix
  8185. standard).
  8186. Example: >vim
  8187. simplify("./dir/.././/file/") == "./file/"
  8188. < Note: The combination "dir/.." is only removed if "dir" is
  8189. a searchable directory or does not exist. On Unix, it is also
  8190. removed when "dir" is a symbolic link within the same
  8191. directory. In order to resolve all the involved symbolic
  8192. links before simplifying the path name, use |resolve()|.
  8193. Parameters: ~
  8194. • {filename} (`string`)
  8195. Return: ~
  8196. (`string`)
  8197. sin({expr}) *sin()*
  8198. Return the sine of {expr}, measured in radians, as a |Float|.
  8199. {expr} must evaluate to a |Float| or a |Number|.
  8200. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8201. Examples: >vim
  8202. echo sin(100)
  8203. < -0.506366 >vim
  8204. echo sin(-4.01)
  8205. < 0.763301
  8206. Parameters: ~
  8207. • {expr} (`number`)
  8208. Return: ~
  8209. (`number`)
  8210. sinh({expr}) *sinh()*
  8211. Return the hyperbolic sine of {expr} as a |Float| in the range
  8212. [-inf, inf].
  8213. {expr} must evaluate to a |Float| or a |Number|.
  8214. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8215. Examples: >vim
  8216. echo sinh(0.5)
  8217. < 0.521095 >vim
  8218. echo sinh(-0.9)
  8219. < -1.026517
  8220. Parameters: ~
  8221. • {expr} (`number`)
  8222. Return: ~
  8223. (`any`)
  8224. slice({expr}, {start} [, {end}]) *slice()*
  8225. Similar to using a |slice| "expr[start : end]", but "end" is
  8226. used exclusive. And for a string the indexes are used as
  8227. character indexes instead of byte indexes.
  8228. Also, composing characters are treated as a part of the
  8229. preceding base character.
  8230. When {end} is omitted the slice continues to the last item.
  8231. When {end} is -1 the last item is omitted.
  8232. Returns an empty value if {start} or {end} are invalid.
  8233. Parameters: ~
  8234. • {expr} (`any`)
  8235. • {start} (`integer`)
  8236. • {end} (`integer?`)
  8237. Return: ~
  8238. (`any`)
  8239. sockconnect({mode}, {address} [, {opts}]) *sockconnect()*
  8240. Connect a socket to an address. If {mode} is "pipe" then
  8241. {address} should be the path of a local domain socket (on
  8242. unix) or named pipe (on Windows). If {mode} is "tcp" then
  8243. {address} should be of the form "host:port" where the host
  8244. should be an ip address or host name, and port the port
  8245. number.
  8246. For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see
  8247. |luv-tcp-handle|.
  8248. Returns a |channel| ID. Close the socket with |chanclose()|.
  8249. Use |chansend()| to send data over a bytes socket, and
  8250. |rpcrequest()| and |rpcnotify()| to communicate with a RPC
  8251. socket.
  8252. {opts} is an optional dictionary with these keys:
  8253. |on_data| : callback invoked when data was read from socket
  8254. data_buffered : read socket data in |channel-buffered| mode.
  8255. rpc : If set, |msgpack-rpc| will be used to communicate
  8256. over the socket.
  8257. Returns:
  8258. - The channel ID on success (greater than zero)
  8259. - 0 on invalid arguments or connection failure.
  8260. Parameters: ~
  8261. • {mode} (`string`)
  8262. • {address} (`string`)
  8263. • {opts} (`table?`)
  8264. Return: ~
  8265. (`any`)
  8266. sort({list} [, {how} [, {dict}]]) *sort()* *E702*
  8267. Sort the items in {list} in-place. Returns {list}.
  8268. If you want a list to remain unmodified make a copy first: >vim
  8269. let sortedlist = sort(copy(mylist))
  8270. < When {how} is omitted or is a string, then sort() uses the
  8271. string representation of each item to sort on. Numbers sort
  8272. after Strings, |Lists| after Numbers. For sorting text in the
  8273. current buffer use |:sort|.
  8274. When {how} is given and it is 'i' then case is ignored.
  8275. For backwards compatibility, the value one can be used to
  8276. ignore case. Zero means to not ignore case.
  8277. When {how} is given and it is 'l' then the current collation
  8278. locale is used for ordering. Implementation details: strcoll()
  8279. is used to compare strings. See |:language| check or set the
  8280. collation locale. |v:collate| can also be used to check the
  8281. current locale. Sorting using the locale typically ignores
  8282. case. Example: >vim
  8283. " ö is sorted similarly to o with English locale.
  8284. language collate en_US.UTF8
  8285. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8286. < ['n', 'o', 'O', 'ö', 'p', 'z'] ~
  8287. >vim
  8288. " ö is sorted after z with Swedish locale.
  8289. language collate sv_SE.UTF8
  8290. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8291. < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
  8292. This does not work properly on Mac.
  8293. When {how} is given and it is 'n' then all items will be
  8294. sorted numerical (Implementation detail: this uses the
  8295. strtod() function to parse numbers, Strings, Lists, Dicts and
  8296. Funcrefs will be considered as being 0).
  8297. When {how} is given and it is 'N' then all items will be
  8298. sorted numerical. This is like 'n' but a string containing
  8299. digits will be used as the number they represent.
  8300. When {how} is given and it is 'f' then all items will be
  8301. sorted numerical. All values must be a Number or a Float.
  8302. When {how} is a |Funcref| or a function name, this function
  8303. is called to compare items. The function is invoked with two
  8304. items as argument and must return zero if they are equal, 1 or
  8305. bigger if the first one sorts after the second one, -1 or
  8306. smaller if the first one sorts before the second one.
  8307. {dict} is for functions with the "dict" attribute. It will be
  8308. used to set the local variable "self". |Dictionary-function|
  8309. The sort is stable, items which compare equal (as number or as
  8310. string) will keep their relative position. E.g., when sorting
  8311. on numbers, text strings will sort next to each other, in the
  8312. same order as they were originally.
  8313. Example: >vim
  8314. func MyCompare(i1, i2)
  8315. return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
  8316. endfunc
  8317. eval mylist->sort("MyCompare")
  8318. < A shorter compare version for this specific simple case, which
  8319. ignores overflow: >vim
  8320. func MyCompare(i1, i2)
  8321. return a:i1 - a:i2
  8322. endfunc
  8323. < For a simple expression you can use a lambda: >vim
  8324. eval mylist->sort({i1, i2 -> i1 - i2})
  8325. <
  8326. Parameters: ~
  8327. • {list} (`T[]`)
  8328. • {how} (`string|function?`)
  8329. • {dict} (`any?`)
  8330. Return: ~
  8331. (`T[]`)
  8332. soundfold({word}) *soundfold()*
  8333. Return the sound-folded equivalent of {word}. Uses the first
  8334. language in 'spelllang' for the current window that supports
  8335. soundfolding. 'spell' must be set. When no sound folding is
  8336. possible the {word} is returned unmodified.
  8337. This can be used for making spelling suggestions. Note that
  8338. the method can be quite slow.
  8339. Parameters: ~
  8340. • {word} (`string`)
  8341. Return: ~
  8342. (`string`)
  8343. spellbadword([{sentence}]) *spellbadword()*
  8344. Without argument: The result is the badly spelled word under
  8345. or after the cursor. The cursor is moved to the start of the
  8346. bad word. When no bad word is found in the cursor line the
  8347. result is an empty string and the cursor doesn't move.
  8348. With argument: The result is the first word in {sentence} that
  8349. is badly spelled. If there are no spelling mistakes the
  8350. result is an empty string.
  8351. The return value is a list with two items:
  8352. - The badly spelled word or an empty string.
  8353. - The type of the spelling error:
  8354. "bad" spelling mistake
  8355. "rare" rare word
  8356. "local" word only valid in another region
  8357. "caps" word should start with Capital
  8358. Example: >vim
  8359. echo spellbadword("the quik brown fox")
  8360. < ['quik', 'bad'] ~
  8361. The spelling information for the current window and the value
  8362. of 'spelllang' are used.
  8363. Parameters: ~
  8364. • {sentence} (`string?`)
  8365. Return: ~
  8366. (`any`)
  8367. spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()*
  8368. Return a |List| with spelling suggestions to replace {word}.
  8369. When {max} is given up to this number of suggestions are
  8370. returned. Otherwise up to 25 suggestions are returned.
  8371. When the {capital} argument is given and it's non-zero only
  8372. suggestions with a leading capital will be given. Use this
  8373. after a match with 'spellcapcheck'.
  8374. {word} can be a badly spelled word followed by other text.
  8375. This allows for joining two words that were split. The
  8376. suggestions also include the following text, thus you can
  8377. replace a line.
  8378. {word} may also be a good word. Similar words will then be
  8379. returned. {word} itself is not included in the suggestions,
  8380. although it may appear capitalized.
  8381. The spelling information for the current window is used. The
  8382. values of 'spelllang' and 'spellsuggest' are used.
  8383. Parameters: ~
  8384. • {word} (`string`)
  8385. • {max} (`integer?`)
  8386. • {capital} (`boolean?`)
  8387. Return: ~
  8388. (`string[]`)
  8389. split({string} [, {pattern} [, {keepempty}]]) *split()*
  8390. Make a |List| out of {string}. When {pattern} is omitted or
  8391. empty each white space separated sequence of characters
  8392. becomes an item.
  8393. Otherwise the string is split where {pattern} matches,
  8394. removing the matched characters. 'ignorecase' is not used
  8395. here, add \c to ignore case. |/\c|
  8396. When the first or last item is empty it is omitted, unless the
  8397. {keepempty} argument is given and it's non-zero.
  8398. Other empty items are kept when {pattern} matches at least one
  8399. character or when {keepempty} is non-zero.
  8400. Example: >vim
  8401. let words = split(getline('.'), '\W\+')
  8402. < To split a string in individual characters: >vim
  8403. for c in split(mystring, '\zs') | endfor
  8404. < If you want to keep the separator you can also use '\zs' at
  8405. the end of the pattern: >vim
  8406. echo split('abc:def:ghi', ':\zs')
  8407. < >
  8408. ['abc:', 'def:', 'ghi']
  8409. <
  8410. Splitting a table where the first element can be empty: >vim
  8411. let items = split(line, ':', 1)
  8412. < The opposite function is |join()|.
  8413. Parameters: ~
  8414. • {string} (`string`)
  8415. • {pattern} (`string?`)
  8416. • {keepempty} (`boolean?`)
  8417. Return: ~
  8418. (`string[]`)
  8419. sqrt({expr}) *sqrt()*
  8420. Return the non-negative square root of Float {expr} as a
  8421. |Float|.
  8422. {expr} must evaluate to a |Float| or a |Number|. When {expr}
  8423. is negative the result is NaN (Not a Number). Returns 0.0 if
  8424. {expr} is not a |Float| or a |Number|.
  8425. Examples: >vim
  8426. echo sqrt(100)
  8427. < 10.0 >vim
  8428. echo sqrt(-4.01)
  8429. < str2float("nan")
  8430. NaN may be different, it depends on system libraries.
  8431. Parameters: ~
  8432. • {expr} (`number`)
  8433. Return: ~
  8434. (`any`)
  8435. srand([{expr}]) *srand()*
  8436. Initialize seed used by |rand()|:
  8437. - If {expr} is not given, seed values are initialized by
  8438. reading from /dev/urandom, if possible, or using time(NULL)
  8439. a.k.a. epoch time otherwise; this only has second accuracy.
  8440. - If {expr} is given it must be a Number. It is used to
  8441. initialize the seed values. This is useful for testing or
  8442. when a predictable sequence is intended.
  8443. Examples: >vim
  8444. let seed = srand()
  8445. let seed = srand(userinput)
  8446. echo rand(seed)
  8447. <
  8448. Parameters: ~
  8449. • {expr} (`number?`)
  8450. Return: ~
  8451. (`any`)
  8452. state([{what}]) *state()*
  8453. Return a string which contains characters indicating the
  8454. current state. Mostly useful in callbacks that want to do
  8455. work that may not always be safe. Roughly this works like:
  8456. - callback uses state() to check if work is safe to do.
  8457. Yes: then do it right away.
  8458. No: add to work queue and add a |SafeState| autocommand.
  8459. - When SafeState is triggered and executes your autocommand,
  8460. check with `state()` if the work can be done now, and if yes
  8461. remove it from the queue and execute.
  8462. Remove the autocommand if the queue is now empty.
  8463. Also see |mode()|.
  8464. When {what} is given only characters in this string will be
  8465. added. E.g, this checks if the screen has scrolled: >vim
  8466. if state('s') == ''
  8467. " screen has not scrolled
  8468. <
  8469. These characters indicate the state, generally indicating that
  8470. something is busy:
  8471. m halfway a mapping, :normal command, feedkeys() or
  8472. stuffed command
  8473. o operator pending, e.g. after |d|
  8474. a Insert mode autocomplete active
  8475. x executing an autocommand
  8476. S not triggering SafeState, e.g. after |f| or a count
  8477. c callback invoked, including timer (repeats for
  8478. recursiveness up to "ccc")
  8479. s screen has scrolled for messages
  8480. Parameters: ~
  8481. • {what} (`string?`)
  8482. Return: ~
  8483. (`any`)
  8484. stdioopen({opts}) *stdioopen()*
  8485. With |--headless| this opens stdin and stdout as a |channel|.
  8486. May be called only once. See |channel-stdio|. stderr is not
  8487. handled by this function, see |v:stderr|.
  8488. Close the stdio handles with |chanclose()|. Use |chansend()|
  8489. to send data to stdout, and |rpcrequest()| and |rpcnotify()|
  8490. to communicate over RPC.
  8491. {opts} is a dictionary with these keys:
  8492. |on_stdin| : callback invoked when stdin is written to.
  8493. on_print : callback invoked when Nvim needs to print a
  8494. message, with the message (whose type is string)
  8495. as sole argument.
  8496. stdin_buffered : read stdin in |channel-buffered| mode.
  8497. rpc : If set, |msgpack-rpc| will be used to communicate
  8498. over stdio
  8499. Returns:
  8500. - |channel-id| on success (value is always 1)
  8501. - 0 on invalid arguments
  8502. Parameters: ~
  8503. • {opts} (`table`)
  8504. Return: ~
  8505. (`any`)
  8506. stdpath({what}) *stdpath()* *E6100*
  8507. Returns |standard-path| locations of various default files and
  8508. directories.
  8509. {what} Type Description ~
  8510. cache String Cache directory: arbitrary temporary
  8511. storage for plugins, etc.
  8512. config String User configuration directory. |init.vim|
  8513. is stored here.
  8514. config_dirs List Other configuration directories.
  8515. data String User data directory.
  8516. data_dirs List Other data directories.
  8517. log String Logs directory (for use by plugins too).
  8518. run String Run directory: temporary, local storage
  8519. for sockets, named pipes, etc.
  8520. state String Session state directory: storage for file
  8521. drafts, swap, undo, |shada|.
  8522. Example: >vim
  8523. echo stdpath("config")
  8524. <
  8525. Parameters: ~
  8526. • {what}
  8527. (`'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'`)
  8528. Return: ~
  8529. (`string|string[]`)
  8530. str2float({string} [, {quoted}]) *str2float()*
  8531. Convert String {string} to a Float. This mostly works the
  8532. same as when using a floating point number in an expression,
  8533. see |floating-point-format|. But it's a bit more permissive.
  8534. E.g., "1e40" is accepted, while in an expression you need to
  8535. write "1.0e40". The hexadecimal form "0x123" is also
  8536. accepted, but not others, like binary or octal.
  8537. When {quoted} is present and non-zero then embedded single
  8538. quotes before the dot are ignored, thus "1'000.0" is a
  8539. thousand.
  8540. Text after the number is silently ignored.
  8541. The decimal point is always '.', no matter what the locale is
  8542. set to. A comma ends the number: "12,345.67" is converted to
  8543. 12.0. You can strip out thousands separators with
  8544. |substitute()|: >vim
  8545. let f = str2float(substitute(text, ',', '', 'g'))
  8546. <
  8547. Returns 0.0 if the conversion fails.
  8548. Parameters: ~
  8549. • {string} (`string`)
  8550. • {quoted} (`boolean?`)
  8551. Return: ~
  8552. (`any`)
  8553. str2list({string} [, {utf8}]) *str2list()*
  8554. Return a list containing the number values which represent
  8555. each character in String {string}. Examples: >vim
  8556. echo str2list(" ") " returns [32]
  8557. echo str2list("ABC") " returns [65, 66, 67]
  8558. < |list2str()| does the opposite.
  8559. UTF-8 encoding is always used, {utf8} option has no effect,
  8560. and exists only for backwards-compatibility.
  8561. With UTF-8 composing characters are handled properly: >vim
  8562. echo str2list("á") " returns [97, 769]
  8563. <
  8564. Parameters: ~
  8565. • {string} (`string`)
  8566. • {utf8} (`boolean?`)
  8567. Return: ~
  8568. (`any`)
  8569. str2nr({string} [, {base}]) *str2nr()*
  8570. Convert string {string} to a number.
  8571. {base} is the conversion base, it can be 2, 8, 10 or 16.
  8572. When {quoted} is present and non-zero then embedded single
  8573. quotes are ignored, thus "1'000'000" is a million.
  8574. When {base} is omitted base 10 is used. This also means that
  8575. a leading zero doesn't cause octal conversion to be used, as
  8576. with the default String to Number conversion. Example: >vim
  8577. let nr = str2nr('0123')
  8578. <
  8579. When {base} is 16 a leading "0x" or "0X" is ignored. With a
  8580. different base the result will be zero. Similarly, when
  8581. {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
  8582. {base} is 2 a leading "0b" or "0B" is ignored.
  8583. Text after the number is silently ignored.
  8584. Returns 0 if {string} is empty or on error.
  8585. Parameters: ~
  8586. • {string} (`string`)
  8587. • {base} (`integer?`)
  8588. Return: ~
  8589. (`any`)
  8590. strcharlen({string}) *strcharlen()*
  8591. The result is a Number, which is the number of characters
  8592. in String {string}. Composing characters are ignored.
  8593. |strchars()| can count the number of characters, counting
  8594. composing characters separately.
  8595. Returns 0 if {string} is empty or on error.
  8596. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8597. Parameters: ~
  8598. • {string} (`string`)
  8599. Return: ~
  8600. (`any`)
  8601. strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
  8602. Like |strpart()| but using character index and length instead
  8603. of byte index and length.
  8604. When {skipcc} is omitted or zero, composing characters are
  8605. counted separately.
  8606. When {skipcc} set to 1, composing characters are treated as a
  8607. part of the preceding base character, similar to |slice()|.
  8608. When a character index is used where a character does not
  8609. exist it is omitted and counted as one character. For
  8610. example: >vim
  8611. echo strcharpart('abc', -1, 2)
  8612. < results in 'a'.
  8613. Returns an empty string on error.
  8614. Parameters: ~
  8615. • {src} (`string`)
  8616. • {start} (`integer`)
  8617. • {len} (`integer?`)
  8618. • {skipcc} (`boolean?`)
  8619. Return: ~
  8620. (`any`)
  8621. strchars({string} [, {skipcc}]) *strchars()*
  8622. The result is a Number, which is the number of characters
  8623. in String {string}.
  8624. When {skipcc} is omitted or zero, composing characters are
  8625. counted separately.
  8626. When {skipcc} set to 1, composing characters are ignored.
  8627. |strcharlen()| always does this.
  8628. Returns zero on error.
  8629. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8630. {skipcc} is only available after 7.4.755. For backward
  8631. compatibility, you can define a wrapper function: >vim
  8632. if has("patch-7.4.755")
  8633. function s:strchars(str, skipcc)
  8634. return strchars(a:str, a:skipcc)
  8635. endfunction
  8636. else
  8637. function s:strchars(str, skipcc)
  8638. if a:skipcc
  8639. return strlen(substitute(a:str, ".", "x", "g"))
  8640. else
  8641. return strchars(a:str)
  8642. endif
  8643. endfunction
  8644. endif
  8645. <
  8646. Parameters: ~
  8647. • {string} (`string`)
  8648. • {skipcc} (`boolean?`)
  8649. Return: ~
  8650. (`integer`)
  8651. strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
  8652. The result is a Number, which is the number of display cells
  8653. String {string} occupies on the screen when it starts at {col}
  8654. (first column is zero). When {col} is omitted zero is used.
  8655. Otherwise it is the screen column where to start. This
  8656. matters for Tab characters.
  8657. The option settings of the current window are used. This
  8658. matters for anything that's displayed differently, such as
  8659. 'tabstop' and 'display'.
  8660. When {string} contains characters with East Asian Width Class
  8661. Ambiguous, this function's return value depends on 'ambiwidth'.
  8662. Returns zero on error.
  8663. Also see |strlen()|, |strwidth()| and |strchars()|.
  8664. Parameters: ~
  8665. • {string} (`string`)
  8666. • {col} (`integer?`)
  8667. Return: ~
  8668. (`integer`)
  8669. strftime({format} [, {time}]) *strftime()*
  8670. The result is a String, which is a formatted date and time, as
  8671. specified by the {format} string. The given {time} is used,
  8672. or the current time if no time is given. The accepted
  8673. {format} depends on your system, thus this is not portable!
  8674. See the manual page of the C function strftime() for the
  8675. format. The maximum length of the result is 80 characters.
  8676. See also |localtime()|, |getftime()| and |strptime()|.
  8677. The language can be changed with the |:language| command.
  8678. Examples: >vim
  8679. echo strftime("%c") " Sun Apr 27 11:49:23 1997
  8680. echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
  8681. echo strftime("%y%m%d %T") " 970427 11:53:55
  8682. echo strftime("%H:%M") " 11:55
  8683. echo strftime("%c", getftime("file.c"))
  8684. " Show mod time of file.c.
  8685. Parameters: ~
  8686. • {format} (`string`)
  8687. • {time} (`number?`)
  8688. Return: ~
  8689. (`string`)
  8690. strgetchar({str}, {index}) *strgetchar()*
  8691. Get a Number corresponding to the character at {index} in
  8692. {str}. This uses a zero-based character index, not a byte
  8693. index. Composing characters are considered separate
  8694. characters here. Use |nr2char()| to convert the Number to a
  8695. String.
  8696. Returns -1 if {index} is invalid.
  8697. Also see |strcharpart()| and |strchars()|.
  8698. Parameters: ~
  8699. • {str} (`string`)
  8700. • {index} (`integer`)
  8701. Return: ~
  8702. (`integer`)
  8703. stridx({haystack}, {needle} [, {start}]) *stridx()*
  8704. The result is a Number, which gives the byte index in
  8705. {haystack} of the first occurrence of the String {needle}.
  8706. If {start} is specified, the search starts at index {start}.
  8707. This can be used to find a second match: >vim
  8708. let colon1 = stridx(line, ":")
  8709. let colon2 = stridx(line, ":", colon1 + 1)
  8710. < The search is done case-sensitive.
  8711. For pattern searches use |match()|.
  8712. -1 is returned if the {needle} does not occur in {haystack}.
  8713. See also |strridx()|.
  8714. Examples: >vim
  8715. echo stridx("An Example", "Example") " 3
  8716. echo stridx("Starting point", "Start") " 0
  8717. echo stridx("Starting point", "start") " -1
  8718. < *strstr()* *strchr()*
  8719. stridx() works similar to the C function strstr(). When used
  8720. with a single character it works similar to strchr().
  8721. Parameters: ~
  8722. • {haystack} (`string`)
  8723. • {needle} (`string`)
  8724. • {start} (`integer?`)
  8725. Return: ~
  8726. (`integer`)
  8727. string({expr}) *string()*
  8728. Return {expr} converted to a String. If {expr} is a Number,
  8729. Float, String, Blob or a composition of them, then the result
  8730. can be parsed back with |eval()|.
  8731. {expr} type result ~
  8732. String 'string'
  8733. Number 123
  8734. Float 123.123456 or 1.123456e8 or
  8735. `str2float('inf')`
  8736. Funcref `function('name')`
  8737. Blob 0z00112233.44556677.8899
  8738. List [item, item]
  8739. Dictionary `{key: value, key: value}`
  8740. Note that in String values the ' character is doubled.
  8741. Also see |strtrans()|.
  8742. Note 2: Output format is mostly compatible with YAML, except
  8743. for infinite and NaN floating-point values representations
  8744. which use |str2float()|. Strings are also dumped literally,
  8745. only single quote is escaped, which does not allow using YAML
  8746. for parsing back binary strings. |eval()| should always work
  8747. for strings and floats though, and this is the only official
  8748. method. Use |msgpackdump()| or |json_encode()| if you need to
  8749. share data with other applications.
  8750. Parameters: ~
  8751. • {expr} (`any`)
  8752. Return: ~
  8753. (`string`)
  8754. strlen({string}) *strlen()*
  8755. The result is a Number, which is the length of the String
  8756. {string} in bytes.
  8757. If the argument is a Number it is first converted to a String.
  8758. For other types an error is given and zero is returned.
  8759. If you want to count the number of multibyte characters use
  8760. |strchars()|.
  8761. Also see |len()|, |strdisplaywidth()| and |strwidth()|.
  8762. Parameters: ~
  8763. • {string} (`string`)
  8764. Return: ~
  8765. (`integer`)
  8766. strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
  8767. The result is a String, which is part of {src}, starting from
  8768. byte {start}, with the byte length {len}.
  8769. When {chars} is present and TRUE then {len} is the number of
  8770. characters positions (composing characters are not counted
  8771. separately, thus "1" means one base character and any
  8772. following composing characters).
  8773. To count {start} as characters instead of bytes use
  8774. |strcharpart()|.
  8775. When bytes are selected which do not exist, this doesn't
  8776. result in an error, the bytes are simply omitted.
  8777. If {len} is missing, the copy continues from {start} till the
  8778. end of the {src}. >vim
  8779. echo strpart("abcdefg", 3, 2) " returns 'de'
  8780. echo strpart("abcdefg", -2, 4) " returns 'ab'
  8781. echo strpart("abcdefg", 5, 4) " returns 'fg'
  8782. echo strpart("abcdefg", 3) " returns 'defg'
  8783. < Note: To get the first character, {start} must be 0. For
  8784. example, to get the character under the cursor: >vim
  8785. strpart(getline("."), col(".") - 1, 1, v:true)
  8786. <
  8787. Returns an empty string on error.
  8788. Parameters: ~
  8789. • {src} (`string`)
  8790. • {start} (`integer`)
  8791. • {len} (`integer?`)
  8792. • {chars} (`0|1?`)
  8793. Return: ~
  8794. (`string`)
  8795. strptime({format}, {timestring}) *strptime()*
  8796. The result is a Number, which is a unix timestamp representing
  8797. the date and time in {timestring}, which is expected to match
  8798. the format specified in {format}.
  8799. The accepted {format} depends on your system, thus this is not
  8800. portable! See the manual page of the C function strptime()
  8801. for the format. Especially avoid "%c". The value of $TZ also
  8802. matters.
  8803. If the {timestring} cannot be parsed with {format} zero is
  8804. returned. If you do not know the format of {timestring} you
  8805. can try different {format} values until you get a non-zero
  8806. result.
  8807. See also |strftime()|.
  8808. Examples: >vim
  8809. echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
  8810. < 862156163 >vim
  8811. echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
  8812. < Sun Apr 27 11:53:55 1997 >vim
  8813. echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
  8814. < Sun Apr 27 12:53:55 1997
  8815. Parameters: ~
  8816. • {format} (`string`)
  8817. • {timestring} (`string`)
  8818. Return: ~
  8819. (`integer`)
  8820. strridx({haystack}, {needle} [, {start}]) *strridx()*
  8821. The result is a Number, which gives the byte index in
  8822. {haystack} of the last occurrence of the String {needle}.
  8823. When {start} is specified, matches beyond this index are
  8824. ignored. This can be used to find a match before a previous
  8825. match: >vim
  8826. let lastcomma = strridx(line, ",")
  8827. let comma2 = strridx(line, ",", lastcomma - 1)
  8828. < The search is done case-sensitive.
  8829. For pattern searches use |match()|.
  8830. -1 is returned if the {needle} does not occur in {haystack}.
  8831. If the {needle} is empty the length of {haystack} is returned.
  8832. See also |stridx()|. Examples: >vim
  8833. echo strridx("an angry armadillo", "an") 3
  8834. < *strrchr()*
  8835. When used with a single character it works similar to the C
  8836. function strrchr().
  8837. Parameters: ~
  8838. • {haystack} (`string`)
  8839. • {needle} (`string`)
  8840. • {start} (`integer?`)
  8841. Return: ~
  8842. (`integer`)
  8843. strtrans({string}) *strtrans()*
  8844. The result is a String, which is {string} with all unprintable
  8845. characters translated into printable characters |'isprint'|.
  8846. Like they are shown in a window. Example: >vim
  8847. echo strtrans(@a)
  8848. < This displays a newline in register a as "^@" instead of
  8849. starting a new line.
  8850. Returns an empty string on error.
  8851. Parameters: ~
  8852. • {string} (`string`)
  8853. Return: ~
  8854. (`string`)
  8855. strutf16len({string} [, {countcc}]) *strutf16len()*
  8856. The result is a Number, which is the number of UTF-16 code
  8857. units in String {string} (after converting it to UTF-16).
  8858. When {countcc} is TRUE, composing characters are counted
  8859. separately.
  8860. When {countcc} is omitted or FALSE, composing characters are
  8861. ignored.
  8862. Returns zero on error.
  8863. Also see |strlen()| and |strcharlen()|.
  8864. Examples: >vim
  8865. echo strutf16len('a') " returns 1
  8866. echo strutf16len('©') " returns 1
  8867. echo strutf16len('😊') " returns 2
  8868. echo strutf16len('ą́') " returns 1
  8869. echo strutf16len('ą́', v:true) " returns 3
  8870. <
  8871. Parameters: ~
  8872. • {string} (`string`)
  8873. • {countcc} (`0|1?`)
  8874. Return: ~
  8875. (`integer`)
  8876. strwidth({string}) *strwidth()*
  8877. The result is a Number, which is the number of display cells
  8878. String {string} occupies. A Tab character is counted as one
  8879. cell, alternatively use |strdisplaywidth()|.
  8880. When {string} contains characters with East Asian Width Class
  8881. Ambiguous, this function's return value depends on 'ambiwidth'.
  8882. Returns zero on error.
  8883. Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
  8884. Parameters: ~
  8885. • {string} (`string`)
  8886. Return: ~
  8887. (`integer`)
  8888. submatch({nr} [, {list}]) *submatch()* *E935*
  8889. Only for an expression in a |:substitute| command or
  8890. substitute() function.
  8891. Returns the {nr}th submatch of the matched text. When {nr}
  8892. is 0 the whole matched text is returned.
  8893. Note that a NL in the string can stand for a line break of a
  8894. multi-line match or a NUL character in the text.
  8895. Also see |sub-replace-expression|.
  8896. If {list} is present and non-zero then submatch() returns
  8897. a list of strings, similar to |getline()| with two arguments.
  8898. NL characters in the text represent NUL characters in the
  8899. text.
  8900. Only returns more than one item for |:substitute|, inside
  8901. |substitute()| this list will always contain one or zero
  8902. items, since there are no real line breaks.
  8903. When substitute() is used recursively only the submatches in
  8904. the current (deepest) call can be obtained.
  8905. Returns an empty string or list on error.
  8906. Examples: >vim
  8907. s/\d\+/\=submatch(0) + 1/
  8908. echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
  8909. < This finds the first number in the line and adds one to it.
  8910. A line break is included as a newline character.
  8911. Parameters: ~
  8912. • {nr} (`integer`)
  8913. • {list} (`nil?`)
  8914. Return: ~
  8915. (`string`)
  8916. substitute({string}, {pat}, {sub}, {flags}) *substitute()*
  8917. The result is a String, which is a copy of {string}, in which
  8918. the first match of {pat} is replaced with {sub}.
  8919. When {flags} is "g", all matches of {pat} in {string} are
  8920. replaced. Otherwise {flags} should be "".
  8921. This works like the ":substitute" command (without any flags).
  8922. But the matching with {pat} is always done like the 'magic'
  8923. option is set and 'cpoptions' is empty (to make scripts
  8924. portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
  8925. if you want to ignore or match case and ignore 'ignorecase'.
  8926. 'smartcase' is not used. See |string-match| for how {pat} is
  8927. used.
  8928. A "~" in {sub} is not replaced with the previous {sub}.
  8929. Note that some codes in {sub} have a special meaning
  8930. |sub-replace-special|. For example, to replace something with
  8931. "\n" (two characters), use "\\\\n" or '\\n'.
  8932. When {pat} does not match in {string}, {string} is returned
  8933. unmodified.
  8934. Example: >vim
  8935. let &path = substitute(&path, ",\\=[^,]*$", "", "")
  8936. < This removes the last component of the 'path' option. >vim
  8937. echo substitute("testing", ".*", "\\U\\0", "")
  8938. < results in "TESTING".
  8939. When {sub} starts with "\=", the remainder is interpreted as
  8940. an expression. See |sub-replace-expression|. Example: >vim
  8941. echo substitute(s, '%\(\x\x\)',
  8942. \ '\=nr2char("0x" .. submatch(1))', 'g')
  8943. < When {sub} is a Funcref that function is called, with one
  8944. optional argument. Example: >vim
  8945. echo substitute(s, '%\(\x\x\)', SubNr, 'g')
  8946. < The optional argument is a list which contains the whole
  8947. matched string and up to nine submatches, like what
  8948. |submatch()| returns. Example: >vim
  8949. echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
  8950. < Returns an empty string on error.
  8951. Parameters: ~
  8952. • {string} (`string`)
  8953. • {pat} (`string`)
  8954. • {sub} (`string`)
  8955. • {flags} (`string`)
  8956. Return: ~
  8957. (`string`)
  8958. swapfilelist() *swapfilelist()*
  8959. Returns a list of swap file names, like what "vim -r" shows.
  8960. See the |-r| command argument. The 'directory' option is used
  8961. for the directories to inspect. If you only want to get a
  8962. list of swap files in the current directory then temporarily
  8963. set 'directory' to a dot: >vim
  8964. let save_dir = &directory
  8965. let &directory = '.'
  8966. let swapfiles = swapfilelist()
  8967. let &directory = save_dir
  8968. Return: ~
  8969. (`string[]`)
  8970. swapinfo({fname}) *swapinfo()*
  8971. The result is a dictionary, which holds information about the
  8972. swapfile {fname}. The available fields are:
  8973. version Vim version
  8974. user user name
  8975. host host name
  8976. fname original file name
  8977. pid PID of the Nvim process that created the swap
  8978. file, or zero if not running.
  8979. mtime last modification time in seconds
  8980. inode Optional: INODE number of the file
  8981. dirty 1 if file was modified, 0 if not
  8982. In case of failure an "error" item is added with the reason:
  8983. Cannot open file: file not found or in accessible
  8984. Cannot read file: cannot read first block
  8985. Not a swap file: does not contain correct block ID
  8986. Magic number mismatch: Info in first block is invalid
  8987. Parameters: ~
  8988. • {fname} (`string`)
  8989. Return: ~
  8990. (`any`)
  8991. swapname({buf}) *swapname()*
  8992. The result is the swap file path of the buffer {buf}.
  8993. For the use of {buf}, see |bufname()| above.
  8994. If buffer {buf} is the current buffer, the result is equal to
  8995. |:swapname| (unless there is no swap file).
  8996. If buffer {buf} has no swap file, returns an empty string.
  8997. Parameters: ~
  8998. • {buf} (`integer|string`)
  8999. Return: ~
  9000. (`string`)
  9001. synID({lnum}, {col}, {trans}) *synID()*
  9002. The result is a Number, which is the syntax ID at the position
  9003. {lnum} and {col} in the current window.
  9004. The syntax ID can be used with |synIDattr()| and
  9005. |synIDtrans()| to obtain syntax information about text.
  9006. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  9007. line. 'synmaxcol' applies, in a longer line zero is returned.
  9008. Note that when the position is after the last character,
  9009. that's where the cursor can be in Insert mode, synID() returns
  9010. zero. {lnum} is used like with |getline()|.
  9011. When {trans} is |TRUE|, transparent items are reduced to the
  9012. item that they reveal. This is useful when wanting to know
  9013. the effective color. When {trans} is |FALSE|, the transparent
  9014. item is returned. This is useful when wanting to know which
  9015. syntax item is effective (e.g. inside parens).
  9016. Warning: This function can be very slow. Best speed is
  9017. obtained by going through the file in forward direction.
  9018. Returns zero on error.
  9019. Example (echoes the name of the syntax item under the cursor): >vim
  9020. echo synIDattr(synID(line("."), col("."), 1), "name")
  9021. <
  9022. Parameters: ~
  9023. • {lnum} (`integer`)
  9024. • {col} (`integer`)
  9025. • {trans} (`0|1`)
  9026. Return: ~
  9027. (`integer`)
  9028. synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
  9029. The result is a String, which is the {what} attribute of
  9030. syntax ID {synID}. This can be used to obtain information
  9031. about a syntax item.
  9032. {mode} can be "gui" or "cterm", to get the attributes
  9033. for that mode. When {mode} is omitted, or an invalid value is
  9034. used, the attributes for the currently active highlighting are
  9035. used (GUI or cterm).
  9036. Use synIDtrans() to follow linked highlight groups.
  9037. {what} result
  9038. "name" the name of the syntax item
  9039. "fg" foreground color (GUI: color name used to set
  9040. the color, cterm: color number as a string,
  9041. term: empty string)
  9042. "bg" background color (as with "fg")
  9043. "font" font name (only available in the GUI)
  9044. |highlight-font|
  9045. "sp" special color (as with "fg") |guisp|
  9046. "fg#" like "fg", but for the GUI and the GUI is
  9047. running the name in "#RRGGBB" form
  9048. "bg#" like "fg#" for "bg"
  9049. "sp#" like "fg#" for "sp"
  9050. "bold" "1" if bold
  9051. "italic" "1" if italic
  9052. "reverse" "1" if reverse
  9053. "inverse" "1" if inverse (= reverse)
  9054. "standout" "1" if standout
  9055. "underline" "1" if underlined
  9056. "undercurl" "1" if undercurled
  9057. "underdouble" "1" if double underlined
  9058. "underdotted" "1" if dotted underlined
  9059. "underdashed" "1" if dashed underlined
  9060. "strikethrough" "1" if struckthrough
  9061. "altfont" "1" if alternative font
  9062. "nocombine" "1" if nocombine
  9063. Returns an empty string on error.
  9064. Example (echoes the color of the syntax item under the
  9065. cursor): >vim
  9066. echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  9067. <
  9068. Can also be used as a |method|: >vim
  9069. echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  9070. <
  9071. Parameters: ~
  9072. • {synID} (`integer`)
  9073. • {what} (`string`)
  9074. • {mode} (`string?`)
  9075. Return: ~
  9076. (`string`)
  9077. synIDtrans({synID}) *synIDtrans()*
  9078. The result is a Number, which is the translated syntax ID of
  9079. {synID}. This is the syntax group ID of what is being used to
  9080. highlight the character. Highlight links given with
  9081. ":highlight link" are followed.
  9082. Returns zero on error.
  9083. Parameters: ~
  9084. • {synID} (`integer`)
  9085. Return: ~
  9086. (`integer`)
  9087. synconcealed({lnum}, {col}) *synconcealed()*
  9088. The result is a |List| with currently three items:
  9089. 1. The first item in the list is 0 if the character at the
  9090. position {lnum} and {col} is not part of a concealable
  9091. region, 1 if it is. {lnum} is used like with |getline()|.
  9092. 2. The second item in the list is a string. If the first item
  9093. is 1, the second item contains the text which will be
  9094. displayed in place of the concealed text, depending on the
  9095. current setting of 'conceallevel' and 'listchars'.
  9096. 3. The third and final item in the list is a number
  9097. representing the specific syntax region matched in the
  9098. line. When the character is not concealed the value is
  9099. zero. This allows detection of the beginning of a new
  9100. concealable region if there are two consecutive regions
  9101. with the same replacement character. For an example, if
  9102. the text is "123456" and both "23" and "45" are concealed
  9103. and replaced by the character "X", then:
  9104. call returns ~
  9105. synconcealed(lnum, 1) [0, '', 0]
  9106. synconcealed(lnum, 2) [1, 'X', 1]
  9107. synconcealed(lnum, 3) [1, 'X', 1]
  9108. synconcealed(lnum, 4) [1, 'X', 2]
  9109. synconcealed(lnum, 5) [1, 'X', 2]
  9110. synconcealed(lnum, 6) [0, '', 0]
  9111. Note: Doesn't consider |matchadd()| highlighting items,
  9112. since syntax and matching highlighting are two different
  9113. mechanisms |syntax-vs-match|.
  9114. Parameters: ~
  9115. • {lnum} (`integer`)
  9116. • {col} (`integer`)
  9117. Return: ~
  9118. (`[integer, string, integer]`)
  9119. synstack({lnum}, {col}) *synstack()*
  9120. Return a |List|, which is the stack of syntax items at the
  9121. position {lnum} and {col} in the current window. {lnum} is
  9122. used like with |getline()|. Each item in the List is an ID
  9123. like what |synID()| returns.
  9124. The first item in the List is the outer region, following are
  9125. items contained in that one. The last one is what |synID()|
  9126. returns, unless not the whole item is highlighted or it is a
  9127. transparent item.
  9128. This function is useful for debugging a syntax file.
  9129. Example that shows the syntax stack under the cursor: >vim
  9130. for id in synstack(line("."), col("."))
  9131. echo synIDattr(id, "name")
  9132. endfor
  9133. < When the position specified with {lnum} and {col} is invalid
  9134. an empty list is returned. The position just after the last
  9135. character in a line and the first column in an empty line are
  9136. valid positions.
  9137. Parameters: ~
  9138. • {lnum} (`integer`)
  9139. • {col} (`integer`)
  9140. Return: ~
  9141. (`integer[]`)
  9142. system({cmd} [, {input}]) *system()* *E677*
  9143. Note: Prefer |vim.system()| in Lua.
  9144. Gets the output of {cmd} as a |string| (|systemlist()| returns
  9145. a |List|) and sets |v:shell_error| to the error code.
  9146. {cmd} is treated as in |jobstart()|:
  9147. If {cmd} is a List it runs directly (no 'shell').
  9148. If {cmd} is a String it runs in the 'shell', like this: >vim
  9149. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  9150. < Not to be used for interactive commands.
  9151. Result is a String, filtered to avoid platform-specific quirks:
  9152. - <CR><NL> is replaced with <NL>
  9153. - NUL characters are replaced with SOH (0x01)
  9154. Example: >vim
  9155. echo system(['ls', expand('%:h')])
  9156. < If {input} is a string it is written to a pipe and passed as
  9157. stdin to the command. The string is written as-is, line
  9158. separators are not changed.
  9159. If {input} is a |List| it is written to the pipe as
  9160. |writefile()| does with {binary} set to "b" (i.e. with
  9161. a newline between each list item, and newlines inside list
  9162. items converted to NULs).
  9163. When {input} is given and is a valid buffer id, the content of
  9164. the buffer is written to the file line by line, each line
  9165. terminated by NL (and NUL where the text has NL).
  9166. *E5677*
  9167. Note: system() cannot write to or read from backgrounded ("&")
  9168. shell commands, e.g.: >vim
  9169. echo system("cat - &", "foo")
  9170. < which is equivalent to: >
  9171. $ echo foo | bash -c 'cat - &'
  9172. < The pipes are disconnected (unless overridden by shell
  9173. redirection syntax) before input can reach it. Use
  9174. |jobstart()| instead.
  9175. Note: Use |shellescape()| or |::S| with |expand()| or
  9176. |fnamemodify()| to escape special characters in a command
  9177. argument. 'shellquote' and 'shellxquote' must be properly
  9178. configured. Example: >vim
  9179. echo system('ls '..shellescape(expand('%:h')))
  9180. echo system('ls '..expand('%:h:S'))
  9181. < Unlike ":!cmd" there is no automatic check for changed files.
  9182. Use |:checktime| to force a check.
  9183. Parameters: ~
  9184. • {cmd} (`string|string[]`)
  9185. • {input} (`string|string[]|integer?`)
  9186. Return: ~
  9187. (`string`)
  9188. systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
  9189. Same as |system()|, but returns a |List| with lines (parts of
  9190. output separated by NL) with NULs transformed into NLs. Output
  9191. is the same as |readfile()| will output with {binary} argument
  9192. set to "b", except that a final newline is not preserved,
  9193. unless {keepempty} is non-zero.
  9194. Note that on MS-Windows you may get trailing CR characters.
  9195. To see the difference between "echo hello" and "echo -n hello"
  9196. use |system()| and |split()|: >vim
  9197. echo split(system('echo hello'), '\n', 1)
  9198. <
  9199. Returns an empty string on error.
  9200. Parameters: ~
  9201. • {cmd} (`string|string[]`)
  9202. • {input} (`string|string[]|integer?`)
  9203. • {keepempty} (`integer?`)
  9204. Return: ~
  9205. (`string[]`)
  9206. tabpagebuflist([{arg}]) *tabpagebuflist()*
  9207. The result is a |List|, where each item is the number of the
  9208. buffer associated with each window in the current tab page.
  9209. {arg} specifies the number of the tab page to be used. When
  9210. omitted the current tab page is used.
  9211. When {arg} is invalid the number zero is returned.
  9212. To get a list of all buffers in all tabs use this: >vim
  9213. let buflist = []
  9214. for i in range(tabpagenr('$'))
  9215. call extend(buflist, tabpagebuflist(i + 1))
  9216. endfor
  9217. < Note that a buffer may appear in more than one window.
  9218. Parameters: ~
  9219. • {arg} (`integer?`)
  9220. Return: ~
  9221. (`any`)
  9222. tabpagenr([{arg}]) *tabpagenr()*
  9223. The result is a Number, which is the number of the current
  9224. tab page. The first tab page has number 1.
  9225. The optional argument {arg} supports the following values:
  9226. $ the number of the last tab page (the tab page
  9227. count).
  9228. # the number of the last accessed tab page
  9229. (where |g<Tab>| goes to). If there is no
  9230. previous tab page, 0 is returned.
  9231. The number can be used with the |:tab| command.
  9232. Returns zero on error.
  9233. Parameters: ~
  9234. • {arg} (`'$'|'#'?`)
  9235. Return: ~
  9236. (`integer`)
  9237. tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
  9238. Like |winnr()| but for tab page {tabarg}.
  9239. {tabarg} specifies the number of tab page to be used.
  9240. {arg} is used like with |winnr()|:
  9241. - When omitted the current window number is returned. This is
  9242. the window which will be used when going to this tab page.
  9243. - When "$" the number of windows is returned.
  9244. - When "#" the previous window nr is returned.
  9245. Useful examples: >vim
  9246. tabpagewinnr(1) " current window of tab page 1
  9247. tabpagewinnr(4, '$') " number of windows in tab page 4
  9248. < When {tabarg} is invalid zero is returned.
  9249. Parameters: ~
  9250. • {tabarg} (`integer`)
  9251. • {arg} (`'$'|'#'?`)
  9252. Return: ~
  9253. (`integer`)
  9254. tagfiles() *tagfiles()*
  9255. Returns a |List| with the file names used to search for tags
  9256. for the current buffer. This is the 'tags' option expanded.
  9257. Return: ~
  9258. (`string[]`)
  9259. taglist({expr} [, {filename}]) *taglist()*
  9260. Returns a |List| of tags matching the regular expression {expr}.
  9261. If {filename} is passed it is used to prioritize the results
  9262. in the same way that |:tselect| does. See |tag-priority|.
  9263. {filename} should be the full path of the file.
  9264. Each list item is a dictionary with at least the following
  9265. entries:
  9266. name Name of the tag.
  9267. filename Name of the file where the tag is
  9268. defined. It is either relative to the
  9269. current directory or a full path.
  9270. cmd Ex command used to locate the tag in
  9271. the file.
  9272. kind Type of the tag. The value for this
  9273. entry depends on the language specific
  9274. kind values. Only available when
  9275. using a tags file generated by
  9276. Universal/Exuberant ctags or hdrtag.
  9277. static A file specific tag. Refer to
  9278. |static-tag| for more information.
  9279. More entries may be present, depending on the content of the
  9280. tags file: access, implementation, inherits and signature.
  9281. Refer to the ctags documentation for information about these
  9282. fields. For C code the fields "struct", "class" and "enum"
  9283. may appear, they give the name of the entity the tag is
  9284. contained in.
  9285. The ex-command "cmd" can be either an ex search pattern, a
  9286. line number or a line number followed by a byte number.
  9287. If there are no matching tags, then an empty list is returned.
  9288. To get an exact tag match, the anchors '^' and '$' should be
  9289. used in {expr}. This also make the function work faster.
  9290. Refer to |tag-regexp| for more information about the tag
  9291. search regular expression pattern.
  9292. Refer to |'tags'| for information about how the tags file is
  9293. located by Vim. Refer to |tags-file-format| for the format of
  9294. the tags file generated by the different ctags tools.
  9295. Parameters: ~
  9296. • {expr} (`any`)
  9297. • {filename} (`string?`)
  9298. Return: ~
  9299. (`any`)
  9300. tan({expr}) *tan()*
  9301. Return the tangent of {expr}, measured in radians, as a |Float|
  9302. in the range [-inf, inf].
  9303. {expr} must evaluate to a |Float| or a |Number|.
  9304. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9305. Examples: >vim
  9306. echo tan(10)
  9307. < 0.648361 >vim
  9308. echo tan(-4.01)
  9309. < -1.181502
  9310. Parameters: ~
  9311. • {expr} (`number`)
  9312. Return: ~
  9313. (`number`)
  9314. tanh({expr}) *tanh()*
  9315. Return the hyperbolic tangent of {expr} as a |Float| in the
  9316. range [-1, 1].
  9317. {expr} must evaluate to a |Float| or a |Number|.
  9318. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9319. Examples: >vim
  9320. echo tanh(0.5)
  9321. < 0.462117 >vim
  9322. echo tanh(-1)
  9323. < -0.761594
  9324. Parameters: ~
  9325. • {expr} (`number`)
  9326. Return: ~
  9327. (`number`)
  9328. tempname() *tempname()*
  9329. Generates a (non-existent) filename located in the Nvim root
  9330. |tempdir|. Scripts can use the filename as a temporary file.
  9331. Example: >vim
  9332. let tmpfile = tempname()
  9333. exe "redir > " .. tmpfile
  9334. <
  9335. Return: ~
  9336. (`string`)
  9337. test_garbagecollect_now() *test_garbagecollect_now()*
  9338. Like |garbagecollect()|, but executed right away. This must
  9339. only be called directly to avoid any structure to exist
  9340. internally, and |v:testing| must have been set before calling
  9341. any function. *E1142*
  9342. Return: ~
  9343. (`any`)
  9344. timer_info([{id}]) *timer_info()*
  9345. Return a list with information about timers.
  9346. When {id} is given only information about this timer is
  9347. returned. When timer {id} does not exist an empty list is
  9348. returned.
  9349. When {id} is omitted information about all timers is returned.
  9350. For each timer the information is stored in a |Dictionary| with
  9351. these items:
  9352. "id" the timer ID
  9353. "time" time the timer was started with
  9354. "repeat" number of times the timer will still fire;
  9355. -1 means forever
  9356. "callback" the callback
  9357. Parameters: ~
  9358. • {id} (`integer?`)
  9359. Return: ~
  9360. (`any`)
  9361. timer_pause({timer}, {paused}) *timer_pause()*
  9362. Pause or unpause a timer. A paused timer does not invoke its
  9363. callback when its time expires. Unpausing a timer may cause
  9364. the callback to be invoked almost immediately if enough time
  9365. has passed.
  9366. Pausing a timer is useful to avoid the callback to be called
  9367. for a short time.
  9368. If {paused} evaluates to a non-zero Number or a non-empty
  9369. String, then the timer is paused, otherwise it is unpaused.
  9370. See |non-zero-arg|.
  9371. Parameters: ~
  9372. • {timer} (`integer`)
  9373. • {paused} (`boolean`)
  9374. Return: ~
  9375. (`any`)
  9376. timer_start({time}, {callback} [, {options}]) *timer_start()* *timer*
  9377. Create a timer and return the timer ID.
  9378. {time} is the waiting time in milliseconds. This is the
  9379. minimum time before invoking the callback. When the system is
  9380. busy or Vim is not waiting for input the time will be longer.
  9381. Zero can be used to execute the callback when Vim is back in
  9382. the main loop.
  9383. {callback} is the function to call. It can be the name of a
  9384. function or a |Funcref|. It is called with one argument, which
  9385. is the timer ID. The callback is only invoked when Vim is
  9386. waiting for input.
  9387. {options} is a dictionary. Supported entries:
  9388. "repeat" Number of times to repeat the callback.
  9389. -1 means forever. Default is 1.
  9390. If the timer causes an error three times in a
  9391. row the repeat is cancelled.
  9392. Returns -1 on error.
  9393. Example: >vim
  9394. func MyHandler(timer)
  9395. echo 'Handler called'
  9396. endfunc
  9397. let timer = timer_start(500, 'MyHandler',
  9398. \ {'repeat': 3})
  9399. < This invokes MyHandler() three times at 500 msec intervals.
  9400. Parameters: ~
  9401. • {time} (`number`)
  9402. • {callback} (`string|function`)
  9403. • {options} (`table?`)
  9404. Return: ~
  9405. (`any`)
  9406. timer_stop({timer}) *timer_stop()*
  9407. Stop a timer. The timer callback will no longer be invoked.
  9408. {timer} is an ID returned by timer_start(), thus it must be a
  9409. Number. If {timer} does not exist there is no error.
  9410. Parameters: ~
  9411. • {timer} (`integer`)
  9412. Return: ~
  9413. (`any`)
  9414. timer_stopall() *timer_stopall()*
  9415. Stop all timers. The timer callbacks will no longer be
  9416. invoked. Useful if some timers is misbehaving. If there are
  9417. no timers there is no error.
  9418. Return: ~
  9419. (`any`)
  9420. tolower({expr}) *tolower()*
  9421. The result is a copy of the String given, with all uppercase
  9422. characters turned into lowercase (just like applying |gu| to
  9423. the string). Returns an empty string on error.
  9424. Parameters: ~
  9425. • {expr} (`string`)
  9426. Return: ~
  9427. (`string`)
  9428. toupper({expr}) *toupper()*
  9429. The result is a copy of the String given, with all lowercase
  9430. characters turned into uppercase (just like applying |gU| to
  9431. the string). Returns an empty string on error.
  9432. Parameters: ~
  9433. • {expr} (`string`)
  9434. Return: ~
  9435. (`string`)
  9436. tr({src}, {fromstr}, {tostr}) *tr()*
  9437. The result is a copy of the {src} string with all characters
  9438. which appear in {fromstr} replaced by the character in that
  9439. position in the {tostr} string. Thus the first character in
  9440. {fromstr} is translated into the first character in {tostr}
  9441. and so on. Exactly like the unix "tr" command.
  9442. This code also deals with multibyte characters properly.
  9443. Returns an empty string on error.
  9444. Examples: >vim
  9445. echo tr("hello there", "ht", "HT")
  9446. < returns "Hello THere" >vim
  9447. echo tr("<blob>", "<>", "{}")
  9448. < returns "{blob}"
  9449. Parameters: ~
  9450. • {src} (`string`)
  9451. • {fromstr} (`string`)
  9452. • {tostr} (`string`)
  9453. Return: ~
  9454. (`string`)
  9455. trim({text} [, {mask} [, {dir}]]) *trim()*
  9456. Return {text} as a String where any character in {mask} is
  9457. removed from the beginning and/or end of {text}.
  9458. If {mask} is not given, or is an empty string, {mask} is all
  9459. characters up to 0x20, which includes Tab, space, NL and CR,
  9460. plus the non-breaking space character 0xa0.
  9461. The optional {dir} argument specifies where to remove the
  9462. characters:
  9463. 0 remove from the beginning and end of {text}
  9464. 1 remove only at the beginning of {text}
  9465. 2 remove only at the end of {text}
  9466. When omitted both ends are trimmed.
  9467. This function deals with multibyte characters properly.
  9468. Returns an empty string on error.
  9469. Examples: >vim
  9470. echo trim(" some text ")
  9471. < returns "some text" >vim
  9472. echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  9473. < returns "RESERVE_TAIL" >vim
  9474. echo trim("rm<Xrm<>X>rrm", "rm<>")
  9475. < returns "Xrm<>X" (characters in the middle are not removed) >vim
  9476. echo trim(" vim ", " ", 2)
  9477. < returns " vim"
  9478. Parameters: ~
  9479. • {text} (`string`)
  9480. • {mask} (`string?`)
  9481. • {dir} (`0|1|2?`)
  9482. Return: ~
  9483. (`string`)
  9484. trunc({expr}) *trunc()*
  9485. Return the largest integral value with magnitude less than or
  9486. equal to {expr} as a |Float| (truncate towards zero).
  9487. {expr} must evaluate to a |Float| or a |Number|.
  9488. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9489. Examples: >vim
  9490. echo trunc(1.456)
  9491. < 1.0 >vim
  9492. echo trunc(-5.456)
  9493. < -5.0 >vim
  9494. echo trunc(4.0)
  9495. < 4.0
  9496. Parameters: ~
  9497. • {expr} (`number`)
  9498. Return: ~
  9499. (`integer`)
  9500. type({expr}) *type()*
  9501. The result is a Number representing the type of {expr}.
  9502. Instead of using the number directly, it is better to use the
  9503. v:t_ variable that has the value:
  9504. Number: 0 |v:t_number|
  9505. String: 1 |v:t_string|
  9506. Funcref: 2 |v:t_func|
  9507. List: 3 |v:t_list|
  9508. Dictionary: 4 |v:t_dict|
  9509. Float: 5 |v:t_float|
  9510. Boolean: 6 |v:t_bool| (|v:false| and |v:true|)
  9511. Null: 7 (|v:null|)
  9512. Blob: 10 |v:t_blob|
  9513. For backward compatibility, this method can be used: >vim
  9514. if type(myvar) == type(0) | endif
  9515. if type(myvar) == type("") | endif
  9516. if type(myvar) == type(function("tr")) | endif
  9517. if type(myvar) == type([]) | endif
  9518. if type(myvar) == type({}) | endif
  9519. if type(myvar) == type(0.0) | endif
  9520. if type(myvar) == type(v:true) | endif
  9521. < In place of checking for |v:null| type it is better to check
  9522. for |v:null| directly as it is the only value of this type: >vim
  9523. if myvar is v:null | endif
  9524. < To check if the v:t_ variables exist use this: >vim
  9525. if exists('v:t_number') | endif
  9526. <
  9527. Parameters: ~
  9528. • {expr} (`any`)
  9529. Return: ~
  9530. (`integer`)
  9531. undofile({name}) *undofile()*
  9532. Return the name of the undo file that would be used for a file
  9533. with name {name} when writing. This uses the 'undodir'
  9534. option, finding directories that exist. It does not check if
  9535. the undo file exists.
  9536. {name} is always expanded to the full path, since that is what
  9537. is used internally.
  9538. If {name} is empty undofile() returns an empty string, since a
  9539. buffer without a file name will not write an undo file.
  9540. Useful in combination with |:wundo| and |:rundo|.
  9541. Parameters: ~
  9542. • {name} (`string`)
  9543. Return: ~
  9544. (`string`)
  9545. undotree([{buf}]) *undotree()*
  9546. Return the current state of the undo tree for the current
  9547. buffer, or for a specific buffer if {buf} is given. The
  9548. result is a dictionary with the following items:
  9549. "seq_last" The highest undo sequence number used.
  9550. "seq_cur" The sequence number of the current position in
  9551. the undo tree. This differs from "seq_last"
  9552. when some changes were undone.
  9553. "time_cur" Time last used for |:earlier| and related
  9554. commands. Use |strftime()| to convert to
  9555. something readable.
  9556. "save_last" Number of the last file write. Zero when no
  9557. write yet.
  9558. "save_cur" Number of the current position in the undo
  9559. tree.
  9560. "synced" Non-zero when the last undo block was synced.
  9561. This happens when waiting from input from the
  9562. user. See |undo-blocks|.
  9563. "entries" A list of dictionaries with information about
  9564. undo blocks.
  9565. The first item in the "entries" list is the oldest undo item.
  9566. Each List item is a |Dictionary| with these items:
  9567. "seq" Undo sequence number. Same as what appears in
  9568. |:undolist|.
  9569. "time" Timestamp when the change happened. Use
  9570. |strftime()| to convert to something readable.
  9571. "newhead" Only appears in the item that is the last one
  9572. that was added. This marks the last change
  9573. and where further changes will be added.
  9574. "curhead" Only appears in the item that is the last one
  9575. that was undone. This marks the current
  9576. position in the undo tree, the block that will
  9577. be used by a redo command. When nothing was
  9578. undone after the last change this item will
  9579. not appear anywhere.
  9580. "save" Only appears on the last block before a file
  9581. write. The number is the write count. The
  9582. first write has number 1, the last one the
  9583. "save_last" mentioned above.
  9584. "alt" Alternate entry. This is again a List of undo
  9585. blocks. Each item may again have an "alt"
  9586. item.
  9587. Parameters: ~
  9588. • {buf} (`integer|string?`)
  9589. Return: ~
  9590. (`vim.fn.undotree.ret`)
  9591. uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
  9592. Remove second and succeeding copies of repeated adjacent
  9593. {list} items in-place. Returns {list}. If you want a list
  9594. to remain unmodified make a copy first: >vim
  9595. let newlist = uniq(copy(mylist))
  9596. < The default compare function uses the string representation of
  9597. each item. For the use of {func} and {dict} see |sort()|.
  9598. Returns zero if {list} is not a |List|.
  9599. Parameters: ~
  9600. • {list} (`any`)
  9601. • {func} (`any?`)
  9602. • {dict} (`any?`)
  9603. Return: ~
  9604. (`any[]|0`)
  9605. utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()*
  9606. Same as |charidx()| but returns the UTF-16 code unit index of
  9607. the byte at {idx} in {string} (after converting it to UTF-16).
  9608. When {charidx} is present and TRUE, {idx} is used as the
  9609. character index in the String {string} instead of as the byte
  9610. index.
  9611. An {idx} in the middle of a UTF-8 sequence is rounded
  9612. downwards to the beginning of that sequence.
  9613. Returns -1 if the arguments are invalid or if there are less
  9614. than {idx} bytes in {string}. If there are exactly {idx} bytes
  9615. the length of the string in UTF-16 code units is returned.
  9616. See |byteidx()| and |byteidxcomp()| for getting the byte index
  9617. from the UTF-16 index and |charidx()| for getting the
  9618. character index from the UTF-16 index.
  9619. Refer to |string-offset-encoding| for more information.
  9620. Examples: >vim
  9621. echo utf16idx('a😊😊', 3) " returns 2
  9622. echo utf16idx('a😊😊', 7) " returns 4
  9623. echo utf16idx('a😊😊', 1, 0, 1) " returns 2
  9624. echo utf16idx('a😊😊', 2, 0, 1) " returns 4
  9625. echo utf16idx('aą́c', 6) " returns 2
  9626. echo utf16idx('aą́c', 6, 1) " returns 4
  9627. echo utf16idx('a😊😊', 9) " returns -1
  9628. <
  9629. Parameters: ~
  9630. • {string} (`string`)
  9631. • {idx} (`integer`)
  9632. • {countcc} (`boolean?`)
  9633. • {charidx} (`boolean?`)
  9634. Return: ~
  9635. (`integer`)
  9636. values({dict}) *values()*
  9637. Return a |List| with all the values of {dict}. The |List| is
  9638. in arbitrary order. Also see |items()| and |keys()|.
  9639. Returns zero if {dict} is not a |Dict|.
  9640. Parameters: ~
  9641. • {dict} (`any`)
  9642. Return: ~
  9643. (`any`)
  9644. virtcol({expr} [, {list} [, {winid}]]) *virtcol()*
  9645. The result is a Number, which is the screen column of the file
  9646. position given with {expr}. That is, the last screen position
  9647. occupied by the character at that position, when the screen
  9648. would be of unlimited width. When there is a <Tab> at the
  9649. position, the returned Number will be the column at the end of
  9650. the <Tab>. For example, for a <Tab> in column 1, with 'ts'
  9651. set to 8, it returns 8. |conceal| is ignored.
  9652. For the byte position use |col()|.
  9653. For the use of {expr} see |getpos()| and |col()|.
  9654. When {expr} is "$", it means the end of the cursor line, so
  9655. the result is the number of cells in the cursor line plus one.
  9656. When 'virtualedit' is used {expr} can be [lnum, col, off],
  9657. where "off" is the offset in screen columns from the start of
  9658. the character. E.g., a position within a <Tab> or after the
  9659. last character. When "off" is omitted zero is used. When
  9660. Virtual editing is active in the current mode, a position
  9661. beyond the end of the line can be returned. Also see
  9662. |'virtualedit'|
  9663. If {list} is present and non-zero then virtcol() returns a
  9664. List with the first and last screen position occupied by the
  9665. character.
  9666. With the optional {winid} argument the values are obtained for
  9667. that window instead of the current window.
  9668. Note that only marks in the current file can be used.
  9669. Examples: >vim
  9670. " With text "foo^Lbar" and cursor on the "^L":
  9671. echo virtcol(".") " returns 5
  9672. echo virtcol(".", 1) " returns [4, 5]
  9673. echo virtcol("$") " returns 9
  9674. " With text " there", with 't at 'h':
  9675. echo virtcol("'t") " returns 6
  9676. <
  9677. The first column is 1. 0 or [0, 0] is returned for an error.
  9678. A more advanced example that echoes the maximum length of
  9679. all lines: >vim
  9680. echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  9681. <
  9682. Parameters: ~
  9683. • {expr} (`string|any[]`)
  9684. • {list} (`boolean?`)
  9685. • {winid} (`integer?`)
  9686. Return: ~
  9687. (`any`)
  9688. virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
  9689. The result is a Number, which is the byte index of the
  9690. character in window {winid} at buffer line {lnum} and virtual
  9691. column {col}.
  9692. If buffer line {lnum} is an empty line, 0 is returned.
  9693. If {col} is greater than the last virtual column in line
  9694. {lnum}, then the byte index of the character at the last
  9695. virtual column is returned.
  9696. For a multi-byte character, the column number of the first
  9697. byte in the character is returned.
  9698. The {winid} argument can be the window number or the
  9699. |window-ID|. If this is zero, then the current window is used.
  9700. Returns -1 if the window {winid} doesn't exist or the buffer
  9701. line {lnum} or virtual column {col} is invalid.
  9702. See also |screenpos()|, |virtcol()| and |col()|.
  9703. Parameters: ~
  9704. • {winid} (`integer`)
  9705. • {lnum} (`integer`)
  9706. • {col} (`integer`)
  9707. Return: ~
  9708. (`integer`)
  9709. visualmode([{expr}]) *visualmode()*
  9710. The result is a String, which describes the last Visual mode
  9711. used in the current buffer. Initially it returns an empty
  9712. string, but once Visual mode has been used, it returns "v",
  9713. "V", or "<CTRL-V>" (a single CTRL-V character) for
  9714. character-wise, line-wise, or block-wise Visual mode
  9715. respectively.
  9716. Example: >vim
  9717. exe "normal " .. visualmode()
  9718. < This enters the same Visual mode as before. It is also useful
  9719. in scripts if you wish to act differently depending on the
  9720. Visual mode that was used.
  9721. If Visual mode is active, use |mode()| to get the Visual mode
  9722. (e.g., in a |:vmap|).
  9723. If {expr} is supplied and it evaluates to a non-zero Number or
  9724. a non-empty String, then the Visual mode will be cleared and
  9725. the old value is returned. See |non-zero-arg|.
  9726. Parameters: ~
  9727. • {expr} (`boolean?`)
  9728. Return: ~
  9729. (`string`)
  9730. wait({timeout}, {condition} [, {interval}]) *wait()*
  9731. Waits until {condition} evaluates to |TRUE|, where {condition}
  9732. is a |Funcref| or |string| containing an expression.
  9733. {timeout} is the maximum waiting time in milliseconds, -1
  9734. means forever.
  9735. Condition is evaluated on user events, internal events, and
  9736. every {interval} milliseconds (default: 200).
  9737. Returns a status integer:
  9738. 0 if the condition was satisfied before timeout
  9739. -1 if the timeout was exceeded
  9740. -2 if the function was interrupted (by |CTRL-C|)
  9741. -3 if an error occurred
  9742. Parameters: ~
  9743. • {timeout} (`integer`)
  9744. • {condition} (`any`)
  9745. • {interval} (`number?`)
  9746. Return: ~
  9747. (`any`)
  9748. wildmenumode() *wildmenumode()*
  9749. Returns |TRUE| when the wildmenu is active and |FALSE|
  9750. otherwise. See 'wildmenu' and 'wildmode'.
  9751. This can be used in mappings to handle the 'wildcharm' option
  9752. gracefully. (Makes only sense with |mapmode-c| mappings).
  9753. For example to make <c-j> work like <down> in wildmode, use: >vim
  9754. cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  9755. <
  9756. (Note: this needs the 'wildcharm' option set appropriately).
  9757. Return: ~
  9758. (`any`)
  9759. win_execute({id}, {command} [, {silent}]) *win_execute()*
  9760. Like `execute()` but in the context of window {id}.
  9761. The window will temporarily be made the current window,
  9762. without triggering autocommands or changing directory. When
  9763. executing {command} autocommands will be triggered, this may
  9764. have unexpected side effects. Use `:noautocmd` if needed.
  9765. Example: >vim
  9766. call win_execute(winid, 'syntax enable')
  9767. < Doing the same with `setwinvar()` would not trigger
  9768. autocommands and not actually show syntax highlighting.
  9769. When window {id} does not exist then no error is given and
  9770. an empty string is returned.
  9771. Parameters: ~
  9772. • {id} (`integer`)
  9773. • {command} (`string`)
  9774. • {silent} (`boolean?`)
  9775. Return: ~
  9776. (`any`)
  9777. win_findbuf({bufnr}) *win_findbuf()*
  9778. Returns a |List| with |window-ID|s for windows that contain
  9779. buffer {bufnr}. When there is none the list is empty.
  9780. Parameters: ~
  9781. • {bufnr} (`integer`)
  9782. Return: ~
  9783. (`integer[]`)
  9784. win_getid([{win} [, {tab}]]) *win_getid()*
  9785. Get the |window-ID| for the specified window.
  9786. When {win} is missing use the current window.
  9787. With {win} this is the window number. The top window has
  9788. number 1.
  9789. Without {tab} use the current tab, otherwise the tab with
  9790. number {tab}. The first tab has number one.
  9791. Return zero if the window cannot be found.
  9792. Parameters: ~
  9793. • {win} (`integer?`)
  9794. • {tab} (`integer?`)
  9795. Return: ~
  9796. (`integer`)
  9797. win_gettype([{nr}]) *win_gettype()*
  9798. Return the type of the window:
  9799. "autocmd" autocommand window. Temporary window
  9800. used to execute autocommands.
  9801. "command" command-line window |cmdwin|
  9802. (empty) normal window
  9803. "loclist" |location-list-window|
  9804. "popup" floating window |api-floatwin|
  9805. "preview" preview window |preview-window|
  9806. "quickfix" |quickfix-window|
  9807. "unknown" window {nr} not found
  9808. When {nr} is omitted return the type of the current window.
  9809. When {nr} is given return the type of this window by number or
  9810. |window-ID|.
  9811. Also see the 'buftype' option.
  9812. Parameters: ~
  9813. • {nr} (`integer?`)
  9814. Return: ~
  9815. (`'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'`)
  9816. win_gotoid({expr}) *win_gotoid()*
  9817. Go to window with ID {expr}. This may also change the current
  9818. tabpage.
  9819. Return TRUE if successful, FALSE if the window cannot be found.
  9820. Parameters: ~
  9821. • {expr} (`integer`)
  9822. Return: ~
  9823. (`0|1`)
  9824. win_id2tabwin({expr}) *win_id2tabwin()*
  9825. Return a list with the tab number and window number of window
  9826. with ID {expr}: [tabnr, winnr].
  9827. Return [0, 0] if the window cannot be found.
  9828. Parameters: ~
  9829. • {expr} (`integer`)
  9830. Return: ~
  9831. (`any`)
  9832. win_id2win({expr}) *win_id2win()*
  9833. Return the window number of window with ID {expr}.
  9834. Return 0 if the window cannot be found in the current tabpage.
  9835. Parameters: ~
  9836. • {expr} (`integer`)
  9837. Return: ~
  9838. (`integer`)
  9839. win_move_separator({nr}, {offset}) *win_move_separator()*
  9840. Move window {nr}'s vertical separator (i.e., the right border)
  9841. by {offset} columns, as if being dragged by the mouse. {nr}
  9842. can be a window number or |window-ID|. A positive {offset}
  9843. moves right and a negative {offset} moves left. Moving a
  9844. window's vertical separator will change the width of the
  9845. window and the width of other windows adjacent to the vertical
  9846. separator. The magnitude of movement may be smaller than
  9847. specified (e.g., as a consequence of maintaining
  9848. 'winminwidth'). Returns TRUE if the window can be found and
  9849. FALSE otherwise.
  9850. This will fail for the rightmost window and a full-width
  9851. window, since it has no separator on the right.
  9852. Only works for the current tab page. *E1308*
  9853. Parameters: ~
  9854. • {nr} (`integer`)
  9855. • {offset} (`integer`)
  9856. Return: ~
  9857. (`any`)
  9858. win_move_statusline({nr}, {offset}) *win_move_statusline()*
  9859. Move window {nr}'s status line (i.e., the bottom border) by
  9860. {offset} rows, as if being dragged by the mouse. {nr} can be a
  9861. window number or |window-ID|. A positive {offset} moves down
  9862. and a negative {offset} moves up. Moving a window's status
  9863. line will change the height of the window and the height of
  9864. other windows adjacent to the status line. The magnitude of
  9865. movement may be smaller than specified (e.g., as a consequence
  9866. of maintaining 'winminheight'). Returns TRUE if the window can
  9867. be found and FALSE otherwise.
  9868. Only works for the current tab page.
  9869. Parameters: ~
  9870. • {nr} (`integer`)
  9871. • {offset} (`integer`)
  9872. Return: ~
  9873. (`any`)
  9874. win_screenpos({nr}) *win_screenpos()*
  9875. Return the screen position of window {nr} as a list with two
  9876. numbers: [row, col]. The first window always has position
  9877. [1, 1], unless there is a tabline, then it is [2, 1].
  9878. {nr} can be the window number or the |window-ID|. Use zero
  9879. for the current window.
  9880. Returns [0, 0] if the window cannot be found.
  9881. Parameters: ~
  9882. • {nr} (`integer`)
  9883. Return: ~
  9884. (`any`)
  9885. win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
  9886. Temporarily switch to window {target}, then move window {nr}
  9887. to a new split adjacent to {target}.
  9888. Unlike commands such as |:split|, no new windows are created
  9889. (the |window-ID| of window {nr} is unchanged after the move).
  9890. Both {nr} and {target} can be window numbers or |window-ID|s.
  9891. Both must be in the current tab page.
  9892. Returns zero for success, non-zero for failure.
  9893. {options} is a |Dictionary| with the following optional entries:
  9894. "vertical" When TRUE, the split is created vertically,
  9895. like with |:vsplit|.
  9896. "rightbelow" When TRUE, the split is made below or to the
  9897. right (if vertical). When FALSE, it is done
  9898. above or to the left (if vertical). When not
  9899. present, the values of 'splitbelow' and
  9900. 'splitright' are used.
  9901. Parameters: ~
  9902. • {nr} (`integer`)
  9903. • {target} (`integer`)
  9904. • {options} (`table?`)
  9905. Return: ~
  9906. (`any`)
  9907. winbufnr({nr}) *winbufnr()*
  9908. The result is a Number, which is the number of the buffer
  9909. associated with window {nr}. {nr} can be the window number or
  9910. the |window-ID|.
  9911. When {nr} is zero, the number of the buffer in the current
  9912. window is returned.
  9913. When window {nr} doesn't exist, -1 is returned.
  9914. Example: >vim
  9915. echo "The file in the current window is " .. bufname(winbufnr(0))
  9916. <
  9917. Parameters: ~
  9918. • {nr} (`integer`)
  9919. Return: ~
  9920. (`integer`)
  9921. wincol() *wincol()*
  9922. The result is a Number, which is the virtual column of the
  9923. cursor in the window. This is counting screen cells from the
  9924. left side of the window. The leftmost column is one.
  9925. Return: ~
  9926. (`integer`)
  9927. windowsversion() *windowsversion()*
  9928. The result is a String. For MS-Windows it indicates the OS
  9929. version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  9930. Windows XP is "5.1". For non-MS-Windows systems the result is
  9931. an empty string.
  9932. Return: ~
  9933. (`string`)
  9934. winheight({nr}) *winheight()*
  9935. The result is a Number, which is the height of window {nr}.
  9936. {nr} can be the window number or the |window-ID|.
  9937. When {nr} is zero, the height of the current window is
  9938. returned. When window {nr} doesn't exist, -1 is returned.
  9939. An existing window always has a height of zero or more.
  9940. This excludes any window toolbar line.
  9941. Examples: >vim
  9942. echo "The current window has " .. winheight(0) .. " lines."
  9943. <
  9944. Parameters: ~
  9945. • {nr} (`integer`)
  9946. Return: ~
  9947. (`integer`)
  9948. winlayout([{tabnr}]) *winlayout()*
  9949. The result is a nested List containing the layout of windows
  9950. in a tabpage.
  9951. Without {tabnr} use the current tabpage, otherwise the tabpage
  9952. with number {tabnr}. If the tabpage {tabnr} is not found,
  9953. returns an empty list.
  9954. For a leaf window, it returns: >
  9955. ["leaf", {winid}]
  9956. <
  9957. For horizontally split windows, which form a column, it
  9958. returns: >
  9959. ["col", [{nested list of windows}]]
  9960. < For vertically split windows, which form a row, it returns: >
  9961. ["row", [{nested list of windows}]]
  9962. <
  9963. Example: >vim
  9964. " Only one window in the tab page
  9965. echo winlayout()
  9966. < >
  9967. ['leaf', 1000]
  9968. < >vim
  9969. " Two horizontally split windows
  9970. echo winlayout()
  9971. < >
  9972. ['col', [['leaf', 1000], ['leaf', 1001]]]
  9973. < >vim
  9974. " The second tab page, with three horizontally split
  9975. " windows, with two vertically split windows in the
  9976. " middle window
  9977. echo winlayout(2)
  9978. < >
  9979. ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  9980. ['leaf', 1001]]], ['leaf', 1000]]]
  9981. <
  9982. Parameters: ~
  9983. • {tabnr} (`integer?`)
  9984. Return: ~
  9985. (`any[]`)
  9986. winline() *winline()*
  9987. The result is a Number, which is the screen line of the cursor
  9988. in the window. This is counting screen lines from the top of
  9989. the window. The first line is one.
  9990. If the cursor was moved the view on the file will be updated
  9991. first, this may cause a scroll.
  9992. Return: ~
  9993. (`integer`)
  9994. winnr([{arg}]) *winnr()*
  9995. The result is a Number, which is the number of the current
  9996. window. The top window has number 1.
  9997. Returns zero for a popup window.
  9998. The optional argument {arg} supports the following values:
  9999. $ the number of the last window (the window
  10000. count).
  10001. # the number of the last accessed window (where
  10002. |CTRL-W_p| goes to). If there is no previous
  10003. window or it is in another tab page 0 is
  10004. returned. May refer to the current window in
  10005. some cases (e.g. when evaluating 'statusline'
  10006. expressions).
  10007. {N}j the number of the Nth window below the
  10008. current window (where |CTRL-W_j| goes to).
  10009. {N}k the number of the Nth window above the current
  10010. window (where |CTRL-W_k| goes to).
  10011. {N}h the number of the Nth window left of the
  10012. current window (where |CTRL-W_h| goes to).
  10013. {N}l the number of the Nth window right of the
  10014. current window (where |CTRL-W_l| goes to).
  10015. The number can be used with |CTRL-W_w| and ":wincmd w"
  10016. |:wincmd|.
  10017. When {arg} is invalid an error is given and zero is returned.
  10018. Also see |tabpagewinnr()| and |win_getid()|.
  10019. Examples: >vim
  10020. let window_count = winnr('$')
  10021. let prev_window = winnr('#')
  10022. let wnum = winnr('3k')
  10023. <
  10024. Parameters: ~
  10025. • {arg} (`string|integer?`)
  10026. Return: ~
  10027. (`integer`)
  10028. winrestcmd() *winrestcmd()*
  10029. Returns a sequence of |:resize| commands that should restore
  10030. the current window sizes. Only works properly when no windows
  10031. are opened or closed and the current window and tab page is
  10032. unchanged.
  10033. Example: >vim
  10034. let cmd = winrestcmd()
  10035. call MessWithWindowSizes()
  10036. exe cmd
  10037. <
  10038. Return: ~
  10039. (`string`)
  10040. winrestview({dict}) *winrestview()*
  10041. Uses the |Dictionary| returned by |winsaveview()| to restore
  10042. the view of the current window.
  10043. Note: The {dict} does not have to contain all values, that are
  10044. returned by |winsaveview()|. If values are missing, those
  10045. settings won't be restored. So you can use: >vim
  10046. call winrestview({'curswant': 4})
  10047. <
  10048. This will only set the curswant value (the column the cursor
  10049. wants to move on vertical movements) of the cursor to column 5
  10050. (yes, that is 5), while all other settings will remain the
  10051. same. This is useful, if you set the cursor position manually.
  10052. If you have changed the values the result is unpredictable.
  10053. If the window size changed the result won't be the same.
  10054. Parameters: ~
  10055. • {dict} (`vim.fn.winrestview.dict`)
  10056. Return: ~
  10057. (`any`)
  10058. winsaveview() *winsaveview()*
  10059. Returns a |Dictionary| that contains information to restore
  10060. the view of the current window. Use |winrestview()| to
  10061. restore the view.
  10062. This is useful if you have a mapping that jumps around in the
  10063. buffer and you want to go back to the original view.
  10064. This does not save fold information. Use the 'foldenable'
  10065. option to temporarily switch off folding, so that folds are
  10066. not opened when moving around. This may have side effects.
  10067. The return value includes:
  10068. lnum cursor line number
  10069. col cursor column (Note: the first column
  10070. zero, as opposed to what |getcurpos()|
  10071. returns)
  10072. coladd cursor column offset for 'virtualedit'
  10073. curswant column for vertical movement (Note:
  10074. the first column is zero, as opposed
  10075. to what |getcurpos()| returns). After
  10076. |$| command it will be a very large
  10077. number equal to |v:maxcol|.
  10078. topline first line in the window
  10079. topfill filler lines, only in diff mode
  10080. leftcol first column displayed; only used when
  10081. 'wrap' is off
  10082. skipcol columns skipped
  10083. Note that no option values are saved.
  10084. Return: ~
  10085. (`vim.fn.winsaveview.ret`)
  10086. winwidth({nr}) *winwidth()*
  10087. The result is a Number, which is the width of window {nr}.
  10088. {nr} can be the window number or the |window-ID|.
  10089. When {nr} is zero, the width of the current window is
  10090. returned. When window {nr} doesn't exist, -1 is returned.
  10091. An existing window always has a width of zero or more.
  10092. Examples: >vim
  10093. echo "The current window has " .. winwidth(0) .. " columns."
  10094. if winwidth(0) <= 50
  10095. 50 wincmd |
  10096. endif
  10097. < For getting the terminal or screen size, see the 'columns'
  10098. option.
  10099. Parameters: ~
  10100. • {nr} (`integer`)
  10101. Return: ~
  10102. (`integer`)
  10103. wordcount() *wordcount()*
  10104. The result is a dictionary of byte/chars/word statistics for
  10105. the current buffer. This is the same info as provided by
  10106. |g_CTRL-G|
  10107. The return value includes:
  10108. bytes Number of bytes in the buffer
  10109. chars Number of chars in the buffer
  10110. words Number of words in the buffer
  10111. cursor_bytes Number of bytes before cursor position
  10112. (not in Visual mode)
  10113. cursor_chars Number of chars before cursor position
  10114. (not in Visual mode)
  10115. cursor_words Number of words before cursor position
  10116. (not in Visual mode)
  10117. visual_bytes Number of bytes visually selected
  10118. (only in Visual mode)
  10119. visual_chars Number of chars visually selected
  10120. (only in Visual mode)
  10121. visual_words Number of words visually selected
  10122. (only in Visual mode)
  10123. Return: ~
  10124. (`any`)
  10125. writefile({object}, {fname} [, {flags}]) *writefile()*
  10126. When {object} is a |List| write it to file {fname}. Each list
  10127. item is separated with a NL. Each list item must be a String
  10128. or Number.
  10129. All NL characters are replaced with a NUL character.
  10130. Inserting CR characters needs to be done before passing {list}
  10131. to writefile().
  10132. When {object} is a |Blob| write the bytes to file {fname}
  10133. unmodified, also when binary mode is not specified.
  10134. {flags} must be a String. These characters are recognized:
  10135. 'b' Binary mode is used: There will not be a NL after the
  10136. last list item. An empty item at the end does cause the
  10137. last line in the file to end in a NL.
  10138. 'a' Append mode is used, lines are appended to the file: >vim
  10139. call writefile(["foo"], "event.log", "a")
  10140. call writefile(["bar"], "event.log", "a")
  10141. <
  10142. 'D' Delete the file when the current function ends. This
  10143. works like: >vim
  10144. defer delete({fname})
  10145. < Fails when not in a function. Also see |:defer|.
  10146. 's' fsync() is called after writing the file. This flushes
  10147. the file to disk, if possible. This takes more time but
  10148. avoids losing the file if the system crashes.
  10149. 'S' fsync() is not called, even when 'fsync' is set.
  10150. When {flags} does not contain "S" or "s" then fsync() is
  10151. called if the 'fsync' option is set.
  10152. An existing file is overwritten, if possible.
  10153. When the write fails -1 is returned, otherwise 0. There is an
  10154. error message if the file can't be created or when writing
  10155. fails.
  10156. Also see |readfile()|.
  10157. To copy a file byte for byte: >vim
  10158. let fl = readfile("foo", "b")
  10159. call writefile(fl, "foocopy", "b")
  10160. <
  10161. Parameters: ~
  10162. • {object} (`any`)
  10163. • {fname} (`string`)
  10164. • {flags} (`string?`)
  10165. Return: ~
  10166. (`any`)
  10167. xor({expr}, {expr}) *xor()*
  10168. Bitwise XOR on the two arguments. The arguments are converted
  10169. to a number. A List, Dict or Float argument causes an error.
  10170. Also see `and()` and `or()`.
  10171. Example: >vim
  10172. let bits = xor(bits, 0x80)
  10173. <
  10174. Parameters: ~
  10175. • {expr} (`integer`)
  10176. • {expr1} (`integer`)
  10177. Return: ~
  10178. (`integer`)
  10179. ==============================================================================
  10180. 2. Matching a pattern in a String *string-match*
  10181. This is common between several functions. A regexp pattern as explained at
  10182. |pattern| is normally used to find a match in the buffer lines. When a
  10183. pattern is used to find a match in a String, almost everything works in the
  10184. same way. The difference is that a String is handled like it is one line.
  10185. When it contains a "\n" character, this is not seen as a line break for the
  10186. pattern. It can be matched with a "\n" in the pattern, or with ".". Example:
  10187. >vim
  10188. let a = "aaaa\nxxxx"
  10189. echo matchstr(a, "..\n..")
  10190. " aa
  10191. " xx
  10192. echo matchstr(a, "a.x")
  10193. " a
  10194. " x
  10195. Don't forget that "^" will only match at the first character of the String and
  10196. "$" at the last character of the string. They don't match after or before a
  10197. "\n".
  10198. vim:tw=78:ts=8:noet:ft=help:norl: