builtin.txt 442 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254
  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. completed Return a dictionary containing the entries of
  979. the currently selected index item.
  980. preview_winid Info floating preview window id.
  981. preview_bufnr Info floating preview buffer id.
  982. *complete_info_mode*
  983. mode values are:
  984. "" Not in completion mode
  985. "keyword" Keyword completion |i_CTRL-X_CTRL-N|
  986. "ctrl_x" Just pressed CTRL-X |i_CTRL-X|
  987. "scroll" Scrolling with |i_CTRL-X_CTRL-E| or
  988. |i_CTRL-X_CTRL-Y|
  989. "whole_line" Whole lines |i_CTRL-X_CTRL-L|
  990. "files" File names |i_CTRL-X_CTRL-F|
  991. "tags" Tags |i_CTRL-X_CTRL-]|
  992. "path_defines" Definition completion |i_CTRL-X_CTRL-D|
  993. "path_patterns" Include completion |i_CTRL-X_CTRL-I|
  994. "dictionary" Dictionary |i_CTRL-X_CTRL-K|
  995. "thesaurus" Thesaurus |i_CTRL-X_CTRL-T|
  996. "cmdline" Vim Command line |i_CTRL-X_CTRL-V|
  997. "function" User defined completion |i_CTRL-X_CTRL-U|
  998. "omni" Omni completion |i_CTRL-X_CTRL-O|
  999. "spell" Spelling suggestions |i_CTRL-X_s|
  1000. "eval" |complete()| completion
  1001. "unknown" Other internal modes
  1002. If the optional {what} list argument is supplied, then only
  1003. the items listed in {what} are returned. Unsupported items in
  1004. {what} are silently ignored.
  1005. To get the position and size of the popup menu, see
  1006. |pum_getpos()|. It's also available in |v:event| during the
  1007. |CompleteChanged| event.
  1008. Returns an empty |Dictionary| on error.
  1009. Examples: >vim
  1010. " Get all items
  1011. call complete_info()
  1012. " Get only 'mode'
  1013. call complete_info(['mode'])
  1014. " Get only 'mode' and 'pum_visible'
  1015. call complete_info(['mode', 'pum_visible'])
  1016. <
  1017. Parameters: ~
  1018. • {what} (`any[]?`)
  1019. Return: ~
  1020. (`table`)
  1021. confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()*
  1022. confirm() offers the user a dialog, from which a choice can be
  1023. made. It returns the number of the choice. For the first
  1024. choice this is 1.
  1025. {msg} is displayed in a dialog with {choices} as the
  1026. alternatives. When {choices} is missing or empty, "&OK" is
  1027. used (and translated).
  1028. {msg} is a String, use '\n' to include a newline. Only on
  1029. some systems the string is wrapped when it doesn't fit.
  1030. {choices} is a String, with the individual choices separated
  1031. by '\n', e.g. >vim
  1032. confirm("Save changes?", "&Yes\n&No\n&Cancel")
  1033. < The letter after the '&' is the shortcut key for that choice.
  1034. Thus you can type 'c' to select "Cancel". The shortcut does
  1035. not need to be the first letter: >vim
  1036. confirm("file has been modified", "&Save\nSave &All")
  1037. < For the console, the first letter of each choice is used as
  1038. the default shortcut key. Case is ignored.
  1039. The optional {type} String argument gives the type of dialog.
  1040. It can be one of these values: "Error", "Question", "Info",
  1041. "Warning" or "Generic". Only the first character is relevant.
  1042. When {type} is omitted, "Generic" is used.
  1043. The optional {type} argument gives the type of dialog. This
  1044. is only used for the icon of the Win32 GUI. It can be one of
  1045. these values: "Error", "Question", "Info", "Warning" or
  1046. "Generic". Only the first character is relevant.
  1047. When {type} is omitted, "Generic" is used.
  1048. If the user aborts the dialog by pressing <Esc>, CTRL-C,
  1049. or another valid interrupt key, confirm() returns 0.
  1050. An example: >vim
  1051. let choice = confirm("What do you want?",
  1052. \ "&Apples\n&Oranges\n&Bananas", 2)
  1053. if choice == 0
  1054. echo "make up your mind!"
  1055. elseif choice == 3
  1056. echo "tasteful"
  1057. else
  1058. echo "I prefer bananas myself."
  1059. endif
  1060. < In a GUI dialog, buttons are used. The layout of the buttons
  1061. depends on the 'v' flag in 'guioptions'. If it is included,
  1062. the buttons are always put vertically. Otherwise, confirm()
  1063. tries to put the buttons in one horizontal line. If they
  1064. don't fit, a vertical layout is used anyway. For some systems
  1065. the horizontal layout is always used.
  1066. Parameters: ~
  1067. • {msg} (`string`)
  1068. • {choices} (`string?`)
  1069. • {default} (`integer?`)
  1070. • {type} (`string?`)
  1071. Return: ~
  1072. (`integer`)
  1073. copy({expr}) *copy()*
  1074. Make a copy of {expr}. For Numbers and Strings this isn't
  1075. different from using {expr} directly.
  1076. When {expr} is a |List| a shallow copy is created. This means
  1077. that the original |List| can be changed without changing the
  1078. copy, and vice versa. But the items are identical, thus
  1079. changing an item changes the contents of both |Lists|.
  1080. A |Dictionary| is copied in a similar way as a |List|.
  1081. Also see |deepcopy()|.
  1082. Parameters: ~
  1083. • {expr} (`T`)
  1084. Return: ~
  1085. (`T`)
  1086. cos({expr}) *cos()*
  1087. Return the cosine of {expr}, measured in radians, as a |Float|.
  1088. {expr} must evaluate to a |Float| or a |Number|.
  1089. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1090. Examples: >vim
  1091. echo cos(100)
  1092. < 0.862319 >vim
  1093. echo cos(-4.01)
  1094. < -0.646043
  1095. Parameters: ~
  1096. • {expr} (`number`)
  1097. Return: ~
  1098. (`number`)
  1099. cosh({expr}) *cosh()*
  1100. Return the hyperbolic cosine of {expr} as a |Float| in the range
  1101. [1, inf].
  1102. {expr} must evaluate to a |Float| or a |Number|.
  1103. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1104. Examples: >vim
  1105. echo cosh(0.5)
  1106. < 1.127626 >vim
  1107. echo cosh(-0.5)
  1108. < -1.127626
  1109. Parameters: ~
  1110. • {expr} (`number`)
  1111. Return: ~
  1112. (`number`)
  1113. count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E706*
  1114. Return the number of times an item with value {expr} appears
  1115. in |String|, |List| or |Dictionary| {comp}.
  1116. If {start} is given then start with the item with this index.
  1117. {start} can only be used with a |List|.
  1118. When {ic} is given and it's |TRUE| then case is ignored.
  1119. When {comp} is a string then the number of not overlapping
  1120. occurrences of {expr} is returned. Zero is returned when
  1121. {expr} is an empty string.
  1122. Parameters: ~
  1123. • {comp} (`string|table|any[]`)
  1124. • {expr} (`any`)
  1125. • {ic} (`boolean?`)
  1126. • {start} (`integer?`)
  1127. Return: ~
  1128. (`integer`)
  1129. ctxget([{index}]) *ctxget()*
  1130. Returns a |Dictionary| representing the |context| at {index}
  1131. from the top of the |context-stack| (see |context-dict|).
  1132. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1133. Parameters: ~
  1134. • {index} (`integer?`)
  1135. Return: ~
  1136. (`table`)
  1137. ctxpop() *ctxpop()*
  1138. Pops and restores the |context| at the top of the
  1139. |context-stack|.
  1140. Return: ~
  1141. (`any`)
  1142. ctxpush([{types}]) *ctxpush()*
  1143. Pushes the current editor state (|context|) on the
  1144. |context-stack|.
  1145. If {types} is given and is a |List| of |String|s, it specifies
  1146. which |context-types| to include in the pushed context.
  1147. Otherwise, all context types are included.
  1148. Parameters: ~
  1149. • {types} (`string[]?`)
  1150. Return: ~
  1151. (`any`)
  1152. ctxset({context} [, {index}]) *ctxset()*
  1153. Sets the |context| at {index} from the top of the
  1154. |context-stack| to that represented by {context}.
  1155. {context} is a Dictionary with context data (|context-dict|).
  1156. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1157. Parameters: ~
  1158. • {context} (`table`)
  1159. • {index} (`integer?`)
  1160. Return: ~
  1161. (`integer`)
  1162. ctxsize() *ctxsize()*
  1163. Returns the size of the |context-stack|.
  1164. Return: ~
  1165. (`any`)
  1166. cursor({lnum}, {col} [, {off}]) *cursor()*
  1167. cursor({list})
  1168. Positions the cursor at the column (byte count) {col} in the
  1169. line {lnum}. The first column is one.
  1170. When there is one argument {list} this is used as a |List|
  1171. with two, three or four item:
  1172. [{lnum}, {col}]
  1173. [{lnum}, {col}, {off}]
  1174. [{lnum}, {col}, {off}, {curswant}]
  1175. This is like the return value of |getpos()| or |getcurpos()|,
  1176. but without the first item.
  1177. To position the cursor using {col} as the character count, use
  1178. |setcursorcharpos()|.
  1179. Does not change the jumplist.
  1180. {lnum} is used like with |getline()|, except that if {lnum} is
  1181. zero, the cursor will stay in the current line.
  1182. If {lnum} is greater than the number of lines in the buffer,
  1183. the cursor will be positioned at the last line in the buffer.
  1184. If {col} is greater than the number of bytes in the line,
  1185. the cursor will be positioned at the last character in the
  1186. line.
  1187. If {col} is zero, the cursor will stay in the current column.
  1188. If {curswant} is given it is used to set the preferred column
  1189. for vertical movement. Otherwise {col} is used.
  1190. When 'virtualedit' is used {off} specifies the offset in
  1191. screen columns from the start of the character. E.g., a
  1192. position within a <Tab> or after the last character.
  1193. Returns 0 when the position could be set, -1 otherwise.
  1194. Parameters: ~
  1195. • {list} (`integer[]`)
  1196. Return: ~
  1197. (`any`)
  1198. debugbreak({pid}) *debugbreak()*
  1199. Specifically used to interrupt a program being debugged. It
  1200. will cause process {pid} to get a SIGTRAP. Behavior for other
  1201. processes is undefined. See |terminal-debug|.
  1202. (Sends a SIGINT to a process {pid} other than MS-Windows)
  1203. Returns |TRUE| if successfully interrupted the program.
  1204. Otherwise returns |FALSE|.
  1205. Parameters: ~
  1206. • {pid} (`integer`)
  1207. Return: ~
  1208. (`any`)
  1209. deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
  1210. Make a copy of {expr}. For Numbers and Strings this isn't
  1211. different from using {expr} directly.
  1212. When {expr} is a |List| a full copy is created. This means
  1213. that the original |List| can be changed without changing the
  1214. copy, and vice versa. When an item is a |List|, a copy for it
  1215. is made, recursively. Thus changing an item in the copy does
  1216. not change the contents of the original |List|.
  1217. When {noref} is omitted or zero a contained |List| or
  1218. |Dictionary| is only copied once. All references point to
  1219. this single copy. With {noref} set to 1 every occurrence of a
  1220. |List| or |Dictionary| results in a new copy. This also means
  1221. that a cyclic reference causes deepcopy() to fail.
  1222. *E724*
  1223. Nesting is possible up to 100 levels. When there is an item
  1224. that refers back to a higher level making a deep copy with
  1225. {noref} set to 1 will fail.
  1226. Also see |copy()|.
  1227. Parameters: ~
  1228. • {expr} (`T`)
  1229. • {noref} (`boolean?`)
  1230. Return: ~
  1231. (`T`)
  1232. delete({fname} [, {flags}]) *delete()*
  1233. Without {flags} or with {flags} empty: Deletes the file by the
  1234. name {fname}.
  1235. This also works when {fname} is a symbolic link. The symbolic
  1236. link itself is deleted, not what it points to.
  1237. When {flags} is "d": Deletes the directory by the name
  1238. {fname}. This fails when directory {fname} is not empty.
  1239. When {flags} is "rf": Deletes the directory by the name
  1240. {fname} and everything in it, recursively. BE CAREFUL!
  1241. Note: on MS-Windows it is not possible to delete a directory
  1242. that is being used.
  1243. The result is a Number, which is 0/false if the delete
  1244. operation was successful and -1/true when the deletion failed
  1245. or partly failed.
  1246. Parameters: ~
  1247. • {fname} (`string`)
  1248. • {flags} (`string?`)
  1249. Return: ~
  1250. (`integer`)
  1251. deletebufline({buf}, {first} [, {last}]) *deletebufline()*
  1252. Delete lines {first} to {last} (inclusive) from buffer {buf}.
  1253. If {last} is omitted then delete line {first} only.
  1254. On success 0 is returned, on failure 1 is returned.
  1255. This function works only for loaded buffers. First call
  1256. |bufload()| if needed.
  1257. For the use of {buf}, see |bufname()| above.
  1258. {first} and {last} are used like with |getline()|. Note that
  1259. when using |line()| this refers to the current buffer. Use "$"
  1260. to refer to the last line in buffer {buf}.
  1261. Parameters: ~
  1262. • {buf} (`integer|string`)
  1263. • {first} (`integer|string`)
  1264. • {last} (`integer|string?`)
  1265. Return: ~
  1266. (`any`)
  1267. dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
  1268. Adds a watcher to a dictionary. A dictionary watcher is
  1269. identified by three components:
  1270. - A dictionary({dict});
  1271. - A key pattern({pattern}).
  1272. - A function({callback}).
  1273. After this is called, every change on {dict} and on keys
  1274. matching {pattern} will result in {callback} being invoked.
  1275. For example, to watch all global variables: >vim
  1276. silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
  1277. function! OnDictChanged(d,k,z)
  1278. echomsg string(a:k) string(a:z)
  1279. endfunction
  1280. call dictwatcheradd(g:, '*', 'OnDictChanged')
  1281. <
  1282. For now {pattern} only accepts very simple patterns that can
  1283. contain a "*" at the end of the string, in which case it will
  1284. match every key that begins with the substring before the "*".
  1285. That means if "*" is not the last character of {pattern}, only
  1286. keys that are exactly equal as {pattern} will be matched.
  1287. The {callback} receives three arguments:
  1288. - The dictionary being watched.
  1289. - The key which changed.
  1290. - A dictionary containing the new and old values for the key.
  1291. The type of change can be determined by examining the keys
  1292. present on the third argument:
  1293. - If contains both `old` and `new`, the key was updated.
  1294. - If it contains only `new`, the key was added.
  1295. - If it contains only `old`, the key was deleted.
  1296. This function can be used by plugins to implement options with
  1297. validation and parsing logic.
  1298. Parameters: ~
  1299. • {dict} (`table`)
  1300. • {pattern} (`string`)
  1301. • {callback} (`function`)
  1302. Return: ~
  1303. (`any`)
  1304. dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()*
  1305. Removes a watcher added with |dictwatcheradd()|. All three
  1306. arguments must match the ones passed to |dictwatcheradd()| in
  1307. order for the watcher to be successfully deleted.
  1308. Parameters: ~
  1309. • {dict} (`any`)
  1310. • {pattern} (`string`)
  1311. • {callback} (`function`)
  1312. Return: ~
  1313. (`any`)
  1314. did_filetype() *did_filetype()*
  1315. Returns |TRUE| when autocommands are being executed and the
  1316. FileType event has been triggered at least once. Can be used
  1317. to avoid triggering the FileType event again in the scripts
  1318. that detect the file type. |FileType|
  1319. Returns |FALSE| when `:setf FALLBACK` was used.
  1320. When editing another file, the counter is reset, thus this
  1321. really checks if the FileType event has been triggered for the
  1322. current buffer. This allows an autocommand that starts
  1323. editing another buffer to set 'filetype' and load a syntax
  1324. file.
  1325. Return: ~
  1326. (`integer`)
  1327. diff_filler({lnum}) *diff_filler()*
  1328. Returns the number of filler lines above line {lnum}.
  1329. These are the lines that were inserted at this point in
  1330. another diff'ed window. These filler lines are shown in the
  1331. display but don't exist in the buffer.
  1332. {lnum} is used like with |getline()|. Thus "." is the current
  1333. line, "'m" mark m, etc.
  1334. Returns 0 if the current window is not in diff mode.
  1335. Parameters: ~
  1336. • {lnum} (`integer`)
  1337. Return: ~
  1338. (`integer`)
  1339. diff_hlID({lnum}, {col}) *diff_hlID()*
  1340. Returns the highlight ID for diff mode at line {lnum} column
  1341. {col} (byte index). When the current line does not have a
  1342. diff change zero is returned.
  1343. {lnum} is used like with |getline()|. Thus "." is the current
  1344. line, "'m" mark m, etc.
  1345. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  1346. line.
  1347. The highlight ID can be used with |synIDattr()| to obtain
  1348. syntax information about the highlighting.
  1349. Parameters: ~
  1350. • {lnum} (`integer`)
  1351. • {col} (`integer`)
  1352. Return: ~
  1353. (`any`)
  1354. digraph_get({chars}) *digraph_get()* *E1214*
  1355. Return the digraph of {chars}. This should be a string with
  1356. exactly two characters. If {chars} are not just two
  1357. characters, or the digraph of {chars} does not exist, an error
  1358. is given and an empty string is returned.
  1359. Also see |digraph_getlist()|.
  1360. Examples: >vim
  1361. " Get a built-in digraph
  1362. echo digraph_get('00') " Returns '∞'
  1363. " Get a user-defined digraph
  1364. call digraph_set('aa', 'あ')
  1365. echo digraph_get('aa') " Returns 'あ'
  1366. <
  1367. Parameters: ~
  1368. • {chars} (`string`)
  1369. Return: ~
  1370. (`string`)
  1371. digraph_getlist([{listall}]) *digraph_getlist()*
  1372. Return a list of digraphs. If the {listall} argument is given
  1373. and it is TRUE, return all digraphs, including the default
  1374. digraphs. Otherwise, return only user-defined digraphs.
  1375. Also see |digraph_get()|.
  1376. Examples: >vim
  1377. " Get user-defined digraphs
  1378. echo digraph_getlist()
  1379. " Get all the digraphs, including default digraphs
  1380. echo digraph_getlist(1)
  1381. <
  1382. Parameters: ~
  1383. • {listall} (`boolean?`)
  1384. Return: ~
  1385. (`string[][]`)
  1386. digraph_set({chars}, {digraph}) *digraph_set()*
  1387. Add digraph {chars} to the list. {chars} must be a string
  1388. with two characters. {digraph} is a string with one UTF-8
  1389. encoded character. *E1215*
  1390. Be careful, composing characters are NOT ignored. This
  1391. function is similar to |:digraphs| command, but useful to add
  1392. digraphs start with a white space.
  1393. The function result is v:true if |digraph| is registered. If
  1394. this fails an error message is given and v:false is returned.
  1395. If you want to define multiple digraphs at once, you can use
  1396. |digraph_setlist()|.
  1397. Example: >vim
  1398. call digraph_set(' ', 'あ')
  1399. <
  1400. Parameters: ~
  1401. • {chars} (`string`)
  1402. • {digraph} (`string`)
  1403. Return: ~
  1404. (`any`)
  1405. digraph_setlist({digraphlist}) *digraph_setlist()*
  1406. Similar to |digraph_set()| but this function can add multiple
  1407. digraphs at once. {digraphlist} is a list composed of lists,
  1408. where each list contains two strings with {chars} and
  1409. {digraph} as in |digraph_set()|. *E1216*
  1410. Example: >vim
  1411. call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
  1412. <
  1413. It is similar to the following: >vim
  1414. for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
  1415. call digraph_set(chars, digraph)
  1416. endfor
  1417. < Except that the function returns after the first error,
  1418. following digraphs will not be added.
  1419. Parameters: ~
  1420. • {digraphlist} (`table<integer,string[]>`)
  1421. Return: ~
  1422. (`any`)
  1423. empty({expr}) *empty()*
  1424. Return the Number 1 if {expr} is empty, zero otherwise.
  1425. - A |List| or |Dictionary| is empty when it does not have any
  1426. items.
  1427. - A |String| is empty when its length is zero.
  1428. - A |Number| and |Float| are empty when their value is zero.
  1429. - |v:false| and |v:null| are empty, |v:true| is not.
  1430. - A |Blob| is empty when its length is zero.
  1431. Parameters: ~
  1432. • {expr} (`any`)
  1433. Return: ~
  1434. (`integer`)
  1435. environ() *environ()*
  1436. Return all of environment variables as dictionary. You can
  1437. check if an environment variable exists like this: >vim
  1438. echo has_key(environ(), 'HOME')
  1439. < Note that the variable name may be CamelCase; to ignore case
  1440. use this: >vim
  1441. echo index(keys(environ()), 'HOME', 0, 1) != -1
  1442. <
  1443. Return: ~
  1444. (`any`)
  1445. escape({string}, {chars}) *escape()*
  1446. Escape the characters in {chars} that occur in {string} with a
  1447. backslash. Example: >vim
  1448. echo escape('c:\program files\vim', ' \')
  1449. < results in: >
  1450. c:\\program\ files\\vim
  1451. < Also see |shellescape()| and |fnameescape()|.
  1452. Parameters: ~
  1453. • {string} (`string`)
  1454. • {chars} (`string`)
  1455. Return: ~
  1456. (`string`)
  1457. eval({string}) *eval()*
  1458. Evaluate {string} and return the result. Especially useful to
  1459. turn the result of |string()| back into the original value.
  1460. This works for Numbers, Floats, Strings, Blobs and composites
  1461. of them. Also works for |Funcref|s that refer to existing
  1462. functions.
  1463. Parameters: ~
  1464. • {string} (`string`)
  1465. Return: ~
  1466. (`any`)
  1467. eventhandler() *eventhandler()*
  1468. Returns 1 when inside an event handler. That is that Vim got
  1469. interrupted while waiting for the user to type a character,
  1470. e.g., when dropping a file on Vim. This means interactive
  1471. commands cannot be used. Otherwise zero is returned.
  1472. Return: ~
  1473. (`any`)
  1474. executable({expr}) *executable()*
  1475. This function checks if an executable with the name {expr}
  1476. exists. {expr} must be the name of the program without any
  1477. arguments.
  1478. executable() uses the value of $PATH and/or the normal
  1479. searchpath for programs.
  1480. *PATHEXT*
  1481. On MS-Windows the ".exe", ".bat", etc. can optionally be
  1482. included. Then the extensions in $PATHEXT are tried. Thus if
  1483. "foo.exe" does not exist, "foo.exe.bat" can be found. If
  1484. $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot
  1485. by itself can be used in $PATHEXT to try using the name
  1486. without an extension. When 'shell' looks like a Unix shell,
  1487. then the name is also tried without adding an extension.
  1488. On MS-Windows it only checks if the file exists and is not a
  1489. directory, not if it's really executable.
  1490. On MS-Windows an executable in the same directory as the Vim
  1491. executable is always found (it's added to $PATH at |startup|).
  1492. *NoDefaultCurrentDirectoryInExePath*
  1493. On MS-Windows an executable in Vim's current working directory
  1494. is also normally found, but this can be disabled by setting
  1495. the $NoDefaultCurrentDirectoryInExePath environment variable.
  1496. The result is a Number:
  1497. 1 exists
  1498. 0 does not exist
  1499. |exepath()| can be used to get the full path of an executable.
  1500. Parameters: ~
  1501. • {expr} (`string`)
  1502. Return: ~
  1503. (`0|1`)
  1504. execute({command} [, {silent}]) *execute()*
  1505. Execute {command} and capture its output.
  1506. If {command} is a |String|, returns {command} output.
  1507. If {command} is a |List|, returns concatenated outputs.
  1508. Line continuations in {command} are not recognized.
  1509. Examples: >vim
  1510. echo execute('echon "foo"')
  1511. < foo >vim
  1512. echo execute(['echon "foo"', 'echon "bar"'])
  1513. < foobar
  1514. The optional {silent} argument can have these values:
  1515. "" no `:silent` used
  1516. "silent" `:silent` used
  1517. "silent!" `:silent!` used
  1518. The default is "silent". Note that with "silent!", unlike
  1519. `:redir`, error messages are dropped.
  1520. To get a list of lines use `split()` on the result: >vim
  1521. execute('args')->split("\n")
  1522. < This function is not available in the |sandbox|.
  1523. Note: If nested, an outer execute() will not observe output of
  1524. the inner calls.
  1525. Note: Text attributes (highlights) are not captured.
  1526. To execute a command in another window than the current one
  1527. use `win_execute()`.
  1528. Parameters: ~
  1529. • {command} (`string|string[]`)
  1530. • {silent} (`''|'silent'|'silent!'?`)
  1531. Return: ~
  1532. (`string`)
  1533. exepath({expr}) *exepath()*
  1534. Returns the full path of {expr} if it is an executable and
  1535. given as a (partial or full) path or is found in $PATH.
  1536. Returns empty string otherwise.
  1537. If {expr} starts with "./" the |current-directory| is used.
  1538. Parameters: ~
  1539. • {expr} (`string`)
  1540. Return: ~
  1541. (`string`)
  1542. exists({expr}) *exists()*
  1543. The result is a Number, which is |TRUE| if {expr} is
  1544. defined, zero otherwise.
  1545. For checking for a supported feature use |has()|.
  1546. For checking if a file exists use |filereadable()|.
  1547. The {expr} argument is a string, which contains one of these:
  1548. varname internal variable (see
  1549. dict.key |internal-variables|). Also works
  1550. list[i] for |curly-braces-names|, |Dictionary|
  1551. entries, |List| items, etc.
  1552. Beware that evaluating an index may
  1553. cause an error message for an invalid
  1554. expression. E.g.: >vim
  1555. let l = [1, 2, 3]
  1556. echo exists("l[5]")
  1557. < 0 >vim
  1558. echo exists("l[xx]")
  1559. < E121: Undefined variable: xx
  1560. 0
  1561. &option-name Vim option (only checks if it exists,
  1562. not if it really works)
  1563. +option-name Vim option that works.
  1564. $ENVNAME environment variable (could also be
  1565. done by comparing with an empty
  1566. string)
  1567. `*funcname` built-in function (see |functions|)
  1568. or user defined function (see
  1569. |user-function|). Also works for a
  1570. variable that is a Funcref.
  1571. :cmdname Ex command: built-in command, user
  1572. command or command modifier |:command|.
  1573. Returns:
  1574. 1 for match with start of a command
  1575. 2 full match with a command
  1576. 3 matches several user commands
  1577. To check for a supported command
  1578. always check the return value to be 2.
  1579. :2match The |:2match| command.
  1580. :3match The |:3match| command (but you
  1581. probably should not use it, it is
  1582. reserved for internal usage)
  1583. #event autocommand defined for this event
  1584. #event#pattern autocommand defined for this event and
  1585. pattern (the pattern is taken
  1586. literally and compared to the
  1587. autocommand patterns character by
  1588. character)
  1589. #group autocommand group exists
  1590. #group#event autocommand defined for this group and
  1591. event.
  1592. #group#event#pattern
  1593. autocommand defined for this group,
  1594. event and pattern.
  1595. ##event autocommand for this event is
  1596. supported.
  1597. Examples: >vim
  1598. echo exists("&mouse")
  1599. echo exists("$HOSTNAME")
  1600. echo exists("*strftime")
  1601. echo exists("*s:MyFunc")
  1602. echo exists("*MyFunc")
  1603. echo exists("*v:lua.Func")
  1604. echo exists("bufcount")
  1605. echo exists(":Make")
  1606. echo exists("#CursorHold")
  1607. echo exists("#BufReadPre#*.gz")
  1608. echo exists("#filetypeindent")
  1609. echo exists("#filetypeindent#FileType")
  1610. echo exists("#filetypeindent#FileType#*")
  1611. echo exists("##ColorScheme")
  1612. < There must be no space between the symbol (&/$/*/#) and the
  1613. name.
  1614. There must be no extra characters after the name, although in
  1615. a few cases this is ignored. That may become stricter in the
  1616. future, thus don't count on it!
  1617. Working example: >vim
  1618. echo exists(":make")
  1619. < NOT working example: >vim
  1620. echo exists(":make install")
  1621. < Note that the argument must be a string, not the name of the
  1622. variable itself. For example: >vim
  1623. echo exists(bufcount)
  1624. < This doesn't check for existence of the "bufcount" variable,
  1625. but gets the value of "bufcount", and checks if that exists.
  1626. Parameters: ~
  1627. • {expr} (`string`)
  1628. Return: ~
  1629. (`0|1`)
  1630. exp({expr}) *exp()*
  1631. Return the exponential of {expr} as a |Float| in the range
  1632. [0, inf].
  1633. {expr} must evaluate to a |Float| or a |Number|.
  1634. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1635. Examples: >vim
  1636. echo exp(2)
  1637. < 7.389056 >vim
  1638. echo exp(-1)
  1639. < 0.367879
  1640. Parameters: ~
  1641. • {expr} (`number`)
  1642. Return: ~
  1643. (`any`)
  1644. expand({string} [, {nosuf} [, {list}]]) *expand()*
  1645. Expand wildcards and the following special keywords in
  1646. {string}. 'wildignorecase' applies.
  1647. If {list} is given and it is |TRUE|, a List will be returned.
  1648. Otherwise the result is a String and when there are several
  1649. matches, they are separated by <NL> characters.
  1650. If the expansion fails, the result is an empty string. A name
  1651. for a non-existing file is not included, unless {string} does
  1652. not start with '%', '#' or '<', see below.
  1653. When {string} starts with '%', '#' or '<', the expansion is
  1654. done like for the |cmdline-special| variables with their
  1655. associated modifiers. Here is a short overview:
  1656. % current file name
  1657. # alternate file name
  1658. #n alternate file name n
  1659. <cfile> file name under the cursor
  1660. <afile> autocmd file name
  1661. <abuf> autocmd buffer number (as a String!)
  1662. <amatch> autocmd matched name
  1663. <cexpr> C expression under the cursor
  1664. <sfile> sourced script file or function name
  1665. <slnum> sourced script line number or function
  1666. line number
  1667. <sflnum> script file line number, also when in
  1668. a function
  1669. <SID> "<SNR>123_" where "123" is the
  1670. current script ID |<SID>|
  1671. <script> sourced script file, or script file
  1672. where the current function was defined
  1673. <stack> call stack
  1674. <cword> word under the cursor
  1675. <cWORD> WORD under the cursor
  1676. <client> the {clientid} of the last received
  1677. message
  1678. Modifiers:
  1679. :p expand to full path
  1680. :h head (last path component removed)
  1681. :t tail (last path component only)
  1682. :r root (one extension removed)
  1683. :e extension only
  1684. Example: >vim
  1685. let &tags = expand("%:p:h") .. "/tags"
  1686. < Note that when expanding a string that starts with '%', '#' or
  1687. '<', any following text is ignored. This does NOT work: >vim
  1688. let doesntwork = expand("%:h.bak")
  1689. < Use this: >vim
  1690. let doeswork = expand("%:h") .. ".bak"
  1691. < Also note that expanding "<cfile>" and others only returns the
  1692. referenced file name without further expansion. If "<cfile>"
  1693. is "~/.cshrc", you need to do another expand() to have the
  1694. "~/" expanded into the path of the home directory: >vim
  1695. echo expand(expand("<cfile>"))
  1696. <
  1697. There cannot be white space between the variables and the
  1698. following modifier. The |fnamemodify()| function can be used
  1699. to modify normal file names.
  1700. When using '%' or '#', and the current or alternate file name
  1701. is not defined, an empty string is used. Using "%:p" in a
  1702. buffer with no name, results in the current directory, with a
  1703. '/' added.
  1704. When 'verbose' is set then expanding '%', '#' and <> items
  1705. will result in an error message if the argument cannot be
  1706. expanded.
  1707. When {string} does not start with '%', '#' or '<', it is
  1708. expanded like a file name is expanded on the command line.
  1709. 'suffixes' and 'wildignore' are used, unless the optional
  1710. {nosuf} argument is given and it is |TRUE|.
  1711. Names for non-existing files are included. The "**" item can
  1712. be used to search in a directory tree. For example, to find
  1713. all "README" files in the current directory and below: >vim
  1714. echo expand("**/README")
  1715. <
  1716. expand() can also be used to expand variables and environment
  1717. variables that are only known in a shell. But this can be
  1718. slow, because a shell may be used to do the expansion. See
  1719. |expr-env-expand|.
  1720. The expanded variable is still handled like a list of file
  1721. names. When an environment variable cannot be expanded, it is
  1722. left unchanged. Thus ":echo expand('$FOOBAR')" results in
  1723. "$FOOBAR".
  1724. See |glob()| for finding existing files. See |system()| for
  1725. getting the raw output of an external command.
  1726. Parameters: ~
  1727. • {string} (`string`)
  1728. • {nosuf} (`boolean?`)
  1729. • {list} (`nil|false?`)
  1730. Return: ~
  1731. (`string`)
  1732. expandcmd({string} [, {options}]) *expandcmd()*
  1733. Expand special items in String {string} like what is done for
  1734. an Ex command such as `:edit`. This expands special keywords,
  1735. like with |expand()|, and environment variables, anywhere in
  1736. {string}. "~user" and "~/path" are only expanded at the
  1737. start.
  1738. The following items are supported in the {options} Dict
  1739. argument:
  1740. errmsg If set to TRUE, error messages are displayed
  1741. if an error is encountered during expansion.
  1742. By default, error messages are not displayed.
  1743. Returns the expanded string. If an error is encountered
  1744. during expansion, the unmodified {string} is returned.
  1745. Example: >vim
  1746. echo expandcmd('make %<.o')
  1747. < >
  1748. make /path/runtime/doc/builtin.o
  1749. < >vim
  1750. echo expandcmd('make %<.o', {'errmsg': v:true})
  1751. <
  1752. Parameters: ~
  1753. • {string} (`string`)
  1754. • {options} (`table?`)
  1755. Return: ~
  1756. (`any`)
  1757. extend({expr1}, {expr2} [, {expr3}]) *extend()*
  1758. {expr1} and {expr2} must be both |Lists| or both
  1759. |Dictionaries|.
  1760. If they are |Lists|: Append {expr2} to {expr1}.
  1761. If {expr3} is given insert the items of {expr2} before the
  1762. item with index {expr3} in {expr1}. When {expr3} is zero
  1763. insert before the first item. When {expr3} is equal to
  1764. len({expr1}) then {expr2} is appended.
  1765. Examples: >vim
  1766. echo sort(extend(mylist, [7, 5]))
  1767. call extend(mylist, [2, 3], 1)
  1768. < When {expr1} is the same List as {expr2} then the number of
  1769. items copied is equal to the original length of the List.
  1770. E.g., when {expr3} is 1 you get N new copies of the first item
  1771. (where N is the original length of the List).
  1772. Use |add()| to concatenate one item to a list. To concatenate
  1773. two lists into a new list use the + operator: >vim
  1774. let newlist = [1, 2, 3] + [4, 5]
  1775. <
  1776. If they are |Dictionaries|:
  1777. Add all entries from {expr2} to {expr1}.
  1778. If a key exists in both {expr1} and {expr2} then {expr3} is
  1779. used to decide what to do:
  1780. {expr3} = "keep": keep the value of {expr1}
  1781. {expr3} = "force": use the value of {expr2}
  1782. {expr3} = "error": give an error message *E737*
  1783. When {expr3} is omitted then "force" is assumed.
  1784. {expr1} is changed when {expr2} is not empty. If necessary
  1785. make a copy of {expr1} first.
  1786. {expr2} remains unchanged.
  1787. When {expr1} is locked and {expr2} is not empty the operation
  1788. fails.
  1789. Returns {expr1}. Returns 0 on error.
  1790. Parameters: ~
  1791. • {expr1} (`table`)
  1792. • {expr2} (`table`)
  1793. • {expr3} (`table?`)
  1794. Return: ~
  1795. (`any`)
  1796. extendnew({expr1}, {expr2} [, {expr3}]) *extendnew()*
  1797. Like |extend()| but instead of adding items to {expr1} a new
  1798. List or Dictionary is created and returned. {expr1} remains
  1799. unchanged.
  1800. Parameters: ~
  1801. • {expr1} (`table`)
  1802. • {expr2} (`table`)
  1803. • {expr3} (`table?`)
  1804. Return: ~
  1805. (`any`)
  1806. feedkeys({string} [, {mode}]) *feedkeys()*
  1807. Characters in {string} are queued for processing as if they
  1808. come from a mapping or were typed by the user.
  1809. By default the string is added to the end of the typeahead
  1810. buffer, thus if a mapping is still being executed the
  1811. characters come after them. Use the 'i' flag to insert before
  1812. other characters, they will be executed next, before any
  1813. characters from a mapping.
  1814. The function does not wait for processing of keys contained in
  1815. {string}.
  1816. To include special keys into {string}, use double-quotes
  1817. and "\..." notation |expr-quote|. For example,
  1818. feedkeys("\<CR>") simulates pressing of the <Enter> key. But
  1819. feedkeys('\<CR>') pushes 5 characters.
  1820. The |<Ignore>| keycode may be used to exit the
  1821. wait-for-character without doing anything.
  1822. {mode} is a String, which can contain these character flags:
  1823. 'm' Remap keys. This is default. If {mode} is absent,
  1824. keys are remapped.
  1825. 'n' Do not remap keys.
  1826. 't' Handle keys as if typed; otherwise they are handled as
  1827. if coming from a mapping. This matters for undo,
  1828. opening folds, etc.
  1829. 'L' Lowlevel input. Other flags are not used.
  1830. 'i' Insert the string instead of appending (see above).
  1831. 'x' Execute commands until typeahead is empty. This is
  1832. similar to using ":normal!". You can call feedkeys()
  1833. several times without 'x' and then one time with 'x'
  1834. (possibly with an empty {string}) to execute all the
  1835. typeahead. Note that when Vim ends in Insert mode it
  1836. will behave as if <Esc> is typed, to avoid getting
  1837. stuck, waiting for a character to be typed before the
  1838. script continues.
  1839. Note that if you manage to call feedkeys() while
  1840. executing commands, thus calling it recursively, then
  1841. all typeahead will be consumed by the last call.
  1842. '!' When used with 'x' will not end Insert mode. Can be
  1843. used in a test when a timer is set to exit Insert mode
  1844. a little later. Useful for testing CursorHoldI.
  1845. Return value is always 0.
  1846. Parameters: ~
  1847. • {string} (`string`)
  1848. • {mode} (`string?`)
  1849. Return: ~
  1850. (`any`)
  1851. filecopy({from}, {to}) *filecopy()*
  1852. Copy the file pointed to by the name {from} to {to}. The
  1853. result is a Number, which is |TRUE| if the file was copied
  1854. successfully, and |FALSE| when it failed.
  1855. If a file with name {to} already exists, it will fail.
  1856. Note that it does not handle directories (yet).
  1857. This function is not available in the |sandbox|.
  1858. Parameters: ~
  1859. • {from} (`string`)
  1860. • {to} (`string`)
  1861. Return: ~
  1862. (`0|1`)
  1863. filereadable({file}) *filereadable()*
  1864. The result is a Number, which is |TRUE| when a file with the
  1865. name {file} exists, and can be read. If {file} doesn't exist,
  1866. or is a directory, the result is |FALSE|. {file} is any
  1867. expression, which is used as a String.
  1868. If you don't care about the file being readable you can use
  1869. |glob()|.
  1870. {file} is used as-is, you may want to expand wildcards first: >vim
  1871. echo filereadable('~/.vimrc')
  1872. < >
  1873. 0
  1874. < >vim
  1875. echo filereadable(expand('~/.vimrc'))
  1876. < >
  1877. 1
  1878. <
  1879. Parameters: ~
  1880. • {file} (`string`)
  1881. Return: ~
  1882. (`0|1`)
  1883. filewritable({file}) *filewritable()*
  1884. The result is a Number, which is 1 when a file with the
  1885. name {file} exists, and can be written. If {file} doesn't
  1886. exist, or is not writable, the result is 0. If {file} is a
  1887. directory, and we can write to it, the result is 2.
  1888. Parameters: ~
  1889. • {file} (`string`)
  1890. Return: ~
  1891. (`0|1`)
  1892. filter({expr1}, {expr2}) *filter()*
  1893. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  1894. For each item in {expr1} evaluate {expr2} and when the result
  1895. is zero or false remove the item from the |List| or
  1896. |Dictionary|. Similarly for each byte in a |Blob| and each
  1897. character in a |String|.
  1898. {expr2} must be a |string| or |Funcref|.
  1899. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  1900. of the current item. For a |Dictionary| |v:key| has the key
  1901. of the current item and for a |List| |v:key| has the index of
  1902. the current item. For a |Blob| |v:key| has the index of the
  1903. current byte. For a |String| |v:key| has the index of the
  1904. current character.
  1905. Examples: >vim
  1906. call filter(mylist, 'v:val !~ "OLD"')
  1907. < Removes the items where "OLD" appears. >vim
  1908. call filter(mydict, 'v:key >= 8')
  1909. < Removes the items with a key below 8. >vim
  1910. call filter(var, 0)
  1911. < Removes all the items, thus clears the |List| or |Dictionary|.
  1912. Note that {expr2} is the result of expression and is then
  1913. used as an expression again. Often it is good to use a
  1914. |literal-string| to avoid having to double backslashes.
  1915. If {expr2} is a |Funcref| it must take two arguments:
  1916. 1. the key or the index of the current item.
  1917. 2. the value of the current item.
  1918. The function must return |TRUE| if the item should be kept.
  1919. Example that keeps the odd items of a list: >vim
  1920. func Odd(idx, val)
  1921. return a:idx % 2 == 1
  1922. endfunc
  1923. call filter(mylist, function('Odd'))
  1924. < It is shorter when using a |lambda|: >vim
  1925. call filter(myList, {idx, val -> idx * val <= 42})
  1926. < If you do not use "val" you can leave it out: >vim
  1927. call filter(myList, {idx -> idx % 2 == 1})
  1928. <
  1929. For a |List| and a |Dictionary| the operation is done
  1930. in-place. If you want it to remain unmodified make a copy
  1931. first: >vim
  1932. let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  1933. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  1934. or a new |Blob| or |String|.
  1935. When an error is encountered while evaluating {expr2} no
  1936. further items in {expr1} are processed.
  1937. When {expr2} is a Funcref errors inside a function are ignored,
  1938. unless it was defined with the "abort" flag.
  1939. Parameters: ~
  1940. • {expr1} (`string|table`)
  1941. • {expr2} (`string|function`)
  1942. Return: ~
  1943. (`any`)
  1944. finddir({name} [, {path} [, {count}]]) *finddir()*
  1945. Find directory {name} in {path}. Supports both downwards and
  1946. upwards recursive directory searches. See |file-searching|
  1947. for the syntax of {path}.
  1948. Returns the path of the first found match. When the found
  1949. directory is below the current directory a relative path is
  1950. returned. Otherwise a full path is returned.
  1951. If {path} is omitted or empty then 'path' is used.
  1952. If the optional {count} is given, find {count}'s occurrence of
  1953. {name} in {path} instead of the first one.
  1954. When {count} is negative return all the matches in a |List|.
  1955. Returns an empty string if the directory is not found.
  1956. This is quite similar to the ex-command `:find`.
  1957. Parameters: ~
  1958. • {name} (`string`)
  1959. • {path} (`string?`)
  1960. • {count} (`integer?`)
  1961. Return: ~
  1962. (`any`)
  1963. findfile({name} [, {path} [, {count}]]) *findfile()*
  1964. Just like |finddir()|, but find a file instead of a directory.
  1965. Uses 'suffixesadd'.
  1966. Example: >vim
  1967. echo findfile("tags.vim", ".;")
  1968. < Searches from the directory of the current file upwards until
  1969. it finds the file "tags.vim".
  1970. Parameters: ~
  1971. • {name} (`string`)
  1972. • {path} (`string?`)
  1973. • {count} (`any?`)
  1974. Return: ~
  1975. (`any`)
  1976. flatten({list} [, {maxdepth}]) *flatten()*
  1977. Flatten {list} up to {maxdepth} levels. Without {maxdepth}
  1978. the result is a |List| without nesting, as if {maxdepth} is
  1979. a very large number.
  1980. The {list} is changed in place, use |flattennew()| if you do
  1981. not want that.
  1982. *E900*
  1983. {maxdepth} means how deep in nested lists changes are made.
  1984. {list} is not modified when {maxdepth} is 0.
  1985. {maxdepth} must be positive number.
  1986. If there is an error the number zero is returned.
  1987. Example: >vim
  1988. echo flatten([1, [2, [3, 4]], 5])
  1989. < [1, 2, 3, 4, 5] >vim
  1990. echo flatten([1, [2, [3, 4]], 5], 1)
  1991. < [1, 2, [3, 4], 5]
  1992. Parameters: ~
  1993. • {list} (`any[]`)
  1994. • {maxdepth} (`integer?`)
  1995. Return: ~
  1996. (`any[]|0`)
  1997. flattennew({list} [, {maxdepth}]) *flattennew()*
  1998. Like |flatten()| but first make a copy of {list}.
  1999. Parameters: ~
  2000. • {list} (`any[]`)
  2001. • {maxdepth} (`integer?`)
  2002. Return: ~
  2003. (`any[]|0`)
  2004. float2nr({expr}) *float2nr()*
  2005. Convert {expr} to a Number by omitting the part after the
  2006. decimal point.
  2007. {expr} must evaluate to a |Float| or a |Number|.
  2008. Returns 0 if {expr} is not a |Float| or a |Number|.
  2009. When the value of {expr} is out of range for a |Number| the
  2010. result is truncated to 0x7fffffff or -0x7fffffff (or when
  2011. 64-bit Number support is enabled, 0x7fffffffffffffff or
  2012. -0x7fffffffffffffff). NaN results in -0x80000000 (or when
  2013. 64-bit Number support is enabled, -0x8000000000000000).
  2014. Examples: >vim
  2015. echo float2nr(3.95)
  2016. < 3 >vim
  2017. echo float2nr(-23.45)
  2018. < -23 >vim
  2019. echo float2nr(1.0e100)
  2020. < 2147483647 (or 9223372036854775807) >vim
  2021. echo float2nr(-1.0e150)
  2022. < -2147483647 (or -9223372036854775807) >vim
  2023. echo float2nr(1.0e-100)
  2024. < 0
  2025. Parameters: ~
  2026. • {expr} (`number`)
  2027. Return: ~
  2028. (`any`)
  2029. floor({expr}) *floor()*
  2030. Return the largest integral value less than or equal to
  2031. {expr} as a |Float| (round down).
  2032. {expr} must evaluate to a |Float| or a |Number|.
  2033. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  2034. Examples: >vim
  2035. echo floor(1.856)
  2036. < 1.0 >vim
  2037. echo floor(-5.456)
  2038. < -6.0 >vim
  2039. echo floor(4.0)
  2040. < 4.0
  2041. Parameters: ~
  2042. • {expr} (`number`)
  2043. Return: ~
  2044. (`any`)
  2045. fmod({expr1}, {expr2}) *fmod()*
  2046. Return the remainder of {expr1} / {expr2}, even if the
  2047. division is not representable. Returns {expr1} - i * {expr2}
  2048. for some integer i such that if {expr2} is non-zero, the
  2049. result has the same sign as {expr1} and magnitude less than
  2050. the magnitude of {expr2}. If {expr2} is zero, the value
  2051. returned is zero. The value returned is a |Float|.
  2052. {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  2053. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  2054. |Number|.
  2055. Examples: >vim
  2056. echo fmod(12.33, 1.22)
  2057. < 0.13 >vim
  2058. echo fmod(-12.33, 1.22)
  2059. < -0.13
  2060. Parameters: ~
  2061. • {expr1} (`number`)
  2062. • {expr2} (`number`)
  2063. Return: ~
  2064. (`any`)
  2065. fnameescape({string}) *fnameescape()*
  2066. Escape {string} for use as file name command argument. All
  2067. characters that have a special meaning, such as `'%'` and `'|'`
  2068. are escaped with a backslash.
  2069. For most systems the characters escaped are
  2070. " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
  2071. appears in a filename, it depends on the value of 'isfname'.
  2072. A leading '+' and '>' is also escaped (special after |:edit|
  2073. and |:write|). And a "-" by itself (special after |:cd|).
  2074. Returns an empty string on error.
  2075. Example: >vim
  2076. let fname = '+some str%nge|name'
  2077. exe "edit " .. fnameescape(fname)
  2078. < results in executing: >vim
  2079. edit \+some\ str\%nge\|name
  2080. <
  2081. Parameters: ~
  2082. • {string} (`string`)
  2083. Return: ~
  2084. (`string`)
  2085. fnamemodify({fname}, {mods}) *fnamemodify()*
  2086. Modify file name {fname} according to {mods}. {mods} is a
  2087. string of characters like it is used for file names on the
  2088. command line. See |filename-modifiers|.
  2089. Example: >vim
  2090. echo fnamemodify("main.c", ":p:h")
  2091. < results in: >
  2092. /home/user/vim/vim/src
  2093. < If {mods} is empty or an unsupported modifier is used then
  2094. {fname} is returned.
  2095. When {fname} is empty then with {mods} ":h" returns ".", so
  2096. that `:cd` can be used with it. This is different from
  2097. expand('%:h') without a buffer name, which returns an empty
  2098. string.
  2099. Note: Environment variables don't work in {fname}, use
  2100. |expand()| first then.
  2101. Parameters: ~
  2102. • {fname} (`string`)
  2103. • {mods} (`string`)
  2104. Return: ~
  2105. (`string`)
  2106. foldclosed({lnum}) *foldclosed()*
  2107. The result is a Number. If the line {lnum} is in a closed
  2108. fold, the result is the number of the first line in that fold.
  2109. If the line {lnum} is not in a closed fold, -1 is returned.
  2110. {lnum} is used like with |getline()|. Thus "." is the current
  2111. line, "'m" mark m, etc.
  2112. Parameters: ~
  2113. • {lnum} (`integer`)
  2114. Return: ~
  2115. (`integer`)
  2116. foldclosedend({lnum}) *foldclosedend()*
  2117. The result is a Number. If the line {lnum} is in a closed
  2118. fold, the result is the number of the last line in that fold.
  2119. If the line {lnum} is not in a closed fold, -1 is returned.
  2120. {lnum} is used like with |getline()|. Thus "." is the current
  2121. line, "'m" mark m, etc.
  2122. Parameters: ~
  2123. • {lnum} (`integer`)
  2124. Return: ~
  2125. (`integer`)
  2126. foldlevel({lnum}) *foldlevel()*
  2127. The result is a Number, which is the foldlevel of line {lnum}
  2128. in the current buffer. For nested folds the deepest level is
  2129. returned. If there is no fold at line {lnum}, zero is
  2130. returned. It doesn't matter if the folds are open or closed.
  2131. When used while updating folds (from 'foldexpr') -1 is
  2132. returned for lines where folds are still to be updated and the
  2133. foldlevel is unknown. As a special case the level of the
  2134. previous line is usually available.
  2135. {lnum} is used like with |getline()|. Thus "." is the current
  2136. line, "'m" mark m, etc.
  2137. Parameters: ~
  2138. • {lnum} (`integer`)
  2139. Return: ~
  2140. (`integer`)
  2141. foldtext() *foldtext()*
  2142. Returns a String, to be displayed for a closed fold. This is
  2143. the default function used for the 'foldtext' option and should
  2144. only be called from evaluating 'foldtext'. It uses the
  2145. |v:foldstart|, |v:foldend| and |v:folddashes| variables.
  2146. The returned string looks like this: >
  2147. +-- 45 lines: abcdef
  2148. < The number of leading dashes depends on the foldlevel. The
  2149. "45" is the number of lines in the fold. "abcdef" is the text
  2150. in the first non-blank line of the fold. Leading white space,
  2151. "//" or "/*" and the text from the 'foldmarker' and
  2152. 'commentstring' options is removed.
  2153. When used to draw the actual foldtext, the rest of the line
  2154. will be filled with the fold char from the 'fillchars'
  2155. setting.
  2156. Returns an empty string when there is no fold.
  2157. Return: ~
  2158. (`string`)
  2159. foldtextresult({lnum}) *foldtextresult()*
  2160. Returns the text that is displayed for the closed fold at line
  2161. {lnum}. Evaluates 'foldtext' in the appropriate context.
  2162. When there is no closed fold at {lnum} an empty string is
  2163. returned.
  2164. {lnum} is used like with |getline()|. Thus "." is the current
  2165. line, "'m" mark m, etc.
  2166. Useful when exporting folded text, e.g., to HTML.
  2167. Parameters: ~
  2168. • {lnum} (`integer`)
  2169. Return: ~
  2170. (`string`)
  2171. foreach({expr1}, {expr2}) *foreach()*
  2172. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  2173. For each item in {expr1} execute {expr2}. {expr1} is not
  2174. modified; its values may be, as with |:lockvar| 1. |E741|
  2175. See |map()| and |filter()| to modify {expr1}.
  2176. {expr2} must be a |string| or |Funcref|.
  2177. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  2178. of the current item. For a |Dictionary| |v:key| has the key
  2179. of the current item and for a |List| |v:key| has the index of
  2180. the current item. For a |Blob| |v:key| has the index of the
  2181. current byte. For a |String| |v:key| has the index of the
  2182. current character.
  2183. Examples: >vim
  2184. call foreach(mylist, 'let used[v:val] = v:true')
  2185. < This records the items that are in the {expr1} list.
  2186. Note that {expr2} is the result of expression and is then used
  2187. as a command. Often it is good to use a |literal-string| to
  2188. avoid having to double backslashes.
  2189. If {expr2} is a |Funcref| it must take two arguments:
  2190. 1. the key or the index of the current item.
  2191. 2. the value of the current item.
  2192. With a lambda you don't get an error if it only accepts one
  2193. argument.
  2194. If the function returns a value, it is ignored.
  2195. Returns {expr1} in all cases.
  2196. When an error is encountered while executing {expr2} no
  2197. further items in {expr1} are processed.
  2198. When {expr2} is a Funcref errors inside a function are ignored,
  2199. unless it was defined with the "abort" flag.
  2200. Parameters: ~
  2201. • {expr1} (`string|table`)
  2202. • {expr2} (`string|function`)
  2203. Return: ~
  2204. (`string|table`)
  2205. fullcommand({name}) *fullcommand()*
  2206. Get the full command name from a short abbreviated command
  2207. name; see |20.2| for details on command abbreviations.
  2208. The string argument {name} may start with a `:` and can
  2209. include a [range], these are skipped and not returned.
  2210. Returns an empty string if a command doesn't exist or if it's
  2211. ambiguous (for user-defined commands).
  2212. For example `fullcommand('s')`, `fullcommand('sub')`,
  2213. `fullcommand(':%substitute')` all return "substitute".
  2214. Parameters: ~
  2215. • {name} (`string`)
  2216. Return: ~
  2217. (`string`)
  2218. funcref({name} [, {arglist}] [, {dict}]) *funcref()*
  2219. Just like |function()|, but the returned Funcref will lookup
  2220. the function by reference, not by name. This matters when the
  2221. function {name} is redefined later.
  2222. Unlike |function()|, {name} must be an existing user function.
  2223. It only works for an autoloaded function if it has already
  2224. been loaded (to avoid mistakenly loading the autoload script
  2225. when only intending to use the function name, use |function()|
  2226. instead). {name} cannot be a builtin function.
  2227. Returns 0 on error.
  2228. Parameters: ~
  2229. • {name} (`string`)
  2230. • {arglist} (`any?`)
  2231. • {dict} (`any?`)
  2232. Return: ~
  2233. (`any`)
  2234. function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923*
  2235. Return a |Funcref| variable that refers to function {name}.
  2236. {name} can be the name of a user defined function or an
  2237. internal function.
  2238. {name} can also be a Funcref or a partial. When it is a
  2239. partial the dict stored in it will be used and the {dict}
  2240. argument is not allowed. E.g.: >vim
  2241. let FuncWithArg = function(dict.Func, [arg])
  2242. let Broken = function(dict.Func, [arg], dict)
  2243. <
  2244. When using the Funcref the function will be found by {name},
  2245. also when it was redefined later. Use |funcref()| to keep the
  2246. same function.
  2247. When {arglist} or {dict} is present this creates a partial.
  2248. That means the argument list and/or the dictionary is stored in
  2249. the Funcref and will be used when the Funcref is called.
  2250. The arguments are passed to the function in front of other
  2251. arguments, but after any argument from |method|. Example: >vim
  2252. func Callback(arg1, arg2, name)
  2253. "...
  2254. endfunc
  2255. let Partial = function('Callback', ['one', 'two'])
  2256. "...
  2257. call Partial('name')
  2258. < Invokes the function as with: >vim
  2259. call Callback('one', 'two', 'name')
  2260. < With a |method|: >vim
  2261. func Callback(one, two, three)
  2262. "...
  2263. endfunc
  2264. let Partial = function('Callback', ['two'])
  2265. "...
  2266. eval 'one'->Partial('three')
  2267. < Invokes the function as with: >vim
  2268. call Callback('one', 'two', 'three')
  2269. < The function() call can be nested to add more arguments to the
  2270. Funcref. The extra arguments are appended to the list of
  2271. arguments. Example: >vim
  2272. func Callback(arg1, arg2, name)
  2273. "...
  2274. endfunc
  2275. let Func = function('Callback', ['one'])
  2276. let Func2 = function(Func, ['two'])
  2277. "...
  2278. call Func2('name')
  2279. < Invokes the function as with: >vim
  2280. call Callback('one', 'two', 'name')
  2281. < The Dictionary is only useful when calling a "dict" function.
  2282. In that case the {dict} is passed in as "self". Example: >vim
  2283. function Callback() dict
  2284. echo "called for " .. self.name
  2285. endfunction
  2286. "...
  2287. let context = {"name": "example"}
  2288. let Func = function('Callback', context)
  2289. "...
  2290. call Func() " will echo: called for example
  2291. < The use of function() is not needed when there are no extra
  2292. arguments, these two are equivalent, if Callback() is defined
  2293. as context.Callback(): >vim
  2294. let Func = function('Callback', context)
  2295. let Func = context.Callback
  2296. < The argument list and the Dictionary can be combined: >vim
  2297. function Callback(arg1, count) dict
  2298. "...
  2299. endfunction
  2300. let context = {"name": "example"}
  2301. let Func = function('Callback', ['one'], context)
  2302. "...
  2303. call Func(500)
  2304. < Invokes the function as with: >vim
  2305. call context.Callback('one', 500)
  2306. <
  2307. Returns 0 on error.
  2308. Parameters: ~
  2309. • {name} (`string`)
  2310. • {arglist} (`any?`)
  2311. • {dict} (`any?`)
  2312. Return: ~
  2313. (`any`)
  2314. garbagecollect([{atexit}]) *garbagecollect()*
  2315. Cleanup unused |Lists| and |Dictionaries| that have circular
  2316. references.
  2317. There is hardly ever a need to invoke this function, as it is
  2318. automatically done when Vim runs out of memory or is waiting
  2319. for the user to press a key after 'updatetime'. Items without
  2320. circular references are always freed when they become unused.
  2321. This is useful if you have deleted a very big |List| and/or
  2322. |Dictionary| with circular references in a script that runs
  2323. for a long time.
  2324. When the optional {atexit} argument is one, garbage
  2325. collection will also be done when exiting Vim, if it wasn't
  2326. done before. This is useful when checking for memory leaks.
  2327. The garbage collection is not done immediately but only when
  2328. it's safe to perform. This is when waiting for the user to
  2329. type a character.
  2330. Parameters: ~
  2331. • {atexit} (`boolean?`)
  2332. Return: ~
  2333. (`any`)
  2334. get({list}, {idx} [, {default}]) *get()* *get()-list*
  2335. Get item {idx} from |List| {list}. When this item is not
  2336. available return {default}. Return zero when {default} is
  2337. omitted.
  2338. Parameters: ~
  2339. • {list} (`any[]`)
  2340. • {idx} (`integer`)
  2341. • {default} (`any?`)
  2342. Return: ~
  2343. (`any`)
  2344. get({blob}, {idx} [, {default}]) *get()-blob*
  2345. Get byte {idx} from |Blob| {blob}. When this byte is not
  2346. available return {default}. Return -1 when {default} is
  2347. omitted.
  2348. Parameters: ~
  2349. • {blob} (`string`)
  2350. • {idx} (`integer`)
  2351. • {default} (`any?`)
  2352. Return: ~
  2353. (`any`)
  2354. get({dict}, {key} [, {default}]) *get()-dict*
  2355. Get item with key {key} from |Dictionary| {dict}. When this
  2356. item is not available return {default}. Return zero when
  2357. {default} is omitted. Useful example: >vim
  2358. let val = get(g:, 'var_name', 'default')
  2359. < This gets the value of g:var_name if it exists, and uses
  2360. "default" when it does not exist.
  2361. Parameters: ~
  2362. • {dict} (`table<string,any>`)
  2363. • {key} (`string`)
  2364. • {default} (`any?`)
  2365. Return: ~
  2366. (`any`)
  2367. get({func}, {what}) *get()-func*
  2368. Get item {what} from |Funcref| {func}. Possible values for
  2369. {what} are:
  2370. "name" The function name
  2371. "func" The function
  2372. "dict" The dictionary
  2373. "args" The list with arguments
  2374. "arity" A dictionary with information about the number of
  2375. arguments accepted by the function (minus the
  2376. {arglist}) with the following fields:
  2377. required the number of positional arguments
  2378. optional the number of optional arguments,
  2379. in addition to the required ones
  2380. varargs |TRUE| if the function accepts a
  2381. variable number of arguments |...|
  2382. Note: There is no error, if the {arglist} of
  2383. the Funcref contains more arguments than the
  2384. Funcref expects, it's not validated.
  2385. Returns zero on error.
  2386. Parameters: ~
  2387. • {func} (`function`)
  2388. • {what} (`string`)
  2389. Return: ~
  2390. (`any`)
  2391. getbufinfo([{buf}]) *getbufinfo()*
  2392. getbufinfo([{dict}])
  2393. Get information about buffers as a List of Dictionaries.
  2394. Without an argument information about all the buffers is
  2395. returned.
  2396. When the argument is a |Dictionary| only the buffers matching
  2397. the specified criteria are returned. The following keys can
  2398. be specified in {dict}:
  2399. buflisted include only listed buffers.
  2400. bufloaded include only loaded buffers.
  2401. bufmodified include only modified buffers.
  2402. Otherwise, {buf} specifies a particular buffer to return
  2403. information for. For the use of {buf}, see |bufname()|
  2404. above. If the buffer is found the returned List has one item.
  2405. Otherwise the result is an empty list.
  2406. Each returned List item is a dictionary with the following
  2407. entries:
  2408. bufnr Buffer number.
  2409. changed TRUE if the buffer is modified.
  2410. changedtick Number of changes made to the buffer.
  2411. command TRUE if the buffer belongs to the
  2412. command-line window |cmdwin|.
  2413. hidden TRUE if the buffer is hidden.
  2414. lastused Timestamp in seconds, like
  2415. |localtime()|, when the buffer was
  2416. last used.
  2417. listed TRUE if the buffer is listed.
  2418. lnum Line number used for the buffer when
  2419. opened in the current window.
  2420. Only valid if the buffer has been
  2421. displayed in the window in the past.
  2422. If you want the line number of the
  2423. last known cursor position in a given
  2424. window, use |line()|: >vim
  2425. echo line('.', {winid})
  2426. <
  2427. linecount Number of lines in the buffer (only
  2428. valid when loaded)
  2429. loaded TRUE if the buffer is loaded.
  2430. name Full path to the file in the buffer.
  2431. signs List of signs placed in the buffer.
  2432. Each list item is a dictionary with
  2433. the following fields:
  2434. id sign identifier
  2435. lnum line number
  2436. name sign name
  2437. variables A reference to the dictionary with
  2438. buffer-local variables.
  2439. windows List of |window-ID|s that display this
  2440. buffer
  2441. Examples: >vim
  2442. for buf in getbufinfo()
  2443. echo buf.name
  2444. endfor
  2445. for buf in getbufinfo({'buflisted':1})
  2446. if buf.changed
  2447. " ....
  2448. endif
  2449. endfor
  2450. <
  2451. To get buffer-local options use: >vim
  2452. getbufvar({bufnr}, '&option_name')
  2453. <
  2454. Parameters: ~
  2455. • {dict} (`vim.fn.getbufinfo.dict?`)
  2456. Return: ~
  2457. (`vim.fn.getbufinfo.ret.item[]`)
  2458. getbufline({buf}, {lnum} [, {end}]) *getbufline()*
  2459. Return a |List| with the lines starting from {lnum} to {end}
  2460. (inclusive) in the buffer {buf}. If {end} is omitted, a
  2461. |List| with only the line {lnum} is returned. See
  2462. `getbufoneline()` for only getting the line.
  2463. For the use of {buf}, see |bufname()| above.
  2464. For {lnum} and {end} "$" can be used for the last line of the
  2465. buffer. Otherwise a number must be used.
  2466. When {lnum} is smaller than 1 or bigger than the number of
  2467. lines in the buffer, an empty |List| is returned.
  2468. When {end} is greater than the number of lines in the buffer,
  2469. it is treated as {end} is set to the number of lines in the
  2470. buffer. When {end} is before {lnum} an empty |List| is
  2471. returned.
  2472. This function works only for loaded buffers. For unloaded and
  2473. non-existing buffers, an empty |List| is returned.
  2474. Example: >vim
  2475. let lines = getbufline(bufnr("myfile"), 1, "$")
  2476. <
  2477. Parameters: ~
  2478. • {buf} (`integer|string`)
  2479. • {lnum} (`integer`)
  2480. • {end} (`integer?`)
  2481. Return: ~
  2482. (`string[]`)
  2483. getbufoneline({buf}, {lnum}) *getbufoneline()*
  2484. Just like `getbufline()` but only get one line and return it
  2485. as a string.
  2486. Parameters: ~
  2487. • {buf} (`integer|string`)
  2488. • {lnum} (`integer`)
  2489. Return: ~
  2490. (`string`)
  2491. getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
  2492. The result is the value of option or local buffer variable
  2493. {varname} in buffer {buf}. Note that the name without "b:"
  2494. must be used.
  2495. The {varname} argument is a string.
  2496. When {varname} is empty returns a |Dictionary| with all the
  2497. buffer-local variables.
  2498. When {varname} is equal to "&" returns a |Dictionary| with all
  2499. the buffer-local options.
  2500. Otherwise, when {varname} starts with "&" returns the value of
  2501. a buffer-local option.
  2502. This also works for a global or buffer-local option, but it
  2503. doesn't work for a global variable, window-local variable or
  2504. window-local option.
  2505. For the use of {buf}, see |bufname()| above.
  2506. When the buffer or variable doesn't exist {def} or an empty
  2507. string is returned, there is no error message.
  2508. Examples: >vim
  2509. let bufmodified = getbufvar(1, "&mod")
  2510. echo "todo myvar = " .. getbufvar("todo", "myvar")
  2511. Parameters: ~
  2512. • {buf} (`integer|string`)
  2513. • {varname} (`string`)
  2514. • {def} (`any?`)
  2515. Return: ~
  2516. (`any`)
  2517. getcellwidths() *getcellwidths()*
  2518. Returns a |List| of cell widths of character ranges overridden
  2519. by |setcellwidths()|. The format is equal to the argument of
  2520. |setcellwidths()|. If no character ranges have their cell
  2521. widths overridden, an empty List is returned.
  2522. Return: ~
  2523. (`any`)
  2524. getchangelist([{buf}]) *getchangelist()*
  2525. Returns the |changelist| for the buffer {buf}. For the use
  2526. of {buf}, see |bufname()| above. If buffer {buf} doesn't
  2527. exist, an empty list is returned.
  2528. The returned list contains two entries: a list with the change
  2529. locations and the current position in the list. Each
  2530. entry in the change list is a dictionary with the following
  2531. entries:
  2532. col column number
  2533. coladd column offset for 'virtualedit'
  2534. lnum line number
  2535. If buffer {buf} is the current buffer, then the current
  2536. position refers to the position in the list. For other
  2537. buffers, it is set to the length of the list.
  2538. Parameters: ~
  2539. • {buf} (`integer|string?`)
  2540. Return: ~
  2541. (`table[]`)
  2542. getchar([{expr}]) *getchar()*
  2543. Get a single character from the user or input stream.
  2544. If {expr} is omitted, wait until a character is available.
  2545. If {expr} is 0, only get a character when one is available.
  2546. Return zero otherwise.
  2547. If {expr} is 1, only check if a character is available, it is
  2548. not consumed. Return zero if no character available.
  2549. If you prefer always getting a string use |getcharstr()|.
  2550. Without {expr} and when {expr} is 0 a whole character or
  2551. special key is returned. If it is a single character, the
  2552. result is a Number. Use |nr2char()| to convert it to a String.
  2553. Otherwise a String is returned with the encoded character.
  2554. For a special key it's a String with a sequence of bytes
  2555. starting with 0x80 (decimal: 128). This is the same value as
  2556. the String "\<Key>", e.g., "\<Left>". The returned value is
  2557. also a String when a modifier (shift, control, alt) was used
  2558. that is not included in the character.
  2559. When {expr} is 0 and Esc is typed, there will be a short delay
  2560. while Vim waits to see if this is the start of an escape
  2561. sequence.
  2562. When {expr} is 1 only the first byte is returned. For a
  2563. one-byte character it is the character itself as a number.
  2564. Use nr2char() to convert it to a String.
  2565. Use getcharmod() to obtain any additional modifiers.
  2566. When the user clicks a mouse button, the mouse event will be
  2567. returned. The position can then be found in |v:mouse_col|,
  2568. |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
  2569. |getmousepos()| can also be used. Mouse move events will be
  2570. ignored.
  2571. This example positions the mouse as it would normally happen: >vim
  2572. let c = getchar()
  2573. if c == "\<LeftMouse>" && v:mouse_win > 0
  2574. exe v:mouse_win .. "wincmd w"
  2575. exe v:mouse_lnum
  2576. exe "normal " .. v:mouse_col .. "|"
  2577. endif
  2578. <
  2579. There is no prompt, you will somehow have to make clear to the
  2580. user that a character has to be typed. The screen is not
  2581. redrawn, e.g. when resizing the window.
  2582. There is no mapping for the character.
  2583. Key codes are replaced, thus when the user presses the <Del>
  2584. key you get the code for the <Del> key, not the raw character
  2585. sequence. Examples: >vim
  2586. getchar() == "\<Del>"
  2587. getchar() == "\<S-Left>"
  2588. < This example redefines "f" to ignore case: >vim
  2589. nmap f :call FindChar()<CR>
  2590. function FindChar()
  2591. let c = nr2char(getchar())
  2592. while col('.') < col('$') - 1
  2593. normal l
  2594. if getline('.')[col('.') - 1] ==? c
  2595. break
  2596. endif
  2597. endwhile
  2598. endfunction
  2599. <
  2600. Parameters: ~
  2601. • {expr} (`0|1?`)
  2602. Return: ~
  2603. (`integer`)
  2604. getcharmod() *getcharmod()*
  2605. The result is a Number which is the state of the modifiers for
  2606. the last obtained character with getchar() or in another way.
  2607. These values are added together:
  2608. 2 shift
  2609. 4 control
  2610. 8 alt (meta)
  2611. 16 meta (when it's different from ALT)
  2612. 32 mouse double click
  2613. 64 mouse triple click
  2614. 96 mouse quadruple click (== 32 + 64)
  2615. 128 command (Mac) or super
  2616. Only the modifiers that have not been included in the
  2617. character itself are obtained. Thus Shift-a results in "A"
  2618. without a modifier. Returns 0 if no modifiers are used.
  2619. Return: ~
  2620. (`integer`)
  2621. getcharpos({expr}) *getcharpos()*
  2622. Get the position for String {expr}. Same as |getpos()| but the
  2623. column number in the returned List is a character index
  2624. instead of a byte index.
  2625. If |getpos()| returns a very large column number, equal to
  2626. |v:maxcol|, then getcharpos() will return the character index
  2627. of the last character.
  2628. Example:
  2629. With the cursor on '세' in line 5 with text "여보세요": >vim
  2630. getcharpos('.') returns [0, 5, 3, 0]
  2631. getpos('.') returns [0, 5, 7, 0]
  2632. <
  2633. Parameters: ~
  2634. • {expr} (`string`)
  2635. Return: ~
  2636. (`integer[]`)
  2637. getcharsearch() *getcharsearch()*
  2638. Return the current character search information as a {dict}
  2639. with the following entries:
  2640. char character previously used for a character
  2641. search (|t|, |f|, |T|, or |F|); empty string
  2642. if no character search has been performed
  2643. forward direction of character search; 1 for forward,
  2644. 0 for backward
  2645. until type of character search; 1 for a |t| or |T|
  2646. character search, 0 for an |f| or |F|
  2647. character search
  2648. This can be useful to always have |;| and |,| search
  2649. forward/backward regardless of the direction of the previous
  2650. character search: >vim
  2651. nnoremap <expr> ; getcharsearch().forward ? ';' : ','
  2652. nnoremap <expr> , getcharsearch().forward ? ',' : ';'
  2653. < Also see |setcharsearch()|.
  2654. Return: ~
  2655. (`table`)
  2656. getcharstr([{expr}]) *getcharstr()*
  2657. Get a single character from the user or input stream as a
  2658. string.
  2659. If {expr} is omitted, wait until a character is available.
  2660. If {expr} is 0 or false, only get a character when one is
  2661. available. Return an empty string otherwise.
  2662. If {expr} is 1 or true, only check if a character is
  2663. available, it is not consumed. Return an empty string
  2664. if no character is available.
  2665. Otherwise this works like |getchar()|, except that a number
  2666. result is converted to a string.
  2667. Parameters: ~
  2668. • {expr} (`0|1?`)
  2669. Return: ~
  2670. (`string`)
  2671. getcmdcomplpat() *getcmdcomplpat()*
  2672. Return completion pattern of the current command-line.
  2673. Only works when the command line is being edited, thus
  2674. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2675. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2676. |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
  2677. Returns an empty string when completion is not defined.
  2678. Return: ~
  2679. (`string`)
  2680. getcmdcompltype() *getcmdcompltype()*
  2681. Return the type of the current command-line completion.
  2682. Only works when the command line is being edited, thus
  2683. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2684. See |:command-completion| for the return string.
  2685. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2686. |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
  2687. Returns an empty string when completion is not defined.
  2688. Return: ~
  2689. (`string`)
  2690. getcmdline() *getcmdline()*
  2691. Return the current command-line input. Only works when the
  2692. command line is being edited, thus requires use of
  2693. |c_CTRL-\_e| or |c_CTRL-R_=|.
  2694. Example: >vim
  2695. cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
  2696. < Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
  2697. |getcmdprompt()| and |setcmdline()|.
  2698. Returns an empty string when entering a password or using
  2699. |inputsecret()|.
  2700. Return: ~
  2701. (`string`)
  2702. getcmdpos() *getcmdpos()*
  2703. Return the position of the cursor in the command line as a
  2704. byte count. The first column is 1.
  2705. Only works when editing the command line, thus requires use of
  2706. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2707. Returns 0 otherwise.
  2708. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2709. |getcmdprompt()| and |setcmdline()|.
  2710. Return: ~
  2711. (`integer`)
  2712. getcmdprompt() *getcmdprompt()*
  2713. Return the current command-line prompt when using functions
  2714. like |input()| or |confirm()|.
  2715. Only works when the command line is being edited, thus
  2716. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2717. Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
  2718. |setcmdpos()| and |setcmdline()|.
  2719. Return: ~
  2720. (`string`)
  2721. getcmdscreenpos() *getcmdscreenpos()*
  2722. Return the screen position of the cursor in the command line
  2723. as a byte count. The first column is 1.
  2724. Instead of |getcmdpos()|, it adds the prompt position.
  2725. Only works when editing the command line, thus requires use of
  2726. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2727. Returns 0 otherwise.
  2728. Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
  2729. |setcmdline()|.
  2730. Return: ~
  2731. (`integer`)
  2732. getcmdtype() *getcmdtype()*
  2733. Return the current command-line type. Possible return values
  2734. are:
  2735. : normal Ex command
  2736. > debug mode command |debug-mode|
  2737. / forward search command
  2738. ? backward search command
  2739. @ |input()| command
  2740. `-` |:insert| or |:append| command
  2741. = |i_CTRL-R_=|
  2742. Only works when editing the command line, thus requires use of
  2743. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2744. Returns an empty string otherwise.
  2745. Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  2746. Return: ~
  2747. (`':'|'>'|'/'|'?'|'@'|'-'|'='`)
  2748. getcmdwintype() *getcmdwintype()*
  2749. Return the current |command-line-window| type. Possible return
  2750. values are the same as |getcmdtype()|. Returns an empty string
  2751. when not in the command-line window.
  2752. Return: ~
  2753. (`':'|'>'|'/'|'?'|'@'|'-'|'='`)
  2754. getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
  2755. Return a list of command-line completion matches. The String
  2756. {type} argument specifies what for. The following completion
  2757. types are supported:
  2758. arglist file names in argument list
  2759. augroup autocmd groups
  2760. buffer buffer names
  2761. breakpoint |:breakadd| and |:breakdel| suboptions
  2762. cmdline |cmdline-completion| result
  2763. color color schemes
  2764. command Ex command
  2765. compiler compilers
  2766. custom,{func} custom completion, defined via {func}
  2767. customlist,{func} custom completion, defined via {func}
  2768. diff_buffer |:diffget| and |:diffput| completion
  2769. dir directory names
  2770. dir_in_path directory names in |'cdpath'|
  2771. environment environment variable names
  2772. event autocommand events
  2773. expression Vim expression
  2774. file file and directory names
  2775. file_in_path file and directory names in |'path'|
  2776. filetype filetype names |'filetype'|
  2777. function function name
  2778. help help subjects
  2779. highlight highlight groups
  2780. history |:history| suboptions
  2781. keymap keyboard mappings
  2782. locale locale names (as output of locale -a)
  2783. mapclear buffer argument
  2784. mapping mapping name
  2785. menu menus
  2786. messages |:messages| suboptions
  2787. option options
  2788. packadd optional package |pack-add| names
  2789. runtime |:runtime| completion
  2790. scriptnames sourced script names |:scriptnames|
  2791. shellcmd Shell command
  2792. shellcmdline Shell command line with filename arguments
  2793. sign |:sign| suboptions
  2794. syntax syntax file names |'syntax'|
  2795. syntime |:syntime| suboptions
  2796. tag tags
  2797. tag_listfiles tags, file names
  2798. user user names
  2799. var user variables
  2800. If {pat} is an empty string, then all the matches are
  2801. returned. Otherwise only items matching {pat} are returned.
  2802. See |wildcards| for the use of special characters in {pat}.
  2803. If the optional {filtered} flag is set to 1, then 'wildignore'
  2804. is applied to filter the results. Otherwise all the matches
  2805. are returned. The 'wildignorecase' option always applies.
  2806. If the 'wildoptions' option contains "fuzzy", then fuzzy
  2807. matching is used to get the completion matches. Otherwise
  2808. regular expression matching is used. Thus this function
  2809. follows the user preference, what happens on the command line.
  2810. If you do not want this you can make 'wildoptions' empty
  2811. before calling getcompletion() and restore it afterwards.
  2812. If {type} is "cmdline", then the |cmdline-completion| result is
  2813. returned. For example, to complete the possible values after
  2814. a ":call" command: >vim
  2815. echo getcompletion('call ', 'cmdline')
  2816. <
  2817. If there are no matches, an empty list is returned. An
  2818. invalid value for {type} produces an error.
  2819. Parameters: ~
  2820. • {pat} (`string`)
  2821. • {type} (`string`)
  2822. • {filtered} (`boolean?`)
  2823. Return: ~
  2824. (`string[]`)
  2825. getcurpos([{winid}]) *getcurpos()*
  2826. Get the position of the cursor. This is like getpos('.'), but
  2827. includes an extra "curswant" item in the list:
  2828. [0, lnum, col, off, curswant] ~
  2829. The "curswant" number is the preferred column when moving the
  2830. cursor vertically. After |$| command it will be a very large
  2831. number equal to |v:maxcol|. Also see |getcursorcharpos()| and
  2832. |getpos()|.
  2833. The first "bufnum" item is always zero. The byte position of
  2834. the cursor is returned in "col". To get the character
  2835. position, use |getcursorcharpos()|.
  2836. The optional {winid} argument can specify the window. It can
  2837. be the window number or the |window-ID|. The last known
  2838. cursor position is returned, this may be invalid for the
  2839. current value of the buffer if it is not the current window.
  2840. If {winid} is invalid a list with zeroes is returned.
  2841. This can be used to save and restore the cursor position: >vim
  2842. let save_cursor = getcurpos()
  2843. MoveTheCursorAround
  2844. call setpos('.', save_cursor)
  2845. < Note that this only works within the window. See
  2846. |winrestview()| for restoring more state.
  2847. Parameters: ~
  2848. • {winid} (`integer?`)
  2849. Return: ~
  2850. (`any`)
  2851. getcursorcharpos([{winid}]) *getcursorcharpos()*
  2852. Same as |getcurpos()| but the column number in the returned
  2853. List is a character index instead of a byte index.
  2854. Example:
  2855. With the cursor on '보' in line 3 with text "여보세요": >vim
  2856. getcursorcharpos() " returns [0, 3, 2, 0, 3]
  2857. getcurpos() " returns [0, 3, 4, 0, 3]
  2858. <
  2859. Parameters: ~
  2860. • {winid} (`integer?`)
  2861. Return: ~
  2862. (`any`)
  2863. getcwd([{winnr} [, {tabnr}]]) *getcwd()*
  2864. With no arguments, returns the name of the effective
  2865. |current-directory|. With {winnr} or {tabnr} the working
  2866. directory of that scope is returned, and 'autochdir' is
  2867. ignored.
  2868. Tabs and windows are identified by their respective numbers,
  2869. 0 means current tab or window. Missing tab number implies 0.
  2870. Thus the following are equivalent: >vim
  2871. getcwd(0)
  2872. getcwd(0, 0)
  2873. < If {winnr} is -1 it is ignored, only the tab is resolved.
  2874. {winnr} can be the window number or the |window-ID|.
  2875. If both {winnr} and {tabnr} are -1 the global working
  2876. directory is returned.
  2877. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  2878. Parameters: ~
  2879. • {winnr} (`integer?`)
  2880. • {tabnr} (`integer?`)
  2881. Return: ~
  2882. (`string`)
  2883. getenv({name}) *getenv()*
  2884. Return the value of environment variable {name}. The {name}
  2885. argument is a string, without a leading '$'. Example: >vim
  2886. myHome = getenv('HOME')
  2887. < When the variable does not exist |v:null| is returned. That
  2888. is different from a variable set to an empty string.
  2889. See also |expr-env|.
  2890. Parameters: ~
  2891. • {name} (`string`)
  2892. Return: ~
  2893. (`string`)
  2894. getfontname([{name}]) *getfontname()*
  2895. Without an argument returns the name of the normal font being
  2896. used. Like what is used for the Normal highlight group
  2897. |hl-Normal|.
  2898. With an argument a check is done whether String {name} is a
  2899. valid font name. If not then an empty string is returned.
  2900. Otherwise the actual font name is returned, or {name} if the
  2901. GUI does not support obtaining the real name.
  2902. Only works when the GUI is running, thus not in your vimrc or
  2903. gvimrc file. Use the |GUIEnter| autocommand to use this
  2904. function just after the GUI has started.
  2905. Parameters: ~
  2906. • {name} (`string?`)
  2907. Return: ~
  2908. (`string`)
  2909. getfperm({fname}) *getfperm()*
  2910. The result is a String, which is the read, write, and execute
  2911. permissions of the given file {fname}.
  2912. If {fname} does not exist or its directory cannot be read, an
  2913. empty string is returned.
  2914. The result is of the form "rwxrwxrwx", where each group of
  2915. "rwx" flags represent, in turn, the permissions of the owner
  2916. of the file, the group the file belongs to, and other users.
  2917. If a user does not have a given permission the flag for this
  2918. is replaced with the string "-". Examples: >vim
  2919. echo getfperm("/etc/passwd")
  2920. echo getfperm(expand("~/.config/nvim/init.vim"))
  2921. < This will hopefully (from a security point of view) display
  2922. the string "rw-r--r--" or even "rw-------".
  2923. For setting permissions use |setfperm()|.
  2924. Parameters: ~
  2925. • {fname} (`string`)
  2926. Return: ~
  2927. (`string`)
  2928. getfsize({fname}) *getfsize()*
  2929. The result is a Number, which is the size in bytes of the
  2930. given file {fname}.
  2931. If {fname} is a directory, 0 is returned.
  2932. If the file {fname} can't be found, -1 is returned.
  2933. If the size of {fname} is too big to fit in a Number then -2
  2934. is returned.
  2935. Parameters: ~
  2936. • {fname} (`string`)
  2937. Return: ~
  2938. (`integer`)
  2939. getftime({fname}) *getftime()*
  2940. The result is a Number, which is the last modification time of
  2941. the given file {fname}. The value is measured as seconds
  2942. since 1st Jan 1970, and may be passed to strftime(). See also
  2943. |localtime()| and |strftime()|.
  2944. If the file {fname} can't be found -1 is returned.
  2945. Parameters: ~
  2946. • {fname} (`string`)
  2947. Return: ~
  2948. (`integer`)
  2949. getftype({fname}) *getftype()*
  2950. The result is a String, which is a description of the kind of
  2951. file of the given file {fname}.
  2952. If {fname} does not exist an empty string is returned.
  2953. Here is a table over different kinds of files and their
  2954. results:
  2955. Normal file "file"
  2956. Directory "dir"
  2957. Symbolic link "link"
  2958. Block device "bdev"
  2959. Character device "cdev"
  2960. Socket "socket"
  2961. FIFO "fifo"
  2962. All other "other"
  2963. Example: >vim
  2964. getftype("/home")
  2965. < Note that a type such as "link" will only be returned on
  2966. systems that support it. On some systems only "dir" and
  2967. "file" are returned.
  2968. Parameters: ~
  2969. • {fname} (`string`)
  2970. Return: ~
  2971. (`'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'`)
  2972. getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
  2973. Returns the |jumplist| for the specified window.
  2974. Without arguments use the current window.
  2975. With {winnr} only use this window in the current tab page.
  2976. {winnr} can also be a |window-ID|.
  2977. With {winnr} and {tabnr} use the window in the specified tab
  2978. page. If {winnr} or {tabnr} is invalid, an empty list is
  2979. returned.
  2980. The returned list contains two entries: a list with the jump
  2981. locations and the last used jump position number in the list.
  2982. Each entry in the jump location list is a dictionary with
  2983. the following entries:
  2984. bufnr buffer number
  2985. col column number
  2986. coladd column offset for 'virtualedit'
  2987. filename filename if available
  2988. lnum line number
  2989. Parameters: ~
  2990. • {winnr} (`integer?`)
  2991. • {tabnr} (`integer?`)
  2992. Return: ~
  2993. (`vim.fn.getjumplist.ret`)
  2994. getline({lnum} [, {end}]) *getline()*
  2995. Without {end} the result is a String, which is line {lnum}
  2996. from the current buffer. Example: >vim
  2997. getline(1)
  2998. < When {lnum} is a String that doesn't start with a
  2999. digit, |line()| is called to translate the String into a Number.
  3000. To get the line under the cursor: >vim
  3001. getline(".")
  3002. < When {lnum} is a number smaller than 1 or bigger than the
  3003. number of lines in the buffer, an empty string is returned.
  3004. When {end} is given the result is a |List| where each item is
  3005. a line from the current buffer in the range {lnum} to {end},
  3006. including line {end}.
  3007. {end} is used in the same way as {lnum}.
  3008. Non-existing lines are silently omitted.
  3009. When {end} is before {lnum} an empty |List| is returned.
  3010. Example: >vim
  3011. let start = line('.')
  3012. let end = search("^$") - 1
  3013. let lines = getline(start, end)
  3014. < To get lines from another buffer see |getbufline()| and
  3015. |getbufoneline()|
  3016. Parameters: ~
  3017. • {lnum} (`integer|string`)
  3018. • {end} (`nil|false?`)
  3019. Return: ~
  3020. (`string`)
  3021. getloclist({nr} [, {what}]) *getloclist()*
  3022. Returns a |List| with all the entries in the location list for
  3023. window {nr}. {nr} can be the window number or the |window-ID|.
  3024. When {nr} is zero the current window is used.
  3025. For a location list window, the displayed location list is
  3026. returned. For an invalid window number {nr}, an empty list is
  3027. returned. Otherwise, same as |getqflist()|.
  3028. If the optional {what} dictionary argument is supplied, then
  3029. returns the items listed in {what} as a dictionary. Refer to
  3030. |getqflist()| for the supported items in {what}.
  3031. In addition to the items supported by |getqflist()| in {what},
  3032. the following item is supported by |getloclist()|:
  3033. filewinid id of the window used to display files
  3034. from the location list. This field is
  3035. applicable only when called from a
  3036. location list window. See
  3037. |location-list-file-window| for more
  3038. details.
  3039. Returns a |Dictionary| with default values if there is no
  3040. location list for the window {nr}.
  3041. Returns an empty Dictionary if window {nr} does not exist.
  3042. Examples (See also |getqflist-examples|): >vim
  3043. echo getloclist(3, {'all': 0})
  3044. echo getloclist(5, {'filewinid': 0})
  3045. <
  3046. Parameters: ~
  3047. • {nr} (`integer`)
  3048. • {what} (`table?`)
  3049. Return: ~
  3050. (`any`)
  3051. getmarklist([{buf}]) *getmarklist()*
  3052. Without the {buf} argument returns a |List| with information
  3053. about all the global marks. |mark|
  3054. If the optional {buf} argument is specified, returns the
  3055. local marks defined in buffer {buf}. For the use of {buf},
  3056. see |bufname()|. If {buf} is invalid, an empty list is
  3057. returned.
  3058. Each item in the returned List is a |Dict| with the following:
  3059. mark name of the mark prefixed by "'"
  3060. pos a |List| with the position of the mark:
  3061. [bufnum, lnum, col, off]
  3062. Refer to |getpos()| for more information.
  3063. file file name
  3064. Refer to |getpos()| for getting information about a specific
  3065. mark.
  3066. Parameters: ~
  3067. • {buf} (`integer??`)
  3068. Return: ~
  3069. (`vim.fn.getmarklist.ret.item[]`)
  3070. getmatches([{win}]) *getmatches()*
  3071. Returns a |List| with all matches previously defined for the
  3072. current window by |matchadd()| and the |:match| commands.
  3073. |getmatches()| is useful in combination with |setmatches()|,
  3074. as |setmatches()| can restore a list of matches saved by
  3075. |getmatches()|.
  3076. If {win} is specified, use the window with this number or
  3077. window ID instead of the current window. If {win} is invalid,
  3078. an empty list is returned.
  3079. Example: >vim
  3080. echo getmatches()
  3081. < >
  3082. [{"group": "MyGroup1", "pattern": "TODO",
  3083. "priority": 10, "id": 1}, {"group": "MyGroup2",
  3084. "pattern": "FIXME", "priority": 10, "id": 2}]
  3085. < >vim
  3086. let m = getmatches()
  3087. call clearmatches()
  3088. echo getmatches()
  3089. < >
  3090. []
  3091. < >vim
  3092. call setmatches(m)
  3093. echo getmatches()
  3094. < >
  3095. [{"group": "MyGroup1", "pattern": "TODO",
  3096. "priority": 10, "id": 1}, {"group": "MyGroup2",
  3097. "pattern": "FIXME", "priority": 10, "id": 2}]
  3098. < >vim
  3099. unlet m
  3100. <
  3101. Parameters: ~
  3102. • {win} (`integer?`)
  3103. Return: ~
  3104. (`any`)
  3105. getmousepos() *getmousepos()*
  3106. Returns a |Dictionary| with the last known position of the
  3107. mouse. This can be used in a mapping for a mouse click. The
  3108. items are:
  3109. screenrow screen row
  3110. screencol screen column
  3111. winid Window ID of the click
  3112. winrow row inside "winid"
  3113. wincol column inside "winid"
  3114. line text line inside "winid"
  3115. column text column inside "winid"
  3116. coladd offset (in screen columns) from the
  3117. start of the clicked char
  3118. All numbers are 1-based.
  3119. If not over a window, e.g. when in the command line, then only
  3120. "screenrow" and "screencol" are valid, the others are zero.
  3121. When on the status line below a window or the vertical
  3122. separator right of a window, the "line" and "column" values
  3123. are zero.
  3124. When the position is after the text then "column" is the
  3125. length of the text in bytes plus one.
  3126. If the mouse is over a focusable floating window then that
  3127. window is used.
  3128. When using |getchar()| the Vim variables |v:mouse_lnum|,
  3129. |v:mouse_col| and |v:mouse_winid| also provide these values.
  3130. Return: ~
  3131. (`vim.fn.getmousepos.ret`)
  3132. getpid() *getpid()*
  3133. Return a Number which is the process ID of the Vim process.
  3134. This is a unique number, until Vim exits.
  3135. Return: ~
  3136. (`integer`)
  3137. getpos({expr}) *getpos()*
  3138. Get the position for String {expr}.
  3139. The accepted values for {expr} are:
  3140. . The cursor position.
  3141. $ The last line in the current buffer.
  3142. 'x Position of mark x (if the mark is not set, 0 is
  3143. returned for all values).
  3144. w0 First line visible in current window (one if the
  3145. display isn't updated, e.g. in silent Ex mode).
  3146. w$ Last line visible in current window (this is one
  3147. less than "w0" if no lines are visible).
  3148. v When not in Visual mode, returns the cursor
  3149. position. In Visual mode, returns the other end
  3150. of the Visual area. A good way to think about
  3151. this is that in Visual mode "v" and "." complement
  3152. each other. While "." refers to the cursor
  3153. position, "v" refers to where |v_o| would move the
  3154. cursor. As a result, you can use "v" and "."
  3155. together to work on all of a selection in
  3156. characterwise Visual mode. If the cursor is at
  3157. the end of a characterwise Visual area, "v" refers
  3158. to the start of the same Visual area. And if the
  3159. cursor is at the start of a characterwise Visual
  3160. area, "v" refers to the end of the same Visual
  3161. area. "v" differs from |'<| and |'>| in that it's
  3162. updated right away.
  3163. Note that a mark in another file can be used. The line number
  3164. then applies to another buffer.
  3165. The result is a |List| with four numbers:
  3166. [bufnum, lnum, col, off]
  3167. "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  3168. is the buffer number of the mark.
  3169. "lnum" and "col" are the position in the buffer. The first
  3170. column is 1.
  3171. The "off" number is zero, unless 'virtualedit' is used. Then
  3172. it is the offset in screen columns from the start of the
  3173. character. E.g., a position within a <Tab> or after the last
  3174. character.
  3175. For getting the cursor position see |getcurpos()|.
  3176. The column number in the returned List is the byte position
  3177. within the line. To get the character position in the line,
  3178. use |getcharpos()|.
  3179. Note that for '< and '> Visual mode matters: when it is "V"
  3180. (visual line mode) the column of '< is zero and the column of
  3181. '> is a large number equal to |v:maxcol|.
  3182. A very large column number equal to |v:maxcol| can be returned,
  3183. in which case it means "after the end of the line".
  3184. If {expr} is invalid, returns a list with all zeros.
  3185. This can be used to save and restore the position of a mark: >vim
  3186. let save_a_mark = getpos("'a")
  3187. " ...
  3188. call setpos("'a", save_a_mark)
  3189. <
  3190. Also see |getcharpos()|, |getcurpos()| and |setpos()|.
  3191. Parameters: ~
  3192. • {expr} (`string`)
  3193. Return: ~
  3194. (`integer[]`)
  3195. getqflist([{what}]) *getqflist()*
  3196. Returns a |List| with all the current quickfix errors. Each
  3197. list item is a dictionary with these entries:
  3198. bufnr number of buffer that has the file name, use
  3199. bufname() to get the name
  3200. module module name
  3201. lnum line number in the buffer (first line is 1)
  3202. end_lnum
  3203. end of line number if the item is multiline
  3204. col column number (first column is 1)
  3205. end_col end of column number if the item has range
  3206. vcol |TRUE|: "col" is visual column
  3207. |FALSE|: "col" is byte index
  3208. nr error number
  3209. pattern search pattern used to locate the error
  3210. text description of the error
  3211. type type of the error, 'E', '1', etc.
  3212. valid |TRUE|: recognized error message
  3213. user_data
  3214. custom data associated with the item, can be
  3215. any type.
  3216. When there is no error list or it's empty, an empty list is
  3217. returned. Quickfix list entries with a non-existing buffer
  3218. number are returned with "bufnr" set to zero (Note: some
  3219. functions accept buffer number zero for the alternate buffer,
  3220. you may need to explicitly check for zero).
  3221. Useful application: Find pattern matches in multiple files and
  3222. do something with them: >vim
  3223. vimgrep /theword/jg *.c
  3224. for d in getqflist()
  3225. echo bufname(d.bufnr) ':' d.lnum '=' d.text
  3226. endfor
  3227. <
  3228. If the optional {what} dictionary argument is supplied, then
  3229. returns only the items listed in {what} as a dictionary. The
  3230. following string items are supported in {what}:
  3231. changedtick get the total number of changes made
  3232. to the list |quickfix-changedtick|
  3233. context get the |quickfix-context|
  3234. efm errorformat to use when parsing "lines". If
  3235. not present, then the 'errorformat' option
  3236. value is used.
  3237. id get information for the quickfix list with
  3238. |quickfix-ID|; zero means the id for the
  3239. current list or the list specified by "nr"
  3240. idx get information for the quickfix entry at this
  3241. index in the list specified by "id" or "nr".
  3242. If set to zero, then uses the current entry.
  3243. See |quickfix-index|
  3244. items quickfix list entries
  3245. lines parse a list of lines using 'efm' and return
  3246. the resulting entries. Only a |List| type is
  3247. accepted. The current quickfix list is not
  3248. modified. See |quickfix-parse|.
  3249. nr get information for this quickfix list; zero
  3250. means the current quickfix list and "$" means
  3251. the last quickfix list
  3252. qfbufnr number of the buffer displayed in the quickfix
  3253. window. Returns 0 if the quickfix buffer is
  3254. not present. See |quickfix-buffer|.
  3255. size number of entries in the quickfix list
  3256. title get the list title |quickfix-title|
  3257. winid get the quickfix |window-ID|
  3258. all all of the above quickfix properties
  3259. Non-string items in {what} are ignored. To get the value of a
  3260. particular item, set it to zero.
  3261. If "nr" is not present then the current quickfix list is used.
  3262. If both "nr" and a non-zero "id" are specified, then the list
  3263. specified by "id" is used.
  3264. To get the number of lists in the quickfix stack, set "nr" to
  3265. "$" in {what}. The "nr" value in the returned dictionary
  3266. contains the quickfix stack size.
  3267. When "lines" is specified, all the other items except "efm"
  3268. are ignored. The returned dictionary contains the entry
  3269. "items" with the list of entries.
  3270. The returned dictionary contains the following entries:
  3271. changedtick total number of changes made to the
  3272. list |quickfix-changedtick|
  3273. context quickfix list context. See |quickfix-context|
  3274. If not present, set to "".
  3275. id quickfix list ID |quickfix-ID|. If not
  3276. present, set to 0.
  3277. idx index of the quickfix entry in the list. If not
  3278. present, set to 0.
  3279. items quickfix list entries. If not present, set to
  3280. an empty list.
  3281. nr quickfix list number. If not present, set to 0
  3282. qfbufnr number of the buffer displayed in the quickfix
  3283. window. If not present, set to 0.
  3284. size number of entries in the quickfix list. If not
  3285. present, set to 0.
  3286. title quickfix list title text. If not present, set
  3287. to "".
  3288. winid quickfix |window-ID|. If not present, set to 0
  3289. Examples (See also |getqflist-examples|): >vim
  3290. echo getqflist({'all': 1})
  3291. echo getqflist({'nr': 2, 'title': 1})
  3292. echo getqflist({'lines' : ["F1:10:L10"]})
  3293. <
  3294. Parameters: ~
  3295. • {what} (`table?`)
  3296. Return: ~
  3297. (`any`)
  3298. getreg([{regname} [, 1 [, {list}]]]) *getreg()*
  3299. The result is a String, which is the contents of register
  3300. {regname}. Example: >vim
  3301. let cliptext = getreg('*')
  3302. < When register {regname} was not set the result is an empty
  3303. string.
  3304. The {regname} argument must be a string.
  3305. getreg('=') returns the last evaluated value of the expression
  3306. register. (For use in maps.)
  3307. getreg('=', 1) returns the expression itself, so that it can
  3308. be restored with |setreg()|. For other registers the extra
  3309. argument is ignored, thus you can always give it.
  3310. If {list} is present and |TRUE|, the result type is changed
  3311. to |List|. Each list item is one text line. Use it if you care
  3312. about zero bytes possibly present inside register: without
  3313. third argument both NLs and zero bytes are represented as NLs
  3314. (see |NL-used-for-Nul|).
  3315. When the register was not set an empty list is returned.
  3316. If {regname} is not specified, |v:register| is used.
  3317. Parameters: ~
  3318. • {regname} (`string?`)
  3319. • {list} (`nil|false?`)
  3320. Return: ~
  3321. (`string`)
  3322. getreginfo([{regname}]) *getreginfo()*
  3323. Returns detailed information about register {regname} as a
  3324. Dictionary with the following entries:
  3325. regcontents List of lines contained in register
  3326. {regname}, like
  3327. getreg({regname}, 1, 1).
  3328. regtype the type of register {regname}, as in
  3329. |getregtype()|.
  3330. isunnamed Boolean flag, v:true if this register
  3331. is currently pointed to by the unnamed
  3332. register.
  3333. points_to for the unnamed register, gives the
  3334. single letter name of the register
  3335. currently pointed to (see |quotequote|).
  3336. For example, after deleting a line
  3337. with `dd`, this field will be "1",
  3338. which is the register that got the
  3339. deleted text.
  3340. The {regname} argument is a string. If {regname} is invalid
  3341. or not set, an empty Dictionary will be returned.
  3342. If {regname} is not specified, |v:register| is used.
  3343. The returned Dictionary can be passed to |setreg()|.
  3344. Parameters: ~
  3345. • {regname} (`string?`)
  3346. Return: ~
  3347. (`table`)
  3348. getregion({pos1}, {pos2} [, {opts}]) *getregion()*
  3349. Returns the list of strings from {pos1} to {pos2} from a
  3350. buffer.
  3351. {pos1} and {pos2} must both be |List|s with four numbers.
  3352. See |getpos()| for the format of the list. It's possible
  3353. to specify positions from a different buffer, but please
  3354. note the limitations at |getregion-notes|.
  3355. The optional argument {opts} is a Dict and supports the
  3356. following items:
  3357. type Specify the region's selection type.
  3358. See |getregtype()| for possible values,
  3359. except that the width can be omitted
  3360. and an empty string cannot be used.
  3361. (default: "v")
  3362. exclusive If |TRUE|, use exclusive selection
  3363. for the end position.
  3364. (default: follow 'selection')
  3365. You can get the last selection type by |visualmode()|.
  3366. If Visual mode is active, use |mode()| to get the Visual mode
  3367. (e.g., in a |:vmap|).
  3368. This function is useful to get text starting and ending in
  3369. different columns, such as a |charwise-visual| selection.
  3370. *getregion-notes*
  3371. Note that:
  3372. - Order of {pos1} and {pos2} doesn't matter, it will always
  3373. return content from the upper left position to the lower
  3374. right position.
  3375. - If 'virtualedit' is enabled and the region is past the end
  3376. of the lines, resulting lines are padded with spaces.
  3377. - If the region is blockwise and it starts or ends in the
  3378. middle of a multi-cell character, it is not included but
  3379. its selected part is substituted with spaces.
  3380. - If {pos1} and {pos2} are not in the same buffer, an empty
  3381. list is returned.
  3382. - {pos1} and {pos2} must belong to a |bufloaded()| buffer.
  3383. - It is evaluated in current window context, which makes a
  3384. difference if the buffer is displayed in a window with
  3385. different 'virtualedit' or 'list' values.
  3386. Examples: >vim
  3387. xnoremap <CR>
  3388. \ <Cmd>echom getregion(
  3389. \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
  3390. <
  3391. Parameters: ~
  3392. • {pos1} (`table`)
  3393. • {pos2} (`table`)
  3394. • {opts} (`table?`)
  3395. Return: ~
  3396. (`string[]`)
  3397. getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
  3398. Same as |getregion()|, but returns a list of positions
  3399. describing the buffer text segments bound by {pos1} and
  3400. {pos2}.
  3401. The segments are a pair of positions for every line: >
  3402. [[{start_pos}, {end_pos}], ...]
  3403. <
  3404. The position is a |List| with four numbers:
  3405. [bufnum, lnum, col, off]
  3406. "bufnum" is the buffer number.
  3407. "lnum" and "col" are the position in the buffer. The first
  3408. column is 1.
  3409. If the "off" number of a starting position is non-zero, it is
  3410. the offset in screen columns from the start of the character.
  3411. E.g., a position within a <Tab> or after the last character.
  3412. If the "off" number of an ending position is non-zero, it is
  3413. the offset of the character's first cell not included in the
  3414. selection, otherwise all its cells are included.
  3415. Apart from the options supported by |getregion()|, {opts} also
  3416. supports the following:
  3417. eol If |TRUE|, indicate positions beyond
  3418. the end of a line with "col" values
  3419. one more than the length of the line.
  3420. If |FALSE|, positions are limited
  3421. within their lines, and if a line is
  3422. empty or the selection is entirely
  3423. beyond the end of a line, a "col"
  3424. value of 0 is used for both positions.
  3425. (default: |FALSE|)
  3426. Parameters: ~
  3427. • {pos1} (`table`)
  3428. • {pos2} (`table`)
  3429. • {opts} (`table?`)
  3430. Return: ~
  3431. (`integer[][][]`)
  3432. getregtype([{regname}]) *getregtype()*
  3433. The result is a String, which is type of register {regname}.
  3434. The value will be one of:
  3435. "v" for |charwise| text
  3436. "V" for |linewise| text
  3437. "<CTRL-V>{width}" for |blockwise-visual| text
  3438. "" for an empty or unknown register
  3439. <CTRL-V> is one character with value 0x16.
  3440. The {regname} argument is a string. If {regname} is not
  3441. specified, |v:register| is used.
  3442. Parameters: ~
  3443. • {regname} (`string?`)
  3444. Return: ~
  3445. (`string`)
  3446. getscriptinfo([{opts}]) *getscriptinfo()*
  3447. Returns a |List| with information about all the sourced Vim
  3448. scripts in the order they were sourced, like what
  3449. `:scriptnames` shows.
  3450. The optional Dict argument {opts} supports the following
  3451. optional items:
  3452. name Script name match pattern. If specified,
  3453. and "sid" is not specified, information about
  3454. scripts with a name that match the pattern
  3455. "name" are returned.
  3456. sid Script ID |<SID>|. If specified, only
  3457. information about the script with ID "sid" is
  3458. returned and "name" is ignored.
  3459. Each item in the returned List is a |Dict| with the following
  3460. items:
  3461. autoload Always set to FALSE.
  3462. functions List of script-local function names defined in
  3463. the script. Present only when a particular
  3464. script is specified using the "sid" item in
  3465. {opts}.
  3466. name Vim script file name.
  3467. sid Script ID |<SID>|.
  3468. variables A dictionary with the script-local variables.
  3469. Present only when a particular script is
  3470. specified using the "sid" item in {opts}.
  3471. Note that this is a copy, the value of
  3472. script-local variables cannot be changed using
  3473. this dictionary.
  3474. version Vim script version, always 1
  3475. Examples: >vim
  3476. echo getscriptinfo({'name': 'myscript'})
  3477. echo getscriptinfo({'sid': 15})[0].variables
  3478. <
  3479. Parameters: ~
  3480. • {opts} (`table?`)
  3481. Return: ~
  3482. (`vim.fn.getscriptinfo.ret[]`)
  3483. getstacktrace() *getstacktrace()*
  3484. Returns the current stack trace of Vim scripts.
  3485. Stack trace is a |List|, of which each item is a |Dictionary|
  3486. with the following items:
  3487. funcref The funcref if the stack is at a function,
  3488. otherwise this item is omitted.
  3489. event The string of the event description if the
  3490. stack is at an autocmd event, otherwise this
  3491. item is omitted.
  3492. lnum The line number in the script on the stack.
  3493. filepath The file path of the script on the stack.
  3494. Return: ~
  3495. (`table[]`)
  3496. gettabinfo([{tabnr}]) *gettabinfo()*
  3497. If {tabnr} is not specified, then information about all the
  3498. tab pages is returned as a |List|. Each List item is a
  3499. |Dictionary|. Otherwise, {tabnr} specifies the tab page
  3500. number and information about that one is returned. If the tab
  3501. page does not exist an empty List is returned.
  3502. Each List item is a |Dictionary| with the following entries:
  3503. tabnr tab page number.
  3504. variables a reference to the dictionary with
  3505. tabpage-local variables
  3506. windows List of |window-ID|s in the tab page.
  3507. Parameters: ~
  3508. • {tabnr} (`integer?`)
  3509. Return: ~
  3510. (`any`)
  3511. gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
  3512. Get the value of a tab-local variable {varname} in tab page
  3513. {tabnr}. |t:var|
  3514. Tabs are numbered starting with one.
  3515. The {varname} argument is a string. When {varname} is empty a
  3516. dictionary with all tab-local variables is returned.
  3517. Note that the name without "t:" must be used.
  3518. When the tab or variable doesn't exist {def} or an empty
  3519. string is returned, there is no error message.
  3520. Parameters: ~
  3521. • {tabnr} (`integer`)
  3522. • {varname} (`string`)
  3523. • {def} (`any?`)
  3524. Return: ~
  3525. (`any`)
  3526. gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
  3527. Get the value of window-local variable {varname} in window
  3528. {winnr} in tab page {tabnr}.
  3529. The {varname} argument is a string. When {varname} is empty a
  3530. dictionary with all window-local variables is returned.
  3531. When {varname} is equal to "&" get the values of all
  3532. window-local options in a |Dictionary|.
  3533. Otherwise, when {varname} starts with "&" get the value of a
  3534. window-local option.
  3535. Note that {varname} must be the name without "w:".
  3536. Tabs are numbered starting with one. For the current tabpage
  3537. use |getwinvar()|.
  3538. {winnr} can be the window number or the |window-ID|.
  3539. When {winnr} is zero the current window is used.
  3540. This also works for a global option, buffer-local option and
  3541. window-local option, but it doesn't work for a global variable
  3542. or buffer-local variable.
  3543. When the tab, window or variable doesn't exist {def} or an
  3544. empty string is returned, there is no error message.
  3545. Examples: >vim
  3546. let list_is_on = gettabwinvar(1, 2, '&list')
  3547. echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
  3548. <
  3549. To obtain all window-local variables use: >vim
  3550. gettabwinvar({tabnr}, {winnr}, '&')
  3551. <
  3552. Parameters: ~
  3553. • {tabnr} (`integer`)
  3554. • {winnr} (`integer`)
  3555. • {varname} (`string`)
  3556. • {def} (`any?`)
  3557. Return: ~
  3558. (`any`)
  3559. gettagstack([{winnr}]) *gettagstack()*
  3560. The result is a Dict, which is the tag stack of window {winnr}.
  3561. {winnr} can be the window number or the |window-ID|.
  3562. When {winnr} is not specified, the current window is used.
  3563. When window {winnr} doesn't exist, an empty Dict is returned.
  3564. The returned dictionary contains the following entries:
  3565. curidx Current index in the stack. When at
  3566. top of the stack, set to (length + 1).
  3567. Index of bottom of the stack is 1.
  3568. items List of items in the stack. Each item
  3569. is a dictionary containing the
  3570. entries described below.
  3571. length Number of entries in the stack.
  3572. Each item in the stack is a dictionary with the following
  3573. entries:
  3574. bufnr buffer number of the current jump
  3575. from cursor position before the tag jump.
  3576. See |getpos()| for the format of the
  3577. returned list.
  3578. matchnr current matching tag number. Used when
  3579. multiple matching tags are found for a
  3580. name.
  3581. tagname name of the tag
  3582. See |tagstack| for more information about the tag stack.
  3583. Parameters: ~
  3584. • {winnr} (`integer?`)
  3585. Return: ~
  3586. (`any`)
  3587. gettext({text}) *gettext()*
  3588. Translate String {text} if possible.
  3589. This is mainly for use in the distributed Vim scripts. When
  3590. generating message translations the {text} is extracted by
  3591. xgettext, the translator can add the translated message in the
  3592. .po file and Vim will lookup the translation when gettext() is
  3593. called.
  3594. For {text} double quoted strings are preferred, because
  3595. xgettext does not understand escaping in single quoted
  3596. strings.
  3597. Parameters: ~
  3598. • {text} (`string`)
  3599. Return: ~
  3600. (`string`)
  3601. getwininfo([{winid}]) *getwininfo()*
  3602. Returns information about windows as a |List| with Dictionaries.
  3603. If {winid} is given Information about the window with that ID
  3604. is returned, as a |List| with one item. If the window does not
  3605. exist the result is an empty list.
  3606. Without {winid} information about all the windows in all the
  3607. tab pages is returned.
  3608. Each List item is a |Dictionary| with the following entries:
  3609. botline last complete displayed buffer line
  3610. bufnr number of buffer in the window
  3611. height window height (excluding winbar)
  3612. leftcol first column displayed; only used when
  3613. 'wrap' is off
  3614. loclist 1 if showing a location list
  3615. quickfix 1 if quickfix or location list window
  3616. terminal 1 if a terminal window
  3617. tabnr tab page number
  3618. topline first displayed buffer line
  3619. variables a reference to the dictionary with
  3620. window-local variables
  3621. width window width
  3622. winbar 1 if the window has a toolbar, 0
  3623. otherwise
  3624. wincol leftmost screen column of the window;
  3625. "col" from |win_screenpos()|
  3626. textoff number of columns occupied by any
  3627. 'foldcolumn', 'signcolumn' and line
  3628. number in front of the text
  3629. winid |window-ID|
  3630. winnr window number
  3631. winrow topmost screen line of the window;
  3632. "row" from |win_screenpos()|
  3633. Parameters: ~
  3634. • {winid} (`integer?`)
  3635. Return: ~
  3636. (`vim.fn.getwininfo.ret.item[]`)
  3637. getwinpos([{timeout}]) *getwinpos()*
  3638. The result is a |List| with two numbers, the result of
  3639. |getwinposx()| and |getwinposy()| combined:
  3640. [x-pos, y-pos]
  3641. {timeout} can be used to specify how long to wait in msec for
  3642. a response from the terminal. When omitted 100 msec is used.
  3643. Use a longer time for a remote terminal.
  3644. When using a value less than 10 and no response is received
  3645. within that time, a previously reported position is returned,
  3646. if available. This can be used to poll for the position and
  3647. do some work in the meantime: >vim
  3648. while 1
  3649. let res = getwinpos(1)
  3650. if res[0] >= 0
  3651. break
  3652. endif
  3653. " Do some work here
  3654. endwhile
  3655. <
  3656. Parameters: ~
  3657. • {timeout} (`integer?`)
  3658. Return: ~
  3659. (`any`)
  3660. getwinposx() *getwinposx()*
  3661. The result is a Number, which is the X coordinate in pixels of
  3662. the left hand side of the GUI Vim window. The result will be
  3663. -1 if the information is not available.
  3664. The value can be used with `:winpos`.
  3665. Return: ~
  3666. (`integer`)
  3667. getwinposy() *getwinposy()*
  3668. The result is a Number, which is the Y coordinate in pixels of
  3669. the top of the GUI Vim window. The result will be -1 if the
  3670. information is not available.
  3671. The value can be used with `:winpos`.
  3672. Return: ~
  3673. (`integer`)
  3674. getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
  3675. Like |gettabwinvar()| for the current tabpage.
  3676. Examples: >vim
  3677. let list_is_on = getwinvar(2, '&list')
  3678. echo "myvar = " .. getwinvar(1, 'myvar')
  3679. Parameters: ~
  3680. • {winnr} (`integer`)
  3681. • {varname} (`string`)
  3682. • {def} (`any?`)
  3683. Return: ~
  3684. (`any`)
  3685. glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
  3686. Expand the file wildcards in {expr}. See |wildcards| for the
  3687. use of special characters.
  3688. Unless the optional {nosuf} argument is given and is |TRUE|,
  3689. the 'suffixes' and 'wildignore' options apply: Names matching
  3690. one of the patterns in 'wildignore' will be skipped and
  3691. 'suffixes' affect the ordering of matches.
  3692. 'wildignorecase' always applies.
  3693. When {list} is present and it is |TRUE| the result is a |List|
  3694. with all matching files. The advantage of using a List is,
  3695. you also get filenames containing newlines correctly.
  3696. Otherwise the result is a String and when there are several
  3697. matches, they are separated by <NL> characters.
  3698. If the expansion fails, the result is an empty String or List.
  3699. You can also use |readdir()| if you need to do complicated
  3700. things, such as limiting the number of matches.
  3701. A name for a non-existing file is not included. A symbolic
  3702. link is only included if it points to an existing file.
  3703. However, when the {alllinks} argument is present and it is
  3704. |TRUE| then all symbolic links are included.
  3705. For most systems backticks can be used to get files names from
  3706. any external command. Example: >vim
  3707. let tagfiles = glob("`find . -name tags -print`")
  3708. let &tags = substitute(tagfiles, "\n", ",", "g")
  3709. < The result of the program inside the backticks should be one
  3710. item per line. Spaces inside an item are allowed.
  3711. See |expand()| for expanding special Vim variables. See
  3712. |system()| for getting the raw output of an external command.
  3713. Parameters: ~
  3714. • {expr} (`string`)
  3715. • {nosuf} (`boolean?`)
  3716. • {list} (`boolean?`)
  3717. • {alllinks} (`boolean?`)
  3718. Return: ~
  3719. (`any`)
  3720. glob2regpat({string}) *glob2regpat()*
  3721. Convert a file pattern, as used by glob(), into a search
  3722. pattern. The result can be used to match with a string that
  3723. is a file name. E.g. >vim
  3724. if filename =~ glob2regpat('Make*.mak')
  3725. " ...
  3726. endif
  3727. < This is equivalent to: >vim
  3728. if filename =~ '^Make.*\.mak$'
  3729. " ...
  3730. endif
  3731. < When {string} is an empty string the result is "^$", match an
  3732. empty string.
  3733. Note that the result depends on the system. On MS-Windows
  3734. a backslash usually means a path separator.
  3735. Parameters: ~
  3736. • {string} (`string`)
  3737. Return: ~
  3738. (`string`)
  3739. globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()*
  3740. Perform glob() for String {expr} on all directories in {path}
  3741. and concatenate the results. Example: >vim
  3742. echo globpath(&rtp, "syntax/c.vim")
  3743. <
  3744. {path} is a comma-separated list of directory names. Each
  3745. directory name is prepended to {expr} and expanded like with
  3746. |glob()|. A path separator is inserted when needed.
  3747. To add a comma inside a directory name escape it with a
  3748. backslash. Note that on MS-Windows a directory may have a
  3749. trailing backslash, remove it if you put a comma after it.
  3750. If the expansion fails for one of the directories, there is no
  3751. error message.
  3752. Unless the optional {nosuf} argument is given and is |TRUE|,
  3753. the 'suffixes' and 'wildignore' options apply: Names matching
  3754. one of the patterns in 'wildignore' will be skipped and
  3755. 'suffixes' affect the ordering of matches.
  3756. When {list} is present and it is |TRUE| the result is a |List|
  3757. with all matching files. The advantage of using a List is, you
  3758. also get filenames containing newlines correctly. Otherwise
  3759. the result is a String and when there are several matches,
  3760. they are separated by <NL> characters. Example: >vim
  3761. echo globpath(&rtp, "syntax/c.vim", 0, 1)
  3762. <
  3763. {allinks} is used as with |glob()|.
  3764. The "**" item can be used to search in a directory tree.
  3765. For example, to find all "README.txt" files in the directories
  3766. in 'runtimepath' and below: >vim
  3767. echo globpath(&rtp, "**/README.txt")
  3768. < Upwards search and limiting the depth of "**" is not
  3769. supported, thus using 'path' will not always work properly.
  3770. Parameters: ~
  3771. • {path} (`string`)
  3772. • {expr} (`string`)
  3773. • {nosuf} (`boolean?`)
  3774. • {list} (`boolean?`)
  3775. • {allinks} (`boolean?`)
  3776. Return: ~
  3777. (`any`)
  3778. has({feature}) *has()*
  3779. Returns 1 if {feature} is supported, 0 otherwise. The
  3780. {feature} argument is a feature name like "nvim-0.2.1" or
  3781. "win32", see below. See also |exists()|.
  3782. To get the system name use |vim.uv|.os_uname() in Lua: >lua
  3783. print(vim.uv.os_uname().sysname)
  3784. < If the code has a syntax error then Vimscript may skip the
  3785. rest of the line. Put |:if| and |:endif| on separate lines to
  3786. avoid the syntax error: >vim
  3787. if has('feature')
  3788. let x = this_breaks_without_the_feature()
  3789. endif
  3790. <
  3791. Vim's compile-time feature-names (prefixed with "+") are not
  3792. recognized because Nvim is always compiled with all possible
  3793. features. |feature-compile|
  3794. Feature names can be:
  3795. 1. Nvim version. For example the "nvim-0.2.1" feature means
  3796. that Nvim is version 0.2.1 or later: >vim
  3797. if has("nvim-0.2.1")
  3798. " ...
  3799. endif
  3800. < 2. Runtime condition or other pseudo-feature. For example the
  3801. "win32" feature checks if the current system is Windows: >vim
  3802. if has("win32")
  3803. " ...
  3804. endif
  3805. < *feature-list*
  3806. List of supported pseudo-feature names:
  3807. acl |ACL| support.
  3808. bsd BSD system (not macOS, use "mac" for that).
  3809. clipboard |clipboard| provider is available.
  3810. fname_case Case in file names matters (for Darwin and MS-Windows
  3811. this is not present).
  3812. gui_running Nvim has a GUI.
  3813. iconv Can use |iconv()| for conversion.
  3814. linux Linux system.
  3815. mac MacOS system.
  3816. nvim This is Nvim.
  3817. python3 Legacy Vim |python3| interface. |has-python|
  3818. pythonx Legacy Vim |python_x| interface. |has-pythonx|
  3819. sun SunOS system.
  3820. ttyin input is a terminal (tty).
  3821. ttyout output is a terminal (tty).
  3822. unix Unix system.
  3823. *vim_starting* True during |startup|.
  3824. win32 Windows system (32 or 64 bit).
  3825. win64 Windows system (64 bit).
  3826. wsl WSL (Windows Subsystem for Linux) system.
  3827. *has-patch*
  3828. 3. Vim patch. For example the "patch123" feature means that
  3829. Vim patch 123 at the current |v:version| was included: >vim
  3830. if v:version > 602 || v:version == 602 && has("patch148")
  3831. " ...
  3832. endif
  3833. < 4. Vim version. For example the "patch-7.4.237" feature means
  3834. that Nvim is Vim-compatible to version 7.4.237 or later. >vim
  3835. if has("patch-7.4.237")
  3836. " ...
  3837. endif
  3838. <
  3839. Parameters: ~
  3840. • {feature} (`string`)
  3841. Return: ~
  3842. (`0|1`)
  3843. has_key({dict}, {key}) *has_key()*
  3844. The result is a Number, which is TRUE if |Dictionary| {dict}
  3845. has an entry with key {key}. FALSE otherwise. The {key}
  3846. argument is a string.
  3847. Parameters: ~
  3848. • {dict} (`table`)
  3849. • {key} (`string`)
  3850. Return: ~
  3851. (`0|1`)
  3852. haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
  3853. The result is a Number, which is 1 when the window has set a
  3854. local path via |:lcd| or when {winnr} is -1 and the tabpage
  3855. has set a local path via |:tcd|, otherwise 0.
  3856. Tabs and windows are identified by their respective numbers,
  3857. 0 means current tab or window. Missing argument implies 0.
  3858. Thus the following are equivalent: >vim
  3859. echo haslocaldir()
  3860. echo haslocaldir(0)
  3861. echo haslocaldir(0, 0)
  3862. < With {winnr} use that window in the current tabpage.
  3863. With {winnr} and {tabnr} use the window in that tabpage.
  3864. {winnr} can be the window number or the |window-ID|.
  3865. If {winnr} is -1 it is ignored, only the tab is resolved.
  3866. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  3867. Parameters: ~
  3868. • {winnr} (`integer?`)
  3869. • {tabnr} (`integer?`)
  3870. Return: ~
  3871. (`0|1`)
  3872. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
  3873. The result is a Number, which is TRUE if there is a mapping
  3874. that contains {what} in somewhere in the rhs (what it is
  3875. mapped to) and this mapping exists in one of the modes
  3876. indicated by {mode}.
  3877. The arguments {what} and {mode} are strings.
  3878. When {abbr} is there and it is |TRUE| use abbreviations
  3879. instead of mappings. Don't forget to specify Insert and/or
  3880. Command-line mode.
  3881. Both the global mappings and the mappings local to the current
  3882. buffer are checked for a match.
  3883. If no matching mapping is found FALSE is returned.
  3884. The following characters are recognized in {mode}:
  3885. n Normal mode
  3886. v Visual and Select mode
  3887. x Visual mode
  3888. s Select mode
  3889. o Operator-pending mode
  3890. i Insert mode
  3891. l Language-Argument ("r", "f", "t", etc.)
  3892. c Command-line mode
  3893. When {mode} is omitted, "nvo" is used.
  3894. This function is useful to check if a mapping already exists
  3895. to a function in a Vim script. Example: >vim
  3896. if !hasmapto('\ABCdoit')
  3897. map <Leader>d \ABCdoit
  3898. endif
  3899. < This installs the mapping to "\ABCdoit" only if there isn't
  3900. already a mapping to "\ABCdoit".
  3901. Parameters: ~
  3902. • {what} (`any`)
  3903. • {mode} (`string?`)
  3904. • {abbr} (`boolean?`)
  3905. Return: ~
  3906. (`0|1`)
  3907. histadd({history}, {item}) *histadd()*
  3908. Add the String {item} to the history {history} which can be
  3909. one of: *hist-names*
  3910. "cmd" or ":" command line history
  3911. "search" or "/" search pattern history
  3912. "expr" or "=" typed expression history
  3913. "input" or "@" input line history
  3914. "debug" or ">" debug command history
  3915. empty the current or last used history
  3916. The {history} string does not need to be the whole name, one
  3917. character is sufficient.
  3918. If {item} does already exist in the history, it will be
  3919. shifted to become the newest entry.
  3920. The result is a Number: TRUE if the operation was successful,
  3921. otherwise FALSE is returned.
  3922. Example: >vim
  3923. call histadd("input", strftime("%Y %b %d"))
  3924. let date=input("Enter date: ")
  3925. < This function is not available in the |sandbox|.
  3926. Parameters: ~
  3927. • {history} (`string`)
  3928. • {item} (`any`)
  3929. Return: ~
  3930. (`0|1`)
  3931. histdel({history} [, {item}]) *histdel()*
  3932. Clear {history}, i.e. delete all its entries. See |hist-names|
  3933. for the possible values of {history}.
  3934. If the parameter {item} evaluates to a String, it is used as a
  3935. regular expression. All entries matching that expression will
  3936. be removed from the history (if there are any).
  3937. Upper/lowercase must match, unless "\c" is used |/\c|.
  3938. If {item} evaluates to a Number, it will be interpreted as
  3939. an index, see |:history-indexing|. The respective entry will
  3940. be removed if it exists.
  3941. The result is TRUE for a successful operation, otherwise FALSE
  3942. is returned.
  3943. Examples:
  3944. Clear expression register history: >vim
  3945. call histdel("expr")
  3946. <
  3947. Remove all entries starting with "*" from the search history: >vim
  3948. call histdel("/", '^\*')
  3949. <
  3950. The following three are equivalent: >vim
  3951. call histdel("search", histnr("search"))
  3952. call histdel("search", -1)
  3953. call histdel("search", '^' .. histget("search", -1) .. '$')
  3954. <
  3955. To delete the last search pattern and use the last-but-one for
  3956. the "n" command and 'hlsearch': >vim
  3957. call histdel("search", -1)
  3958. let @/ = histget("search", -1)
  3959. <
  3960. Parameters: ~
  3961. • {history} (`string`)
  3962. • {item} (`any?`)
  3963. Return: ~
  3964. (`0|1`)
  3965. histget({history} [, {index}]) *histget()*
  3966. The result is a String, the entry with Number {index} from
  3967. {history}. See |hist-names| for the possible values of
  3968. {history}, and |:history-indexing| for {index}. If there is
  3969. no such entry, an empty String is returned. When {index} is
  3970. omitted, the most recent item from the history is used.
  3971. Examples:
  3972. Redo the second last search from history. >vim
  3973. execute '/' .. histget("search", -2)
  3974. < Define an Ex command ":H {num}" that supports re-execution of
  3975. the {num}th entry from the output of |:history|. >vim
  3976. command -nargs=1 H execute histget("cmd", 0+<args>)
  3977. <
  3978. Parameters: ~
  3979. • {history} (`string`)
  3980. • {index} (`integer|string?`)
  3981. Return: ~
  3982. (`string`)
  3983. histnr({history}) *histnr()*
  3984. The result is the Number of the current entry in {history}.
  3985. See |hist-names| for the possible values of {history}.
  3986. If an error occurred, -1 is returned.
  3987. Example: >vim
  3988. let inp_index = histnr("expr")
  3989. <
  3990. Parameters: ~
  3991. • {history} (`string`)
  3992. Return: ~
  3993. (`integer`)
  3994. hlID({name}) *hlID()*
  3995. The result is a Number, which is the ID of the highlight group
  3996. with name {name}. When the highlight group doesn't exist,
  3997. zero is returned.
  3998. This can be used to retrieve information about the highlight
  3999. group. For example, to get the background color of the
  4000. "Comment" group: >vim
  4001. echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  4002. <
  4003. Parameters: ~
  4004. • {name} (`string`)
  4005. Return: ~
  4006. (`integer`)
  4007. hlexists({name}) *hlexists()*
  4008. The result is a Number, which is TRUE if a highlight group
  4009. called {name} exists. This is when the group has been
  4010. defined in some way. Not necessarily when highlighting has
  4011. been defined for it, it may also have been used for a syntax
  4012. item.
  4013. Parameters: ~
  4014. • {name} (`string`)
  4015. Return: ~
  4016. (`0|1`)
  4017. hostname() *hostname()*
  4018. The result is a String, which is the name of the machine on
  4019. which Vim is currently running. Machine names greater than
  4020. 256 characters long are truncated.
  4021. Return: ~
  4022. (`string`)
  4023. iconv({string}, {from}, {to}) *iconv()*
  4024. The result is a String, which is the text {string} converted
  4025. from encoding {from} to encoding {to}.
  4026. When the conversion completely fails an empty string is
  4027. returned. When some characters could not be converted they
  4028. are replaced with "?".
  4029. The encoding names are whatever the iconv() library function
  4030. can accept, see ":!man 3 iconv".
  4031. Note that Vim uses UTF-8 for all Unicode encodings, conversion
  4032. from/to UCS-2 is automatically changed to use UTF-8. You
  4033. cannot use UCS-2 in a string anyway, because of the NUL bytes.
  4034. Parameters: ~
  4035. • {string} (`string`)
  4036. • {from} (`string`)
  4037. • {to} (`string`)
  4038. Return: ~
  4039. (`string`)
  4040. id({expr}) *id()*
  4041. Returns a |String| which is a unique identifier of the
  4042. container type (|List|, |Dict|, |Blob| and |Partial|). It is
  4043. guaranteed that for the mentioned types `id(v1) ==# id(v2)`
  4044. returns true iff `type(v1) == type(v2) && v1 is v2`.
  4045. Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
  4046. `v:_null_blob` have the same `id()` with different types
  4047. because they are internally represented as NULL pointers.
  4048. `id()` returns a hexadecimal representation of the pointers to
  4049. the containers (i.e. like `0x994a40`), same as `printf("%p",
  4050. {expr})`, but it is advised against counting on the exact
  4051. format of the return value.
  4052. It is not guaranteed that `id(no_longer_existing_container)`
  4053. will not be equal to some other `id()`: new containers may
  4054. reuse identifiers of the garbage-collected ones.
  4055. Parameters: ~
  4056. • {expr} (`any`)
  4057. Return: ~
  4058. (`string`)
  4059. indent({lnum}) *indent()*
  4060. The result is a Number, which is indent of line {lnum} in the
  4061. current buffer. The indent is counted in spaces, the value
  4062. of 'tabstop' is relevant. {lnum} is used just like in
  4063. |getline()|.
  4064. When {lnum} is invalid -1 is returned.
  4065. Parameters: ~
  4066. • {lnum} (`integer|string`)
  4067. Return: ~
  4068. (`integer`)
  4069. index({object}, {expr} [, {start} [, {ic}]]) *index()*
  4070. Find {expr} in {object} and return its index. See
  4071. |indexof()| for using a lambda to select the item.
  4072. If {object} is a |List| return the lowest index where the item
  4073. has a value equal to {expr}. There is no automatic
  4074. conversion, so the String "4" is different from the Number 4.
  4075. And the Number 4 is different from the Float 4.0. The value
  4076. of 'ignorecase' is not used here, case matters as indicated by
  4077. the {ic} argument.
  4078. If {object} is a |Blob| return the lowest index where the byte
  4079. value is equal to {expr}.
  4080. If {start} is given then start looking at the item with index
  4081. {start} (may be negative for an item relative to the end).
  4082. When {ic} is given and it is |TRUE|, ignore case. Otherwise
  4083. case must match.
  4084. -1 is returned when {expr} is not found in {object}.
  4085. Example: >vim
  4086. let idx = index(words, "the")
  4087. if index(numbers, 123) >= 0
  4088. " ...
  4089. endif
  4090. <
  4091. Parameters: ~
  4092. • {object} (`any`)
  4093. • {expr} (`any`)
  4094. • {start} (`integer?`)
  4095. • {ic} (`boolean?`)
  4096. Return: ~
  4097. (`integer`)
  4098. indexof({object}, {expr} [, {opts}]) *indexof()*
  4099. Returns the index of an item in {object} where {expr} is
  4100. v:true. {object} must be a |List| or a |Blob|.
  4101. If {object} is a |List|, evaluate {expr} for each item in the
  4102. List until the expression is v:true and return the index of
  4103. this item.
  4104. If {object} is a |Blob| evaluate {expr} for each byte in the
  4105. Blob until the expression is v:true and return the index of
  4106. this byte.
  4107. {expr} must be a |string| or |Funcref|.
  4108. If {expr} is a |string|: If {object} is a |List|, inside
  4109. {expr} |v:key| has the index of the current List item and
  4110. |v:val| has the value of the item. If {object} is a |Blob|,
  4111. inside {expr} |v:key| has the index of the current byte and
  4112. |v:val| has the byte value.
  4113. If {expr} is a |Funcref| it must take two arguments:
  4114. 1. the key or the index of the current item.
  4115. 2. the value of the current item.
  4116. The function must return |TRUE| if the item is found and the
  4117. search should stop.
  4118. The optional argument {opts} is a Dict and supports the
  4119. following items:
  4120. startidx start evaluating {expr} at the item with this
  4121. index; may be negative for an item relative to
  4122. the end
  4123. Returns -1 when {expr} evaluates to v:false for all the items.
  4124. Example: >vim
  4125. let l = [#{n: 10}, #{n: 20}, #{n: 30}]
  4126. echo indexof(l, "v:val.n == 20")
  4127. echo indexof(l, {i, v -> v.n == 30})
  4128. echo indexof(l, "v:val.n == 20", #{startidx: 1})
  4129. <
  4130. Parameters: ~
  4131. • {object} (`any`)
  4132. • {expr} (`any`)
  4133. • {opts} (`table?`)
  4134. Return: ~
  4135. (`integer`)
  4136. input({prompt} [, {text} [, {completion}]]) *input()*
  4137. Parameters: ~
  4138. • {prompt} (`string`)
  4139. • {text} (`string?`)
  4140. • {completion} (`string?`)
  4141. Return: ~
  4142. (`string`)
  4143. input({opts})
  4144. The result is a String, which is whatever the user typed on
  4145. the command-line. The {prompt} argument is either a prompt
  4146. string, or a blank string (for no prompt). A '\n' can be used
  4147. in the prompt to start a new line.
  4148. In the second form it accepts a single dictionary with the
  4149. following keys, any of which may be omitted:
  4150. Key Default Description ~
  4151. prompt "" Same as {prompt} in the first form.
  4152. default "" Same as {text} in the first form.
  4153. completion nothing Same as {completion} in the first form.
  4154. cancelreturn "" The value returned when the dialog is
  4155. cancelled.
  4156. highlight nothing Highlight handler: |Funcref|.
  4157. The highlighting set with |:echohl| is used for the prompt.
  4158. The input is entered just like a command-line, with the same
  4159. editing commands and mappings. There is a separate history
  4160. for lines typed for input().
  4161. Example: >vim
  4162. if input("Coffee or beer? ") == "beer"
  4163. echo "Cheers!"
  4164. endif
  4165. <
  4166. If the optional {text} argument is present and not empty, this
  4167. is used for the default reply, as if the user typed this.
  4168. Example: >vim
  4169. let color = input("Color? ", "white")
  4170. < The optional {completion} argument specifies the type of
  4171. completion supported for the input. Without it completion is
  4172. not performed. The supported completion types are the same as
  4173. that can be supplied to a user-defined command using the
  4174. "-complete=" argument. Refer to |:command-completion| for
  4175. more information. Example: >vim
  4176. let fname = input("File: ", "", "file")
  4177. < *input()-highlight* *E5400* *E5402*
  4178. The optional `highlight` key allows specifying function which
  4179. will be used for highlighting user input. This function
  4180. receives user input as its only argument and must return
  4181. a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
  4182. where
  4183. hl_start_col is the first highlighted column,
  4184. hl_end_col is the last highlighted column (+ 1!),
  4185. hl_group is |:hi| group used for highlighting.
  4186. *E5403* *E5404* *E5405* *E5406*
  4187. Both hl_start_col and hl_end_col + 1 must point to the start
  4188. of the multibyte character (highlighting must not break
  4189. multibyte characters), hl_end_col + 1 may be equal to the
  4190. input length. Start column must be in range [0, len(input)),
  4191. end column must be in range (hl_start_col, len(input)],
  4192. sections must be ordered so that next hl_start_col is greater
  4193. then or equal to previous hl_end_col.
  4194. Example (try some input with parentheses): >vim
  4195. highlight RBP1 guibg=Red ctermbg=red
  4196. highlight RBP2 guibg=Yellow ctermbg=yellow
  4197. highlight RBP3 guibg=Green ctermbg=green
  4198. highlight RBP4 guibg=Blue ctermbg=blue
  4199. let g:rainbow_levels = 4
  4200. function! RainbowParens(cmdline)
  4201. let ret = []
  4202. let i = 0
  4203. let lvl = 0
  4204. while i < len(a:cmdline)
  4205. if a:cmdline[i] is# '('
  4206. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4207. let lvl += 1
  4208. elseif a:cmdline[i] is# ')'
  4209. let lvl -= 1
  4210. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4211. endif
  4212. let i += 1
  4213. endwhile
  4214. return ret
  4215. endfunction
  4216. call input({'prompt':'>','highlight':'RainbowParens'})
  4217. <
  4218. Highlight function is called at least once for each new
  4219. displayed input string, before command-line is redrawn. It is
  4220. expected that function is pure for the duration of one input()
  4221. call, i.e. it produces the same output for the same input, so
  4222. output may be memoized. Function is run like under |:silent|
  4223. modifier. If the function causes any errors, it will be
  4224. skipped for the duration of the current input() call.
  4225. Highlighting is disabled if command-line contains arabic
  4226. characters.
  4227. NOTE: This function must not be used in a startup file, for
  4228. the versions that only run in GUI mode (e.g., the Win32 GUI).
  4229. Note: When input() is called from within a mapping it will
  4230. consume remaining characters from that mapping, because a
  4231. mapping is handled like the characters were typed.
  4232. Use |inputsave()| before input() and |inputrestore()|
  4233. after input() to avoid that. Another solution is to avoid
  4234. that further characters follow in the mapping, e.g., by using
  4235. |:execute| or |:normal|.
  4236. Example with a mapping: >vim
  4237. nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
  4238. function GetFoo()
  4239. call inputsave()
  4240. let g:Foo = input("enter search pattern: ")
  4241. call inputrestore()
  4242. endfunction
  4243. <
  4244. Parameters: ~
  4245. • {opts} (`table`)
  4246. Return: ~
  4247. (`string`)
  4248. inputlist({textlist}) *inputlist()*
  4249. {textlist} must be a |List| of strings. This |List| is
  4250. displayed, one string per line. The user will be prompted to
  4251. enter a number, which is returned.
  4252. The user can also select an item by clicking on it with the
  4253. mouse, if the mouse is enabled in the command line ('mouse' is
  4254. "a" or includes "c"). For the first string 0 is returned.
  4255. When clicking above the first item a negative number is
  4256. returned. When clicking on the prompt one more than the
  4257. length of {textlist} is returned.
  4258. Make sure {textlist} has less than 'lines' entries, otherwise
  4259. it won't work. It's a good idea to put the entry number at
  4260. the start of the string. And put a prompt in the first item.
  4261. Example: >vim
  4262. let color = inputlist(['Select color:', '1. red',
  4263. \ '2. green', '3. blue'])
  4264. Parameters: ~
  4265. • {textlist} (`string[]`)
  4266. Return: ~
  4267. (`any`)
  4268. inputrestore() *inputrestore()*
  4269. Restore typeahead that was saved with a previous |inputsave()|.
  4270. Should be called the same number of times inputsave() is
  4271. called. Calling it more often is harmless though.
  4272. Returns TRUE when there is nothing to restore, FALSE otherwise.
  4273. Return: ~
  4274. (`integer`)
  4275. inputsave() *inputsave()*
  4276. Preserve typeahead (also from mappings) and clear it, so that
  4277. a following prompt gets input from the user. Should be
  4278. followed by a matching inputrestore() after the prompt. Can
  4279. be used several times, in which case there must be just as
  4280. many inputrestore() calls.
  4281. Returns TRUE when out of memory, FALSE otherwise.
  4282. Return: ~
  4283. (`integer`)
  4284. inputsecret({prompt} [, {text}]) *inputsecret()*
  4285. This function acts much like the |input()| function with but
  4286. two exceptions:
  4287. a) the user's response will be displayed as a sequence of
  4288. asterisks ("*") thereby keeping the entry secret, and
  4289. b) the user's response will not be recorded on the input
  4290. |history| stack.
  4291. The result is a String, which is whatever the user actually
  4292. typed on the command-line in response to the issued prompt.
  4293. NOTE: Command-line completion is not supported.
  4294. Parameters: ~
  4295. • {prompt} (`string`)
  4296. • {text} (`string?`)
  4297. Return: ~
  4298. (`string`)
  4299. insert({object}, {item} [, {idx}]) *insert()*
  4300. When {object} is a |List| or a |Blob| insert {item} at the start
  4301. of it.
  4302. If {idx} is specified insert {item} before the item with index
  4303. {idx}. If {idx} is zero it goes before the first item, just
  4304. like omitting {idx}. A negative {idx} is also possible, see
  4305. |list-index|. -1 inserts just before the last item.
  4306. Returns the resulting |List| or |Blob|. Examples: >vim
  4307. let mylist = insert([2, 3, 5], 1)
  4308. call insert(mylist, 4, -1)
  4309. call insert(mylist, 6, len(mylist))
  4310. < The last example can be done simpler with |add()|.
  4311. Note that when {item} is a |List| it is inserted as a single
  4312. item. Use |extend()| to concatenate |Lists|.
  4313. Parameters: ~
  4314. • {object} (`any`)
  4315. • {item} (`any`)
  4316. • {idx} (`integer?`)
  4317. Return: ~
  4318. (`any`)
  4319. interrupt() *interrupt()*
  4320. Interrupt script execution. It works more or less like the
  4321. user typing CTRL-C, most commands won't execute and control
  4322. returns to the user. This is useful to abort execution
  4323. from lower down, e.g. in an autocommand. Example: >vim
  4324. function s:check_typoname(file)
  4325. if fnamemodify(a:file, ':t') == '['
  4326. echomsg 'Maybe typo'
  4327. call interrupt()
  4328. endif
  4329. endfunction
  4330. au BufWritePre * call s:check_typoname(expand('<amatch>'))
  4331. <
  4332. Return: ~
  4333. (`any`)
  4334. invert({expr}) *invert()*
  4335. Bitwise invert. The argument is converted to a number. A
  4336. List, Dict or Float argument causes an error. Example: >vim
  4337. let bits = invert(bits)
  4338. <
  4339. Parameters: ~
  4340. • {expr} (`integer`)
  4341. Return: ~
  4342. (`integer`)
  4343. isabsolutepath({path}) *isabsolutepath()*
  4344. The result is a Number, which is |TRUE| when {path} is an
  4345. absolute path.
  4346. On Unix, a path is considered absolute when it starts with '/'.
  4347. On MS-Windows, it is considered absolute when it starts with an
  4348. optional drive prefix and is followed by a '\' or '/'. UNC paths
  4349. are always absolute.
  4350. Example: >vim
  4351. echo isabsolutepath('/usr/share/') " 1
  4352. echo isabsolutepath('./foobar') " 0
  4353. echo isabsolutepath('C:\Windows') " 1
  4354. echo isabsolutepath('foobar') " 0
  4355. echo isabsolutepath('\\remote\file') " 1
  4356. <
  4357. Parameters: ~
  4358. • {path} (`string`)
  4359. Return: ~
  4360. (`0|1`)
  4361. isdirectory({directory}) *isdirectory()*
  4362. The result is a Number, which is |TRUE| when a directory
  4363. with the name {directory} exists. If {directory} doesn't
  4364. exist, or isn't a directory, the result is |FALSE|. {directory}
  4365. is any expression, which is used as a String.
  4366. Parameters: ~
  4367. • {directory} (`string`)
  4368. Return: ~
  4369. (`0|1`)
  4370. isinf({expr}) *isinf()*
  4371. Return 1 if {expr} is a positive infinity, or -1 a negative
  4372. infinity, otherwise 0. >vim
  4373. echo isinf(1.0 / 0.0)
  4374. < 1 >vim
  4375. echo isinf(-1.0 / 0.0)
  4376. < -1
  4377. Parameters: ~
  4378. • {expr} (`number`)
  4379. Return: ~
  4380. (`1|0|-1`)
  4381. islocked({expr}) *islocked()* *E786*
  4382. The result is a Number, which is |TRUE| when {expr} is the
  4383. name of a locked variable.
  4384. The string argument {expr} must be the name of a variable,
  4385. |List| item or |Dictionary| entry, not the variable itself!
  4386. Example: >vim
  4387. let alist = [0, ['a', 'b'], 2, 3]
  4388. lockvar 1 alist
  4389. echo islocked('alist') " 1
  4390. echo islocked('alist[1]') " 0
  4391. < When {expr} is a variable that does not exist you get an error
  4392. message. Use |exists()| to check for existence.
  4393. Parameters: ~
  4394. • {expr} (`any`)
  4395. Return: ~
  4396. (`0|1`)
  4397. isnan({expr}) *isnan()*
  4398. Return |TRUE| if {expr} is a float with value NaN. >vim
  4399. echo isnan(0.0 / 0.0)
  4400. < 1
  4401. Parameters: ~
  4402. • {expr} (`number`)
  4403. Return: ~
  4404. (`0|1`)
  4405. items({dict}) *items()*
  4406. Return a |List| with all the key-value pairs of {dict}. Each
  4407. |List| item is a list with two items: the key of a {dict}
  4408. entry and the value of this entry. The |List| is in arbitrary
  4409. order. Also see |keys()| and |values()|.
  4410. Example: >vim
  4411. for [key, value] in items(mydict)
  4412. echo key .. ': ' .. value
  4413. endfor
  4414. <
  4415. A List or a String argument is also supported. In these
  4416. cases, items() returns a List with the index and the value at
  4417. the index.
  4418. Parameters: ~
  4419. • {dict} (`table`)
  4420. Return: ~
  4421. (`any`)
  4422. jobpid({job}) *jobpid()*
  4423. Return the PID (process id) of |job-id| {job}.
  4424. Parameters: ~
  4425. • {job} (`integer`)
  4426. Return: ~
  4427. (`integer`)
  4428. jobresize({job}, {width}, {height}) *jobresize()*
  4429. Resize the pseudo terminal window of |job-id| {job} to {width}
  4430. columns and {height} rows.
  4431. Fails if the job was not started with `"pty":v:true`.
  4432. Parameters: ~
  4433. • {job} (`integer`)
  4434. • {width} (`integer`)
  4435. • {height} (`integer`)
  4436. Return: ~
  4437. (`any`)
  4438. jobstart({cmd} [, {opts}]) *jobstart()*
  4439. Note: Prefer |vim.system()| in Lua (unless using `rpc`, `pty`, or `term`).
  4440. Spawns {cmd} as a job.
  4441. If {cmd} is a List it runs directly (no 'shell').
  4442. If {cmd} is a String it runs in the 'shell', like this: >vim
  4443. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  4444. < (See |shell-unquoting| for details.)
  4445. Example: start a job and handle its output: >vim
  4446. call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}})
  4447. <
  4448. Example: start a job in a |terminal| connected to the current buffer: >vim
  4449. call jobstart(['nvim', '-h'], {'term':v:true})
  4450. <
  4451. Returns |job-id| on success, 0 on invalid arguments (or job
  4452. table is full), -1 if {cmd}[0] or 'shell' is not executable.
  4453. The returned job-id is a valid |channel-id| representing the
  4454. job's stdio streams. Use |chansend()| (or |rpcnotify()| and
  4455. |rpcrequest()| if "rpc" was enabled) to send data to stdin and
  4456. |chanclose()| to close the streams without stopping the job.
  4457. See |job-control| and |RPC|.
  4458. NOTE: on Windows if {cmd} is a List:
  4459. - cmd[0] must be an executable (not a "built-in"). If it is
  4460. in $PATH it can be called by name, without an extension: >vim
  4461. call jobstart(['ping', 'neovim.io'])
  4462. < If it is a full or partial path, extension is required: >vim
  4463. call jobstart(['System32\ping.exe', 'neovim.io'])
  4464. < - {cmd} is collapsed to a string of quoted args as expected
  4465. by CommandLineToArgvW https://msdn.microsoft.com/bb776391
  4466. unless cmd[0] is some form of "cmd.exe".
  4467. *jobstart-env*
  4468. The job environment is initialized as follows:
  4469. $NVIM is set to |v:servername| of the parent Nvim
  4470. $NVIM_LISTEN_ADDRESS is unset
  4471. $NVIM_LOG_FILE is unset
  4472. $VIM is unset
  4473. $VIMRUNTIME is unset
  4474. You can set these with the `env` option.
  4475. *jobstart-options*
  4476. {opts} is a dictionary with these keys:
  4477. clear_env: (boolean) `env` defines the job environment
  4478. exactly, instead of merging current environment.
  4479. cwd: (string, default=|current-directory|) Working
  4480. directory of the job.
  4481. detach: (boolean) Detach the job process: it will not be
  4482. killed when Nvim exits. If the process exits
  4483. before Nvim, `on_exit` will be invoked.
  4484. env: (dict) Map of environment variable name:value
  4485. pairs extending (or replace with "clear_env")
  4486. the current environment. |jobstart-env|
  4487. height: (number) Height of the `pty` terminal.
  4488. |on_exit|: (function) Callback invoked when the job exits.
  4489. |on_stdout|: (function) Callback invoked when the job emits
  4490. stdout data.
  4491. |on_stderr|: (function) Callback invoked when the job emits
  4492. stderr data.
  4493. overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
  4494. stdio passed to the child process. Only on
  4495. MS-Windows; ignored on other platforms.
  4496. pty: (boolean) Connect the job to a new pseudo
  4497. terminal, and its streams to the master file
  4498. descriptor. `on_stdout` receives all output,
  4499. `on_stderr` is ignored. |terminal-start|
  4500. rpc: (boolean) Use |msgpack-rpc| to communicate with
  4501. the job over stdio. Then `on_stdout` is ignored,
  4502. but `on_stderr` can still be used.
  4503. stderr_buffered: (boolean) Collect data until EOF (stream closed)
  4504. before invoking `on_stderr`. |channel-buffered|
  4505. stdout_buffered: (boolean) Collect data until EOF (stream
  4506. closed) before invoking `on_stdout`. |channel-buffered|
  4507. stdin: (string) Either "pipe" (default) to connect the
  4508. job's stdin to a channel or "null" to disconnect
  4509. stdin.
  4510. term: (boolean) Spawns {cmd} in a new pseudo-terminal session
  4511. connected to the current (unmodified) buffer. Implies "pty".
  4512. Default "height" and "width" are set to the current window
  4513. dimensions. |jobstart()|. Defaults $TERM to "xterm-256color".
  4514. width: (number) Width of the `pty` terminal.
  4515. {opts} is passed as |self| dictionary to the callback; the
  4516. caller may set other keys to pass application-specific data.
  4517. Returns:
  4518. - |channel-id| on success
  4519. - 0 on invalid arguments
  4520. - -1 if {cmd}[0] is not executable.
  4521. See also |job-control|, |channel|, |msgpack-rpc|.
  4522. Parameters: ~
  4523. • {cmd} (`string|string[]`)
  4524. • {opts} (`table?`)
  4525. Return: ~
  4526. (`integer`)
  4527. jobstop({id}) *jobstop()*
  4528. Stop |job-id| {id} by sending SIGTERM to the job process. If
  4529. the process does not terminate after a timeout then SIGKILL
  4530. will be sent. When the job terminates its |on_exit| handler
  4531. (if any) will be invoked.
  4532. See |job-control|.
  4533. Returns 1 for valid job id, 0 for invalid id, including jobs have
  4534. exited or stopped.
  4535. Parameters: ~
  4536. • {id} (`integer`)
  4537. Return: ~
  4538. (`integer`)
  4539. jobwait({jobs} [, {timeout}]) *jobwait()*
  4540. Waits for jobs and their |on_exit| handlers to complete.
  4541. {jobs} is a List of |job-id|s to wait for.
  4542. {timeout} is the maximum waiting time in milliseconds. If
  4543. omitted or -1, wait forever.
  4544. Timeout of 0 can be used to check the status of a job: >vim
  4545. let running = jobwait([{job-id}], 0)[0] == -1
  4546. <
  4547. During jobwait() callbacks for jobs not in the {jobs} list may
  4548. be invoked. The screen will not redraw unless |:redraw| is
  4549. invoked by a callback.
  4550. Returns a list of len({jobs}) integers, where each integer is
  4551. the status of the corresponding job:
  4552. Exit-code, if the job exited
  4553. -1 if the timeout was exceeded
  4554. -2 if the job was interrupted (by |CTRL-C|)
  4555. -3 if the job-id is invalid
  4556. Parameters: ~
  4557. • {jobs} (`integer[]`)
  4558. • {timeout} (`integer?`)
  4559. Return: ~
  4560. (`integer[]`)
  4561. join({list} [, {sep}]) *join()*
  4562. Join the items in {list} together into one String.
  4563. When {sep} is specified it is put in between the items. If
  4564. {sep} is omitted a single space is used.
  4565. Note that {sep} is not added at the end. You might want to
  4566. add it there too: >vim
  4567. let lines = join(mylist, "\n") .. "\n"
  4568. < String items are used as-is. |Lists| and |Dictionaries| are
  4569. converted into a string like with |string()|.
  4570. The opposite function is |split()|.
  4571. Parameters: ~
  4572. • {list} (`any[]`)
  4573. • {sep} (`string?`)
  4574. Return: ~
  4575. (`string`)
  4576. json_decode({expr}) *json_decode()*
  4577. Convert {expr} from JSON object. Accepts |readfile()|-style
  4578. list as the input, as well as regular string. May output any
  4579. Vim value. In the following cases it will output
  4580. |msgpack-special-dict|:
  4581. 1. Dictionary contains duplicate key.
  4582. 2. String contains NUL byte. Two special dictionaries: for
  4583. dictionary and for string will be emitted in case string
  4584. with NUL byte was a dictionary key.
  4585. Note: function treats its input as UTF-8 always. The JSON
  4586. standard allows only a few encodings, of which UTF-8 is
  4587. recommended and the only one required to be supported.
  4588. Non-UTF-8 characters are an error.
  4589. Parameters: ~
  4590. • {expr} (`any`)
  4591. Return: ~
  4592. (`any`)
  4593. json_encode({expr}) *json_encode()*
  4594. Convert {expr} into a JSON string. Accepts
  4595. |msgpack-special-dict| as the input. Will not convert
  4596. |Funcref|s, mappings with non-string keys (can be created as
  4597. |msgpack-special-dict|), values with self-referencing
  4598. containers, strings which contain non-UTF-8 characters,
  4599. pseudo-UTF-8 strings which contain codepoints reserved for
  4600. surrogate pairs (such strings are not valid UTF-8 strings).
  4601. Non-printable characters are converted into "\u1234" escapes
  4602. or special escapes like "\t", other are dumped as-is.
  4603. |Blob|s are converted to arrays of the individual bytes.
  4604. Parameters: ~
  4605. • {expr} (`any`)
  4606. Return: ~
  4607. (`string`)
  4608. keys({dict}) *keys()*
  4609. Return a |List| with all the keys of {dict}. The |List| is in
  4610. arbitrary order. Also see |items()| and |values()|.
  4611. Parameters: ~
  4612. • {dict} (`table`)
  4613. Return: ~
  4614. (`string[]`)
  4615. keytrans({string}) *keytrans()*
  4616. Turn the internal byte representation of keys into a form that
  4617. can be used for |:map|. E.g. >vim
  4618. let xx = "\<C-Home>"
  4619. echo keytrans(xx)
  4620. < <C-Home>
  4621. Parameters: ~
  4622. • {string} (`string`)
  4623. Return: ~
  4624. (`string`)
  4625. len({expr}) *len()* *E701*
  4626. The result is a Number, which is the length of the argument.
  4627. When {expr} is a String or a Number the length in bytes is
  4628. used, as with |strlen()|.
  4629. When {expr} is a |List| the number of items in the |List| is
  4630. returned.
  4631. When {expr} is a |Blob| the number of bytes is returned.
  4632. When {expr} is a |Dictionary| the number of entries in the
  4633. |Dictionary| is returned.
  4634. Otherwise an error is given and returns zero.
  4635. Parameters: ~
  4636. • {expr} (`any[]`)
  4637. Return: ~
  4638. (`integer`)
  4639. libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E368*
  4640. Call function {funcname} in the run-time library {libname}
  4641. with single argument {argument}.
  4642. This is useful to call functions in a library that you
  4643. especially made to be used with Vim. Since only one argument
  4644. is possible, calling standard library functions is rather
  4645. limited.
  4646. The result is the String returned by the function. If the
  4647. function returns NULL, this will appear as an empty string ""
  4648. to Vim.
  4649. If the function returns a number, use libcallnr()!
  4650. If {argument} is a number, it is passed to the function as an
  4651. int; if {argument} is a string, it is passed as a
  4652. null-terminated string.
  4653. libcall() allows you to write your own 'plug-in' extensions to
  4654. Vim without having to recompile the program. It is NOT a
  4655. means to call system functions! If you try to do so Vim will
  4656. very probably crash.
  4657. For Win32, the functions you write must be placed in a DLL
  4658. and use the normal C calling convention (NOT Pascal which is
  4659. used in Windows System DLLs). The function must take exactly
  4660. one parameter, either a character pointer or a long integer,
  4661. and must return a character pointer or NULL. The character
  4662. pointer returned must point to memory that will remain valid
  4663. after the function has returned (e.g. in static data in the
  4664. DLL). If it points to allocated memory, that memory will
  4665. leak away. Using a static buffer in the function should work,
  4666. it's then freed when the DLL is unloaded.
  4667. WARNING: If the function returns a non-valid pointer, Vim may
  4668. crash! This also happens if the function returns a number,
  4669. because Vim thinks it's a pointer.
  4670. For Win32 systems, {libname} should be the filename of the DLL
  4671. without the ".DLL" suffix. A full path is only required if
  4672. the DLL is not in the usual places.
  4673. For Unix: When compiling your own plugins, remember that the
  4674. object code must be compiled as position-independent ('PIC').
  4675. Examples: >vim
  4676. echo libcall("libc.so", "getenv", "HOME")
  4677. Parameters: ~
  4678. • {libname} (`string`)
  4679. • {funcname} (`string`)
  4680. • {argument} (`any`)
  4681. Return: ~
  4682. (`any`)
  4683. libcallnr({libname}, {funcname}, {argument}) *libcallnr()*
  4684. Just like |libcall()|, but used for a function that returns an
  4685. int instead of a string.
  4686. Examples: >vim
  4687. echo libcallnr("/usr/lib/libc.so", "getpid", "")
  4688. call libcallnr("libc.so", "printf", "Hello World!\n")
  4689. call libcallnr("libc.so", "sleep", 10)
  4690. <
  4691. Parameters: ~
  4692. • {libname} (`string`)
  4693. • {funcname} (`string`)
  4694. • {argument} (`any`)
  4695. Return: ~
  4696. (`any`)
  4697. line({expr} [, {winid}]) *line()*
  4698. See |getpos()| for accepted positions.
  4699. To get the column number use |col()|. To get both use
  4700. |getpos()|.
  4701. With the optional {winid} argument the values are obtained for
  4702. that window instead of the current window.
  4703. Returns 0 for invalid values of {expr} and {winid}.
  4704. Examples: >vim
  4705. echo line(".") " line number of the cursor
  4706. echo line(".", winid) " idem, in window "winid"
  4707. echo line("'t") " line number of mark t
  4708. echo line("'" .. marker) " line number of mark marker
  4709. <
  4710. To jump to the last known position when opening a file see
  4711. |last-position-jump|.
  4712. Parameters: ~
  4713. • {expr} (`string|integer[]`)
  4714. • {winid} (`integer?`)
  4715. Return: ~
  4716. (`integer`)
  4717. line2byte({lnum}) *line2byte()*
  4718. Return the byte count from the start of the buffer for line
  4719. {lnum}. This includes the end-of-line character, depending on
  4720. the 'fileformat' option for the current buffer. The first
  4721. line returns 1. UTF-8 encoding is used, 'fileencoding' is
  4722. ignored. This can also be used to get the byte count for the
  4723. line just below the last line: >vim
  4724. echo line2byte(line("$") + 1)
  4725. < This is the buffer size plus one. If 'fileencoding' is empty
  4726. it is the file size plus one. {lnum} is used like with
  4727. |getline()|. When {lnum} is invalid -1 is returned.
  4728. Also see |byte2line()|, |go| and |:goto|.
  4729. Parameters: ~
  4730. • {lnum} (`integer`)
  4731. Return: ~
  4732. (`integer`)
  4733. lispindent({lnum}) *lispindent()*
  4734. Get the amount of indent for line {lnum} according the lisp
  4735. indenting rules, as with 'lisp'.
  4736. The indent is counted in spaces, the value of 'tabstop' is
  4737. relevant. {lnum} is used just like in |getline()|.
  4738. When {lnum} is invalid, -1 is returned.
  4739. Parameters: ~
  4740. • {lnum} (`integer`)
  4741. Return: ~
  4742. (`integer`)
  4743. list2blob({list}) *list2blob()*
  4744. Return a Blob concatenating all the number values in {list}.
  4745. Examples: >vim
  4746. echo list2blob([1, 2, 3, 4]) " returns 0z01020304
  4747. echo list2blob([]) " returns 0z
  4748. < Returns an empty Blob on error. If one of the numbers is
  4749. negative or more than 255 error *E1239* is given.
  4750. |blob2list()| does the opposite.
  4751. Parameters: ~
  4752. • {list} (`any[]`)
  4753. Return: ~
  4754. (`string`)
  4755. list2str({list} [, {utf8}]) *list2str()*
  4756. Convert each number in {list} to a character string can
  4757. concatenate them all. Examples: >vim
  4758. echo list2str([32]) " returns " "
  4759. echo list2str([65, 66, 67]) " returns "ABC"
  4760. < The same can be done (slowly) with: >vim
  4761. echo join(map(list, {nr, val -> nr2char(val)}), '')
  4762. < |str2list()| does the opposite.
  4763. UTF-8 encoding is always used, {utf8} option has no effect,
  4764. and exists only for backwards-compatibility.
  4765. With UTF-8 composing characters work as expected: >vim
  4766. echo list2str([97, 769]) " returns "á"
  4767. <
  4768. Returns an empty string on error.
  4769. Parameters: ~
  4770. • {list} (`any[]`)
  4771. • {utf8} (`boolean?`)
  4772. Return: ~
  4773. (`string`)
  4774. localtime() *localtime()*
  4775. Return the current time, measured as seconds since 1st Jan
  4776. 1970. See also |strftime()|, |strptime()| and |getftime()|.
  4777. Return: ~
  4778. (`integer`)
  4779. log({expr}) *log()*
  4780. Return the natural logarithm (base e) of {expr} as a |Float|.
  4781. {expr} must evaluate to a |Float| or a |Number| in the range
  4782. (0, inf].
  4783. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4784. Examples: >vim
  4785. echo log(10)
  4786. < 2.302585 >vim
  4787. echo log(exp(5))
  4788. < 5.0
  4789. Parameters: ~
  4790. • {expr} (`number`)
  4791. Return: ~
  4792. (`number`)
  4793. log10({expr}) *log10()*
  4794. Return the logarithm of Float {expr} to base 10 as a |Float|.
  4795. {expr} must evaluate to a |Float| or a |Number|.
  4796. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4797. Examples: >vim
  4798. echo log10(1000)
  4799. < 3.0 >vim
  4800. echo log10(0.01)
  4801. < -2.0
  4802. Parameters: ~
  4803. • {expr} (`number`)
  4804. Return: ~
  4805. (`number`)
  4806. luaeval({expr} [, {expr}]) *luaeval()*
  4807. Evaluate Lua expression {expr} and return its result converted
  4808. to Vim data structures. See |lua-eval| for more details.
  4809. Parameters: ~
  4810. • {expr} (`string`)
  4811. • {expr1} (`any[]?`)
  4812. Return: ~
  4813. (`any`)
  4814. map({expr1}, {expr2}) *map()*
  4815. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  4816. When {expr1} is a |List| or |Dictionary|, replace each
  4817. item in {expr1} with the result of evaluating {expr2}.
  4818. For a |Blob| each byte is replaced.
  4819. For a |String|, each character, including composing
  4820. characters, is replaced.
  4821. If the item type changes you may want to use |mapnew()| to
  4822. create a new List or Dictionary.
  4823. {expr2} must be a |String| or |Funcref|.
  4824. If {expr2} is a |String|, inside {expr2} |v:val| has the value
  4825. of the current item. For a |Dictionary| |v:key| has the key
  4826. of the current item and for a |List| |v:key| has the index of
  4827. the current item. For a |Blob| |v:key| has the index of the
  4828. current byte. For a |String| |v:key| has the index of the
  4829. current character.
  4830. Example: >vim
  4831. call map(mylist, '"> " .. v:val .. " <"')
  4832. < This puts "> " before and " <" after each item in "mylist".
  4833. Note that {expr2} is the result of an expression and is then
  4834. used as an expression again. Often it is good to use a
  4835. |literal-string| to avoid having to double backslashes. You
  4836. still have to double ' quotes
  4837. If {expr2} is a |Funcref| it is called with two arguments:
  4838. 1. The key or the index of the current item.
  4839. 2. the value of the current item.
  4840. The function must return the new value of the item. Example
  4841. that changes each value by "key-value": >vim
  4842. func KeyValue(key, val)
  4843. return a:key .. '-' .. a:val
  4844. endfunc
  4845. call map(myDict, function('KeyValue'))
  4846. < It is shorter when using a |lambda|: >vim
  4847. call map(myDict, {key, val -> key .. '-' .. val})
  4848. < If you do not use "val" you can leave it out: >vim
  4849. call map(myDict, {key -> 'item: ' .. key})
  4850. < If you do not use "key" you can use a short name: >vim
  4851. call map(myDict, {_, val -> 'item: ' .. val})
  4852. <
  4853. The operation is done in-place for a |List| and |Dictionary|.
  4854. If you want it to remain unmodified make a copy first: >vim
  4855. let tlist = map(copy(mylist), ' v:val .. "\t"')
  4856. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  4857. or a new |Blob| or |String|.
  4858. When an error is encountered while evaluating {expr2} no
  4859. further items in {expr1} are processed.
  4860. When {expr2} is a Funcref errors inside a function are ignored,
  4861. unless it was defined with the "abort" flag.
  4862. Parameters: ~
  4863. • {expr1} (`string|table|any[]`)
  4864. • {expr2} (`string|function`)
  4865. Return: ~
  4866. (`any`)
  4867. maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
  4868. When {dict} is omitted or zero: Return the rhs of mapping
  4869. {name} in mode {mode}. The returned String has special
  4870. characters translated like in the output of the ":map" command
  4871. listing. When {dict} is TRUE a dictionary is returned, see
  4872. below. To get a list of all mappings see |maplist()|.
  4873. When there is no mapping for {name}, an empty String is
  4874. returned if {dict} is FALSE, otherwise returns an empty Dict.
  4875. When the mapping for {name} is empty, then "<Nop>" is
  4876. returned.
  4877. The {name} can have special key names, like in the ":map"
  4878. command.
  4879. {mode} can be one of these strings:
  4880. "n" Normal
  4881. "v" Visual (including Select)
  4882. "o" Operator-pending
  4883. "i" Insert
  4884. "c" Cmd-line
  4885. "s" Select
  4886. "x" Visual
  4887. "l" langmap |language-mapping|
  4888. "t" Terminal
  4889. "" Normal, Visual and Operator-pending
  4890. When {mode} is omitted, the modes for "" are used.
  4891. When {abbr} is there and it is |TRUE| use abbreviations
  4892. instead of mappings.
  4893. When {dict} is there and it is |TRUE| return a dictionary
  4894. containing all the information of the mapping with the
  4895. following items: *mapping-dict*
  4896. "lhs" The {lhs} of the mapping as it would be typed
  4897. "lhsraw" The {lhs} of the mapping as raw bytes
  4898. "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
  4899. form, only present when it differs from "lhsraw"
  4900. "rhs" The {rhs} of the mapping as typed.
  4901. "callback" Lua function, if RHS was defined as such.
  4902. "silent" 1 for a |:map-silent| mapping, else 0.
  4903. "noremap" 1 if the {rhs} of the mapping is not remappable.
  4904. "script" 1 if mapping was defined with <script>.
  4905. "expr" 1 for an expression mapping (|:map-<expr>|).
  4906. "buffer" 1 for a buffer local mapping (|:map-local|).
  4907. "mode" Modes for which the mapping is defined. In
  4908. addition to the modes mentioned above, these
  4909. characters will be used:
  4910. " " Normal, Visual and Operator-pending
  4911. "!" Insert and Commandline mode
  4912. (|mapmode-ic|)
  4913. "sid" The script local ID, used for <sid> mappings
  4914. (|<SID>|). Negative for special contexts.
  4915. "scriptversion" The version of the script, always 1.
  4916. "lnum" The line number in "sid", zero if unknown.
  4917. "nowait" Do not wait for other, longer mappings.
  4918. (|:map-<nowait>|).
  4919. "abbr" True if this is an |abbreviation|.
  4920. "mode_bits" Nvim's internal binary representation of "mode".
  4921. |mapset()| ignores this; only "mode" is used.
  4922. See |maplist()| for usage examples. The values
  4923. are from src/nvim/state_defs.h and may change in
  4924. the future.
  4925. The dictionary can be used to restore a mapping with
  4926. |mapset()|.
  4927. The mappings local to the current buffer are checked first,
  4928. then the global mappings.
  4929. This function can be used to map a key even when it's already
  4930. mapped, and have it do the original mapping too. Sketch: >vim
  4931. exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
  4932. <
  4933. Parameters: ~
  4934. • {name} (`string`)
  4935. • {mode} (`string?`)
  4936. • {abbr} (`boolean?`)
  4937. • {dict} (`false?`)
  4938. Return: ~
  4939. (`string`)
  4940. mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
  4941. Check if there is a mapping that matches with {name} in mode
  4942. {mode}. See |maparg()| for {mode} and special names in
  4943. {name}.
  4944. When {abbr} is there and it is non-zero use abbreviations
  4945. instead of mappings.
  4946. A match happens with a mapping that starts with {name} and
  4947. with a mapping which is equal to the start of {name}.
  4948. matches mapping "a" "ab" "abc" ~
  4949. mapcheck("a") yes yes yes
  4950. mapcheck("abc") yes yes yes
  4951. mapcheck("ax") yes no no
  4952. mapcheck("b") no no no
  4953. The difference with maparg() is that mapcheck() finds a
  4954. mapping that matches with {name}, while maparg() only finds a
  4955. mapping for {name} exactly.
  4956. When there is no mapping that starts with {name}, an empty
  4957. String is returned. If there is one, the RHS of that mapping
  4958. is returned. If there are several mappings that start with
  4959. {name}, the RHS of one of them is returned. This will be
  4960. "<Nop>" if the RHS is empty.
  4961. The mappings local to the current buffer are checked first,
  4962. then the global mappings.
  4963. This function can be used to check if a mapping can be added
  4964. without being ambiguous. Example: >vim
  4965. if mapcheck("_vv") == ""
  4966. map _vv :set guifont=7x13<CR>
  4967. endif
  4968. < This avoids adding the "_vv" mapping when there already is a
  4969. mapping for "_v" or for "_vvv".
  4970. Parameters: ~
  4971. • {name} (`string`)
  4972. • {mode} (`string?`)
  4973. • {abbr} (`boolean?`)
  4974. Return: ~
  4975. (`any`)
  4976. maplist([{abbr}]) *maplist()*
  4977. Returns a |List| of all mappings. Each List item is a |Dict|,
  4978. the same as what is returned by |maparg()|, see
  4979. |mapping-dict|. When {abbr} is there and it is |TRUE| use
  4980. abbreviations instead of mappings.
  4981. Example to show all mappings with "MultiMatch" in rhs: >vim
  4982. echo maplist()->filter({_, m ->
  4983. \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
  4984. \ })
  4985. < It can be tricky to find mappings for particular |:map-modes|.
  4986. |mapping-dict|'s "mode_bits" can simplify this. For example,
  4987. the mode_bits for Normal, Insert or Command-line modes are
  4988. 0x19. To find all the mappings available in those modes you
  4989. can do: >vim
  4990. let saved_maps = []
  4991. for m in maplist()
  4992. if and(m.mode_bits, 0x19) != 0
  4993. eval saved_maps->add(m)
  4994. endif
  4995. endfor
  4996. echo saved_maps->mapnew({_, m -> m.lhs})
  4997. < The values of the mode_bits are defined in Nvim's
  4998. src/nvim/state_defs.h file and they can be discovered at
  4999. runtime using |:map-commands| and "maplist()". Example: >vim
  5000. omap xyzzy <Nop>
  5001. let op_bit = maplist()->filter(
  5002. \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
  5003. ounmap xyzzy
  5004. echo printf("Operator-pending mode bit: 0x%x", op_bit)
  5005. <
  5006. Parameters: ~
  5007. • {abbr} (`0|1?`)
  5008. Return: ~
  5009. (`table[]`)
  5010. mapnew({expr1}, {expr2}) *mapnew()*
  5011. Like |map()| but instead of replacing items in {expr1} a new
  5012. List or Dictionary is created and returned. {expr1} remains
  5013. unchanged. Items can still be changed by {expr2}, if you
  5014. don't want that use |deepcopy()| first.
  5015. Parameters: ~
  5016. • {expr1} (`any`)
  5017. • {expr2} (`any`)
  5018. Return: ~
  5019. (`any`)
  5020. mapset({mode}, {abbr}, {dict}) *mapset()*
  5021. mapset({dict})
  5022. Restore a mapping from a dictionary, possibly returned by
  5023. |maparg()| or |maplist()|. A buffer mapping, when dict.buffer
  5024. is true, is set on the current buffer; it is up to the caller
  5025. to ensure that the intended buffer is the current buffer. This
  5026. feature allows copying mappings from one buffer to another.
  5027. The dict.mode value may restore a single mapping that covers
  5028. more than one mode, like with mode values of '!', ' ', "nox",
  5029. or 'v'. *E1276*
  5030. In the first form, {mode} and {abbr} should be the same as
  5031. for the call to |maparg()|. *E460*
  5032. {mode} is used to define the mode in which the mapping is set,
  5033. not the "mode" entry in {dict}.
  5034. Example for saving and restoring a mapping: >vim
  5035. let save_map = maparg('K', 'n', 0, 1)
  5036. nnoremap K somethingelse
  5037. " ...
  5038. call mapset('n', 0, save_map)
  5039. < Note that if you are going to replace a map in several modes,
  5040. e.g. with `:map!`, you need to save/restore the mapping for
  5041. all of them, when they might differ.
  5042. In the second form, with {dict} as the only argument, mode
  5043. and abbr are taken from the dict.
  5044. Example: >vim
  5045. let save_maps = maplist()->filter(
  5046. \ {_, m -> m.lhs == 'K'})
  5047. nnoremap K somethingelse
  5048. cnoremap K somethingelse2
  5049. " ...
  5050. unmap K
  5051. for d in save_maps
  5052. call mapset(d)
  5053. endfor
  5054. <
  5055. Parameters: ~
  5056. • {dict} (`boolean`)
  5057. Return: ~
  5058. (`any`)
  5059. match({expr}, {pat} [, {start} [, {count}]]) *match()*
  5060. When {expr} is a |List| then this returns the index of the
  5061. first item where {pat} matches. Each item is used as a
  5062. String, |Lists| and |Dictionaries| are used as echoed.
  5063. Otherwise, {expr} is used as a String. The result is a
  5064. Number, which gives the index (byte offset) in {expr} where
  5065. {pat} matches.
  5066. A match at the first character or |List| item returns zero.
  5067. If there is no match -1 is returned.
  5068. For getting submatches see |matchlist()|.
  5069. Example: >vim
  5070. echo match("testing", "ing") " results in 4
  5071. echo match([1, 'x'], '\a') " results in 1
  5072. < See |string-match| for how {pat} is used.
  5073. *strpbrk()*
  5074. Vim doesn't have a strpbrk() function. But you can do: >vim
  5075. let sepidx = match(line, '[.,;: \t]')
  5076. < *strcasestr()*
  5077. Vim doesn't have a strcasestr() function. But you can add
  5078. "\c" to the pattern to ignore case: >vim
  5079. let idx = match(haystack, '\cneedle')
  5080. <
  5081. If {start} is given, the search starts from byte index
  5082. {start} in a String or item {start} in a |List|.
  5083. The result, however, is still the index counted from the
  5084. first character/item. Example: >vim
  5085. echo match("testing", "ing", 2)
  5086. < result is again "4". >vim
  5087. echo match("testing", "ing", 4)
  5088. < result is again "4". >vim
  5089. echo match("testing", "t", 2)
  5090. < result is "3".
  5091. For a String, if {start} > 0 then it is like the string starts
  5092. {start} bytes later, thus "^" will match at {start}. Except
  5093. when {count} is given, then it's like matches before the
  5094. {start} byte are ignored (this is a bit complicated to keep it
  5095. backwards compatible).
  5096. For a String, if {start} < 0, it will be set to 0. For a list
  5097. the index is counted from the end.
  5098. If {start} is out of range ({start} > strlen({expr}) for a
  5099. String or {start} > len({expr}) for a |List|) -1 is returned.
  5100. When {count} is given use the {count}th match. When a match
  5101. is found in a String the search for the next one starts one
  5102. character further. Thus this example results in 1: >vim
  5103. echo match("testing", "..", 0, 2)
  5104. < In a |List| the search continues in the next item.
  5105. Note that when {count} is added the way {start} works changes,
  5106. see above.
  5107. *match-pattern*
  5108. See |pattern| for the patterns that are accepted.
  5109. The 'ignorecase' option is used to set the ignore-caseness of
  5110. the pattern. 'smartcase' is NOT used. The matching is always
  5111. done like 'magic' is set and 'cpoptions' is empty.
  5112. Note that a match at the start is preferred, thus when the
  5113. pattern is using "*" (any number of matches) it tends to find
  5114. zero matches at the start instead of a number of matches
  5115. further down in the text.
  5116. Parameters: ~
  5117. • {expr} (`string|any[]`)
  5118. • {pat} (`string`)
  5119. • {start} (`integer?`)
  5120. • {count} (`integer?`)
  5121. Return: ~
  5122. (`any`)
  5123. *matchadd()* *E798* *E799* *E801* *E957*
  5124. matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
  5125. Defines a pattern to be highlighted in the current window (a
  5126. "match"). It will be highlighted with {group}. Returns an
  5127. identification number (ID), which can be used to delete the
  5128. match using |matchdelete()|. The ID is bound to the window.
  5129. Matching is case sensitive and magic, unless case sensitivity
  5130. or magicness are explicitly overridden in {pattern}. The
  5131. 'magic', 'smartcase' and 'ignorecase' options are not used.
  5132. The "Conceal" value is special, it causes the match to be
  5133. concealed.
  5134. The optional {priority} argument assigns a priority to the
  5135. match. A match with a high priority will have its
  5136. highlighting overrule that of a match with a lower priority.
  5137. A priority is specified as an integer (negative numbers are no
  5138. exception). If the {priority} argument is not specified, the
  5139. default priority is 10. The priority of 'hlsearch' is zero,
  5140. hence all matches with a priority greater than zero will
  5141. overrule it. Syntax highlighting (see 'syntax') is a separate
  5142. mechanism, and regardless of the chosen priority a match will
  5143. always overrule syntax highlighting.
  5144. The optional {id} argument allows the request for a specific
  5145. match ID. If a specified ID is already taken, an error
  5146. message will appear and the match will not be added. An ID
  5147. is specified as a positive integer (zero excluded). IDs 1, 2
  5148. and 3 are reserved for |:match|, |:2match| and |:3match|,
  5149. respectively. 3 is reserved for use by the |matchparen|
  5150. plugin.
  5151. If the {id} argument is not specified or -1, |matchadd()|
  5152. automatically chooses a free ID, which is at least 1000.
  5153. The optional {dict} argument allows for further custom
  5154. values. Currently this is used to specify a match specific
  5155. conceal character that will be shown for |hl-Conceal|
  5156. highlighted matches. The dict can have the following members:
  5157. conceal Special character to show instead of the
  5158. match (only for |hl-Conceal| highlighted
  5159. matches, see |:syn-cchar|)
  5160. window Instead of the current window use the
  5161. window with this number or window ID.
  5162. The number of matches is not limited, as it is the case with
  5163. the |:match| commands.
  5164. Returns -1 on error.
  5165. Example: >vim
  5166. highlight MyGroup ctermbg=green guibg=green
  5167. let m = matchadd("MyGroup", "TODO")
  5168. < Deletion of the pattern: >vim
  5169. call matchdelete(m)
  5170. < A list of matches defined by |matchadd()| and |:match| are
  5171. available from |getmatches()|. All matches can be deleted in
  5172. one operation by |clearmatches()|.
  5173. Parameters: ~
  5174. • {group} (`integer|string`)
  5175. • {pattern} (`string`)
  5176. • {priority} (`integer?`)
  5177. • {id} (`integer?`)
  5178. • {dict} (`string?`)
  5179. Return: ~
  5180. (`any`)
  5181. matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
  5182. Same as |matchadd()|, but requires a list of positions {pos}
  5183. instead of a pattern. This command is faster than |matchadd()|
  5184. because it does not handle regular expressions and it sets
  5185. buffer line boundaries to redraw screen. It is supposed to be
  5186. used when fast match additions and deletions are required, for
  5187. example to highlight matching parentheses.
  5188. *E5030* *E5031*
  5189. {pos} is a list of positions. Each position can be one of
  5190. these:
  5191. - A number. This whole line will be highlighted. The first
  5192. line has number 1.
  5193. - A list with one number, e.g., [23]. The whole line with this
  5194. number will be highlighted.
  5195. - A list with two numbers, e.g., [23, 11]. The first number is
  5196. the line number, the second one is the column number (first
  5197. column is 1, the value must correspond to the byte index as
  5198. |col()| would return). The character at this position will
  5199. be highlighted.
  5200. - A list with three numbers, e.g., [23, 11, 3]. As above, but
  5201. the third number gives the length of the highlight in bytes.
  5202. Entries with zero and negative line numbers are silently
  5203. ignored, as well as entries with negative column numbers and
  5204. lengths.
  5205. Returns -1 on error.
  5206. Example: >vim
  5207. highlight MyGroup ctermbg=green guibg=green
  5208. let m = matchaddpos("MyGroup", [[23, 24], 34])
  5209. < Deletion of the pattern: >vim
  5210. call matchdelete(m)
  5211. < Matches added by |matchaddpos()| are returned by
  5212. |getmatches()|.
  5213. Parameters: ~
  5214. • {group} (`integer|string`)
  5215. • {pos} (`any[]`)
  5216. • {priority} (`integer?`)
  5217. • {id} (`integer?`)
  5218. • {dict} (`string?`)
  5219. Return: ~
  5220. (`any`)
  5221. matcharg({nr}) *matcharg()*
  5222. Selects the {nr} match item, as set with a |:match|,
  5223. |:2match| or |:3match| command.
  5224. Return a |List| with two elements:
  5225. The name of the highlight group used
  5226. The pattern used.
  5227. When {nr} is not 1, 2 or 3 returns an empty |List|.
  5228. When there is no match item set returns ['', ''].
  5229. This is useful to save and restore a |:match|.
  5230. Highlighting matches using the |:match| commands are limited
  5231. to three matches. |matchadd()| does not have this limitation.
  5232. Parameters: ~
  5233. • {nr} (`integer`)
  5234. Return: ~
  5235. (`any`)
  5236. matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
  5237. Returns the |List| of matches in lines from {lnum} to {end} in
  5238. buffer {buf} where {pat} matches.
  5239. {lnum} and {end} can either be a line number or the string "$"
  5240. to refer to the last line in {buf}.
  5241. The {dict} argument supports following items:
  5242. submatches include submatch information (|/\(|)
  5243. For each match, a |Dict| with the following items is returned:
  5244. byteidx starting byte index of the match
  5245. lnum line number where there is a match
  5246. text matched string
  5247. Note that there can be multiple matches in a single line.
  5248. This function works only for loaded buffers. First call
  5249. |bufload()| if needed.
  5250. See |match-pattern| for information about the effect of some
  5251. option settings on the pattern.
  5252. When {buf} is not a valid buffer, the buffer is not loaded or
  5253. {lnum} or {end} is not valid then an error is given and an
  5254. empty |List| is returned.
  5255. Examples: >vim
  5256. " Assuming line 3 in buffer 5 contains "a"
  5257. echo matchbufline(5, '\<\k\+\>', 3, 3)
  5258. < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
  5259. " Assuming line 4 in buffer 10 contains "tik tok"
  5260. echo matchbufline(10, '\<\k\+\>', 1, 4)
  5261. < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
  5262. If {submatch} is present and is v:true, then submatches like
  5263. "\1", "\2", etc. are also returned. Example: >vim
  5264. " Assuming line 2 in buffer 2 contains "acd"
  5265. echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
  5266. \ {'submatches': v:true})
  5267. < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5268. The "submatches" List always contains 9 items. If a submatch
  5269. is not found, then an empty string is returned for that
  5270. submatch.
  5271. Parameters: ~
  5272. • {buf} (`string|integer`)
  5273. • {pat} (`string`)
  5274. • {lnum} (`string|integer`)
  5275. • {end} (`string|integer`)
  5276. • {dict} (`table?`)
  5277. Return: ~
  5278. (`any`)
  5279. matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
  5280. Deletes a match with ID {id} previously defined by |matchadd()|
  5281. or one of the |:match| commands. Returns 0 if successful,
  5282. otherwise -1. See example for |matchadd()|. All matches can
  5283. be deleted in one operation by |clearmatches()|.
  5284. If {win} is specified, use the window with this number or
  5285. window ID instead of the current window.
  5286. Parameters: ~
  5287. • {id} (`integer`)
  5288. • {win} (`integer?`)
  5289. Return: ~
  5290. (`any`)
  5291. matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
  5292. Same as |match()|, but return the index of first character
  5293. after the match. Example: >vim
  5294. echo matchend("testing", "ing")
  5295. < results in "7".
  5296. *strspn()* *strcspn()*
  5297. Vim doesn't have a strspn() or strcspn() function, but you can
  5298. do it with matchend(): >vim
  5299. let span = matchend(line, '[a-zA-Z]')
  5300. let span = matchend(line, '[^a-zA-Z]')
  5301. < Except that -1 is returned when there are no matches.
  5302. The {start}, if given, has the same meaning as for |match()|. >vim
  5303. echo matchend("testing", "ing", 2)
  5304. < results in "7". >vim
  5305. echo matchend("testing", "ing", 5)
  5306. < result is "-1".
  5307. When {expr} is a |List| the result is equal to |match()|.
  5308. Parameters: ~
  5309. • {expr} (`any`)
  5310. • {pat} (`string`)
  5311. • {start} (`integer?`)
  5312. • {count} (`integer?`)
  5313. Return: ~
  5314. (`any`)
  5315. matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
  5316. If {list} is a list of strings, then returns a |List| with all
  5317. the strings in {list} that fuzzy match {str}. The strings in
  5318. the returned list are sorted based on the matching score.
  5319. The optional {dict} argument always supports the following
  5320. items:
  5321. matchseq When this item is present return only matches
  5322. that contain the characters in {str} in the
  5323. given sequence.
  5324. limit Maximum number of matches in {list} to be
  5325. returned. Zero means no limit.
  5326. If {list} is a list of dictionaries, then the optional {dict}
  5327. argument supports the following additional items:
  5328. key Key of the item which is fuzzy matched against
  5329. {str}. The value of this item should be a
  5330. string.
  5331. text_cb |Funcref| that will be called for every item
  5332. in {list} to get the text for fuzzy matching.
  5333. This should accept a dictionary item as the
  5334. argument and return the text for that item to
  5335. use for fuzzy matching.
  5336. {str} is treated as a literal string and regular expression
  5337. matching is NOT supported. The maximum supported {str} length
  5338. is 256.
  5339. When {str} has multiple words each separated by white space,
  5340. then the list of strings that have all the words is returned.
  5341. If there are no matching strings or there is an error, then an
  5342. empty list is returned. If length of {str} is greater than
  5343. 256, then returns an empty list.
  5344. When {limit} is given, matchfuzzy() will find up to this
  5345. number of matches in {list} and return them in sorted order.
  5346. Refer to |fuzzy-matching| for more information about fuzzy
  5347. matching strings.
  5348. Example: >vim
  5349. echo matchfuzzy(["clay", "crow"], "cay")
  5350. < results in ["clay"]. >vim
  5351. echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
  5352. < results in a list of buffer names fuzzy matching "ndl". >vim
  5353. echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
  5354. < results in a list of buffer information dicts with buffer
  5355. names fuzzy matching "ndl". >vim
  5356. echo getbufinfo()->matchfuzzy("spl",
  5357. \ {'text_cb' : {v -> v.name}})
  5358. < results in a list of buffer information dicts with buffer
  5359. names fuzzy matching "spl". >vim
  5360. echo v:oldfiles->matchfuzzy("test")
  5361. < results in a list of file names fuzzy matching "test". >vim
  5362. let l = readfile("buffer.c")->matchfuzzy("str")
  5363. < results in a list of lines in "buffer.c" fuzzy matching "str". >vim
  5364. echo ['one two', 'two one']->matchfuzzy('two one')
  5365. < results in `['two one', 'one two']` . >vim
  5366. echo ['one two', 'two one']->matchfuzzy('two one',
  5367. \ {'matchseq': 1})
  5368. < results in `['two one']`.
  5369. Parameters: ~
  5370. • {list} (`any[]`)
  5371. • {str} (`string`)
  5372. • {dict} (`string?`)
  5373. Return: ~
  5374. (`any`)
  5375. matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
  5376. Same as |matchfuzzy()|, but returns the list of matched
  5377. strings, the list of character positions where characters
  5378. in {str} matches and a list of matching scores. You can
  5379. use |byteidx()| to convert a character position to a byte
  5380. position.
  5381. If {str} matches multiple times in a string, then only the
  5382. positions for the best match is returned.
  5383. If there are no matching strings or there is an error, then a
  5384. list with three empty list items is returned.
  5385. Example: >vim
  5386. echo matchfuzzypos(['testing'], 'tsg')
  5387. < results in [["testing"], [[0, 2, 6]], [99]] >vim
  5388. echo matchfuzzypos(['clay', 'lacy'], 'la')
  5389. < results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
  5390. echo [{'text': 'hello', 'id' : 10}]
  5391. \ ->matchfuzzypos('ll', {'key' : 'text'})
  5392. < results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
  5393. Parameters: ~
  5394. • {list} (`any[]`)
  5395. • {str} (`string`)
  5396. • {dict} (`string?`)
  5397. Return: ~
  5398. (`any`)
  5399. matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
  5400. Same as |match()|, but return a |List|. The first item in the
  5401. list is the matched string, same as what matchstr() would
  5402. return. Following items are submatches, like "\1", "\2", etc.
  5403. in |:substitute|. When an optional submatch didn't match an
  5404. empty string is used. Example: >vim
  5405. echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
  5406. < Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
  5407. When there is no match an empty list is returned.
  5408. You can pass in a List, but that is not very useful.
  5409. Parameters: ~
  5410. • {expr} (`any`)
  5411. • {pat} (`string`)
  5412. • {start} (`integer?`)
  5413. • {count} (`integer?`)
  5414. Return: ~
  5415. (`any`)
  5416. matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
  5417. Same as |match()|, but return the matched string. Example: >vim
  5418. echo matchstr("testing", "ing")
  5419. < results in "ing".
  5420. When there is no match "" is returned.
  5421. The {start}, if given, has the same meaning as for |match()|. >vim
  5422. echo matchstr("testing", "ing", 2)
  5423. < results in "ing". >vim
  5424. echo matchstr("testing", "ing", 5)
  5425. < result is "".
  5426. When {expr} is a |List| then the matching item is returned.
  5427. The type isn't changed, it's not necessarily a String.
  5428. Parameters: ~
  5429. • {expr} (`any`)
  5430. • {pat} (`string`)
  5431. • {start} (`integer?`)
  5432. • {count} (`integer?`)
  5433. Return: ~
  5434. (`any`)
  5435. matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
  5436. Returns the |List| of matches in {list} where {pat} matches.
  5437. {list} is a |List| of strings. {pat} is matched against each
  5438. string in {list}.
  5439. The {dict} argument supports following items:
  5440. submatches include submatch information (|/\(|)
  5441. For each match, a |Dict| with the following items is returned:
  5442. byteidx starting byte index of the match.
  5443. idx index in {list} of the match.
  5444. text matched string
  5445. submatches a List of submatches. Present only if
  5446. "submatches" is set to v:true in {dict}.
  5447. See |match-pattern| for information about the effect of some
  5448. option settings on the pattern.
  5449. Example: >vim
  5450. echo matchstrlist(['tik tok'], '\<\k\+\>')
  5451. < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
  5452. echo matchstrlist(['a', 'b'], '\<\k\+\>')
  5453. < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
  5454. If "submatches" is present and is v:true, then submatches like
  5455. "\1", "\2", etc. are also returned. Example: >vim
  5456. echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
  5457. \ #{submatches: v:true})
  5458. < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5459. The "submatches" List always contains 9 items. If a submatch
  5460. is not found, then an empty string is returned for that
  5461. submatch.
  5462. Parameters: ~
  5463. • {list} (`string[]`)
  5464. • {pat} (`string`)
  5465. • {dict} (`table?`)
  5466. Return: ~
  5467. (`any`)
  5468. matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
  5469. Same as |matchstr()|, but return the matched string, the start
  5470. position and the end position of the match. Example: >vim
  5471. echo matchstrpos("testing", "ing")
  5472. < results in ["ing", 4, 7].
  5473. When there is no match ["", -1, -1] is returned.
  5474. The {start}, if given, has the same meaning as for |match()|. >vim
  5475. echo matchstrpos("testing", "ing", 2)
  5476. < results in ["ing", 4, 7]. >vim
  5477. echo matchstrpos("testing", "ing", 5)
  5478. < result is ["", -1, -1].
  5479. When {expr} is a |List| then the matching item, the index
  5480. of first item where {pat} matches, the start position and the
  5481. end position of the match are returned. >vim
  5482. echo matchstrpos([1, '__x'], '\a')
  5483. < result is ["x", 1, 2, 3].
  5484. The type isn't changed, it's not necessarily a String.
  5485. Parameters: ~
  5486. • {expr} (`any`)
  5487. • {pat} (`string`)
  5488. • {start} (`integer?`)
  5489. • {count} (`integer?`)
  5490. Return: ~
  5491. (`any`)
  5492. max({expr}) *max()*
  5493. Return the maximum value of all items in {expr}. Example: >vim
  5494. echo max([apples, pears, oranges])
  5495. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5496. it returns the maximum of all values in the Dictionary.
  5497. If {expr} is neither a List nor a Dictionary, or one of the
  5498. items in {expr} cannot be used as a Number this results in
  5499. an error. An empty |List| or |Dictionary| results in zero.
  5500. Parameters: ~
  5501. • {expr} (`any`)
  5502. Return: ~
  5503. (`number`)
  5504. menu_get({path} [, {modes}]) *menu_get()*
  5505. Returns a |List| of |Dictionaries| describing |menus| (defined
  5506. by |:menu|, |:amenu|, …), including |hidden-menus|.
  5507. {path} matches a menu by name, or all menus if {path} is an
  5508. empty string. Example: >vim
  5509. echo menu_get('File','')
  5510. echo menu_get('')
  5511. <
  5512. {modes} is a string of zero or more modes (see |maparg()| or
  5513. |creating-menus| for the list of modes). "a" means "all".
  5514. Example: >vim
  5515. nnoremenu &Test.Test inormal
  5516. inoremenu Test.Test insert
  5517. vnoremenu Test.Test x
  5518. echo menu_get("")
  5519. < returns something like this: >
  5520. [ {
  5521. "hidden": 0,
  5522. "name": "Test",
  5523. "priority": 500,
  5524. "shortcut": 84,
  5525. "submenus": [ {
  5526. "hidden": 0,
  5527. "mappings": {
  5528. i": {
  5529. "enabled": 1,
  5530. "noremap": 1,
  5531. "rhs": "insert",
  5532. "sid": 1,
  5533. "silent": 0
  5534. },
  5535. n": { ... },
  5536. s": { ... },
  5537. v": { ... }
  5538. },
  5539. "name": "Test",
  5540. "priority": 500,
  5541. "shortcut": 0
  5542. } ]
  5543. } ]
  5544. <
  5545. Parameters: ~
  5546. • {path} (`string`)
  5547. • {modes} (`string?`)
  5548. Return: ~
  5549. (`any`)
  5550. menu_info({name} [, {mode}]) *menu_info()*
  5551. Return information about the specified menu {name} in
  5552. mode {mode}. The menu name should be specified without the
  5553. shortcut character ('&'). If {name} is "", then the top-level
  5554. menu names are returned.
  5555. {mode} can be one of these strings:
  5556. "n" Normal
  5557. "v" Visual (including Select)
  5558. "o" Operator-pending
  5559. "i" Insert
  5560. "c" Cmd-line
  5561. "s" Select
  5562. "x" Visual
  5563. "t" Terminal-Job
  5564. "" Normal, Visual and Operator-pending
  5565. "!" Insert and Cmd-line
  5566. When {mode} is omitted, the modes for "" are used.
  5567. Returns a |Dictionary| containing the following items:
  5568. accel menu item accelerator text |menu-text|
  5569. display display name (name without '&')
  5570. enabled v:true if this menu item is enabled
  5571. Refer to |:menu-enable|
  5572. icon name of the icon file (for toolbar)
  5573. |toolbar-icon|
  5574. iconidx index of a built-in icon
  5575. modes modes for which the menu is defined. In
  5576. addition to the modes mentioned above, these
  5577. characters will be used:
  5578. " " Normal, Visual and Operator-pending
  5579. name menu item name.
  5580. noremenu v:true if the {rhs} of the menu item is not
  5581. remappable else v:false.
  5582. priority menu order priority |menu-priority|
  5583. rhs right-hand-side of the menu item. The returned
  5584. string has special characters translated like
  5585. in the output of the ":menu" command listing.
  5586. When the {rhs} of a menu item is empty, then
  5587. "<Nop>" is returned.
  5588. script v:true if script-local remapping of {rhs} is
  5589. allowed else v:false. See |:menu-script|.
  5590. shortcut shortcut key (character after '&' in
  5591. the menu name) |menu-shortcut|
  5592. silent v:true if the menu item is created
  5593. with <silent> argument |:menu-silent|
  5594. submenus |List| containing the names of
  5595. all the submenus. Present only if the menu
  5596. item has submenus.
  5597. Returns an empty dictionary if the menu item is not found.
  5598. Examples: >vim
  5599. echo menu_info('Edit.Cut')
  5600. echo menu_info('File.Save', 'n')
  5601. " Display the entire menu hierarchy in a buffer
  5602. func ShowMenu(name, pfx)
  5603. let m = menu_info(a:name)
  5604. call append(line('$'), a:pfx .. m.display)
  5605. for child in m->get('submenus', [])
  5606. call ShowMenu(a:name .. '.' .. escape(child, '.'),
  5607. \ a:pfx .. ' ')
  5608. endfor
  5609. endfunc
  5610. new
  5611. for topmenu in menu_info('').submenus
  5612. call ShowMenu(topmenu, '')
  5613. endfor
  5614. <
  5615. Parameters: ~
  5616. • {name} (`string`)
  5617. • {mode} (`string?`)
  5618. Return: ~
  5619. (`any`)
  5620. min({expr}) *min()*
  5621. Return the minimum value of all items in {expr}. Example: >vim
  5622. echo min([apples, pears, oranges])
  5623. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5624. it returns the minimum of all values in the Dictionary.
  5625. If {expr} is neither a List nor a Dictionary, or one of the
  5626. items in {expr} cannot be used as a Number this results in
  5627. an error. An empty |List| or |Dictionary| results in zero.
  5628. Parameters: ~
  5629. • {expr} (`any`)
  5630. Return: ~
  5631. (`number`)
  5632. mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
  5633. Create directory {name}.
  5634. When {flags} is present it must be a string. An empty string
  5635. has no effect.
  5636. {flags} can contain these character flags:
  5637. "p" intermediate directories will be created as necessary
  5638. "D" {name} will be deleted at the end of the current
  5639. function, but not recursively |:defer|
  5640. "R" {name} will be deleted recursively at the end of the
  5641. current function |:defer|
  5642. Note that when {name} has more than one part and "p" is used
  5643. some directories may already exist. Only the first one that
  5644. is created and what it contains is scheduled to be deleted.
  5645. E.g. when using: >vim
  5646. call mkdir('subdir/tmp/autoload', 'pR')
  5647. < and "subdir" already exists then "subdir/tmp" will be
  5648. scheduled for deletion, like with: >vim
  5649. defer delete('subdir/tmp', 'rf')
  5650. <
  5651. If {prot} is given it is used to set the protection bits of
  5652. the new directory. The default is 0o755 (rwxr-xr-x: r/w for
  5653. the user, readable for others). Use 0o700 to make it
  5654. unreadable for others.
  5655. {prot} is applied for all parts of {name}. Thus if you create
  5656. /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
  5657. call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
  5658. < This function is not available in the |sandbox|.
  5659. If you try to create an existing directory with {flags} set to
  5660. "p" mkdir() will silently exit.
  5661. The function result is a Number, which is TRUE if the call was
  5662. successful or FALSE if the directory creation failed or partly
  5663. failed.
  5664. Parameters: ~
  5665. • {name} (`string`)
  5666. • {flags} (`string?`)
  5667. • {prot} (`string?`)
  5668. Return: ~
  5669. (`integer`)
  5670. mode([{expr}]) *mode()*
  5671. Return a string that indicates the current mode.
  5672. If {expr} is supplied and it evaluates to a non-zero Number or
  5673. a non-empty String (|non-zero-arg|), then the full mode is
  5674. returned, otherwise only the first letter is returned.
  5675. Also see |state()|.
  5676. n Normal
  5677. no Operator-pending
  5678. nov Operator-pending (forced charwise |o_v|)
  5679. noV Operator-pending (forced linewise |o_V|)
  5680. noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
  5681. CTRL-V is one character
  5682. niI Normal using |i_CTRL-O| in |Insert-mode|
  5683. niR Normal using |i_CTRL-O| in |Replace-mode|
  5684. niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
  5685. nt Normal in |terminal-emulator| (insert goes to
  5686. Terminal mode)
  5687. ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
  5688. v Visual by character
  5689. vs Visual by character using |v_CTRL-O| in Select mode
  5690. V Visual by line
  5691. Vs Visual by line using |v_CTRL-O| in Select mode
  5692. CTRL-V Visual blockwise
  5693. CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
  5694. s Select by character
  5695. S Select by line
  5696. CTRL-S Select blockwise
  5697. i Insert
  5698. ic Insert mode completion |compl-generic|
  5699. ix Insert mode |i_CTRL-X| completion
  5700. R Replace |R|
  5701. Rc Replace mode completion |compl-generic|
  5702. Rx Replace mode |i_CTRL-X| completion
  5703. Rv Virtual Replace |gR|
  5704. Rvc Virtual Replace mode completion |compl-generic|
  5705. Rvx Virtual Replace mode |i_CTRL-X| completion
  5706. c Command-line editing
  5707. cr Command-line editing overstrike mode |c_<Insert>|
  5708. cv Vim Ex mode |gQ|
  5709. cvr Vim Ex mode while in overstrike mode |c_<Insert>|
  5710. r Hit-enter prompt
  5711. rm The -- more -- prompt
  5712. r? A |:confirm| query of some sort
  5713. ! Shell or external command is executing
  5714. t Terminal mode: keys go to the job
  5715. This is useful in the 'statusline' option or RPC calls. In
  5716. most other places it always returns "c" or "n".
  5717. Note that in the future more modes and more specific modes may
  5718. be added. It's better not to compare the whole string but only
  5719. the leading character(s).
  5720. Also see |visualmode()|.
  5721. Parameters: ~
  5722. • {expr} (`any?`)
  5723. Return: ~
  5724. (`any`)
  5725. msgpackdump({list} [, {type}]) *msgpackdump()*
  5726. Convert a list of Vimscript objects to msgpack. Returned value is a
  5727. |readfile()|-style list. When {type} contains "B", a |Blob| is
  5728. returned instead. Example: >vim
  5729. call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
  5730. < or, using a |Blob|: >vim
  5731. call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
  5732. <
  5733. This will write the single 0x80 byte to a `fname.mpack` file
  5734. (dictionary with zero items is represented by 0x80 byte in
  5735. messagepack).
  5736. Limitations: *E5004* *E5005*
  5737. 1. |Funcref|s cannot be dumped.
  5738. 2. Containers that reference themselves cannot be dumped.
  5739. 3. Dictionary keys are always dumped as STR strings.
  5740. 4. Other strings and |Blob|s are always dumped as BIN strings.
  5741. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
  5742. Parameters: ~
  5743. • {list} (`any`)
  5744. • {type} (`any?`)
  5745. Return: ~
  5746. (`any`)
  5747. msgpackparse({data}) *msgpackparse()*
  5748. Convert a |readfile()|-style list or a |Blob| to a list of
  5749. Vimscript objects.
  5750. Example: >vim
  5751. let fname = expand('~/.config/nvim/shada/main.shada')
  5752. let mpack = readfile(fname, 'b')
  5753. let shada_objects = msgpackparse(mpack)
  5754. < This will read ~/.config/nvim/shada/main.shada file to
  5755. `shada_objects` list.
  5756. Limitations:
  5757. 1. Mapping ordering is not preserved unless messagepack
  5758. mapping is dumped using generic mapping
  5759. (|msgpack-special-map|).
  5760. 2. Since the parser aims to preserve all data untouched
  5761. (except for 1.) some strings are parsed to
  5762. |msgpack-special-dict| format which is not convenient to
  5763. use.
  5764. *msgpack-special-dict*
  5765. Some messagepack strings may be parsed to special
  5766. dictionaries. Special dictionaries are dictionaries which
  5767. 1. Contain exactly two keys: `_TYPE` and `_VAL`.
  5768. 2. `_TYPE` key is one of the types found in |v:msgpack_types|
  5769. variable.
  5770. 3. Value for `_VAL` has the following format (Key column
  5771. contains name of the key from |v:msgpack_types|):
  5772. Key Value ~
  5773. nil Zero, ignored when dumping. Not returned by
  5774. |msgpackparse()| since |v:null| was introduced.
  5775. boolean One or zero. When dumping it is only checked that
  5776. value is a |Number|. Not returned by |msgpackparse()|
  5777. since |v:true| and |v:false| were introduced.
  5778. integer |List| with four numbers: sign (-1 or 1), highest two
  5779. bits, number with bits from 62nd to 31st, lowest 31
  5780. bits. I.e. to get actual number one will need to use
  5781. code like >
  5782. _VAL[0] * ((_VAL[1] << 62)
  5783. & (_VAL[2] << 31)
  5784. & _VAL[3])
  5785. < Special dictionary with this type will appear in
  5786. |msgpackparse()| output under one of the following
  5787. circumstances:
  5788. 1. |Number| is 32-bit and value is either above
  5789. INT32_MAX or below INT32_MIN.
  5790. 2. |Number| is 64-bit and value is above INT64_MAX. It
  5791. cannot possibly be below INT64_MIN because msgpack
  5792. C parser does not support such values.
  5793. float |Float|. This value cannot possibly appear in
  5794. |msgpackparse()| output.
  5795. string |String|, or |Blob| if binary string contains zero
  5796. byte. This value cannot appear in |msgpackparse()|
  5797. output since blobs were introduced.
  5798. array |List|. This value cannot appear in |msgpackparse()|
  5799. output.
  5800. *msgpack-special-map*
  5801. map |List| of |List|s with two items (key and value) each.
  5802. This value will appear in |msgpackparse()| output if
  5803. parsed mapping contains one of the following keys:
  5804. 1. Any key that is not a string (including keys which
  5805. are binary strings).
  5806. 2. String with NUL byte inside.
  5807. 3. Duplicate key.
  5808. ext |List| with two values: first is a signed integer
  5809. representing extension type. Second is
  5810. |readfile()|-style list of strings.
  5811. Parameters: ~
  5812. • {data} (`any`)
  5813. Return: ~
  5814. (`any`)
  5815. nextnonblank({lnum}) *nextnonblank()*
  5816. Return the line number of the first line at or below {lnum}
  5817. that is not blank. Example: >vim
  5818. if getline(nextnonblank(1)) =~ "Java" | endif
  5819. < When {lnum} is invalid or there is no non-blank line at or
  5820. below it, zero is returned.
  5821. {lnum} is used like with |getline()|.
  5822. See also |prevnonblank()|.
  5823. Parameters: ~
  5824. • {lnum} (`integer`)
  5825. Return: ~
  5826. (`integer`)
  5827. nr2char({expr} [, {utf8}]) *nr2char()*
  5828. Return a string with a single character, which has the number
  5829. value {expr}. Examples: >vim
  5830. echo nr2char(64) " returns '@'
  5831. echo nr2char(32) " returns ' '
  5832. < Example for "utf-8": >vim
  5833. echo nr2char(300) " returns I with bow character
  5834. <
  5835. UTF-8 encoding is always used, {utf8} option has no effect,
  5836. and exists only for backwards-compatibility.
  5837. Note that a NUL character in the file is specified with
  5838. nr2char(10), because NULs are represented with newline
  5839. characters. nr2char(0) is a real NUL and terminates the
  5840. string, thus results in an empty string.
  5841. Parameters: ~
  5842. • {expr} (`integer`)
  5843. • {utf8} (`boolean?`)
  5844. Return: ~
  5845. (`string`)
  5846. nvim_...({...}) *nvim_...()* *E5555* *eval-api*
  5847. Call nvim |api| functions. The type checking of arguments will
  5848. be stricter than for most other builtins. For instance,
  5849. if Integer is expected, a |Number| must be passed in, a
  5850. |String| will not be autoconverted.
  5851. Buffer numbers, as returned by |bufnr()| could be used as
  5852. first argument to nvim_buf_... functions. All functions
  5853. expecting an object (buffer, window or tabpage) can
  5854. also take the numerical value 0 to indicate the current
  5855. (focused) object.
  5856. Parameters: ~
  5857. • {...} (`any`)
  5858. Return: ~
  5859. (`any`)
  5860. or({expr}, {expr}) *or()*
  5861. Bitwise OR on the two arguments. The arguments are converted
  5862. to a number. A List, Dict or Float argument causes an error.
  5863. Also see `and()` and `xor()`.
  5864. Example: >vim
  5865. let bits = or(bits, 0x80)
  5866. < Rationale: The reason this is a function and not using the "|"
  5867. character like many languages, is that Vi has always used "|"
  5868. to separate commands. In many places it would not be clear if
  5869. "|" is an operator or a command separator.
  5870. Parameters: ~
  5871. • {expr} (`number`)
  5872. • {expr1} (`number`)
  5873. Return: ~
  5874. (`any`)
  5875. pathshorten({path} [, {len}]) *pathshorten()*
  5876. Shorten directory names in the path {path} and return the
  5877. result. The tail, the file name, is kept as-is. The other
  5878. components in the path are reduced to {len} letters in length.
  5879. If {len} is omitted or smaller than 1 then 1 is used (single
  5880. letters). Leading '~' and '.' characters are kept. Examples: >vim
  5881. echo pathshorten('~/.config/nvim/autoload/file1.vim')
  5882. < ~/.c/n/a/file1.vim ~
  5883. >vim
  5884. echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
  5885. < ~/.co/nv/au/file2.vim ~
  5886. It doesn't matter if the path exists or not.
  5887. Returns an empty string on error.
  5888. Parameters: ~
  5889. • {path} (`string`)
  5890. • {len} (`integer?`)
  5891. Return: ~
  5892. (`string`)
  5893. perleval({expr}) *perleval()*
  5894. Evaluate |perl| expression {expr} and return its result
  5895. converted to Vim data structures.
  5896. Numbers and strings are returned as they are (strings are
  5897. copied though).
  5898. Lists are represented as Vim |List| type.
  5899. Dictionaries are represented as Vim |Dictionary| type,
  5900. non-string keys result in error.
  5901. Note: If you want an array or hash, {expr} must return a
  5902. reference to it.
  5903. Example: >vim
  5904. echo perleval('[1 .. 4]')
  5905. < [1, 2, 3, 4]
  5906. Parameters: ~
  5907. • {expr} (`any`)
  5908. Return: ~
  5909. (`any`)
  5910. pow({x}, {y}) *pow()*
  5911. Return the power of {x} to the exponent {y} as a |Float|.
  5912. {x} and {y} must evaluate to a |Float| or a |Number|.
  5913. Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
  5914. Examples: >vim
  5915. echo pow(3, 3)
  5916. < 27.0 >vim
  5917. echo pow(2, 16)
  5918. < 65536.0 >vim
  5919. echo pow(32, 0.20)
  5920. < 2.0
  5921. Parameters: ~
  5922. • {x} (`number`)
  5923. • {y} (`number`)
  5924. Return: ~
  5925. (`number`)
  5926. prevnonblank({lnum}) *prevnonblank()*
  5927. Return the line number of the first line at or above {lnum}
  5928. that is not blank. Example: >vim
  5929. let ind = indent(prevnonblank(v:lnum - 1))
  5930. < When {lnum} is invalid or there is no non-blank line at or
  5931. above it, zero is returned.
  5932. {lnum} is used like with |getline()|.
  5933. Also see |nextnonblank()|.
  5934. Parameters: ~
  5935. • {lnum} (`integer`)
  5936. Return: ~
  5937. (`integer`)
  5938. printf({fmt}, {expr1} ...) *printf()*
  5939. Return a String with {fmt}, where "%" items are replaced by
  5940. the formatted form of their respective arguments. Example: >vim
  5941. echo printf("%4d: E%d %.30s", lnum, errno, msg)
  5942. < May result in:
  5943. " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
  5944. When used as a |method| the base is passed as the second
  5945. argument: >vim
  5946. Compute()->printf("result: %d")
  5947. <
  5948. You can use `call()` to pass the items as a list.
  5949. Often used items are:
  5950. %s string
  5951. %6S string right-aligned in 6 display cells
  5952. %6s string right-aligned in 6 bytes
  5953. %.9s string truncated to 9 bytes
  5954. %c single byte
  5955. %d decimal number
  5956. %5d decimal number padded with spaces to 5 characters
  5957. %b binary number
  5958. %08b binary number padded with zeros to at least 8 characters
  5959. %B binary number using upper case letters
  5960. %x hex number
  5961. %04x hex number padded with zeros to at least 4 characters
  5962. %X hex number using upper case letters
  5963. %o octal number
  5964. %f floating point number as 12.23, inf, -inf or nan
  5965. %F floating point number as 12.23, INF, -INF or NAN
  5966. %e floating point number as 1.23e3, inf, -inf or nan
  5967. %E floating point number as 1.23E3, INF, -INF or NAN
  5968. %g floating point number, as %f or %e depending on value
  5969. %G floating point number, as %F or %E depending on value
  5970. %% the % character itself
  5971. %p representation of the pointer to the container
  5972. Conversion specifications start with '%' and end with the
  5973. conversion type. All other characters are copied unchanged to
  5974. the result.
  5975. The "%" starts a conversion specification. The following
  5976. arguments appear in sequence:
  5977. % [pos-argument] [flags] [field-width] [.precision] type
  5978. pos-argument
  5979. At most one positional argument specifier. These
  5980. take the form {n$}, where n is >= 1.
  5981. flags
  5982. Zero or more of the following flags:
  5983. # The value should be converted to an "alternate
  5984. form". For c, d, and s conversions, this option
  5985. has no effect. For o conversions, the precision
  5986. of the number is increased to force the first
  5987. character of the output string to a zero (except
  5988. if a zero value is printed with an explicit
  5989. precision of zero).
  5990. For x and X conversions, a non-zero result has
  5991. the string "0x" (or "0X" for X conversions)
  5992. prepended to it.
  5993. 0 (zero) Zero padding. For all conversions the converted
  5994. value is padded on the left with zeros rather
  5995. than blanks. If a precision is given with a
  5996. numeric conversion (d, o, x, and X), the 0 flag
  5997. is ignored.
  5998. - A negative field width flag; the converted value
  5999. is to be left adjusted on the field boundary.
  6000. The converted value is padded on the right with
  6001. blanks, rather than on the left with blanks or
  6002. zeros. A - overrides a 0 if both are given.
  6003. ' ' (space) A blank should be left before a positive
  6004. number produced by a signed conversion (d).
  6005. + A sign must always be placed before a number
  6006. produced by a signed conversion. A + overrides
  6007. a space if both are used.
  6008. field-width
  6009. An optional decimal digit string specifying a minimum
  6010. field width. If the converted value has fewer bytes
  6011. than the field width, it will be padded with spaces on
  6012. the left (or right, if the left-adjustment flag has
  6013. been given) to fill out the field width. For the S
  6014. conversion the count is in cells.
  6015. .precision
  6016. An optional precision, in the form of a period '.'
  6017. followed by an optional digit string. If the digit
  6018. string is omitted, the precision is taken as zero.
  6019. This gives the minimum number of digits to appear for
  6020. d, o, x, and X conversions, the maximum number of
  6021. bytes to be printed from a string for s conversions,
  6022. or the maximum number of cells to be printed from a
  6023. string for S conversions.
  6024. For floating point it is the number of digits after
  6025. the decimal point.
  6026. type
  6027. A character that specifies the type of conversion to
  6028. be applied, see below.
  6029. A field width or precision, or both, may be indicated by an
  6030. asterisk "*" instead of a digit string. In this case, a
  6031. Number argument supplies the field width or precision. A
  6032. negative field width is treated as a left adjustment flag
  6033. followed by a positive field width; a negative precision is
  6034. treated as though it were missing. Example: >vim
  6035. echo printf("%d: %.*s", nr, width, line)
  6036. < This limits the length of the text used from "line" to
  6037. "width" bytes.
  6038. If the argument to be formatted is specified using a
  6039. positional argument specifier, and a '*' is used to indicate
  6040. that a number argument is to be used to specify the width or
  6041. precision, the argument(s) to be used must also be specified
  6042. using a {n$} positional argument specifier. See |printf-$|.
  6043. The conversion specifiers and their meanings are:
  6044. *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
  6045. dbBoxX The Number argument is converted to signed decimal (d),
  6046. unsigned binary (b and B), unsigned octal (o), or
  6047. unsigned hexadecimal (x and X) notation. The letters
  6048. "abcdef" are used for x conversions; the letters
  6049. "ABCDEF" are used for X conversions. The precision, if
  6050. any, gives the minimum number of digits that must
  6051. appear; if the converted value requires fewer digits, it
  6052. is padded on the left with zeros. In no case does a
  6053. non-existent or small field width cause truncation of a
  6054. numeric field; if the result of a conversion is wider
  6055. than the field width, the field is expanded to contain
  6056. the conversion result.
  6057. The 'h' modifier indicates the argument is 16 bits.
  6058. The 'l' modifier indicates the argument is a long
  6059. integer. The size will be 32 bits or 64 bits
  6060. depending on your platform.
  6061. The "ll" modifier indicates the argument is 64 bits.
  6062. The b and B conversion specifiers never take a width
  6063. modifier and always assume their argument is a 64 bit
  6064. integer.
  6065. Generally, these modifiers are not useful. They are
  6066. ignored when type is known from the argument.
  6067. i alias for d
  6068. D alias for ld
  6069. U alias for lu
  6070. O alias for lo
  6071. *printf-c*
  6072. c The Number argument is converted to a byte, and the
  6073. resulting character is written.
  6074. *printf-s*
  6075. s The text of the String argument is used. If a
  6076. precision is specified, no more bytes than the number
  6077. specified are used.
  6078. If the argument is not a String type, it is
  6079. automatically converted to text with the same format
  6080. as ":echo".
  6081. *printf-S*
  6082. S The text of the String argument is used. If a
  6083. precision is specified, no more display cells than the
  6084. number specified are used.
  6085. *printf-f* *E807*
  6086. f F The Float argument is converted into a string of the
  6087. form 123.456. The precision specifies the number of
  6088. digits after the decimal point. When the precision is
  6089. zero the decimal point is omitted. When the precision
  6090. is not specified 6 is used. A really big number
  6091. (out of range or dividing by zero) results in "inf"
  6092. or "-inf" with %f (INF or -INF with %F).
  6093. "0.0 / 0.0" results in "nan" with %f (NAN with %F).
  6094. Example: >vim
  6095. echo printf("%.2f", 12.115)
  6096. < 12.12
  6097. Note that roundoff depends on the system libraries.
  6098. Use |round()| when in doubt.
  6099. *printf-e* *printf-E*
  6100. e E The Float argument is converted into a string of the
  6101. form 1.234e+03 or 1.234E+03 when using 'E'. The
  6102. precision specifies the number of digits after the
  6103. decimal point, like with 'f'.
  6104. *printf-g* *printf-G*
  6105. g G The Float argument is converted like with 'f' if the
  6106. value is between 0.001 (inclusive) and 10000000.0
  6107. (exclusive). Otherwise 'e' is used for 'g' and 'E'
  6108. for 'G'. When no precision is specified superfluous
  6109. zeroes and '+' signs are removed, except for the zero
  6110. immediately after the decimal point. Thus 10000000.0
  6111. results in 1.0e7.
  6112. *printf-%*
  6113. % A '%' is written. No argument is converted. The
  6114. complete conversion specification is "%%".
  6115. When a Number argument is expected a String argument is also
  6116. accepted and automatically converted.
  6117. When a Float or String argument is expected a Number argument
  6118. is also accepted and automatically converted.
  6119. Any other argument type results in an error message.
  6120. *E766* *E767*
  6121. The number of {exprN} arguments must exactly match the number
  6122. of "%" items. If there are not sufficient or too many
  6123. arguments an error is given. Up to 18 arguments can be used.
  6124. *printf-$*
  6125. In certain languages, error and informative messages are
  6126. more readable when the order of words is different from the
  6127. corresponding message in English. To accommodate translations
  6128. having a different word order, positional arguments may be
  6129. used to indicate this. For instance: >vim
  6130. #, c-format
  6131. msgid "%s returning %s"
  6132. msgstr "waarde %2$s komt terug van %1$s"
  6133. <
  6134. In this example, the sentence has its 2 string arguments
  6135. reversed in the output. >vim
  6136. echo printf(
  6137. "In The Netherlands, vim's creator's name is: %1$s %2$s",
  6138. "Bram", "Moolenaar")
  6139. < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim
  6140. echo printf(
  6141. "In Belgium, vim's creator's name is: %2$s %1$s",
  6142. "Bram", "Moolenaar")
  6143. < In Belgium, vim's creator's name is: Moolenaar Bram
  6144. Width (and precision) can be specified using the '*' specifier.
  6145. In this case, you must specify the field width position in the
  6146. argument list. >vim
  6147. echo printf("%1$*2$.*3$d", 1, 2, 3)
  6148. < 001 >vim
  6149. echo printf("%2$*3$.*1$d", 1, 2, 3)
  6150. < 2 >vim
  6151. echo printf("%3$*1$.*2$d", 1, 2, 3)
  6152. < 03 >vim
  6153. echo printf("%1$*2$.*3$g", 1.4142, 2, 3)
  6154. < 1.414
  6155. You can mix specifying the width and/or precision directly
  6156. and via positional arguments: >vim
  6157. echo printf("%1$4.*2$f", 1.4142135, 6)
  6158. < 1.414214 >vim
  6159. echo printf("%1$*2$.4f", 1.4142135, 6)
  6160. < 1.4142 >vim
  6161. echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
  6162. < 1.41
  6163. You will get an overflow error |E1510|, when the field-width
  6164. or precision will result in a string longer than 6400 chars.
  6165. *E1500*
  6166. You cannot mix positional and non-positional arguments: >vim
  6167. echo printf("%s%1$s", "One", "Two")
  6168. < E1500: Cannot mix positional and non-positional arguments:
  6169. %s%1$s
  6170. *E1501*
  6171. You cannot skip a positional argument in a format string: >vim
  6172. echo printf("%3$s%1$s", "One", "Two", "Three")
  6173. < E1501: format argument 2 unused in $-style format:
  6174. %3$s%1$s
  6175. *E1502*
  6176. You can re-use a [field-width] (or [precision]) argument: >vim
  6177. echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
  6178. < 1 at width 2 is: 01
  6179. However, you can't use it as a different type: >vim
  6180. echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
  6181. < E1502: Positional argument 2 used as field width reused as
  6182. different type: long int/int
  6183. *E1503*
  6184. When a positional argument is used, but not the correct number
  6185. or arguments is given, an error is raised: >vim
  6186. echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
  6187. < E1503: Positional argument 3 out of bounds: %1$d at width
  6188. %2$d is: %01$*2$.*3$d
  6189. Only the first error is reported: >vim
  6190. echo printf("%01$*2$.*3$d %4$d", 1, 2)
  6191. < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
  6192. %4$d
  6193. *E1504*
  6194. A positional argument can be used more than once: >vim
  6195. echo printf("%1$s %2$s %1$s", "One", "Two")
  6196. < One Two One
  6197. However, you can't use a different type the second time: >vim
  6198. echo printf("%1$s %2$s %1$d", "One", "Two")
  6199. < E1504: Positional argument 1 type used inconsistently:
  6200. int/string
  6201. *E1505*
  6202. Various other errors that lead to a format string being
  6203. wrongly formatted lead to: >vim
  6204. echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
  6205. < E1505: Invalid format specifier: %1$d at width %2$d is:
  6206. %01$*2$.3$d
  6207. *E1507*
  6208. This internal error indicates that the logic to parse a
  6209. positional format argument ran into a problem that couldn't be
  6210. otherwise reported. Please file a bug against Vim if you run
  6211. into this, copying the exact format string and parameters that
  6212. were used.
  6213. Parameters: ~
  6214. • {fmt} (`string`)
  6215. • {expr1} (`any?`)
  6216. Return: ~
  6217. (`string`)
  6218. prompt_getprompt({buf}) *prompt_getprompt()*
  6219. Returns the effective prompt text for buffer {buf}. {buf} can
  6220. be a buffer name or number. See |prompt-buffer|.
  6221. If the buffer doesn't exist or isn't a prompt buffer, an empty
  6222. string is returned.
  6223. Parameters: ~
  6224. • {buf} (`integer|string`)
  6225. Return: ~
  6226. (`any`)
  6227. prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
  6228. Set prompt callback for buffer {buf} to {expr}. When {expr}
  6229. is an empty string the callback is removed. This has only
  6230. effect if {buf} has 'buftype' set to "prompt".
  6231. The callback is invoked when pressing Enter. The current
  6232. buffer will always be the prompt buffer. A new line for a
  6233. prompt is added before invoking the callback, thus the prompt
  6234. for which the callback was invoked will be in the last but one
  6235. line.
  6236. If the callback wants to add text to the buffer, it must
  6237. insert it above the last line, since that is where the current
  6238. prompt is. This can also be done asynchronously.
  6239. The callback is invoked with one argument, which is the text
  6240. that was entered at the prompt. This can be an empty string
  6241. if the user only typed Enter.
  6242. Example: >vim
  6243. func s:TextEntered(text)
  6244. if a:text == 'exit' || a:text == 'quit'
  6245. stopinsert
  6246. " Reset 'modified' to allow the buffer to be closed.
  6247. " We assume there is nothing useful to be saved.
  6248. set nomodified
  6249. close
  6250. else
  6251. " Do something useful with "a:text". In this example
  6252. " we just repeat it.
  6253. call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
  6254. endif
  6255. endfunc
  6256. call prompt_setcallback(bufnr(), function('s:TextEntered'))
  6257. Parameters: ~
  6258. • {buf} (`integer|string`)
  6259. • {expr} (`string|function`)
  6260. Return: ~
  6261. (`any`)
  6262. prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
  6263. Set a callback for buffer {buf} to {expr}. When {expr} is an
  6264. empty string the callback is removed. This has only effect if
  6265. {buf} has 'buftype' set to "prompt".
  6266. This callback will be invoked when pressing CTRL-C in Insert
  6267. mode. Without setting a callback Vim will exit Insert mode,
  6268. as in any buffer.
  6269. Parameters: ~
  6270. • {buf} (`integer|string`)
  6271. • {expr} (`string|function`)
  6272. Return: ~
  6273. (`any`)
  6274. prompt_setprompt({buf}, {text}) *prompt_setprompt()*
  6275. Set prompt for buffer {buf} to {text}. You most likely want
  6276. {text} to end in a space.
  6277. The result is only visible if {buf} has 'buftype' set to
  6278. "prompt". Example: >vim
  6279. call prompt_setprompt(bufnr(''), 'command: ')
  6280. <
  6281. Parameters: ~
  6282. • {buf} (`integer|string`)
  6283. • {text} (`string`)
  6284. Return: ~
  6285. (`any`)
  6286. pum_getpos() *pum_getpos()*
  6287. If the popup menu (see |ins-completion-menu|) is not visible,
  6288. returns an empty |Dictionary|, otherwise, returns a
  6289. |Dictionary| with the following keys:
  6290. height nr of items visible
  6291. width screen cells
  6292. row top screen row (0 first row)
  6293. col leftmost screen column (0 first col)
  6294. size total nr of items
  6295. scrollbar |TRUE| if scrollbar is visible
  6296. The values are the same as in |v:event| during |CompleteChanged|.
  6297. Return: ~
  6298. (`any`)
  6299. pumvisible() *pumvisible()*
  6300. Returns non-zero when the popup menu is visible, zero
  6301. otherwise. See |ins-completion-menu|.
  6302. This can be used to avoid some things that would remove the
  6303. popup menu.
  6304. Return: ~
  6305. (`any`)
  6306. py3eval({expr}) *py3eval()*
  6307. Evaluate Python expression {expr} and return its result
  6308. converted to Vim data structures.
  6309. Numbers and strings are returned as they are (strings are
  6310. copied though, Unicode strings are additionally converted to
  6311. UTF-8).
  6312. Lists are represented as Vim |List| type.
  6313. Dictionaries are represented as Vim |Dictionary| type with
  6314. keys converted to strings.
  6315. Parameters: ~
  6316. • {expr} (`any`)
  6317. Return: ~
  6318. (`any`)
  6319. pyeval({expr}) *pyeval()* *E858* *E859*
  6320. Evaluate Python expression {expr} and return its result
  6321. converted to Vim data structures.
  6322. Numbers and strings are returned as they are (strings are
  6323. copied though).
  6324. Lists are represented as Vim |List| type.
  6325. Dictionaries are represented as Vim |Dictionary| type,
  6326. non-string keys result in error.
  6327. Parameters: ~
  6328. • {expr} (`any`)
  6329. Return: ~
  6330. (`any`)
  6331. pyxeval({expr}) *pyxeval()*
  6332. Evaluate Python expression {expr} and return its result
  6333. converted to Vim data structures.
  6334. Uses Python 2 or 3, see |python_x| and 'pyxversion'.
  6335. See also: |pyeval()|, |py3eval()|
  6336. Parameters: ~
  6337. • {expr} (`any`)
  6338. Return: ~
  6339. (`any`)
  6340. rand([{expr}]) *rand()*
  6341. Return a pseudo-random Number generated with an xoshiro128**
  6342. algorithm using seed {expr}. The returned number is 32 bits,
  6343. also on 64 bits systems, for consistency.
  6344. {expr} can be initialized by |srand()| and will be updated by
  6345. rand(). If {expr} is omitted, an internal seed value is used
  6346. and updated.
  6347. Returns -1 if {expr} is invalid.
  6348. Examples: >vim
  6349. echo rand()
  6350. let seed = srand()
  6351. echo rand(seed)
  6352. echo rand(seed) % 16 " random number 0 - 15
  6353. <
  6354. Parameters: ~
  6355. • {expr} (`number?`)
  6356. Return: ~
  6357. (`any`)
  6358. range({expr} [, {max} [, {stride}]]) *range()* *E726* *E727*
  6359. Returns a |List| with Numbers:
  6360. - If only {expr} is specified: [0, 1, ..., {expr} - 1]
  6361. - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
  6362. - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
  6363. {max}] (increasing {expr} with {stride} each time, not
  6364. producing a value past {max}).
  6365. When the maximum is one before the start the result is an
  6366. empty list. When the maximum is more than one before the
  6367. start this is an error.
  6368. Examples: >vim
  6369. echo range(4) " [0, 1, 2, 3]
  6370. echo range(2, 4) " [2, 3, 4]
  6371. echo range(2, 9, 3) " [2, 5, 8]
  6372. echo range(2, -2, -1) " [2, 1, 0, -1, -2]
  6373. echo range(0) " []
  6374. echo range(2, 0) " error!
  6375. <
  6376. Parameters: ~
  6377. • {expr} (`any`)
  6378. • {max} (`integer?`)
  6379. • {stride} (`integer?`)
  6380. Return: ~
  6381. (`any`)
  6382. readblob({fname} [, {offset} [, {size}]]) *readblob()*
  6383. Read file {fname} in binary mode and return a |Blob|.
  6384. If {offset} is specified, read the file from the specified
  6385. offset. If it is a negative value, it is used as an offset
  6386. from the end of the file. E.g., to read the last 12 bytes: >vim
  6387. echo readblob('file.bin', -12)
  6388. < If {size} is specified, only the specified size will be read.
  6389. E.g. to read the first 100 bytes of a file: >vim
  6390. echo readblob('file.bin', 0, 100)
  6391. < If {size} is -1 or omitted, the whole data starting from
  6392. {offset} will be read.
  6393. This can be also used to read the data from a character device
  6394. on Unix when {size} is explicitly set. Only if the device
  6395. supports seeking {offset} can be used. Otherwise it should be
  6396. zero. E.g. to read 10 bytes from a serial console: >vim
  6397. echo readblob('/dev/ttyS0', 0, 10)
  6398. < When the file can't be opened an error message is given and
  6399. the result is an empty |Blob|.
  6400. When the offset is beyond the end of the file the result is an
  6401. empty blob.
  6402. When trying to read more bytes than are available the result
  6403. is truncated.
  6404. Also see |readfile()| and |writefile()|.
  6405. Parameters: ~
  6406. • {fname} (`string`)
  6407. • {offset} (`integer?`)
  6408. • {size} (`integer?`)
  6409. Return: ~
  6410. (`any`)
  6411. readdir({directory} [, {expr}]) *readdir()*
  6412. Return a list with file and directory names in {directory}.
  6413. You can also use |glob()| if you don't need to do complicated
  6414. things, such as limiting the number of matches.
  6415. When {expr} is omitted all entries are included.
  6416. When {expr} is given, it is evaluated to check what to do:
  6417. If {expr} results in -1 then no further entries will
  6418. be handled.
  6419. If {expr} results in 0 then this entry will not be
  6420. added to the list.
  6421. If {expr} results in 1 then this entry will be added
  6422. to the list.
  6423. Each time {expr} is evaluated |v:val| is set to the entry name.
  6424. When {expr} is a function the name is passed as the argument.
  6425. For example, to get a list of files ending in ".txt": >vim
  6426. echo readdir(dirname, {n -> n =~ '.txt$'})
  6427. < To skip hidden and backup files: >vim
  6428. echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
  6429. < If you want to get a directory tree: >vim
  6430. function! s:tree(dir)
  6431. return {a:dir : map(readdir(a:dir),
  6432. \ {_, x -> isdirectory(x) ?
  6433. \ {x : s:tree(a:dir .. '/' .. x)} : x})}
  6434. endfunction
  6435. echo s:tree(".")
  6436. <
  6437. Returns an empty List on error.
  6438. Parameters: ~
  6439. • {directory} (`string`)
  6440. • {expr} (`integer?`)
  6441. Return: ~
  6442. (`any`)
  6443. readfile({fname} [, {type} [, {max}]]) *readfile()*
  6444. Read file {fname} and return a |List|, each line of the file
  6445. as an item. Lines are broken at NL characters. Macintosh
  6446. files separated with CR will result in a single long line
  6447. (unless a NL appears somewhere).
  6448. All NUL characters are replaced with a NL character.
  6449. When {type} contains "b" binary mode is used:
  6450. - When the last line ends in a NL an extra empty list item is
  6451. added.
  6452. - No CR characters are removed.
  6453. Otherwise:
  6454. - CR characters that appear before a NL are removed.
  6455. - Whether the last line ends in a NL or not does not matter.
  6456. - Any UTF-8 byte order mark is removed from the text.
  6457. When {max} is given this specifies the maximum number of lines
  6458. to be read. Useful if you only want to check the first ten
  6459. lines of a file: >vim
  6460. for line in readfile(fname, '', 10)
  6461. if line =~ 'Date' | echo line | endif
  6462. endfor
  6463. < When {max} is negative -{max} lines from the end of the file
  6464. are returned, or as many as there are.
  6465. When {max} is zero the result is an empty list.
  6466. Note that without {max} the whole file is read into memory.
  6467. Also note that there is no recognition of encoding. Read a
  6468. file into a buffer if you need to.
  6469. Deprecated (use |readblob()| instead): When {type} contains
  6470. "B" a |Blob| is returned with the binary data of the file
  6471. unmodified.
  6472. When the file can't be opened an error message is given and
  6473. the result is an empty list.
  6474. Also see |writefile()|.
  6475. Parameters: ~
  6476. • {fname} (`string`)
  6477. • {type} (`string?`)
  6478. • {max} (`integer?`)
  6479. Return: ~
  6480. (`any`)
  6481. reduce({object}, {func} [, {initial}]) *reduce()* *E998*
  6482. {func} is called for every item in {object}, which can be a
  6483. |String|, |List| or a |Blob|. {func} is called with two
  6484. arguments: the result so far and current item. After
  6485. processing all items the result is returned.
  6486. {initial} is the initial result. When omitted, the first item
  6487. in {object} is used and {func} is first called for the second
  6488. item. If {initial} is not given and {object} is empty no
  6489. result can be computed, an E998 error is given.
  6490. Examples: >vim
  6491. echo reduce([1, 3, 5], { acc, val -> acc + val })
  6492. echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
  6493. echo reduce(0z1122, { acc, val -> 2 * acc + val })
  6494. echo reduce('xyz', { acc, val -> acc .. ',' .. val })
  6495. <
  6496. Parameters: ~
  6497. • {object} (`any`)
  6498. • {func} (`fun(accumulator: T, current: any): any`)
  6499. • {initial} (`any?`)
  6500. Return: ~
  6501. (`T`)
  6502. reg_executing() *reg_executing()*
  6503. Returns the single letter name of the register being executed.
  6504. Returns an empty string when no register is being executed.
  6505. See |@|.
  6506. Return: ~
  6507. (`any`)
  6508. reg_recorded() *reg_recorded()*
  6509. Returns the single letter name of the last recorded register.
  6510. Returns an empty string when nothing was recorded yet.
  6511. See |q| and |Q|.
  6512. Return: ~
  6513. (`any`)
  6514. reg_recording() *reg_recording()*
  6515. Returns the single letter name of the register being recorded.
  6516. Returns an empty string when not recording. See |q|.
  6517. Return: ~
  6518. (`any`)
  6519. reltime() *reltime()*
  6520. reltime({start})
  6521. reltime({start}, {end})
  6522. Return an item that represents a time value. The item is a
  6523. list with items that depend on the system.
  6524. The item can be passed to |reltimestr()| to convert it to a
  6525. string or |reltimefloat()| to convert to a Float.
  6526. Without an argument it returns the current "relative time", an
  6527. implementation-defined value meaningful only when used as an
  6528. argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
  6529. With one argument it returns the time passed since the time
  6530. specified in the argument.
  6531. With two arguments it returns the time passed between {start}
  6532. and {end}.
  6533. The {start} and {end} arguments must be values returned by
  6534. reltime(). Returns zero on error.
  6535. Note: |localtime()| returns the current (non-relative) time.
  6536. Parameters: ~
  6537. • {start} (`any?`)
  6538. • {end} (`any?`)
  6539. Return: ~
  6540. (`any`)
  6541. reltimefloat({time}) *reltimefloat()*
  6542. Return a Float that represents the time value of {time}.
  6543. Unit of time is seconds.
  6544. Example:
  6545. let start = reltime()
  6546. call MyFunction()
  6547. let seconds = reltimefloat(reltime(start))
  6548. See the note of reltimestr() about overhead.
  6549. Also see |profiling|.
  6550. If there is an error an empty string is returned
  6551. Parameters: ~
  6552. • {time} (`any`)
  6553. Return: ~
  6554. (`any`)
  6555. reltimestr({time}) *reltimestr()*
  6556. Return a String that represents the time value of {time}.
  6557. This is the number of seconds, a dot and the number of
  6558. microseconds. Example: >vim
  6559. let start = reltime()
  6560. call MyFunction()
  6561. echo reltimestr(reltime(start))
  6562. < Note that overhead for the commands will be added to the time.
  6563. Leading spaces are used to make the string align nicely. You
  6564. can use split() to remove it. >vim
  6565. echo split(reltimestr(reltime(start)))[0]
  6566. < Also see |profiling|.
  6567. If there is an error an empty string is returned
  6568. Parameters: ~
  6569. • {time} (`any`)
  6570. Return: ~
  6571. (`any`)
  6572. remove({list}, {idx}) *remove()*
  6573. remove({list}, {idx}, {end})
  6574. Without {end}: Remove the item at {idx} from |List| {list} and
  6575. return the item.
  6576. With {end}: Remove items from {idx} to {end} (inclusive) and
  6577. return a |List| with these items. When {idx} points to the same
  6578. item as {end} a list with one item is returned. When {end}
  6579. points to an item before {idx} this is an error.
  6580. See |list-index| for possible values of {idx} and {end}.
  6581. Returns zero on error.
  6582. Example: >vim
  6583. echo "last item: " .. remove(mylist, -1)
  6584. call remove(mylist, 0, 9)
  6585. <
  6586. Use |delete()| to remove a file.
  6587. Parameters: ~
  6588. • {list} (`any[]`)
  6589. • {idx} (`integer`)
  6590. • {end} (`integer?`)
  6591. Return: ~
  6592. (`any`)
  6593. remove({blob}, {idx})
  6594. remove({blob}, {idx}, {end})
  6595. Without {end}: Remove the byte at {idx} from |Blob| {blob} and
  6596. return the byte.
  6597. With {end}: Remove bytes from {idx} to {end} (inclusive) and
  6598. return a |Blob| with these bytes. When {idx} points to the same
  6599. byte as {end} a |Blob| with one byte is returned. When {end}
  6600. points to a byte before {idx} this is an error.
  6601. Returns zero on error.
  6602. Example: >vim
  6603. echo "last byte: " .. remove(myblob, -1)
  6604. call remove(mylist, 0, 9)
  6605. <
  6606. Parameters: ~
  6607. • {blob} (`any`)
  6608. • {idx} (`integer`)
  6609. • {end} (`integer?`)
  6610. Return: ~
  6611. (`any`)
  6612. remove({dict}, {key})
  6613. Remove the entry from {dict} with key {key} and return it.
  6614. Example: >vim
  6615. echo "removed " .. remove(dict, "one")
  6616. < If there is no {key} in {dict} this is an error.
  6617. Returns zero on error.
  6618. Parameters: ~
  6619. • {dict} (`any`)
  6620. • {key} (`string`)
  6621. Return: ~
  6622. (`any`)
  6623. rename({from}, {to}) *rename()*
  6624. Rename the file by the name {from} to the name {to}. This
  6625. should also work to move files across file systems. The
  6626. result is a Number, which is 0 if the file was renamed
  6627. successfully, and non-zero when the renaming failed.
  6628. NOTE: If {to} exists it is overwritten without warning.
  6629. This function is not available in the |sandbox|.
  6630. Parameters: ~
  6631. • {from} (`string`)
  6632. • {to} (`string`)
  6633. Return: ~
  6634. (`integer`)
  6635. repeat({expr}, {count}) *repeat()*
  6636. Repeat {expr} {count} times and return the concatenated
  6637. result. Example: >vim
  6638. let separator = repeat('-', 80)
  6639. < When {count} is zero or negative the result is empty.
  6640. When {expr} is a |List| or a |Blob| the result is {expr}
  6641. concatenated {count} times. Example: >vim
  6642. let longlist = repeat(['a', 'b'], 3)
  6643. < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
  6644. Parameters: ~
  6645. • {expr} (`any`)
  6646. • {count} (`integer`)
  6647. Return: ~
  6648. (`any`)
  6649. resolve({filename}) *resolve()* *E655*
  6650. On MS-Windows, when {filename} is a shortcut (a .lnk file),
  6651. returns the path the shortcut points to in a simplified form.
  6652. On Unix, repeat resolving symbolic links in all path
  6653. components of {filename} and return the simplified result.
  6654. To cope with link cycles, resolving of symbolic links is
  6655. stopped after 100 iterations.
  6656. On other systems, return the simplified {filename}.
  6657. The simplification step is done as by |simplify()|.
  6658. resolve() keeps a leading path component specifying the
  6659. current directory (provided the result is still a relative
  6660. path name) and also keeps a trailing path separator.
  6661. Parameters: ~
  6662. • {filename} (`string`)
  6663. Return: ~
  6664. (`string`)
  6665. reverse({object}) *reverse()*
  6666. Reverse the order of items in {object}. {object} can be a
  6667. |List|, a |Blob| or a |String|. For a List and a Blob the
  6668. items are reversed in-place and {object} is returned.
  6669. For a String a new String is returned.
  6670. Returns zero if {object} is not a List, Blob or a String.
  6671. If you want a List or Blob to remain unmodified make a copy
  6672. first: >vim
  6673. let revlist = reverse(copy(mylist))
  6674. <
  6675. Parameters: ~
  6676. • {object} (`T[]`)
  6677. Return: ~
  6678. (`T[]`)
  6679. round({expr}) *round()*
  6680. Round off {expr} to the nearest integral value and return it
  6681. as a |Float|. If {expr} lies halfway between two integral
  6682. values, then use the larger one (away from zero).
  6683. {expr} must evaluate to a |Float| or a |Number|.
  6684. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6685. Examples: >vim
  6686. echo round(0.456)
  6687. < 0.0 >vim
  6688. echo round(4.5)
  6689. < 5.0 >vim
  6690. echo round(-4.5)
  6691. < -5.0
  6692. Parameters: ~
  6693. • {expr} (`number`)
  6694. Return: ~
  6695. (`number`)
  6696. rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()*
  6697. Sends {event} to {channel} via |RPC| and returns immediately.
  6698. If {channel} is 0, the event is broadcast to all channels.
  6699. Example: >vim
  6700. au VimLeave call rpcnotify(0, "leaving")
  6701. <
  6702. Parameters: ~
  6703. • {channel} (`integer`)
  6704. • {event} (`string`)
  6705. • {...} (`any`)
  6706. Return: ~
  6707. (`integer`)
  6708. rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()*
  6709. Sends a request to {channel} to invoke {method} via
  6710. |RPC| and blocks until a response is received.
  6711. Example: >vim
  6712. let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
  6713. <
  6714. Parameters: ~
  6715. • {channel} (`integer`)
  6716. • {method} (`string`)
  6717. • {...} (`any`)
  6718. Return: ~
  6719. (`any`)
  6720. rubyeval({expr}) *rubyeval()*
  6721. Evaluate Ruby expression {expr} and return its result
  6722. converted to Vim data structures.
  6723. Numbers, floats and strings are returned as they are (strings
  6724. are copied though).
  6725. Arrays are represented as Vim |List| type.
  6726. Hashes are represented as Vim |Dictionary| type.
  6727. Other objects are represented as strings resulted from their
  6728. "Object#to_s" method.
  6729. Parameters: ~
  6730. • {expr} (`any`)
  6731. Return: ~
  6732. (`any`)
  6733. screenattr({row}, {col}) *screenattr()*
  6734. Like |screenchar()|, but return the attribute. This is a rather
  6735. arbitrary number that can only be used to compare to the
  6736. attribute at other positions.
  6737. Returns -1 when row or col is out of range.
  6738. Parameters: ~
  6739. • {row} (`integer`)
  6740. • {col} (`integer`)
  6741. Return: ~
  6742. (`integer`)
  6743. screenchar({row}, {col}) *screenchar()*
  6744. The result is a Number, which is the character at position
  6745. [row, col] on the screen. This works for every possible
  6746. screen position, also status lines, window separators and the
  6747. command line. The top left position is row one, column one
  6748. The character excludes composing characters. For double-byte
  6749. encodings it may only be the first byte.
  6750. This is mainly to be used for testing.
  6751. Returns -1 when row or col is out of range.
  6752. Parameters: ~
  6753. • {row} (`integer`)
  6754. • {col} (`integer`)
  6755. Return: ~
  6756. (`integer`)
  6757. screenchars({row}, {col}) *screenchars()*
  6758. The result is a |List| of Numbers. The first number is the same
  6759. as what |screenchar()| returns. Further numbers are
  6760. composing characters on top of the base character.
  6761. This is mainly to be used for testing.
  6762. Returns an empty List when row or col is out of range.
  6763. Parameters: ~
  6764. • {row} (`integer`)
  6765. • {col} (`integer`)
  6766. Return: ~
  6767. (`integer[]`)
  6768. screencol() *screencol()*
  6769. The result is a Number, which is the current screen column of
  6770. the cursor. The leftmost column has number 1.
  6771. This function is mainly used for testing.
  6772. Note: Always returns the current screen column, thus if used
  6773. in a command (e.g. ":echo screencol()") it will return the
  6774. column inside the command line, which is 1 when the command is
  6775. executed. To get the cursor position in the file use one of
  6776. the following mappings: >vim
  6777. nnoremap <expr> GG ":echom " .. screencol() .. "\n"
  6778. nnoremap <silent> GG :echom screencol()<CR>
  6779. noremap GG <Cmd>echom screencol()<CR>
  6780. <
  6781. Return: ~
  6782. (`integer[]`)
  6783. screenpos({winid}, {lnum}, {col}) *screenpos()*
  6784. The result is a Dict with the screen position of the text
  6785. character in window {winid} at buffer line {lnum} and column
  6786. {col}. {col} is a one-based byte index.
  6787. The Dict has these members:
  6788. row screen row
  6789. col first screen column
  6790. endcol last screen column
  6791. curscol cursor screen column
  6792. If the specified position is not visible, all values are zero.
  6793. The "endcol" value differs from "col" when the character
  6794. occupies more than one screen cell. E.g. for a Tab "col" can
  6795. be 1 and "endcol" can be 8.
  6796. The "curscol" value is where the cursor would be placed. For
  6797. a Tab it would be the same as "endcol", while for a double
  6798. width character it would be the same as "col".
  6799. The |conceal| feature is ignored here, the column numbers are
  6800. as if 'conceallevel' is zero. You can set the cursor to the
  6801. right position and use |screencol()| to get the value with
  6802. |conceal| taken into account.
  6803. If the position is in a closed fold the screen position of the
  6804. first character is returned, {col} is not used.
  6805. Returns an empty Dict if {winid} is invalid.
  6806. Parameters: ~
  6807. • {winid} (`integer`)
  6808. • {lnum} (`integer`)
  6809. • {col} (`integer`)
  6810. Return: ~
  6811. (`any`)
  6812. screenrow() *screenrow()*
  6813. The result is a Number, which is the current screen row of the
  6814. cursor. The top line has number one.
  6815. This function is mainly used for testing.
  6816. Alternatively you can use |winline()|.
  6817. Note: Same restrictions as with |screencol()|.
  6818. Return: ~
  6819. (`integer`)
  6820. screenstring({row}, {col}) *screenstring()*
  6821. The result is a String that contains the base character and
  6822. any composing characters at position [row, col] on the screen.
  6823. This is like |screenchars()| but returning a String with the
  6824. characters.
  6825. This is mainly to be used for testing.
  6826. Returns an empty String when row or col is out of range.
  6827. Parameters: ~
  6828. • {row} (`integer`)
  6829. • {col} (`integer`)
  6830. Return: ~
  6831. (`string`)
  6832. search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
  6833. Search for regexp pattern {pattern}. The search starts at the
  6834. cursor position (you can use |cursor()| to set it).
  6835. When a match has been found its line number is returned.
  6836. If there is no match a 0 is returned and the cursor doesn't
  6837. move. No error message is given.
  6838. To get the matched string, use |matchbufline()|.
  6839. {flags} is a String, which can contain these character flags:
  6840. 'b' search Backward instead of forward
  6841. 'c' accept a match at the Cursor position
  6842. 'e' move to the End of the match
  6843. 'n' do Not move the cursor
  6844. 'p' return number of matching sub-Pattern (see below)
  6845. 's' Set the ' mark at the previous location of the cursor
  6846. 'w' Wrap around the end of the file
  6847. 'W' don't Wrap around the end of the file
  6848. 'z' start searching at the cursor column instead of Zero
  6849. If neither 'w' or 'W' is given, the 'wrapscan' option applies.
  6850. If the 's' flag is supplied, the ' mark is set, only if the
  6851. cursor is moved. The 's' flag cannot be combined with the 'n'
  6852. flag.
  6853. 'ignorecase', 'smartcase' and 'magic' are used.
  6854. When the 'z' flag is not given, forward searching always
  6855. starts in column zero and then matches before the cursor are
  6856. skipped. When the 'c' flag is present in 'cpo' the next
  6857. search starts after the match. Without the 'c' flag the next
  6858. search starts one column after the start of the match. This
  6859. matters for overlapping matches. See |cpo-c|. You can also
  6860. insert "\ze" to change where the match ends, see |/\ze|.
  6861. When searching backwards and the 'z' flag is given then the
  6862. search starts in column zero, thus no match in the current
  6863. line will be found (unless wrapping around the end of the
  6864. file).
  6865. When the {stopline} argument is given then the search stops
  6866. after searching this line. This is useful to restrict the
  6867. search to a range of lines. Examples: >vim
  6868. let match = search('(', 'b', line("w0"))
  6869. let end = search('END', '', line("w$"))
  6870. < When {stopline} is used and it is not zero this also implies
  6871. that the search does not wrap around the end of the file.
  6872. A zero value is equal to not giving the argument.
  6873. When the {timeout} argument is given the search stops when
  6874. more than this many milliseconds have passed. Thus when
  6875. {timeout} is 500 the search stops after half a second.
  6876. The value must not be negative. A zero value is like not
  6877. giving the argument.
  6878. Note: the timeout is only considered when searching, not
  6879. while evaluating the {skip} expression.
  6880. If the {skip} expression is given it is evaluated with the
  6881. cursor positioned on the start of a match. If it evaluates to
  6882. non-zero this match is skipped. This can be used, for
  6883. example, to skip a match in a comment or a string.
  6884. {skip} can be a string, which is evaluated as an expression, a
  6885. function reference or a lambda.
  6886. When {skip} is omitted or empty, every match is accepted.
  6887. When evaluating {skip} causes an error the search is aborted
  6888. and -1 returned.
  6889. *search()-sub-match*
  6890. With the 'p' flag the returned value is one more than the
  6891. first sub-match in \(\). One if none of them matched but the
  6892. whole pattern did match.
  6893. To get the column number too use |searchpos()|.
  6894. The cursor will be positioned at the match, unless the 'n'
  6895. flag is used.
  6896. Example (goes over all files in the argument list): >vim
  6897. let n = 1
  6898. while n <= argc() " loop over all files in arglist
  6899. exe "argument " .. n
  6900. " start at the last char in the file and wrap for the
  6901. " first search to find match at start of file
  6902. normal G$
  6903. let flags = "w"
  6904. while search("foo", flags) > 0
  6905. s/foo/bar/g
  6906. let flags = "W"
  6907. endwhile
  6908. update " write the file if modified
  6909. let n = n + 1
  6910. endwhile
  6911. <
  6912. Example for using some flags: >vim
  6913. echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
  6914. < This will search for the keywords "if", "else", and "endif"
  6915. under or after the cursor. Because of the 'p' flag, it
  6916. returns 1, 2, or 3 depending on which keyword is found, or 0
  6917. if the search fails. With the cursor on the first word of the
  6918. line:
  6919. if (foo == 0) | let foo = foo + 1 | endif ~
  6920. the function returns 1. Without the 'c' flag, the function
  6921. finds the "endif" and returns 3. The same thing happens
  6922. without the 'e' flag if the cursor is on the "f" of "if".
  6923. The 'n' flag tells the function not to move the cursor.
  6924. Parameters: ~
  6925. • {pattern} (`string`)
  6926. • {flags} (`string?`)
  6927. • {stopline} (`integer?`)
  6928. • {timeout} (`integer?`)
  6929. • {skip} (`string|function?`)
  6930. Return: ~
  6931. (`integer`)
  6932. searchcount([{options}]) *searchcount()*
  6933. Get or update the last search count, like what is displayed
  6934. without the "S" flag in 'shortmess'. This works even if
  6935. 'shortmess' does contain the "S" flag.
  6936. This returns a |Dictionary|. The dictionary is empty if the
  6937. previous pattern was not set and "pattern" was not specified.
  6938. key type meaning ~
  6939. current |Number| current position of match;
  6940. 0 if the cursor position is
  6941. before the first match
  6942. exact_match |Boolean| 1 if "current" is matched on
  6943. "pos", otherwise 0
  6944. total |Number| total count of matches found
  6945. incomplete |Number| 0: search was fully completed
  6946. 1: recomputing was timed out
  6947. 2: max count exceeded
  6948. For {options} see further down.
  6949. To get the last search count when |n| or |N| was pressed, call
  6950. this function with `recompute: 0` . This sometimes returns
  6951. wrong information because |n| and |N|'s maximum count is 99.
  6952. If it exceeded 99 the result must be max count + 1 (100). If
  6953. you want to get correct information, specify `recompute: 1`: >vim
  6954. " result == maxcount + 1 (100) when many matches
  6955. let result = searchcount(#{recompute: 0})
  6956. " Below returns correct result (recompute defaults
  6957. " to 1)
  6958. let result = searchcount()
  6959. <
  6960. The function is useful to add the count to 'statusline': >vim
  6961. function! LastSearchCount() abort
  6962. let result = searchcount(#{recompute: 0})
  6963. if empty(result)
  6964. return ''
  6965. endif
  6966. if result.incomplete ==# 1 " timed out
  6967. return printf(' /%s [?/??]', @/)
  6968. elseif result.incomplete ==# 2 " max count exceeded
  6969. if result.total > result.maxcount &&
  6970. \ result.current > result.maxcount
  6971. return printf(' /%s [>%d/>%d]', @/,
  6972. \ result.current, result.total)
  6973. elseif result.total > result.maxcount
  6974. return printf(' /%s [%d/>%d]', @/,
  6975. \ result.current, result.total)
  6976. endif
  6977. endif
  6978. return printf(' /%s [%d/%d]', @/,
  6979. \ result.current, result.total)
  6980. endfunction
  6981. let &statusline ..= '%{LastSearchCount()}'
  6982. " Or if you want to show the count only when
  6983. " 'hlsearch' was on
  6984. " let &statusline ..=
  6985. " \ '%{v:hlsearch ? LastSearchCount() : ""}'
  6986. <
  6987. You can also update the search count, which can be useful in a
  6988. |CursorMoved| or |CursorMovedI| autocommand: >vim
  6989. autocmd CursorMoved,CursorMovedI *
  6990. \ let s:searchcount_timer = timer_start(
  6991. \ 200, function('s:update_searchcount'))
  6992. function! s:update_searchcount(timer) abort
  6993. if a:timer ==# s:searchcount_timer
  6994. call searchcount(#{
  6995. \ recompute: 1, maxcount: 0, timeout: 100})
  6996. redrawstatus
  6997. endif
  6998. endfunction
  6999. <
  7000. This can also be used to count matched texts with specified
  7001. pattern in the current buffer using "pattern": >vim
  7002. " Count '\<foo\>' in this buffer
  7003. " (Note that it also updates search count)
  7004. let result = searchcount(#{pattern: '\<foo\>'})
  7005. " To restore old search count by old pattern,
  7006. " search again
  7007. call searchcount()
  7008. <
  7009. {options} must be a |Dictionary|. It can contain:
  7010. key type meaning ~
  7011. recompute |Boolean| if |TRUE|, recompute the count
  7012. like |n| or |N| was executed.
  7013. otherwise returns the last
  7014. computed result (when |n| or
  7015. |N| was used when "S" is not
  7016. in 'shortmess', or this
  7017. function was called).
  7018. (default: |TRUE|)
  7019. pattern |String| recompute if this was given
  7020. and different with |@/|.
  7021. this works as same as the
  7022. below command is executed
  7023. before calling this function >vim
  7024. let @/ = pattern
  7025. < (default: |@/|)
  7026. timeout |Number| 0 or negative number is no
  7027. timeout. timeout milliseconds
  7028. for recomputing the result
  7029. (default: 0)
  7030. maxcount |Number| 0 or negative number is no
  7031. limit. max count of matched
  7032. text while recomputing the
  7033. result. if search exceeded
  7034. total count, "total" value
  7035. becomes `maxcount + 1`
  7036. (default: 0)
  7037. pos |List| `[lnum, col, off]` value
  7038. when recomputing the result.
  7039. this changes "current" result
  7040. value. see |cursor()|, |getpos()|
  7041. (default: cursor's position)
  7042. Parameters: ~
  7043. • {options} (`table?`)
  7044. Return: ~
  7045. (`any`)
  7046. searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
  7047. Search for the declaration of {name}.
  7048. With a non-zero {global} argument it works like |gD|, find
  7049. first match in the file. Otherwise it works like |gd|, find
  7050. first match in the function.
  7051. With a non-zero {thisblock} argument matches in a {} block
  7052. that ends before the cursor position are ignored. Avoids
  7053. finding variable declarations only valid in another scope.
  7054. Moves the cursor to the found match.
  7055. Returns zero for success, non-zero for failure.
  7056. Example: >vim
  7057. if searchdecl('myvar') == 0
  7058. echo getline('.')
  7059. endif
  7060. <
  7061. Parameters: ~
  7062. • {name} (`string`)
  7063. • {global} (`boolean?`)
  7064. • {thisblock} (`boolean?`)
  7065. Return: ~
  7066. (`any`)
  7067. *searchpair()*
  7068. searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7069. Search for the match of a nested start-end pair. This can be
  7070. used to find the "endif" that matches an "if", while other
  7071. if/endif pairs in between are ignored.
  7072. The search starts at the cursor. The default is to search
  7073. forward, include 'b' in {flags} to search backward.
  7074. If a match is found, the cursor is positioned at it and the
  7075. line number is returned. If no match is found 0 or -1 is
  7076. returned and the cursor doesn't move. No error message is
  7077. given.
  7078. {start}, {middle} and {end} are patterns, see |pattern|. They
  7079. must not contain \( \) pairs. Use of \%( \) is allowed. When
  7080. {middle} is not empty, it is found when searching from either
  7081. direction, but only when not in a nested start-end pair. A
  7082. typical use is: >vim
  7083. echo searchpair('\<if\>', '\<else\>', '\<endif\>')
  7084. < By leaving {middle} empty the "else" is skipped.
  7085. {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
  7086. |search()|. Additionally:
  7087. 'r' Repeat until no more matches found; will find the
  7088. outer pair. Implies the 'W' flag.
  7089. 'm' Return number of matches instead of line number with
  7090. the match; will be > 1 when 'r' is used.
  7091. Note: it's nearly always a good idea to use the 'W' flag, to
  7092. avoid wrapping around the end of the file.
  7093. When a match for {start}, {middle} or {end} is found, the
  7094. {skip} expression is evaluated with the cursor positioned on
  7095. the start of the match. It should return non-zero if this
  7096. match is to be skipped. E.g., because it is inside a comment
  7097. or a string.
  7098. When {skip} is omitted or empty, every match is accepted.
  7099. When evaluating {skip} causes an error the search is aborted
  7100. and -1 returned.
  7101. {skip} can be a string, a lambda, a funcref or a partial.
  7102. Anything else makes the function fail.
  7103. For {stopline} and {timeout} see |search()|.
  7104. The value of 'ignorecase' is used. 'magic' is ignored, the
  7105. patterns are used like it's on.
  7106. The search starts exactly at the cursor. A match with
  7107. {start}, {middle} or {end} at the next character, in the
  7108. direction of searching, is the first one found. Example: >vim
  7109. if 1
  7110. if 2
  7111. endif 2
  7112. endif 1
  7113. < When starting at the "if 2", with the cursor on the "i", and
  7114. searching forwards, the "endif 2" is found. When starting on
  7115. the character just before the "if 2", the "endif 1" will be
  7116. found. That's because the "if 2" will be found first, and
  7117. then this is considered to be a nested if/endif from "if 2" to
  7118. "endif 2".
  7119. When searching backwards and {end} is more than one character,
  7120. it may be useful to put "\zs" at the end of the pattern, so
  7121. that when the cursor is inside a match with the end it finds
  7122. the matching start.
  7123. Example, to find the "endif" command in a Vim script: >vim
  7124. echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
  7125. \ 'getline(".") =~ "^\\s*\""')
  7126. < The cursor must be at or after the "if" for which a match is
  7127. to be found. Note that single-quote strings are used to avoid
  7128. having to double the backslashes. The skip expression only
  7129. catches comments at the start of a line, not after a command.
  7130. Also, a word "en" or "if" halfway through a line is considered
  7131. a match.
  7132. Another example, to search for the matching "{" of a "}": >vim
  7133. echo searchpair('{', '', '}', 'bW')
  7134. < This works when the cursor is at or before the "}" for which a
  7135. match is to be found. To reject matches that syntax
  7136. highlighting recognized as strings: >vim
  7137. echo searchpair('{', '', '}', 'bW',
  7138. \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
  7139. <
  7140. Parameters: ~
  7141. • {start} (`string`)
  7142. • {middle} (`string`)
  7143. • {end} (`string`)
  7144. • {flags} (`string?`)
  7145. • {skip} (`string|function?`)
  7146. • {stopline} (`integer?`)
  7147. • {timeout} (`integer?`)
  7148. Return: ~
  7149. (`integer`)
  7150. *searchpairpos()*
  7151. searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7152. Same as |searchpair()|, but returns a |List| with the line and
  7153. column position of the match. The first element of the |List|
  7154. is the line number and the second element is the byte index of
  7155. the column position of the match. If no match is found,
  7156. returns [0, 0]. >vim
  7157. let [lnum,col] = searchpairpos('{', '', '}', 'n')
  7158. <
  7159. See |match-parens| for a bigger and more useful example.
  7160. Parameters: ~
  7161. • {start} (`string`)
  7162. • {middle} (`string`)
  7163. • {end} (`string`)
  7164. • {flags} (`string?`)
  7165. • {skip} (`string|function?`)
  7166. • {stopline} (`integer?`)
  7167. • {timeout} (`integer?`)
  7168. Return: ~
  7169. (`[integer, integer]`)
  7170. *searchpos()*
  7171. searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  7172. Same as |search()|, but returns a |List| with the line and
  7173. column position of the match. The first element of the |List|
  7174. is the line number and the second element is the byte index of
  7175. the column position of the match. If no match is found,
  7176. returns [0, 0].
  7177. Example: >vim
  7178. let [lnum, col] = searchpos('mypattern', 'n')
  7179. < When the 'p' flag is given then there is an extra item with
  7180. the sub-pattern match number |search()-sub-match|. Example: >vim
  7181. let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
  7182. < In this example "submatch" is 2 when a lowercase letter is
  7183. found |/\l|, 3 when an uppercase letter is found |/\u|.
  7184. Parameters: ~
  7185. • {pattern} (`string`)
  7186. • {flags} (`string?`)
  7187. • {stopline} (`integer?`)
  7188. • {timeout} (`integer?`)
  7189. • {skip} (`string|function?`)
  7190. Return: ~
  7191. (`any`)
  7192. serverlist() *serverlist()*
  7193. Returns a list of server addresses, or empty if all servers
  7194. were stopped. |serverstart()| |serverstop()|
  7195. Example: >vim
  7196. echo serverlist()
  7197. <
  7198. Return: ~
  7199. (`string[]`)
  7200. serverstart([{address}]) *serverstart()*
  7201. Opens a socket or named pipe at {address} and listens for
  7202. |RPC| messages. Clients can send |API| commands to the
  7203. returned address to control Nvim.
  7204. Returns the address string (which may differ from the
  7205. {address} argument, see below).
  7206. - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
  7207. where the last ":" separates host and port (empty or zero
  7208. assigns a random port).
  7209. - Else {address} is the path to a named pipe (except on Windows).
  7210. - If {address} has no slashes ("/") it is treated as the
  7211. "name" part of a generated path in this format: >vim
  7212. stdpath("run").."/{name}.{pid}.{counter}"
  7213. < - If {address} is omitted the name is "nvim". >vim
  7214. echo serverstart()
  7215. < >
  7216. => /tmp/nvim.bram/oknANW/nvim.15430.5
  7217. <
  7218. Example bash command to list all Nvim servers: >bash
  7219. ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
  7220. < Example named pipe: >vim
  7221. if has('win32')
  7222. echo serverstart('\\.\pipe\nvim-pipe-1234')
  7223. else
  7224. echo serverstart('nvim.sock')
  7225. endif
  7226. <
  7227. Example TCP/IP address: >vim
  7228. echo serverstart('::1:12345')
  7229. <
  7230. Parameters: ~
  7231. • {address} (`string?`)
  7232. Return: ~
  7233. (`string`)
  7234. serverstop({address}) *serverstop()*
  7235. Closes the pipe or socket at {address}.
  7236. Returns TRUE if {address} is valid, else FALSE.
  7237. If |v:servername| is stopped it is set to the next available
  7238. address in |serverlist()|.
  7239. Parameters: ~
  7240. • {address} (`string`)
  7241. Return: ~
  7242. (`integer`)
  7243. setbufline({buf}, {lnum}, {text}) *setbufline()*
  7244. Set line {lnum} to {text} in buffer {buf}. This works like
  7245. |setline()| for the specified buffer.
  7246. This function works only for loaded buffers. First call
  7247. |bufload()| if needed.
  7248. To insert lines use |appendbufline()|.
  7249. {text} can be a string to set one line, or a List of strings
  7250. to set multiple lines. If the List extends below the last
  7251. line then those lines are added. If the List is empty then
  7252. nothing is changed and zero is returned.
  7253. For the use of {buf}, see |bufname()| above.
  7254. {lnum} is used like with |setline()|.
  7255. Use "$" to refer to the last line in buffer {buf}.
  7256. When {lnum} is just below the last line the {text} will be
  7257. added below the last line.
  7258. On success 0 is returned, on failure 1 is returned.
  7259. If {buf} is not a valid buffer or {lnum} is not valid, an
  7260. error message is given.
  7261. Parameters: ~
  7262. • {buf} (`integer|string`)
  7263. • {lnum} (`integer`)
  7264. • {text} (`string|string[]`)
  7265. Return: ~
  7266. (`integer`)
  7267. setbufvar({buf}, {varname}, {val}) *setbufvar()*
  7268. Set option or local variable {varname} in buffer {buf} to
  7269. {val}.
  7270. This also works for a global or local window option, but it
  7271. doesn't work for a global or local window variable.
  7272. For a local window option the global value is unchanged.
  7273. For the use of {buf}, see |bufname()| above.
  7274. The {varname} argument is a string.
  7275. Note that the variable name without "b:" must be used.
  7276. Examples: >vim
  7277. call setbufvar(1, "&mod", 1)
  7278. call setbufvar("todo", "myvar", "foobar")
  7279. < This function is not available in the |sandbox|.
  7280. Parameters: ~
  7281. • {buf} (`integer|string`)
  7282. • {varname} (`string`)
  7283. • {val} (`any`)
  7284. Return: ~
  7285. (`any`)
  7286. setcellwidths({list}) *setcellwidths()*
  7287. Specify overrides for cell widths of character ranges. This
  7288. tells Vim how wide characters are when displayed in the
  7289. terminal, counted in screen cells. The values override
  7290. 'ambiwidth'. Example: >vim
  7291. call setcellwidths([
  7292. \ [0x111, 0x111, 1],
  7293. \ [0x2194, 0x2199, 2],
  7294. \ ])
  7295. < The {list} argument is a List of Lists with each three
  7296. numbers: [{low}, {high}, {width}]. *E1109* *E1110*
  7297. {low} and {high} can be the same, in which case this refers to
  7298. one character. Otherwise it is the range of characters from
  7299. {low} to {high} (inclusive). *E1111* *E1114*
  7300. Only characters with value 0x80 and higher can be used.
  7301. {width} must be either 1 or 2, indicating the character width
  7302. in screen cells. *E1112*
  7303. An error is given if the argument is invalid, also when a
  7304. range overlaps with another. *E1113*
  7305. If the new value causes 'fillchars' or 'listchars' to become
  7306. invalid it is rejected and an error is given.
  7307. To clear the overrides pass an empty {list}: >vim
  7308. call setcellwidths([])
  7309. < You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
  7310. the effect for known emoji characters. Move the cursor
  7311. through the text to check if the cell widths of your terminal
  7312. match with what Vim knows about each emoji. If it doesn't
  7313. look right you need to adjust the {list} argument.
  7314. Parameters: ~
  7315. • {list} (`any[]`)
  7316. Return: ~
  7317. (`any`)
  7318. setcharpos({expr}, {list}) *setcharpos()*
  7319. Same as |setpos()| but uses the specified column number as the
  7320. character index instead of the byte index in the line.
  7321. Example:
  7322. With the text "여보세요" in line 8: >vim
  7323. call setcharpos('.', [0, 8, 4, 0])
  7324. < positions the cursor on the fourth character '요'. >vim
  7325. call setpos('.', [0, 8, 4, 0])
  7326. < positions the cursor on the second character '보'.
  7327. Parameters: ~
  7328. • {expr} (`string`)
  7329. • {list} (`integer[]`)
  7330. Return: ~
  7331. (`any`)
  7332. setcharsearch({dict}) *setcharsearch()*
  7333. Set the current character search information to {dict},
  7334. which contains one or more of the following entries:
  7335. char character which will be used for a subsequent
  7336. |,| or |;| command; an empty string clears the
  7337. character search
  7338. forward direction of character search; 1 for forward,
  7339. 0 for backward
  7340. until type of character search; 1 for a |t| or |T|
  7341. character search, 0 for an |f| or |F|
  7342. character search
  7343. This can be useful to save/restore a user's character search
  7344. from a script: >vim
  7345. let prevsearch = getcharsearch()
  7346. " Perform a command which clobbers user's search
  7347. call setcharsearch(prevsearch)
  7348. < Also see |getcharsearch()|.
  7349. Parameters: ~
  7350. • {dict} (`string`)
  7351. Return: ~
  7352. (`any`)
  7353. setcmdline({str} [, {pos}]) *setcmdline()*
  7354. Set the command line to {str} and set the cursor position to
  7355. {pos}.
  7356. If {pos} is omitted, the cursor is positioned after the text.
  7357. Returns 0 when successful, 1 when not editing the command
  7358. line.
  7359. Parameters: ~
  7360. • {str} (`string`)
  7361. • {pos} (`integer?`)
  7362. Return: ~
  7363. (`integer`)
  7364. setcmdpos({pos}) *setcmdpos()*
  7365. Set the cursor position in the command line to byte position
  7366. {pos}. The first position is 1.
  7367. Use |getcmdpos()| to obtain the current position.
  7368. Only works while editing the command line, thus you must use
  7369. |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
  7370. |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
  7371. set after the command line is set to the expression. For
  7372. |c_CTRL-R_=| it is set after evaluating the expression but
  7373. before inserting the resulting text.
  7374. When the number is too big the cursor is put at the end of the
  7375. line. A number smaller than one has undefined results.
  7376. Returns 0 when successful, 1 when not editing the command
  7377. line.
  7378. Parameters: ~
  7379. • {pos} (`integer`)
  7380. Return: ~
  7381. (`any`)
  7382. setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()*
  7383. setcursorcharpos({list})
  7384. Same as |cursor()| but uses the specified column number as the
  7385. character index instead of the byte index in the line.
  7386. Example:
  7387. With the text "여보세요" in line 4: >vim
  7388. call setcursorcharpos(4, 3)
  7389. < positions the cursor on the third character '세'. >vim
  7390. call cursor(4, 3)
  7391. < positions the cursor on the first character '여'.
  7392. Parameters: ~
  7393. • {list} (`integer[]`)
  7394. Return: ~
  7395. (`any`)
  7396. setenv({name}, {val}) *setenv()*
  7397. Set environment variable {name} to {val}. Example: >vim
  7398. call setenv('HOME', '/home/myhome')
  7399. < When {val} is |v:null| the environment variable is deleted.
  7400. See also |expr-env|.
  7401. Parameters: ~
  7402. • {name} (`string`)
  7403. • {val} (`string`)
  7404. Return: ~
  7405. (`any`)
  7406. setfperm({fname}, {mode}) *setfperm()* *chmod*
  7407. Set the file permissions for {fname} to {mode}.
  7408. {mode} must be a string with 9 characters. It is of the form
  7409. "rwxrwxrwx", where each group of "rwx" flags represent, in
  7410. turn, the permissions of the owner of the file, the group the
  7411. file belongs to, and other users. A '-' character means the
  7412. permission is off, any other character means on. Multi-byte
  7413. characters are not supported.
  7414. For example "rw-r-----" means read-write for the user,
  7415. readable by the group, not accessible by others. "xx-x-----"
  7416. would do the same thing.
  7417. Returns non-zero for success, zero for failure.
  7418. To read permissions see |getfperm()|.
  7419. Parameters: ~
  7420. • {fname} (`string`)
  7421. • {mode} (`string`)
  7422. Return: ~
  7423. (`any`)
  7424. setline({lnum}, {text}) *setline()*
  7425. Set line {lnum} of the current buffer to {text}. To insert
  7426. lines use |append()|. To set lines in another buffer use
  7427. |setbufline()|.
  7428. {lnum} is used like with |getline()|.
  7429. When {lnum} is just below the last line the {text} will be
  7430. added below the last line.
  7431. {text} can be any type or a List of any type, each item is
  7432. converted to a String. When {text} is an empty List then
  7433. nothing is changed and FALSE is returned.
  7434. If this succeeds, FALSE is returned. If this fails (most likely
  7435. because {lnum} is invalid) TRUE is returned.
  7436. Example: >vim
  7437. call setline(5, strftime("%c"))
  7438. < When {text} is a |List| then line {lnum} and following lines
  7439. will be set to the items in the list. Example: >vim
  7440. call setline(5, ['aaa', 'bbb', 'ccc'])
  7441. < This is equivalent to: >vim
  7442. for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
  7443. call setline(n, l)
  7444. endfor
  7445. < Note: The '[ and '] marks are not set.
  7446. Parameters: ~
  7447. • {lnum} (`integer`)
  7448. • {text} (`any`)
  7449. Return: ~
  7450. (`any`)
  7451. setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
  7452. Create or replace or add to the location list for window {nr}.
  7453. {nr} can be the window number or the |window-ID|.
  7454. When {nr} is zero the current window is used.
  7455. For a location list window, the displayed location list is
  7456. modified. For an invalid window number {nr}, -1 is returned.
  7457. Otherwise, same as |setqflist()|.
  7458. Also see |location-list|.
  7459. For {action} see |setqflist-action|.
  7460. If the optional {what} dictionary argument is supplied, then
  7461. only the items listed in {what} are set. Refer to |setqflist()|
  7462. for the list of supported keys in {what}.
  7463. Parameters: ~
  7464. • {nr} (`integer`)
  7465. • {list} (`any`)
  7466. • {action} (`string?`)
  7467. • {what} (`table?`)
  7468. Return: ~
  7469. (`any`)
  7470. setmatches({list} [, {win}]) *setmatches()*
  7471. Restores a list of matches saved by |getmatches()| for the
  7472. current window. Returns 0 if successful, otherwise -1. All
  7473. current matches are cleared before the list is restored. See
  7474. example for |getmatches()|.
  7475. If {win} is specified, use the window with this number or
  7476. window ID instead of the current window.
  7477. Parameters: ~
  7478. • {list} (`any`)
  7479. • {win} (`integer?`)
  7480. Return: ~
  7481. (`any`)
  7482. setpos({expr}, {list}) *setpos()*
  7483. Set the position for String {expr}. Possible values:
  7484. . the cursor
  7485. 'x mark x
  7486. {list} must be a |List| with four or five numbers:
  7487. [bufnum, lnum, col, off]
  7488. [bufnum, lnum, col, off, curswant]
  7489. "bufnum" is the buffer number. Zero can be used for the
  7490. current buffer. When setting an uppercase mark "bufnum" is
  7491. used for the mark position. For other marks it specifies the
  7492. buffer to set the mark in. You can use the |bufnr()| function
  7493. to turn a file name into a buffer number.
  7494. For setting the cursor and the ' mark "bufnum" is ignored,
  7495. since these are associated with a window, not a buffer.
  7496. Does not change the jumplist.
  7497. "lnum" and "col" are the position in the buffer. The first
  7498. column is 1. Use a zero "lnum" to delete a mark. If "col" is
  7499. smaller than 1 then 1 is used. To use the character count
  7500. instead of the byte count, use |setcharpos()|.
  7501. The "off" number is only used when 'virtualedit' is set. Then
  7502. it is the offset in screen columns from the start of the
  7503. character. E.g., a position within a <Tab> or after the last
  7504. character.
  7505. The "curswant" number is only used when setting the cursor
  7506. position. It sets the preferred column for when moving the
  7507. cursor vertically. When the "curswant" number is missing the
  7508. preferred column is not set. When it is present and setting a
  7509. mark position it is not used.
  7510. Note that for '< and '> changing the line number may result in
  7511. the marks to be effectively be swapped, so that '< is always
  7512. before '>.
  7513. Returns 0 when the position could be set, -1 otherwise.
  7514. An error message is given if {expr} is invalid.
  7515. Also see |setcharpos()|, |getpos()| and |getcurpos()|.
  7516. This does not restore the preferred column for moving
  7517. vertically; if you set the cursor position with this, |j| and
  7518. |k| motions will jump to previous columns! Use |cursor()| to
  7519. also set the preferred column. Also see the "curswant" key in
  7520. |winrestview()|.
  7521. Parameters: ~
  7522. • {expr} (`string`)
  7523. • {list} (`integer[]`)
  7524. Return: ~
  7525. (`any`)
  7526. setqflist({list} [, {action} [, {what}]]) *setqflist()*
  7527. Create or replace or add to the quickfix list.
  7528. If the optional {what} dictionary argument is supplied, then
  7529. only the items listed in {what} are set. The first {list}
  7530. argument is ignored. See below for the supported items in
  7531. {what}.
  7532. *setqflist-what*
  7533. When {what} is not present, the items in {list} are used. Each
  7534. item must be a dictionary. Non-dictionary items in {list} are
  7535. ignored. Each dictionary item can contain the following
  7536. entries:
  7537. bufnr buffer number; must be the number of a valid
  7538. buffer
  7539. filename name of a file; only used when "bufnr" is not
  7540. present or it is invalid.
  7541. module name of a module; if given it will be used in
  7542. quickfix error window instead of the filename.
  7543. lnum line number in the file
  7544. end_lnum end of lines, if the item spans multiple lines
  7545. pattern search pattern used to locate the error
  7546. col column number
  7547. vcol when non-zero: "col" is visual column
  7548. when zero: "col" is byte index
  7549. end_col end column, if the item spans multiple columns
  7550. nr error number
  7551. text description of the error
  7552. type single-character error type, 'E', 'W', etc.
  7553. valid recognized error message
  7554. user_data
  7555. custom data associated with the item, can be
  7556. any type.
  7557. The "col", "vcol", "nr", "type" and "text" entries are
  7558. optional. Either "lnum" or "pattern" entry can be used to
  7559. locate a matching error line.
  7560. If the "filename" and "bufnr" entries are not present or
  7561. neither the "lnum" or "pattern" entries are present, then the
  7562. item will not be handled as an error line.
  7563. If both "pattern" and "lnum" are present then "pattern" will
  7564. be used.
  7565. If the "valid" entry is not supplied, then the valid flag is
  7566. set when "bufnr" is a valid buffer or "filename" exists.
  7567. If you supply an empty {list}, the quickfix list will be
  7568. cleared.
  7569. Note that the list is not exactly the same as what
  7570. |getqflist()| returns.
  7571. {action} values: *setqflist-action* *E927*
  7572. 'a' The items from {list} are added to the existing
  7573. quickfix list. If there is no existing list, then a
  7574. new list is created.
  7575. 'r' The items from the current quickfix list are replaced
  7576. with the items from {list}. This can also be used to
  7577. clear the list: >vim
  7578. call setqflist([], 'r')
  7579. <
  7580. 'u' Like 'r', but tries to preserve the current selection
  7581. in the quickfix list.
  7582. 'f' All the quickfix lists in the quickfix stack are
  7583. freed.
  7584. If {action} is not present or is set to ' ', then a new list
  7585. is created. The new quickfix list is added after the current
  7586. quickfix list in the stack and all the following lists are
  7587. freed. To add a new quickfix list at the end of the stack,
  7588. set "nr" in {what} to "$".
  7589. The following items can be specified in dictionary {what}:
  7590. context quickfix list context. See |quickfix-context|
  7591. efm errorformat to use when parsing text from
  7592. "lines". If this is not present, then the
  7593. 'errorformat' option value is used.
  7594. See |quickfix-parse|
  7595. id quickfix list identifier |quickfix-ID|
  7596. idx index of the current entry in the quickfix
  7597. list specified by "id" or "nr". If set to '$',
  7598. then the last entry in the list is set as the
  7599. current entry. See |quickfix-index|
  7600. items list of quickfix entries. Same as the {list}
  7601. argument.
  7602. lines use 'errorformat' to parse a list of lines and
  7603. add the resulting entries to the quickfix list
  7604. {nr} or {id}. Only a |List| value is supported.
  7605. See |quickfix-parse|
  7606. nr list number in the quickfix stack; zero
  7607. means the current quickfix list and "$" means
  7608. the last quickfix list.
  7609. quickfixtextfunc
  7610. function to get the text to display in the
  7611. quickfix window. The value can be the name of
  7612. a function or a funcref or a lambda. Refer to
  7613. |quickfix-window-function| for an explanation
  7614. of how to write the function and an example.
  7615. title quickfix list title text. See |quickfix-title|
  7616. Unsupported keys in {what} are ignored.
  7617. If the "nr" item is not present, then the current quickfix list
  7618. is modified. When creating a new quickfix list, "nr" can be
  7619. set to a value one greater than the quickfix stack size.
  7620. When modifying a quickfix list, to guarantee that the correct
  7621. list is modified, "id" should be used instead of "nr" to
  7622. specify the list.
  7623. Examples (See also |setqflist-examples|): >vim
  7624. call setqflist([], 'r', {'title': 'My search'})
  7625. call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
  7626. call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
  7627. <
  7628. Returns zero for success, -1 for failure.
  7629. This function can be used to create a quickfix list
  7630. independent of the 'errorformat' setting. Use a command like
  7631. `:cc 1` to jump to the first position.
  7632. Parameters: ~
  7633. • {list} (`vim.quickfix.entry[]`)
  7634. • {action} (`string?`)
  7635. • {what} (`vim.fn.setqflist.what?`)
  7636. Return: ~
  7637. (`integer`)
  7638. setreg({regname}, {value} [, {options}]) *setreg()*
  7639. Set the register {regname} to {value}.
  7640. If {regname} is "" or "@", the unnamed register '"' is used.
  7641. The {regname} argument is a string.
  7642. {value} may be any value returned by |getreg()| or
  7643. |getreginfo()|, including a |List| or |Dict|.
  7644. If {options} contains "a" or {regname} is upper case,
  7645. then the value is appended.
  7646. {options} can also contain a register type specification:
  7647. "c" or "v" |charwise| mode
  7648. "l" or "V" |linewise| mode
  7649. "b" or "<CTRL-V>" |blockwise-visual| mode
  7650. If a number immediately follows "b" or "<CTRL-V>" then this is
  7651. used as the width of the selection - if it is not specified
  7652. then the width of the block is set to the number of characters
  7653. in the longest line (counting a <Tab> as 1 character).
  7654. If {options} contains "u" or '"', then the unnamed register is
  7655. set to point to register {regname}.
  7656. If {options} contains no register settings, then the default
  7657. is to use character mode unless {value} ends in a <NL> for
  7658. string {value} and linewise mode for list {value}. Blockwise
  7659. mode is never selected automatically.
  7660. Returns zero for success, non-zero for failure.
  7661. *E883*
  7662. Note: you may not use |List| containing more than one item to
  7663. set search and expression registers. Lists containing no
  7664. items act like empty strings.
  7665. Examples: >vim
  7666. call setreg(v:register, @*)
  7667. call setreg('*', @%, 'ac')
  7668. call setreg('a', "1\n2\n3", 'b5')
  7669. call setreg('"', { 'points_to': 'a'})
  7670. < This example shows using the functions to save and restore a
  7671. register: >vim
  7672. let var_a = getreginfo()
  7673. call setreg('a', var_a)
  7674. < or: >vim
  7675. let var_a = getreg('a', 1, 1)
  7676. let var_amode = getregtype('a')
  7677. " ....
  7678. call setreg('a', var_a, var_amode)
  7679. < Note: you may not reliably restore register value
  7680. without using the third argument to |getreg()| as without it
  7681. newlines are represented as newlines AND Nul bytes are
  7682. represented as newlines as well, see |NL-used-for-Nul|.
  7683. You can also change the type of a register by appending
  7684. nothing: >vim
  7685. call setreg('a', '', 'al')
  7686. Parameters: ~
  7687. • {regname} (`string`)
  7688. • {value} (`any`)
  7689. • {options} (`string?`)
  7690. Return: ~
  7691. (`any`)
  7692. settabvar({tabnr}, {varname}, {val}) *settabvar()*
  7693. Set tab-local variable {varname} to {val} in tab page {tabnr}.
  7694. |t:var|
  7695. The {varname} argument is a string.
  7696. Note that the variable name without "t:" must be used.
  7697. Tabs are numbered starting with one.
  7698. This function is not available in the |sandbox|.
  7699. Parameters: ~
  7700. • {tabnr} (`integer`)
  7701. • {varname} (`string`)
  7702. • {val} (`any`)
  7703. Return: ~
  7704. (`any`)
  7705. settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
  7706. Set option or local variable {varname} in window {winnr} to
  7707. {val}.
  7708. Tabs are numbered starting with one. For the current tabpage
  7709. use |setwinvar()|.
  7710. {winnr} can be the window number or the |window-ID|.
  7711. When {winnr} is zero the current window is used.
  7712. This also works for a global or local buffer option, but it
  7713. doesn't work for a global or local buffer variable.
  7714. For a local buffer option the global value is unchanged.
  7715. Note that the variable name without "w:" must be used.
  7716. Examples: >vim
  7717. call settabwinvar(1, 1, "&list", 0)
  7718. call settabwinvar(3, 2, "myvar", "foobar")
  7719. < This function is not available in the |sandbox|.
  7720. Parameters: ~
  7721. • {tabnr} (`integer`)
  7722. • {winnr} (`integer`)
  7723. • {varname} (`string`)
  7724. • {val} (`any`)
  7725. Return: ~
  7726. (`any`)
  7727. settagstack({nr}, {dict} [, {action}]) *settagstack()*
  7728. Modify the tag stack of the window {nr} using {dict}.
  7729. {nr} can be the window number or the |window-ID|.
  7730. For a list of supported items in {dict}, refer to
  7731. |gettagstack()|. "curidx" takes effect before changing the tag
  7732. stack.
  7733. *E962*
  7734. How the tag stack is modified depends on the {action}
  7735. argument:
  7736. - If {action} is not present or is set to 'r', then the tag
  7737. stack is replaced.
  7738. - If {action} is set to 'a', then new entries from {dict} are
  7739. pushed (added) onto the tag stack.
  7740. - If {action} is set to 't', then all the entries from the
  7741. current entry in the tag stack or "curidx" in {dict} are
  7742. removed and then new entries are pushed to the stack.
  7743. The current index is set to one after the length of the tag
  7744. stack after the modification.
  7745. Returns zero for success, -1 for failure.
  7746. Examples (for more examples see |tagstack-examples|):
  7747. Empty the tag stack of window 3: >vim
  7748. call settagstack(3, {'items' : []})
  7749. < Save and restore the tag stack: >vim
  7750. let stack = gettagstack(1003)
  7751. " do something else
  7752. call settagstack(1003, stack)
  7753. unlet stack
  7754. <
  7755. Parameters: ~
  7756. • {nr} (`integer`)
  7757. • {dict} (`any`)
  7758. • {action} (`string?`)
  7759. Return: ~
  7760. (`any`)
  7761. setwinvar({nr}, {varname}, {val}) *setwinvar()*
  7762. Like |settabwinvar()| for the current tab page.
  7763. Examples: >vim
  7764. call setwinvar(1, "&list", 0)
  7765. call setwinvar(2, "myvar", "foobar")
  7766. Parameters: ~
  7767. • {nr} (`integer`)
  7768. • {varname} (`string`)
  7769. • {val} (`any`)
  7770. Return: ~
  7771. (`any`)
  7772. sha256({string}) *sha256()*
  7773. Returns a String with 64 hex characters, which is the SHA256
  7774. checksum of {string}.
  7775. Parameters: ~
  7776. • {string} (`string`)
  7777. Return: ~
  7778. (`string`)
  7779. shellescape({string} [, {special}]) *shellescape()*
  7780. Escape {string} for use as a shell command argument.
  7781. On Windows when 'shellslash' is not set, encloses {string} in
  7782. double-quotes and doubles all double-quotes within {string}.
  7783. Otherwise encloses {string} in single-quotes and replaces all
  7784. "'" with "'\''".
  7785. The {special} argument adds additional escaping of keywords
  7786. used in Vim commands. If it is a |non-zero-arg|:
  7787. - Special items such as "!", "%", "#" and "<cword>" (as listed
  7788. in |expand()|) will be preceded by a backslash.
  7789. The backslash will be removed again by the |:!| command.
  7790. - The <NL> character is escaped.
  7791. If 'shell' contains "csh" in the tail:
  7792. - The "!" character will be escaped. This is because csh and
  7793. tcsh use "!" for history replacement even in single-quotes.
  7794. - The <NL> character is escaped (twice if {special} is
  7795. a |non-zero-arg|).
  7796. If 'shell' contains "fish" in the tail, the "\" character will
  7797. be escaped because in fish it is used as an escape character
  7798. inside single quotes.
  7799. Example of use with a |:!| command: >vim
  7800. exe '!dir ' .. shellescape(expand('<cfile>'), 1)
  7801. < This results in a directory listing for the file under the
  7802. cursor. Example of use with |system()|: >vim
  7803. call system("chmod +w -- " .. shellescape(expand("%")))
  7804. < See also |::S|.
  7805. Parameters: ~
  7806. • {string} (`string`)
  7807. • {special} (`boolean?`)
  7808. Return: ~
  7809. (`string`)
  7810. shiftwidth([{col}]) *shiftwidth()*
  7811. Returns the effective value of 'shiftwidth'. This is the
  7812. 'shiftwidth' value unless it is zero, in which case it is the
  7813. 'tabstop' value. To be backwards compatible in indent
  7814. plugins, use this: >vim
  7815. if exists('*shiftwidth')
  7816. func s:sw()
  7817. return shiftwidth()
  7818. endfunc
  7819. else
  7820. func s:sw()
  7821. return &sw
  7822. endfunc
  7823. endif
  7824. < And then use s:sw() instead of &sw.
  7825. When there is one argument {col} this is used as column number
  7826. for which to return the 'shiftwidth' value. This matters for the
  7827. 'vartabstop' feature. If no {col} argument is given, column 1
  7828. will be assumed.
  7829. Parameters: ~
  7830. • {col} (`integer?`)
  7831. Return: ~
  7832. (`integer`)
  7833. sign_define({name} [, {dict}]) *sign_define()*
  7834. sign_define({list})
  7835. Define a new sign named {name} or modify the attributes of an
  7836. existing sign. This is similar to the |:sign-define| command.
  7837. Prefix {name} with a unique text to avoid name collisions.
  7838. There is no {group} like with placing signs.
  7839. The {name} can be a String or a Number. The optional {dict}
  7840. argument specifies the sign attributes. The following values
  7841. are supported:
  7842. icon full path to the bitmap file for the sign.
  7843. linehl highlight group used for the whole line the
  7844. sign is placed in.
  7845. priority default priority value of the sign
  7846. numhl highlight group used for the line number where
  7847. the sign is placed.
  7848. text text that is displayed when there is no icon
  7849. or the GUI is not being used.
  7850. texthl highlight group used for the text item
  7851. culhl highlight group used for the text item when
  7852. the cursor is on the same line as the sign and
  7853. 'cursorline' is enabled.
  7854. If the sign named {name} already exists, then the attributes
  7855. of the sign are updated.
  7856. The one argument {list} can be used to define a list of signs.
  7857. Each list item is a dictionary with the above items in {dict}
  7858. and a "name" item for the sign name.
  7859. Returns 0 on success and -1 on failure. When the one argument
  7860. {list} is used, then returns a List of values one for each
  7861. defined sign.
  7862. Examples: >vim
  7863. call sign_define("mySign", {
  7864. \ "text" : "=>",
  7865. \ "texthl" : "Error",
  7866. \ "linehl" : "Search"})
  7867. call sign_define([
  7868. \ {'name' : 'sign1',
  7869. \ 'text' : '=>'},
  7870. \ {'name' : 'sign2',
  7871. \ 'text' : '!!'}
  7872. \ ])
  7873. <
  7874. Parameters: ~
  7875. • {list} (`vim.fn.sign_define.dict[]`)
  7876. Return: ~
  7877. (`(0|-1)[]`)
  7878. sign_getdefined([{name}]) *sign_getdefined()*
  7879. Get a list of defined signs and their attributes.
  7880. This is similar to the |:sign-list| command.
  7881. If the {name} is not supplied, then a list of all the defined
  7882. signs is returned. Otherwise the attribute of the specified
  7883. sign is returned.
  7884. Each list item in the returned value is a dictionary with the
  7885. following entries:
  7886. icon full path to the bitmap file of the sign
  7887. linehl highlight group used for the whole line the
  7888. sign is placed in; not present if not set.
  7889. name name of the sign
  7890. priority default priority value of the sign
  7891. numhl highlight group used for the line number where
  7892. the sign is placed; not present if not set.
  7893. text text that is displayed when there is no icon
  7894. or the GUI is not being used.
  7895. texthl highlight group used for the text item; not
  7896. present if not set.
  7897. culhl highlight group used for the text item when
  7898. the cursor is on the same line as the sign and
  7899. 'cursorline' is enabled; not present if not
  7900. set.
  7901. Returns an empty List if there are no signs and when {name} is
  7902. not found.
  7903. Examples: >vim
  7904. " Get a list of all the defined signs
  7905. echo sign_getdefined()
  7906. " Get the attribute of the sign named mySign
  7907. echo sign_getdefined("mySign")
  7908. <
  7909. Parameters: ~
  7910. • {name} (`string?`)
  7911. Return: ~
  7912. (`vim.fn.sign_getdefined.ret.item[]`)
  7913. sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
  7914. Return a list of signs placed in a buffer or all the buffers.
  7915. This is similar to the |:sign-place-list| command.
  7916. If the optional buffer name {buf} is specified, then only the
  7917. list of signs placed in that buffer is returned. For the use
  7918. of {buf}, see |bufname()|. The optional {dict} can contain
  7919. the following entries:
  7920. group select only signs in this group
  7921. id select sign with this identifier
  7922. lnum select signs placed in this line. For the use
  7923. of {lnum}, see |line()|.
  7924. If {group} is "*", then signs in all the groups including the
  7925. global group are returned. If {group} is not supplied or is an
  7926. empty string, then only signs in the global group are
  7927. returned. If no arguments are supplied, then signs in the
  7928. global group placed in all the buffers are returned.
  7929. See |sign-group|.
  7930. Each list item in the returned value is a dictionary with the
  7931. following entries:
  7932. bufnr number of the buffer with the sign
  7933. signs list of signs placed in {bufnr}. Each list
  7934. item is a dictionary with the below listed
  7935. entries
  7936. The dictionary for each sign contains the following entries:
  7937. group sign group. Set to '' for the global group.
  7938. id identifier of the sign
  7939. lnum line number where the sign is placed
  7940. name name of the defined sign
  7941. priority sign priority
  7942. The returned signs in a buffer are ordered by their line
  7943. number and priority.
  7944. Returns an empty list on failure or if there are no placed
  7945. signs.
  7946. Examples: >vim
  7947. " Get a List of signs placed in eval.c in the
  7948. " global group
  7949. echo sign_getplaced("eval.c")
  7950. " Get a List of signs in group 'g1' placed in eval.c
  7951. echo sign_getplaced("eval.c", {'group' : 'g1'})
  7952. " Get a List of signs placed at line 10 in eval.c
  7953. echo sign_getplaced("eval.c", {'lnum' : 10})
  7954. " Get sign with identifier 10 placed in a.py
  7955. echo sign_getplaced("a.py", {'id' : 10})
  7956. " Get sign with id 20 in group 'g1' placed in a.py
  7957. echo sign_getplaced("a.py", {'group' : 'g1',
  7958. \ 'id' : 20})
  7959. " Get a List of all the placed signs
  7960. echo sign_getplaced()
  7961. <
  7962. Parameters: ~
  7963. • {buf} (`integer|string?`)
  7964. • {dict} (`vim.fn.sign_getplaced.dict?`)
  7965. Return: ~
  7966. (`vim.fn.sign_getplaced.ret.item[]`)
  7967. sign_jump({id}, {group}, {buf}) *sign_jump()*
  7968. Open the buffer {buf} or jump to the window that contains
  7969. {buf} and position the cursor at sign {id} in group {group}.
  7970. This is similar to the |:sign-jump| command.
  7971. If {group} is an empty string, then the global group is used.
  7972. For the use of {buf}, see |bufname()|.
  7973. Returns the line number of the sign. Returns -1 if the
  7974. arguments are invalid.
  7975. Example: >vim
  7976. " Jump to sign 10 in the current buffer
  7977. call sign_jump(10, '', '')
  7978. <
  7979. Parameters: ~
  7980. • {id} (`integer`)
  7981. • {group} (`string`)
  7982. • {buf} (`integer|string`)
  7983. Return: ~
  7984. (`integer`)
  7985. sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()*
  7986. Place the sign defined as {name} at line {lnum} in file or
  7987. buffer {buf} and assign {id} and {group} to sign. This is
  7988. similar to the |:sign-place| command.
  7989. If the sign identifier {id} is zero, then a new identifier is
  7990. allocated. Otherwise the specified number is used. {group} is
  7991. the sign group name. To use the global sign group, use an
  7992. empty string. {group} functions as a namespace for {id}, thus
  7993. two groups can use the same IDs. Refer to |sign-identifier|
  7994. and |sign-group| for more information.
  7995. {name} refers to a defined sign.
  7996. {buf} refers to a buffer name or number. For the accepted
  7997. values, see |bufname()|.
  7998. The optional {dict} argument supports the following entries:
  7999. lnum line number in the file or buffer
  8000. {buf} where the sign is to be placed.
  8001. For the accepted values, see |line()|.
  8002. priority priority of the sign. See
  8003. |sign-priority| for more information.
  8004. If the optional {dict} is not specified, then it modifies the
  8005. placed sign {id} in group {group} to use the defined sign
  8006. {name}.
  8007. Returns the sign identifier on success and -1 on failure.
  8008. Examples: >vim
  8009. " Place a sign named sign1 with id 5 at line 20 in
  8010. " buffer json.c
  8011. call sign_place(5, '', 'sign1', 'json.c',
  8012. \ {'lnum' : 20})
  8013. " Updates sign 5 in buffer json.c to use sign2
  8014. call sign_place(5, '', 'sign2', 'json.c')
  8015. " Place a sign named sign3 at line 30 in
  8016. " buffer json.c with a new identifier
  8017. let id = sign_place(0, '', 'sign3', 'json.c',
  8018. \ {'lnum' : 30})
  8019. " Place a sign named sign4 with id 10 in group 'g3'
  8020. " at line 40 in buffer json.c with priority 90
  8021. call sign_place(10, 'g3', 'sign4', 'json.c',
  8022. \ {'lnum' : 40, 'priority' : 90})
  8023. <
  8024. Parameters: ~
  8025. • {id} (`integer`)
  8026. • {group} (`string`)
  8027. • {name} (`string`)
  8028. • {buf} (`integer|string`)
  8029. • {dict} (`vim.fn.sign_place.dict?`)
  8030. Return: ~
  8031. (`integer`)
  8032. sign_placelist({list}) *sign_placelist()*
  8033. Place one or more signs. This is similar to the
  8034. |sign_place()| function. The {list} argument specifies the
  8035. List of signs to place. Each list item is a dict with the
  8036. following sign attributes:
  8037. buffer Buffer name or number. For the accepted
  8038. values, see |bufname()|.
  8039. group Sign group. {group} functions as a namespace
  8040. for {id}, thus two groups can use the same
  8041. IDs. If not specified or set to an empty
  8042. string, then the global group is used. See
  8043. |sign-group| for more information.
  8044. id Sign identifier. If not specified or zero,
  8045. then a new unique identifier is allocated.
  8046. Otherwise the specified number is used. See
  8047. |sign-identifier| for more information.
  8048. lnum Line number in the buffer where the sign is to
  8049. be placed. For the accepted values, see
  8050. |line()|.
  8051. name Name of the sign to place. See |sign_define()|
  8052. for more information.
  8053. priority Priority of the sign. When multiple signs are
  8054. placed on a line, the sign with the highest
  8055. priority is used. If not specified, the
  8056. default value of 10 is used, unless specified
  8057. otherwise by the sign definition. See
  8058. |sign-priority| for more information.
  8059. If {id} refers to an existing sign, then the existing sign is
  8060. modified to use the specified {name} and/or {priority}.
  8061. Returns a List of sign identifiers. If failed to place a
  8062. sign, the corresponding list item is set to -1.
  8063. Examples: >vim
  8064. " Place sign s1 with id 5 at line 20 and id 10 at line
  8065. " 30 in buffer a.c
  8066. let [n1, n2] = sign_placelist([
  8067. \ {'id' : 5,
  8068. \ 'name' : 's1',
  8069. \ 'buffer' : 'a.c',
  8070. \ 'lnum' : 20},
  8071. \ {'id' : 10,
  8072. \ 'name' : 's1',
  8073. \ 'buffer' : 'a.c',
  8074. \ 'lnum' : 30}
  8075. \ ])
  8076. " Place sign s1 in buffer a.c at line 40 and 50
  8077. " with auto-generated identifiers
  8078. let [n1, n2] = sign_placelist([
  8079. \ {'name' : 's1',
  8080. \ 'buffer' : 'a.c',
  8081. \ 'lnum' : 40},
  8082. \ {'name' : 's1',
  8083. \ 'buffer' : 'a.c',
  8084. \ 'lnum' : 50}
  8085. \ ])
  8086. <
  8087. Parameters: ~
  8088. • {list} (`vim.fn.sign_placelist.list.item[]`)
  8089. Return: ~
  8090. (`integer[]`)
  8091. sign_undefine([{name}]) *sign_undefine()*
  8092. sign_undefine({list})
  8093. Deletes a previously defined sign {name}. This is similar to
  8094. the |:sign-undefine| command. If {name} is not supplied, then
  8095. deletes all the defined signs.
  8096. The one argument {list} can be used to undefine a list of
  8097. signs. Each list item is the name of a sign.
  8098. Returns 0 on success and -1 on failure. For the one argument
  8099. {list} call, returns a list of values one for each undefined
  8100. sign.
  8101. Examples: >vim
  8102. " Delete a sign named mySign
  8103. call sign_undefine("mySign")
  8104. " Delete signs 'sign1' and 'sign2'
  8105. call sign_undefine(["sign1", "sign2"])
  8106. " Delete all the signs
  8107. call sign_undefine()
  8108. <
  8109. Parameters: ~
  8110. • {list} (`string[]?`)
  8111. Return: ~
  8112. (`integer[]`)
  8113. sign_unplace({group} [, {dict}]) *sign_unplace()*
  8114. Remove a previously placed sign in one or more buffers. This
  8115. is similar to the |:sign-unplace| command.
  8116. {group} is the sign group name. To use the global sign group,
  8117. use an empty string. If {group} is set to "*", then all the
  8118. groups including the global group are used.
  8119. The signs in {group} are selected based on the entries in
  8120. {dict}. The following optional entries in {dict} are
  8121. supported:
  8122. buffer buffer name or number. See |bufname()|.
  8123. id sign identifier
  8124. If {dict} is not supplied, then all the signs in {group} are
  8125. removed.
  8126. Returns 0 on success and -1 on failure.
  8127. Examples: >vim
  8128. " Remove sign 10 from buffer a.vim
  8129. call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
  8130. " Remove sign 20 in group 'g1' from buffer 3
  8131. call sign_unplace('g1', {'buffer' : 3, 'id' : 20})
  8132. " Remove all the signs in group 'g2' from buffer 10
  8133. call sign_unplace('g2', {'buffer' : 10})
  8134. " Remove sign 30 in group 'g3' from all the buffers
  8135. call sign_unplace('g3', {'id' : 30})
  8136. " Remove all the signs placed in buffer 5
  8137. call sign_unplace('*', {'buffer' : 5})
  8138. " Remove the signs in group 'g4' from all the buffers
  8139. call sign_unplace('g4')
  8140. " Remove sign 40 from all the buffers
  8141. call sign_unplace('*', {'id' : 40})
  8142. " Remove all the placed signs from all the buffers
  8143. call sign_unplace('*')
  8144. Parameters: ~
  8145. • {group} (`string`)
  8146. • {dict} (`vim.fn.sign_unplace.dict?`)
  8147. Return: ~
  8148. (`0|-1`)
  8149. sign_unplacelist({list}) *sign_unplacelist()*
  8150. Remove previously placed signs from one or more buffers. This
  8151. is similar to the |sign_unplace()| function.
  8152. The {list} argument specifies the List of signs to remove.
  8153. Each list item is a dict with the following sign attributes:
  8154. buffer buffer name or number. For the accepted
  8155. values, see |bufname()|. If not specified,
  8156. then the specified sign is removed from all
  8157. the buffers.
  8158. group sign group name. If not specified or set to an
  8159. empty string, then the global sign group is
  8160. used. If set to "*", then all the groups
  8161. including the global group are used.
  8162. id sign identifier. If not specified, then all
  8163. the signs in the specified group are removed.
  8164. Returns a List where an entry is set to 0 if the corresponding
  8165. sign was successfully removed or -1 on failure.
  8166. Example: >vim
  8167. " Remove sign with id 10 from buffer a.vim and sign
  8168. " with id 20 from buffer b.vim
  8169. call sign_unplacelist([
  8170. \ {'id' : 10, 'buffer' : "a.vim"},
  8171. \ {'id' : 20, 'buffer' : 'b.vim'},
  8172. \ ])
  8173. <
  8174. Parameters: ~
  8175. • {list} (`vim.fn.sign_unplacelist.list.item`)
  8176. Return: ~
  8177. (`(0|-1)[]`)
  8178. simplify({filename}) *simplify()*
  8179. Simplify the file name as much as possible without changing
  8180. the meaning. Shortcuts (on MS-Windows) or symbolic links (on
  8181. Unix) are not resolved. If the first path component in
  8182. {filename} designates the current directory, this will be
  8183. valid for the result as well. A trailing path separator is
  8184. not removed either. On Unix "//path" is unchanged, but
  8185. "///path" is simplified to "/path" (this follows the Posix
  8186. standard).
  8187. Example: >vim
  8188. simplify("./dir/.././/file/") == "./file/"
  8189. < Note: The combination "dir/.." is only removed if "dir" is
  8190. a searchable directory or does not exist. On Unix, it is also
  8191. removed when "dir" is a symbolic link within the same
  8192. directory. In order to resolve all the involved symbolic
  8193. links before simplifying the path name, use |resolve()|.
  8194. Parameters: ~
  8195. • {filename} (`string`)
  8196. Return: ~
  8197. (`string`)
  8198. sin({expr}) *sin()*
  8199. Return the sine of {expr}, measured in radians, as a |Float|.
  8200. {expr} must evaluate to a |Float| or a |Number|.
  8201. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8202. Examples: >vim
  8203. echo sin(100)
  8204. < -0.506366 >vim
  8205. echo sin(-4.01)
  8206. < 0.763301
  8207. Parameters: ~
  8208. • {expr} (`number`)
  8209. Return: ~
  8210. (`number`)
  8211. sinh({expr}) *sinh()*
  8212. Return the hyperbolic sine of {expr} as a |Float| in the range
  8213. [-inf, inf].
  8214. {expr} must evaluate to a |Float| or a |Number|.
  8215. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8216. Examples: >vim
  8217. echo sinh(0.5)
  8218. < 0.521095 >vim
  8219. echo sinh(-0.9)
  8220. < -1.026517
  8221. Parameters: ~
  8222. • {expr} (`number`)
  8223. Return: ~
  8224. (`any`)
  8225. slice({expr}, {start} [, {end}]) *slice()*
  8226. Similar to using a |slice| "expr[start : end]", but "end" is
  8227. used exclusive. And for a string the indexes are used as
  8228. character indexes instead of byte indexes.
  8229. Also, composing characters are treated as a part of the
  8230. preceding base character.
  8231. When {end} is omitted the slice continues to the last item.
  8232. When {end} is -1 the last item is omitted.
  8233. Returns an empty value if {start} or {end} are invalid.
  8234. Parameters: ~
  8235. • {expr} (`any`)
  8236. • {start} (`integer`)
  8237. • {end} (`integer?`)
  8238. Return: ~
  8239. (`any`)
  8240. sockconnect({mode}, {address} [, {opts}]) *sockconnect()*
  8241. Connect a socket to an address. If {mode} is "pipe" then
  8242. {address} should be the path of a local domain socket (on
  8243. unix) or named pipe (on Windows). If {mode} is "tcp" then
  8244. {address} should be of the form "host:port" where the host
  8245. should be an ip address or host name, and port the port
  8246. number.
  8247. For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see
  8248. |luv-tcp-handle|.
  8249. Returns a |channel| ID. Close the socket with |chanclose()|.
  8250. Use |chansend()| to send data over a bytes socket, and
  8251. |rpcrequest()| and |rpcnotify()| to communicate with a RPC
  8252. socket.
  8253. {opts} is an optional dictionary with these keys:
  8254. |on_data| : callback invoked when data was read from socket
  8255. data_buffered : read socket data in |channel-buffered| mode.
  8256. rpc : If set, |msgpack-rpc| will be used to communicate
  8257. over the socket.
  8258. Returns:
  8259. - The channel ID on success (greater than zero)
  8260. - 0 on invalid arguments or connection failure.
  8261. Parameters: ~
  8262. • {mode} (`string`)
  8263. • {address} (`string`)
  8264. • {opts} (`table?`)
  8265. Return: ~
  8266. (`any`)
  8267. sort({list} [, {how} [, {dict}]]) *sort()* *E702*
  8268. Sort the items in {list} in-place. Returns {list}.
  8269. If you want a list to remain unmodified make a copy first: >vim
  8270. let sortedlist = sort(copy(mylist))
  8271. < When {how} is omitted or is a string, then sort() uses the
  8272. string representation of each item to sort on. Numbers sort
  8273. after Strings, |Lists| after Numbers. For sorting text in the
  8274. current buffer use |:sort|.
  8275. When {how} is given and it is 'i' then case is ignored.
  8276. For backwards compatibility, the value one can be used to
  8277. ignore case. Zero means to not ignore case.
  8278. When {how} is given and it is 'l' then the current collation
  8279. locale is used for ordering. Implementation details: strcoll()
  8280. is used to compare strings. See |:language| check or set the
  8281. collation locale. |v:collate| can also be used to check the
  8282. current locale. Sorting using the locale typically ignores
  8283. case. Example: >vim
  8284. " ö is sorted similarly to o with English locale.
  8285. language collate en_US.UTF8
  8286. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8287. < ['n', 'o', 'O', 'ö', 'p', 'z'] ~
  8288. >vim
  8289. " ö is sorted after z with Swedish locale.
  8290. language collate sv_SE.UTF8
  8291. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8292. < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
  8293. This does not work properly on Mac.
  8294. When {how} is given and it is 'n' then all items will be
  8295. sorted numerical (Implementation detail: this uses the
  8296. strtod() function to parse numbers, Strings, Lists, Dicts and
  8297. Funcrefs will be considered as being 0).
  8298. When {how} is given and it is 'N' then all items will be
  8299. sorted numerical. This is like 'n' but a string containing
  8300. digits will be used as the number they represent.
  8301. When {how} is given and it is 'f' then all items will be
  8302. sorted numerical. All values must be a Number or a Float.
  8303. When {how} is a |Funcref| or a function name, this function
  8304. is called to compare items. The function is invoked with two
  8305. items as argument and must return zero if they are equal, 1 or
  8306. bigger if the first one sorts after the second one, -1 or
  8307. smaller if the first one sorts before the second one.
  8308. {dict} is for functions with the "dict" attribute. It will be
  8309. used to set the local variable "self". |Dictionary-function|
  8310. The sort is stable, items which compare equal (as number or as
  8311. string) will keep their relative position. E.g., when sorting
  8312. on numbers, text strings will sort next to each other, in the
  8313. same order as they were originally.
  8314. Example: >vim
  8315. func MyCompare(i1, i2)
  8316. return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
  8317. endfunc
  8318. eval mylist->sort("MyCompare")
  8319. < A shorter compare version for this specific simple case, which
  8320. ignores overflow: >vim
  8321. func MyCompare(i1, i2)
  8322. return a:i1 - a:i2
  8323. endfunc
  8324. < For a simple expression you can use a lambda: >vim
  8325. eval mylist->sort({i1, i2 -> i1 - i2})
  8326. <
  8327. Parameters: ~
  8328. • {list} (`T[]`)
  8329. • {how} (`string|function?`)
  8330. • {dict} (`any?`)
  8331. Return: ~
  8332. (`T[]`)
  8333. soundfold({word}) *soundfold()*
  8334. Return the sound-folded equivalent of {word}. Uses the first
  8335. language in 'spelllang' for the current window that supports
  8336. soundfolding. 'spell' must be set. When no sound folding is
  8337. possible the {word} is returned unmodified.
  8338. This can be used for making spelling suggestions. Note that
  8339. the method can be quite slow.
  8340. Parameters: ~
  8341. • {word} (`string`)
  8342. Return: ~
  8343. (`string`)
  8344. spellbadword([{sentence}]) *spellbadword()*
  8345. Without argument: The result is the badly spelled word under
  8346. or after the cursor. The cursor is moved to the start of the
  8347. bad word. When no bad word is found in the cursor line the
  8348. result is an empty string and the cursor doesn't move.
  8349. With argument: The result is the first word in {sentence} that
  8350. is badly spelled. If there are no spelling mistakes the
  8351. result is an empty string.
  8352. The return value is a list with two items:
  8353. - The badly spelled word or an empty string.
  8354. - The type of the spelling error:
  8355. "bad" spelling mistake
  8356. "rare" rare word
  8357. "local" word only valid in another region
  8358. "caps" word should start with Capital
  8359. Example: >vim
  8360. echo spellbadword("the quik brown fox")
  8361. < ['quik', 'bad'] ~
  8362. The spelling information for the current window and the value
  8363. of 'spelllang' are used.
  8364. Parameters: ~
  8365. • {sentence} (`string?`)
  8366. Return: ~
  8367. (`any`)
  8368. spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()*
  8369. Return a |List| with spelling suggestions to replace {word}.
  8370. When {max} is given up to this number of suggestions are
  8371. returned. Otherwise up to 25 suggestions are returned.
  8372. When the {capital} argument is given and it's non-zero only
  8373. suggestions with a leading capital will be given. Use this
  8374. after a match with 'spellcapcheck'.
  8375. {word} can be a badly spelled word followed by other text.
  8376. This allows for joining two words that were split. The
  8377. suggestions also include the following text, thus you can
  8378. replace a line.
  8379. {word} may also be a good word. Similar words will then be
  8380. returned. {word} itself is not included in the suggestions,
  8381. although it may appear capitalized.
  8382. The spelling information for the current window is used. The
  8383. values of 'spelllang' and 'spellsuggest' are used.
  8384. Parameters: ~
  8385. • {word} (`string`)
  8386. • {max} (`integer?`)
  8387. • {capital} (`boolean?`)
  8388. Return: ~
  8389. (`string[]`)
  8390. split({string} [, {pattern} [, {keepempty}]]) *split()*
  8391. Make a |List| out of {string}. When {pattern} is omitted or
  8392. empty each white space separated sequence of characters
  8393. becomes an item.
  8394. Otherwise the string is split where {pattern} matches,
  8395. removing the matched characters. 'ignorecase' is not used
  8396. here, add \c to ignore case. |/\c|
  8397. When the first or last item is empty it is omitted, unless the
  8398. {keepempty} argument is given and it's non-zero.
  8399. Other empty items are kept when {pattern} matches at least one
  8400. character or when {keepempty} is non-zero.
  8401. Example: >vim
  8402. let words = split(getline('.'), '\W\+')
  8403. < To split a string in individual characters: >vim
  8404. for c in split(mystring, '\zs') | endfor
  8405. < If you want to keep the separator you can also use '\zs' at
  8406. the end of the pattern: >vim
  8407. echo split('abc:def:ghi', ':\zs')
  8408. < >
  8409. ['abc:', 'def:', 'ghi']
  8410. <
  8411. Splitting a table where the first element can be empty: >vim
  8412. let items = split(line, ':', 1)
  8413. < The opposite function is |join()|.
  8414. Parameters: ~
  8415. • {string} (`string`)
  8416. • {pattern} (`string?`)
  8417. • {keepempty} (`boolean?`)
  8418. Return: ~
  8419. (`string[]`)
  8420. sqrt({expr}) *sqrt()*
  8421. Return the non-negative square root of Float {expr} as a
  8422. |Float|.
  8423. {expr} must evaluate to a |Float| or a |Number|. When {expr}
  8424. is negative the result is NaN (Not a Number). Returns 0.0 if
  8425. {expr} is not a |Float| or a |Number|.
  8426. Examples: >vim
  8427. echo sqrt(100)
  8428. < 10.0 >vim
  8429. echo sqrt(-4.01)
  8430. < str2float("nan")
  8431. NaN may be different, it depends on system libraries.
  8432. Parameters: ~
  8433. • {expr} (`number`)
  8434. Return: ~
  8435. (`any`)
  8436. srand([{expr}]) *srand()*
  8437. Initialize seed used by |rand()|:
  8438. - If {expr} is not given, seed values are initialized by
  8439. reading from /dev/urandom, if possible, or using time(NULL)
  8440. a.k.a. epoch time otherwise; this only has second accuracy.
  8441. - If {expr} is given it must be a Number. It is used to
  8442. initialize the seed values. This is useful for testing or
  8443. when a predictable sequence is intended.
  8444. Examples: >vim
  8445. let seed = srand()
  8446. let seed = srand(userinput)
  8447. echo rand(seed)
  8448. <
  8449. Parameters: ~
  8450. • {expr} (`number?`)
  8451. Return: ~
  8452. (`any`)
  8453. state([{what}]) *state()*
  8454. Return a string which contains characters indicating the
  8455. current state. Mostly useful in callbacks that want to do
  8456. work that may not always be safe. Roughly this works like:
  8457. - callback uses state() to check if work is safe to do.
  8458. Yes: then do it right away.
  8459. No: add to work queue and add a |SafeState| autocommand.
  8460. - When SafeState is triggered and executes your autocommand,
  8461. check with `state()` if the work can be done now, and if yes
  8462. remove it from the queue and execute.
  8463. Remove the autocommand if the queue is now empty.
  8464. Also see |mode()|.
  8465. When {what} is given only characters in this string will be
  8466. added. E.g, this checks if the screen has scrolled: >vim
  8467. if state('s') == ''
  8468. " screen has not scrolled
  8469. <
  8470. These characters indicate the state, generally indicating that
  8471. something is busy:
  8472. m halfway a mapping, :normal command, feedkeys() or
  8473. stuffed command
  8474. o operator pending, e.g. after |d|
  8475. a Insert mode autocomplete active
  8476. x executing an autocommand
  8477. S not triggering SafeState, e.g. after |f| or a count
  8478. c callback invoked, including timer (repeats for
  8479. recursiveness up to "ccc")
  8480. s screen has scrolled for messages
  8481. Parameters: ~
  8482. • {what} (`string?`)
  8483. Return: ~
  8484. (`any`)
  8485. stdioopen({opts}) *stdioopen()*
  8486. With |--headless| this opens stdin and stdout as a |channel|.
  8487. May be called only once. See |channel-stdio|. stderr is not
  8488. handled by this function, see |v:stderr|.
  8489. Close the stdio handles with |chanclose()|. Use |chansend()|
  8490. to send data to stdout, and |rpcrequest()| and |rpcnotify()|
  8491. to communicate over RPC.
  8492. {opts} is a dictionary with these keys:
  8493. |on_stdin| : callback invoked when stdin is written to.
  8494. on_print : callback invoked when Nvim needs to print a
  8495. message, with the message (whose type is string)
  8496. as sole argument.
  8497. stdin_buffered : read stdin in |channel-buffered| mode.
  8498. rpc : If set, |msgpack-rpc| will be used to communicate
  8499. over stdio
  8500. Returns:
  8501. - |channel-id| on success (value is always 1)
  8502. - 0 on invalid arguments
  8503. Parameters: ~
  8504. • {opts} (`table`)
  8505. Return: ~
  8506. (`any`)
  8507. stdpath({what}) *stdpath()* *E6100*
  8508. Returns |standard-path| locations of various default files and
  8509. directories.
  8510. {what} Type Description ~
  8511. cache String Cache directory: arbitrary temporary
  8512. storage for plugins, etc.
  8513. config String User configuration directory. |init.vim|
  8514. is stored here.
  8515. config_dirs List Other configuration directories.
  8516. data String User data directory.
  8517. data_dirs List Other data directories.
  8518. log String Logs directory (for use by plugins too).
  8519. run String Run directory: temporary, local storage
  8520. for sockets, named pipes, etc.
  8521. state String Session state directory: storage for file
  8522. drafts, swap, undo, |shada|.
  8523. Example: >vim
  8524. echo stdpath("config")
  8525. <
  8526. Parameters: ~
  8527. • {what}
  8528. (`'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'`)
  8529. Return: ~
  8530. (`string|string[]`)
  8531. str2float({string} [, {quoted}]) *str2float()*
  8532. Convert String {string} to a Float. This mostly works the
  8533. same as when using a floating point number in an expression,
  8534. see |floating-point-format|. But it's a bit more permissive.
  8535. E.g., "1e40" is accepted, while in an expression you need to
  8536. write "1.0e40". The hexadecimal form "0x123" is also
  8537. accepted, but not others, like binary or octal.
  8538. When {quoted} is present and non-zero then embedded single
  8539. quotes before the dot are ignored, thus "1'000.0" is a
  8540. thousand.
  8541. Text after the number is silently ignored.
  8542. The decimal point is always '.', no matter what the locale is
  8543. set to. A comma ends the number: "12,345.67" is converted to
  8544. 12.0. You can strip out thousands separators with
  8545. |substitute()|: >vim
  8546. let f = str2float(substitute(text, ',', '', 'g'))
  8547. <
  8548. Returns 0.0 if the conversion fails.
  8549. Parameters: ~
  8550. • {string} (`string`)
  8551. • {quoted} (`boolean?`)
  8552. Return: ~
  8553. (`any`)
  8554. str2list({string} [, {utf8}]) *str2list()*
  8555. Return a list containing the number values which represent
  8556. each character in String {string}. Examples: >vim
  8557. echo str2list(" ") " returns [32]
  8558. echo str2list("ABC") " returns [65, 66, 67]
  8559. < |list2str()| does the opposite.
  8560. UTF-8 encoding is always used, {utf8} option has no effect,
  8561. and exists only for backwards-compatibility.
  8562. With UTF-8 composing characters are handled properly: >vim
  8563. echo str2list("á") " returns [97, 769]
  8564. <
  8565. Parameters: ~
  8566. • {string} (`string`)
  8567. • {utf8} (`boolean?`)
  8568. Return: ~
  8569. (`any`)
  8570. str2nr({string} [, {base}]) *str2nr()*
  8571. Convert string {string} to a number.
  8572. {base} is the conversion base, it can be 2, 8, 10 or 16.
  8573. When {quoted} is present and non-zero then embedded single
  8574. quotes are ignored, thus "1'000'000" is a million.
  8575. When {base} is omitted base 10 is used. This also means that
  8576. a leading zero doesn't cause octal conversion to be used, as
  8577. with the default String to Number conversion. Example: >vim
  8578. let nr = str2nr('0123')
  8579. <
  8580. When {base} is 16 a leading "0x" or "0X" is ignored. With a
  8581. different base the result will be zero. Similarly, when
  8582. {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
  8583. {base} is 2 a leading "0b" or "0B" is ignored.
  8584. Text after the number is silently ignored.
  8585. Returns 0 if {string} is empty or on error.
  8586. Parameters: ~
  8587. • {string} (`string`)
  8588. • {base} (`integer?`)
  8589. Return: ~
  8590. (`any`)
  8591. strcharlen({string}) *strcharlen()*
  8592. The result is a Number, which is the number of characters
  8593. in String {string}. Composing characters are ignored.
  8594. |strchars()| can count the number of characters, counting
  8595. composing characters separately.
  8596. Returns 0 if {string} is empty or on error.
  8597. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8598. Parameters: ~
  8599. • {string} (`string`)
  8600. Return: ~
  8601. (`any`)
  8602. strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
  8603. Like |strpart()| but using character index and length instead
  8604. of byte index and length.
  8605. When {skipcc} is omitted or zero, composing characters are
  8606. counted separately.
  8607. When {skipcc} set to 1, composing characters are treated as a
  8608. part of the preceding base character, similar to |slice()|.
  8609. When a character index is used where a character does not
  8610. exist it is omitted and counted as one character. For
  8611. example: >vim
  8612. echo strcharpart('abc', -1, 2)
  8613. < results in 'a'.
  8614. Returns an empty string on error.
  8615. Parameters: ~
  8616. • {src} (`string`)
  8617. • {start} (`integer`)
  8618. • {len} (`integer?`)
  8619. • {skipcc} (`boolean?`)
  8620. Return: ~
  8621. (`any`)
  8622. strchars({string} [, {skipcc}]) *strchars()*
  8623. The result is a Number, which is the number of characters
  8624. in String {string}.
  8625. When {skipcc} is omitted or zero, composing characters are
  8626. counted separately.
  8627. When {skipcc} set to 1, composing characters are ignored.
  8628. |strcharlen()| always does this.
  8629. Returns zero on error.
  8630. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8631. {skipcc} is only available after 7.4.755. For backward
  8632. compatibility, you can define a wrapper function: >vim
  8633. if has("patch-7.4.755")
  8634. function s:strchars(str, skipcc)
  8635. return strchars(a:str, a:skipcc)
  8636. endfunction
  8637. else
  8638. function s:strchars(str, skipcc)
  8639. if a:skipcc
  8640. return strlen(substitute(a:str, ".", "x", "g"))
  8641. else
  8642. return strchars(a:str)
  8643. endif
  8644. endfunction
  8645. endif
  8646. <
  8647. Parameters: ~
  8648. • {string} (`string`)
  8649. • {skipcc} (`boolean?`)
  8650. Return: ~
  8651. (`integer`)
  8652. strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
  8653. The result is a Number, which is the number of display cells
  8654. String {string} occupies on the screen when it starts at {col}
  8655. (first column is zero). When {col} is omitted zero is used.
  8656. Otherwise it is the screen column where to start. This
  8657. matters for Tab characters.
  8658. The option settings of the current window are used. This
  8659. matters for anything that's displayed differently, such as
  8660. 'tabstop' and 'display'.
  8661. When {string} contains characters with East Asian Width Class
  8662. Ambiguous, this function's return value depends on 'ambiwidth'.
  8663. Returns zero on error.
  8664. Also see |strlen()|, |strwidth()| and |strchars()|.
  8665. Parameters: ~
  8666. • {string} (`string`)
  8667. • {col} (`integer?`)
  8668. Return: ~
  8669. (`integer`)
  8670. strftime({format} [, {time}]) *strftime()*
  8671. The result is a String, which is a formatted date and time, as
  8672. specified by the {format} string. The given {time} is used,
  8673. or the current time if no time is given. The accepted
  8674. {format} depends on your system, thus this is not portable!
  8675. See the manual page of the C function strftime() for the
  8676. format. The maximum length of the result is 80 characters.
  8677. See also |localtime()|, |getftime()| and |strptime()|.
  8678. The language can be changed with the |:language| command.
  8679. Examples: >vim
  8680. echo strftime("%c") " Sun Apr 27 11:49:23 1997
  8681. echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
  8682. echo strftime("%y%m%d %T") " 970427 11:53:55
  8683. echo strftime("%H:%M") " 11:55
  8684. echo strftime("%c", getftime("file.c"))
  8685. " Show mod time of file.c.
  8686. Parameters: ~
  8687. • {format} (`string`)
  8688. • {time} (`number?`)
  8689. Return: ~
  8690. (`string`)
  8691. strgetchar({str}, {index}) *strgetchar()*
  8692. Get a Number corresponding to the character at {index} in
  8693. {str}. This uses a zero-based character index, not a byte
  8694. index. Composing characters are considered separate
  8695. characters here. Use |nr2char()| to convert the Number to a
  8696. String.
  8697. Returns -1 if {index} is invalid.
  8698. Also see |strcharpart()| and |strchars()|.
  8699. Parameters: ~
  8700. • {str} (`string`)
  8701. • {index} (`integer`)
  8702. Return: ~
  8703. (`integer`)
  8704. stridx({haystack}, {needle} [, {start}]) *stridx()*
  8705. The result is a Number, which gives the byte index in
  8706. {haystack} of the first occurrence of the String {needle}.
  8707. If {start} is specified, the search starts at index {start}.
  8708. This can be used to find a second match: >vim
  8709. let colon1 = stridx(line, ":")
  8710. let colon2 = stridx(line, ":", colon1 + 1)
  8711. < The search is done case-sensitive.
  8712. For pattern searches use |match()|.
  8713. -1 is returned if the {needle} does not occur in {haystack}.
  8714. See also |strridx()|.
  8715. Examples: >vim
  8716. echo stridx("An Example", "Example") " 3
  8717. echo stridx("Starting point", "Start") " 0
  8718. echo stridx("Starting point", "start") " -1
  8719. < *strstr()* *strchr()*
  8720. stridx() works similar to the C function strstr(). When used
  8721. with a single character it works similar to strchr().
  8722. Parameters: ~
  8723. • {haystack} (`string`)
  8724. • {needle} (`string`)
  8725. • {start} (`integer?`)
  8726. Return: ~
  8727. (`integer`)
  8728. string({expr}) *string()*
  8729. Return {expr} converted to a String. If {expr} is a Number,
  8730. Float, String, Blob or a composition of them, then the result
  8731. can be parsed back with |eval()|.
  8732. {expr} type result ~
  8733. String 'string'
  8734. Number 123
  8735. Float 123.123456 or 1.123456e8 or
  8736. `str2float('inf')`
  8737. Funcref `function('name')`
  8738. Blob 0z00112233.44556677.8899
  8739. List [item, item]
  8740. Dictionary `{key: value, key: value}`
  8741. Note that in String values the ' character is doubled.
  8742. Also see |strtrans()|.
  8743. Note 2: Output format is mostly compatible with YAML, except
  8744. for infinite and NaN floating-point values representations
  8745. which use |str2float()|. Strings are also dumped literally,
  8746. only single quote is escaped, which does not allow using YAML
  8747. for parsing back binary strings. |eval()| should always work
  8748. for strings and floats though, and this is the only official
  8749. method. Use |msgpackdump()| or |json_encode()| if you need to
  8750. share data with other applications.
  8751. Parameters: ~
  8752. • {expr} (`any`)
  8753. Return: ~
  8754. (`string`)
  8755. strlen({string}) *strlen()*
  8756. The result is a Number, which is the length of the String
  8757. {string} in bytes.
  8758. If the argument is a Number it is first converted to a String.
  8759. For other types an error is given and zero is returned.
  8760. If you want to count the number of multibyte characters use
  8761. |strchars()|.
  8762. Also see |len()|, |strdisplaywidth()| and |strwidth()|.
  8763. Parameters: ~
  8764. • {string} (`string`)
  8765. Return: ~
  8766. (`integer`)
  8767. strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
  8768. The result is a String, which is part of {src}, starting from
  8769. byte {start}, with the byte length {len}.
  8770. When {chars} is present and TRUE then {len} is the number of
  8771. characters positions (composing characters are not counted
  8772. separately, thus "1" means one base character and any
  8773. following composing characters).
  8774. To count {start} as characters instead of bytes use
  8775. |strcharpart()|.
  8776. When bytes are selected which do not exist, this doesn't
  8777. result in an error, the bytes are simply omitted.
  8778. If {len} is missing, the copy continues from {start} till the
  8779. end of the {src}. >vim
  8780. echo strpart("abcdefg", 3, 2) " returns 'de'
  8781. echo strpart("abcdefg", -2, 4) " returns 'ab'
  8782. echo strpart("abcdefg", 5, 4) " returns 'fg'
  8783. echo strpart("abcdefg", 3) " returns 'defg'
  8784. < Note: To get the first character, {start} must be 0. For
  8785. example, to get the character under the cursor: >vim
  8786. strpart(getline("."), col(".") - 1, 1, v:true)
  8787. <
  8788. Returns an empty string on error.
  8789. Parameters: ~
  8790. • {src} (`string`)
  8791. • {start} (`integer`)
  8792. • {len} (`integer?`)
  8793. • {chars} (`0|1?`)
  8794. Return: ~
  8795. (`string`)
  8796. strptime({format}, {timestring}) *strptime()*
  8797. The result is a Number, which is a unix timestamp representing
  8798. the date and time in {timestring}, which is expected to match
  8799. the format specified in {format}.
  8800. The accepted {format} depends on your system, thus this is not
  8801. portable! See the manual page of the C function strptime()
  8802. for the format. Especially avoid "%c". The value of $TZ also
  8803. matters.
  8804. If the {timestring} cannot be parsed with {format} zero is
  8805. returned. If you do not know the format of {timestring} you
  8806. can try different {format} values until you get a non-zero
  8807. result.
  8808. See also |strftime()|.
  8809. Examples: >vim
  8810. echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
  8811. < 862156163 >vim
  8812. echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
  8813. < Sun Apr 27 11:53:55 1997 >vim
  8814. echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
  8815. < Sun Apr 27 12:53:55 1997
  8816. Parameters: ~
  8817. • {format} (`string`)
  8818. • {timestring} (`string`)
  8819. Return: ~
  8820. (`integer`)
  8821. strridx({haystack}, {needle} [, {start}]) *strridx()*
  8822. The result is a Number, which gives the byte index in
  8823. {haystack} of the last occurrence of the String {needle}.
  8824. When {start} is specified, matches beyond this index are
  8825. ignored. This can be used to find a match before a previous
  8826. match: >vim
  8827. let lastcomma = strridx(line, ",")
  8828. let comma2 = strridx(line, ",", lastcomma - 1)
  8829. < The search is done case-sensitive.
  8830. For pattern searches use |match()|.
  8831. -1 is returned if the {needle} does not occur in {haystack}.
  8832. If the {needle} is empty the length of {haystack} is returned.
  8833. See also |stridx()|. Examples: >vim
  8834. echo strridx("an angry armadillo", "an") 3
  8835. < *strrchr()*
  8836. When used with a single character it works similar to the C
  8837. function strrchr().
  8838. Parameters: ~
  8839. • {haystack} (`string`)
  8840. • {needle} (`string`)
  8841. • {start} (`integer?`)
  8842. Return: ~
  8843. (`integer`)
  8844. strtrans({string}) *strtrans()*
  8845. The result is a String, which is {string} with all unprintable
  8846. characters translated into printable characters |'isprint'|.
  8847. Like they are shown in a window. Example: >vim
  8848. echo strtrans(@a)
  8849. < This displays a newline in register a as "^@" instead of
  8850. starting a new line.
  8851. Returns an empty string on error.
  8852. Parameters: ~
  8853. • {string} (`string`)
  8854. Return: ~
  8855. (`string`)
  8856. strutf16len({string} [, {countcc}]) *strutf16len()*
  8857. The result is a Number, which is the number of UTF-16 code
  8858. units in String {string} (after converting it to UTF-16).
  8859. When {countcc} is TRUE, composing characters are counted
  8860. separately.
  8861. When {countcc} is omitted or FALSE, composing characters are
  8862. ignored.
  8863. Returns zero on error.
  8864. Also see |strlen()| and |strcharlen()|.
  8865. Examples: >vim
  8866. echo strutf16len('a') " returns 1
  8867. echo strutf16len('©') " returns 1
  8868. echo strutf16len('😊') " returns 2
  8869. echo strutf16len('ą́') " returns 1
  8870. echo strutf16len('ą́', v:true) " returns 3
  8871. <
  8872. Parameters: ~
  8873. • {string} (`string`)
  8874. • {countcc} (`0|1?`)
  8875. Return: ~
  8876. (`integer`)
  8877. strwidth({string}) *strwidth()*
  8878. The result is a Number, which is the number of display cells
  8879. String {string} occupies. A Tab character is counted as one
  8880. cell, alternatively use |strdisplaywidth()|.
  8881. When {string} contains characters with East Asian Width Class
  8882. Ambiguous, this function's return value depends on 'ambiwidth'.
  8883. Returns zero on error.
  8884. Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
  8885. Parameters: ~
  8886. • {string} (`string`)
  8887. Return: ~
  8888. (`integer`)
  8889. submatch({nr} [, {list}]) *submatch()* *E935*
  8890. Only for an expression in a |:substitute| command or
  8891. substitute() function.
  8892. Returns the {nr}th submatch of the matched text. When {nr}
  8893. is 0 the whole matched text is returned.
  8894. Note that a NL in the string can stand for a line break of a
  8895. multi-line match or a NUL character in the text.
  8896. Also see |sub-replace-expression|.
  8897. If {list} is present and non-zero then submatch() returns
  8898. a list of strings, similar to |getline()| with two arguments.
  8899. NL characters in the text represent NUL characters in the
  8900. text.
  8901. Only returns more than one item for |:substitute|, inside
  8902. |substitute()| this list will always contain one or zero
  8903. items, since there are no real line breaks.
  8904. When substitute() is used recursively only the submatches in
  8905. the current (deepest) call can be obtained.
  8906. Returns an empty string or list on error.
  8907. Examples: >vim
  8908. s/\d\+/\=submatch(0) + 1/
  8909. echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
  8910. < This finds the first number in the line and adds one to it.
  8911. A line break is included as a newline character.
  8912. Parameters: ~
  8913. • {nr} (`integer`)
  8914. • {list} (`nil?`)
  8915. Return: ~
  8916. (`string`)
  8917. substitute({string}, {pat}, {sub}, {flags}) *substitute()*
  8918. The result is a String, which is a copy of {string}, in which
  8919. the first match of {pat} is replaced with {sub}.
  8920. When {flags} is "g", all matches of {pat} in {string} are
  8921. replaced. Otherwise {flags} should be "".
  8922. This works like the ":substitute" command (without any flags).
  8923. But the matching with {pat} is always done like the 'magic'
  8924. option is set and 'cpoptions' is empty (to make scripts
  8925. portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
  8926. if you want to ignore or match case and ignore 'ignorecase'.
  8927. 'smartcase' is not used. See |string-match| for how {pat} is
  8928. used.
  8929. A "~" in {sub} is not replaced with the previous {sub}.
  8930. Note that some codes in {sub} have a special meaning
  8931. |sub-replace-special|. For example, to replace something with
  8932. "\n" (two characters), use "\\\\n" or '\\n'.
  8933. When {pat} does not match in {string}, {string} is returned
  8934. unmodified.
  8935. Example: >vim
  8936. let &path = substitute(&path, ",\\=[^,]*$", "", "")
  8937. < This removes the last component of the 'path' option. >vim
  8938. echo substitute("testing", ".*", "\\U\\0", "")
  8939. < results in "TESTING".
  8940. When {sub} starts with "\=", the remainder is interpreted as
  8941. an expression. See |sub-replace-expression|. Example: >vim
  8942. echo substitute(s, '%\(\x\x\)',
  8943. \ '\=nr2char("0x" .. submatch(1))', 'g')
  8944. < When {sub} is a Funcref that function is called, with one
  8945. optional argument. Example: >vim
  8946. echo substitute(s, '%\(\x\x\)', SubNr, 'g')
  8947. < The optional argument is a list which contains the whole
  8948. matched string and up to nine submatches, like what
  8949. |submatch()| returns. Example: >vim
  8950. echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
  8951. < Returns an empty string on error.
  8952. Parameters: ~
  8953. • {string} (`string`)
  8954. • {pat} (`string`)
  8955. • {sub} (`string`)
  8956. • {flags} (`string`)
  8957. Return: ~
  8958. (`string`)
  8959. swapfilelist() *swapfilelist()*
  8960. Returns a list of swap file names, like what "vim -r" shows.
  8961. See the |-r| command argument. The 'directory' option is used
  8962. for the directories to inspect. If you only want to get a
  8963. list of swap files in the current directory then temporarily
  8964. set 'directory' to a dot: >vim
  8965. let save_dir = &directory
  8966. let &directory = '.'
  8967. let swapfiles = swapfilelist()
  8968. let &directory = save_dir
  8969. Return: ~
  8970. (`string[]`)
  8971. swapinfo({fname}) *swapinfo()*
  8972. The result is a dictionary, which holds information about the
  8973. swapfile {fname}. The available fields are:
  8974. version Vim version
  8975. user user name
  8976. host host name
  8977. fname original file name
  8978. pid PID of the Nvim process that created the swap
  8979. file, or zero if not running.
  8980. mtime last modification time in seconds
  8981. inode Optional: INODE number of the file
  8982. dirty 1 if file was modified, 0 if not
  8983. In case of failure an "error" item is added with the reason:
  8984. Cannot open file: file not found or in accessible
  8985. Cannot read file: cannot read first block
  8986. Not a swap file: does not contain correct block ID
  8987. Magic number mismatch: Info in first block is invalid
  8988. Parameters: ~
  8989. • {fname} (`string`)
  8990. Return: ~
  8991. (`any`)
  8992. swapname({buf}) *swapname()*
  8993. The result is the swap file path of the buffer {buf}.
  8994. For the use of {buf}, see |bufname()| above.
  8995. If buffer {buf} is the current buffer, the result is equal to
  8996. |:swapname| (unless there is no swap file).
  8997. If buffer {buf} has no swap file, returns an empty string.
  8998. Parameters: ~
  8999. • {buf} (`integer|string`)
  9000. Return: ~
  9001. (`string`)
  9002. synID({lnum}, {col}, {trans}) *synID()*
  9003. The result is a Number, which is the syntax ID at the position
  9004. {lnum} and {col} in the current window.
  9005. The syntax ID can be used with |synIDattr()| and
  9006. |synIDtrans()| to obtain syntax information about text.
  9007. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  9008. line. 'synmaxcol' applies, in a longer line zero is returned.
  9009. Note that when the position is after the last character,
  9010. that's where the cursor can be in Insert mode, synID() returns
  9011. zero. {lnum} is used like with |getline()|.
  9012. When {trans} is |TRUE|, transparent items are reduced to the
  9013. item that they reveal. This is useful when wanting to know
  9014. the effective color. When {trans} is |FALSE|, the transparent
  9015. item is returned. This is useful when wanting to know which
  9016. syntax item is effective (e.g. inside parens).
  9017. Warning: This function can be very slow. Best speed is
  9018. obtained by going through the file in forward direction.
  9019. Returns zero on error.
  9020. Example (echoes the name of the syntax item under the cursor): >vim
  9021. echo synIDattr(synID(line("."), col("."), 1), "name")
  9022. <
  9023. Parameters: ~
  9024. • {lnum} (`integer`)
  9025. • {col} (`integer`)
  9026. • {trans} (`0|1`)
  9027. Return: ~
  9028. (`integer`)
  9029. synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
  9030. The result is a String, which is the {what} attribute of
  9031. syntax ID {synID}. This can be used to obtain information
  9032. about a syntax item.
  9033. {mode} can be "gui" or "cterm", to get the attributes
  9034. for that mode. When {mode} is omitted, or an invalid value is
  9035. used, the attributes for the currently active highlighting are
  9036. used (GUI or cterm).
  9037. Use synIDtrans() to follow linked highlight groups.
  9038. {what} result
  9039. "name" the name of the syntax item
  9040. "fg" foreground color (GUI: color name used to set
  9041. the color, cterm: color number as a string,
  9042. term: empty string)
  9043. "bg" background color (as with "fg")
  9044. "font" font name (only available in the GUI)
  9045. |highlight-font|
  9046. "sp" special color (as with "fg") |guisp|
  9047. "fg#" like "fg", but for the GUI and the GUI is
  9048. running the name in "#RRGGBB" form
  9049. "bg#" like "fg#" for "bg"
  9050. "sp#" like "fg#" for "sp"
  9051. "bold" "1" if bold
  9052. "italic" "1" if italic
  9053. "reverse" "1" if reverse
  9054. "inverse" "1" if inverse (= reverse)
  9055. "standout" "1" if standout
  9056. "underline" "1" if underlined
  9057. "undercurl" "1" if undercurled
  9058. "underdouble" "1" if double underlined
  9059. "underdotted" "1" if dotted underlined
  9060. "underdashed" "1" if dashed underlined
  9061. "strikethrough" "1" if struckthrough
  9062. "altfont" "1" if alternative font
  9063. "nocombine" "1" if nocombine
  9064. Returns an empty string on error.
  9065. Example (echoes the color of the syntax item under the
  9066. cursor): >vim
  9067. echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  9068. <
  9069. Can also be used as a |method|: >vim
  9070. echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  9071. <
  9072. Parameters: ~
  9073. • {synID} (`integer`)
  9074. • {what} (`string`)
  9075. • {mode} (`string?`)
  9076. Return: ~
  9077. (`string`)
  9078. synIDtrans({synID}) *synIDtrans()*
  9079. The result is a Number, which is the translated syntax ID of
  9080. {synID}. This is the syntax group ID of what is being used to
  9081. highlight the character. Highlight links given with
  9082. ":highlight link" are followed.
  9083. Returns zero on error.
  9084. Parameters: ~
  9085. • {synID} (`integer`)
  9086. Return: ~
  9087. (`integer`)
  9088. synconcealed({lnum}, {col}) *synconcealed()*
  9089. The result is a |List| with currently three items:
  9090. 1. The first item in the list is 0 if the character at the
  9091. position {lnum} and {col} is not part of a concealable
  9092. region, 1 if it is. {lnum} is used like with |getline()|.
  9093. 2. The second item in the list is a string. If the first item
  9094. is 1, the second item contains the text which will be
  9095. displayed in place of the concealed text, depending on the
  9096. current setting of 'conceallevel' and 'listchars'.
  9097. 3. The third and final item in the list is a number
  9098. representing the specific syntax region matched in the
  9099. line. When the character is not concealed the value is
  9100. zero. This allows detection of the beginning of a new
  9101. concealable region if there are two consecutive regions
  9102. with the same replacement character. For an example, if
  9103. the text is "123456" and both "23" and "45" are concealed
  9104. and replaced by the character "X", then:
  9105. call returns ~
  9106. synconcealed(lnum, 1) [0, '', 0]
  9107. synconcealed(lnum, 2) [1, 'X', 1]
  9108. synconcealed(lnum, 3) [1, 'X', 1]
  9109. synconcealed(lnum, 4) [1, 'X', 2]
  9110. synconcealed(lnum, 5) [1, 'X', 2]
  9111. synconcealed(lnum, 6) [0, '', 0]
  9112. Note: Doesn't consider |matchadd()| highlighting items,
  9113. since syntax and matching highlighting are two different
  9114. mechanisms |syntax-vs-match|.
  9115. Parameters: ~
  9116. • {lnum} (`integer`)
  9117. • {col} (`integer`)
  9118. Return: ~
  9119. (`[integer, string, integer]`)
  9120. synstack({lnum}, {col}) *synstack()*
  9121. Return a |List|, which is the stack of syntax items at the
  9122. position {lnum} and {col} in the current window. {lnum} is
  9123. used like with |getline()|. Each item in the List is an ID
  9124. like what |synID()| returns.
  9125. The first item in the List is the outer region, following are
  9126. items contained in that one. The last one is what |synID()|
  9127. returns, unless not the whole item is highlighted or it is a
  9128. transparent item.
  9129. This function is useful for debugging a syntax file.
  9130. Example that shows the syntax stack under the cursor: >vim
  9131. for id in synstack(line("."), col("."))
  9132. echo synIDattr(id, "name")
  9133. endfor
  9134. < When the position specified with {lnum} and {col} is invalid
  9135. an empty list is returned. The position just after the last
  9136. character in a line and the first column in an empty line are
  9137. valid positions.
  9138. Parameters: ~
  9139. • {lnum} (`integer`)
  9140. • {col} (`integer`)
  9141. Return: ~
  9142. (`integer[]`)
  9143. system({cmd} [, {input}]) *system()* *E677*
  9144. Note: Prefer |vim.system()| in Lua.
  9145. Gets the output of {cmd} as a |string| (|systemlist()| returns
  9146. a |List|) and sets |v:shell_error| to the error code.
  9147. {cmd} is treated as in |jobstart()|:
  9148. If {cmd} is a List it runs directly (no 'shell').
  9149. If {cmd} is a String it runs in the 'shell', like this: >vim
  9150. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  9151. < Not to be used for interactive commands.
  9152. Result is a String, filtered to avoid platform-specific quirks:
  9153. - <CR><NL> is replaced with <NL>
  9154. - NUL characters are replaced with SOH (0x01)
  9155. Example: >vim
  9156. echo system(['ls', expand('%:h')])
  9157. < If {input} is a string it is written to a pipe and passed as
  9158. stdin to the command. The string is written as-is, line
  9159. separators are not changed.
  9160. If {input} is a |List| it is written to the pipe as
  9161. |writefile()| does with {binary} set to "b" (i.e. with
  9162. a newline between each list item, and newlines inside list
  9163. items converted to NULs).
  9164. When {input} is given and is a valid buffer id, the content of
  9165. the buffer is written to the file line by line, each line
  9166. terminated by NL (and NUL where the text has NL).
  9167. *E5677*
  9168. Note: system() cannot write to or read from backgrounded ("&")
  9169. shell commands, e.g.: >vim
  9170. echo system("cat - &", "foo")
  9171. < which is equivalent to: >
  9172. $ echo foo | bash -c 'cat - &'
  9173. < The pipes are disconnected (unless overridden by shell
  9174. redirection syntax) before input can reach it. Use
  9175. |jobstart()| instead.
  9176. Note: Use |shellescape()| or |::S| with |expand()| or
  9177. |fnamemodify()| to escape special characters in a command
  9178. argument. 'shellquote' and 'shellxquote' must be properly
  9179. configured. Example: >vim
  9180. echo system('ls '..shellescape(expand('%:h')))
  9181. echo system('ls '..expand('%:h:S'))
  9182. < Unlike ":!cmd" there is no automatic check for changed files.
  9183. Use |:checktime| to force a check.
  9184. Parameters: ~
  9185. • {cmd} (`string|string[]`)
  9186. • {input} (`string|string[]|integer?`)
  9187. Return: ~
  9188. (`string`)
  9189. systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
  9190. Same as |system()|, but returns a |List| with lines (parts of
  9191. output separated by NL) with NULs transformed into NLs. Output
  9192. is the same as |readfile()| will output with {binary} argument
  9193. set to "b", except that a final newline is not preserved,
  9194. unless {keepempty} is non-zero.
  9195. Note that on MS-Windows you may get trailing CR characters.
  9196. To see the difference between "echo hello" and "echo -n hello"
  9197. use |system()| and |split()|: >vim
  9198. echo split(system('echo hello'), '\n', 1)
  9199. <
  9200. Returns an empty string on error.
  9201. Parameters: ~
  9202. • {cmd} (`string|string[]`)
  9203. • {input} (`string|string[]|integer?`)
  9204. • {keepempty} (`integer?`)
  9205. Return: ~
  9206. (`string[]`)
  9207. tabpagebuflist([{arg}]) *tabpagebuflist()*
  9208. The result is a |List|, where each item is the number of the
  9209. buffer associated with each window in the current tab page.
  9210. {arg} specifies the number of the tab page to be used. When
  9211. omitted the current tab page is used.
  9212. When {arg} is invalid the number zero is returned.
  9213. To get a list of all buffers in all tabs use this: >vim
  9214. let buflist = []
  9215. for i in range(tabpagenr('$'))
  9216. call extend(buflist, tabpagebuflist(i + 1))
  9217. endfor
  9218. < Note that a buffer may appear in more than one window.
  9219. Parameters: ~
  9220. • {arg} (`integer?`)
  9221. Return: ~
  9222. (`any`)
  9223. tabpagenr([{arg}]) *tabpagenr()*
  9224. The result is a Number, which is the number of the current
  9225. tab page. The first tab page has number 1.
  9226. The optional argument {arg} supports the following values:
  9227. $ the number of the last tab page (the tab page
  9228. count).
  9229. # the number of the last accessed tab page
  9230. (where |g<Tab>| goes to). If there is no
  9231. previous tab page, 0 is returned.
  9232. The number can be used with the |:tab| command.
  9233. Returns zero on error.
  9234. Parameters: ~
  9235. • {arg} (`'$'|'#'?`)
  9236. Return: ~
  9237. (`integer`)
  9238. tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
  9239. Like |winnr()| but for tab page {tabarg}.
  9240. {tabarg} specifies the number of tab page to be used.
  9241. {arg} is used like with |winnr()|:
  9242. - When omitted the current window number is returned. This is
  9243. the window which will be used when going to this tab page.
  9244. - When "$" the number of windows is returned.
  9245. - When "#" the previous window nr is returned.
  9246. Useful examples: >vim
  9247. tabpagewinnr(1) " current window of tab page 1
  9248. tabpagewinnr(4, '$') " number of windows in tab page 4
  9249. < When {tabarg} is invalid zero is returned.
  9250. Parameters: ~
  9251. • {tabarg} (`integer`)
  9252. • {arg} (`'$'|'#'?`)
  9253. Return: ~
  9254. (`integer`)
  9255. tagfiles() *tagfiles()*
  9256. Returns a |List| with the file names used to search for tags
  9257. for the current buffer. This is the 'tags' option expanded.
  9258. Return: ~
  9259. (`string[]`)
  9260. taglist({expr} [, {filename}]) *taglist()*
  9261. Returns a |List| of tags matching the regular expression {expr}.
  9262. If {filename} is passed it is used to prioritize the results
  9263. in the same way that |:tselect| does. See |tag-priority|.
  9264. {filename} should be the full path of the file.
  9265. Each list item is a dictionary with at least the following
  9266. entries:
  9267. name Name of the tag.
  9268. filename Name of the file where the tag is
  9269. defined. It is either relative to the
  9270. current directory or a full path.
  9271. cmd Ex command used to locate the tag in
  9272. the file.
  9273. kind Type of the tag. The value for this
  9274. entry depends on the language specific
  9275. kind values. Only available when
  9276. using a tags file generated by
  9277. Universal/Exuberant ctags or hdrtag.
  9278. static A file specific tag. Refer to
  9279. |static-tag| for more information.
  9280. More entries may be present, depending on the content of the
  9281. tags file: access, implementation, inherits and signature.
  9282. Refer to the ctags documentation for information about these
  9283. fields. For C code the fields "struct", "class" and "enum"
  9284. may appear, they give the name of the entity the tag is
  9285. contained in.
  9286. The ex-command "cmd" can be either an ex search pattern, a
  9287. line number or a line number followed by a byte number.
  9288. If there are no matching tags, then an empty list is returned.
  9289. To get an exact tag match, the anchors '^' and '$' should be
  9290. used in {expr}. This also make the function work faster.
  9291. Refer to |tag-regexp| for more information about the tag
  9292. search regular expression pattern.
  9293. Refer to |'tags'| for information about how the tags file is
  9294. located by Vim. Refer to |tags-file-format| for the format of
  9295. the tags file generated by the different ctags tools.
  9296. Parameters: ~
  9297. • {expr} (`any`)
  9298. • {filename} (`string?`)
  9299. Return: ~
  9300. (`any`)
  9301. tan({expr}) *tan()*
  9302. Return the tangent of {expr}, measured in radians, as a |Float|
  9303. in the range [-inf, inf].
  9304. {expr} must evaluate to a |Float| or a |Number|.
  9305. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9306. Examples: >vim
  9307. echo tan(10)
  9308. < 0.648361 >vim
  9309. echo tan(-4.01)
  9310. < -1.181502
  9311. Parameters: ~
  9312. • {expr} (`number`)
  9313. Return: ~
  9314. (`number`)
  9315. tanh({expr}) *tanh()*
  9316. Return the hyperbolic tangent of {expr} as a |Float| in the
  9317. range [-1, 1].
  9318. {expr} must evaluate to a |Float| or a |Number|.
  9319. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9320. Examples: >vim
  9321. echo tanh(0.5)
  9322. < 0.462117 >vim
  9323. echo tanh(-1)
  9324. < -0.761594
  9325. Parameters: ~
  9326. • {expr} (`number`)
  9327. Return: ~
  9328. (`number`)
  9329. tempname() *tempname()*
  9330. Generates a (non-existent) filename located in the Nvim root
  9331. |tempdir|. Scripts can use the filename as a temporary file.
  9332. Example: >vim
  9333. let tmpfile = tempname()
  9334. exe "redir > " .. tmpfile
  9335. <
  9336. Return: ~
  9337. (`string`)
  9338. test_garbagecollect_now() *test_garbagecollect_now()*
  9339. Like |garbagecollect()|, but executed right away. This must
  9340. only be called directly to avoid any structure to exist
  9341. internally, and |v:testing| must have been set before calling
  9342. any function. *E1142*
  9343. Return: ~
  9344. (`any`)
  9345. timer_info([{id}]) *timer_info()*
  9346. Return a list with information about timers.
  9347. When {id} is given only information about this timer is
  9348. returned. When timer {id} does not exist an empty list is
  9349. returned.
  9350. When {id} is omitted information about all timers is returned.
  9351. For each timer the information is stored in a |Dictionary| with
  9352. these items:
  9353. "id" the timer ID
  9354. "time" time the timer was started with
  9355. "repeat" number of times the timer will still fire;
  9356. -1 means forever
  9357. "callback" the callback
  9358. Parameters: ~
  9359. • {id} (`integer?`)
  9360. Return: ~
  9361. (`any`)
  9362. timer_pause({timer}, {paused}) *timer_pause()*
  9363. Pause or unpause a timer. A paused timer does not invoke its
  9364. callback when its time expires. Unpausing a timer may cause
  9365. the callback to be invoked almost immediately if enough time
  9366. has passed.
  9367. Pausing a timer is useful to avoid the callback to be called
  9368. for a short time.
  9369. If {paused} evaluates to a non-zero Number or a non-empty
  9370. String, then the timer is paused, otherwise it is unpaused.
  9371. See |non-zero-arg|.
  9372. Parameters: ~
  9373. • {timer} (`integer`)
  9374. • {paused} (`boolean`)
  9375. Return: ~
  9376. (`any`)
  9377. timer_start({time}, {callback} [, {options}]) *timer_start()* *timer*
  9378. Create a timer and return the timer ID.
  9379. {time} is the waiting time in milliseconds. This is the
  9380. minimum time before invoking the callback. When the system is
  9381. busy or Vim is not waiting for input the time will be longer.
  9382. Zero can be used to execute the callback when Vim is back in
  9383. the main loop.
  9384. {callback} is the function to call. It can be the name of a
  9385. function or a |Funcref|. It is called with one argument, which
  9386. is the timer ID. The callback is only invoked when Vim is
  9387. waiting for input.
  9388. {options} is a dictionary. Supported entries:
  9389. "repeat" Number of times to repeat the callback.
  9390. -1 means forever. Default is 1.
  9391. If the timer causes an error three times in a
  9392. row the repeat is cancelled.
  9393. Returns -1 on error.
  9394. Example: >vim
  9395. func MyHandler(timer)
  9396. echo 'Handler called'
  9397. endfunc
  9398. let timer = timer_start(500, 'MyHandler',
  9399. \ {'repeat': 3})
  9400. < This invokes MyHandler() three times at 500 msec intervals.
  9401. Parameters: ~
  9402. • {time} (`number`)
  9403. • {callback} (`string|function`)
  9404. • {options} (`table?`)
  9405. Return: ~
  9406. (`any`)
  9407. timer_stop({timer}) *timer_stop()*
  9408. Stop a timer. The timer callback will no longer be invoked.
  9409. {timer} is an ID returned by timer_start(), thus it must be a
  9410. Number. If {timer} does not exist there is no error.
  9411. Parameters: ~
  9412. • {timer} (`integer`)
  9413. Return: ~
  9414. (`any`)
  9415. timer_stopall() *timer_stopall()*
  9416. Stop all timers. The timer callbacks will no longer be
  9417. invoked. Useful if some timers is misbehaving. If there are
  9418. no timers there is no error.
  9419. Return: ~
  9420. (`any`)
  9421. tolower({expr}) *tolower()*
  9422. The result is a copy of the String given, with all uppercase
  9423. characters turned into lowercase (just like applying |gu| to
  9424. the string). Returns an empty string on error.
  9425. Parameters: ~
  9426. • {expr} (`string`)
  9427. Return: ~
  9428. (`string`)
  9429. toupper({expr}) *toupper()*
  9430. The result is a copy of the String given, with all lowercase
  9431. characters turned into uppercase (just like applying |gU| to
  9432. the string). Returns an empty string on error.
  9433. Parameters: ~
  9434. • {expr} (`string`)
  9435. Return: ~
  9436. (`string`)
  9437. tr({src}, {fromstr}, {tostr}) *tr()*
  9438. The result is a copy of the {src} string with all characters
  9439. which appear in {fromstr} replaced by the character in that
  9440. position in the {tostr} string. Thus the first character in
  9441. {fromstr} is translated into the first character in {tostr}
  9442. and so on. Exactly like the unix "tr" command.
  9443. This code also deals with multibyte characters properly.
  9444. Returns an empty string on error.
  9445. Examples: >vim
  9446. echo tr("hello there", "ht", "HT")
  9447. < returns "Hello THere" >vim
  9448. echo tr("<blob>", "<>", "{}")
  9449. < returns "{blob}"
  9450. Parameters: ~
  9451. • {src} (`string`)
  9452. • {fromstr} (`string`)
  9453. • {tostr} (`string`)
  9454. Return: ~
  9455. (`string`)
  9456. trim({text} [, {mask} [, {dir}]]) *trim()*
  9457. Return {text} as a String where any character in {mask} is
  9458. removed from the beginning and/or end of {text}.
  9459. If {mask} is not given, or is an empty string, {mask} is all
  9460. characters up to 0x20, which includes Tab, space, NL and CR,
  9461. plus the non-breaking space character 0xa0.
  9462. The optional {dir} argument specifies where to remove the
  9463. characters:
  9464. 0 remove from the beginning and end of {text}
  9465. 1 remove only at the beginning of {text}
  9466. 2 remove only at the end of {text}
  9467. When omitted both ends are trimmed.
  9468. This function deals with multibyte characters properly.
  9469. Returns an empty string on error.
  9470. Examples: >vim
  9471. echo trim(" some text ")
  9472. < returns "some text" >vim
  9473. echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  9474. < returns "RESERVE_TAIL" >vim
  9475. echo trim("rm<Xrm<>X>rrm", "rm<>")
  9476. < returns "Xrm<>X" (characters in the middle are not removed) >vim
  9477. echo trim(" vim ", " ", 2)
  9478. < returns " vim"
  9479. Parameters: ~
  9480. • {text} (`string`)
  9481. • {mask} (`string?`)
  9482. • {dir} (`0|1|2?`)
  9483. Return: ~
  9484. (`string`)
  9485. trunc({expr}) *trunc()*
  9486. Return the largest integral value with magnitude less than or
  9487. equal to {expr} as a |Float| (truncate towards zero).
  9488. {expr} must evaluate to a |Float| or a |Number|.
  9489. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9490. Examples: >vim
  9491. echo trunc(1.456)
  9492. < 1.0 >vim
  9493. echo trunc(-5.456)
  9494. < -5.0 >vim
  9495. echo trunc(4.0)
  9496. < 4.0
  9497. Parameters: ~
  9498. • {expr} (`number`)
  9499. Return: ~
  9500. (`integer`)
  9501. type({expr}) *type()*
  9502. The result is a Number representing the type of {expr}.
  9503. Instead of using the number directly, it is better to use the
  9504. v:t_ variable that has the value:
  9505. Number: 0 |v:t_number|
  9506. String: 1 |v:t_string|
  9507. Funcref: 2 |v:t_func|
  9508. List: 3 |v:t_list|
  9509. Dictionary: 4 |v:t_dict|
  9510. Float: 5 |v:t_float|
  9511. Boolean: 6 |v:t_bool| (|v:false| and |v:true|)
  9512. Null: 7 (|v:null|)
  9513. Blob: 10 |v:t_blob|
  9514. For backward compatibility, this method can be used: >vim
  9515. if type(myvar) == type(0) | endif
  9516. if type(myvar) == type("") | endif
  9517. if type(myvar) == type(function("tr")) | endif
  9518. if type(myvar) == type([]) | endif
  9519. if type(myvar) == type({}) | endif
  9520. if type(myvar) == type(0.0) | endif
  9521. if type(myvar) == type(v:true) | endif
  9522. < In place of checking for |v:null| type it is better to check
  9523. for |v:null| directly as it is the only value of this type: >vim
  9524. if myvar is v:null | endif
  9525. < To check if the v:t_ variables exist use this: >vim
  9526. if exists('v:t_number') | endif
  9527. <
  9528. Parameters: ~
  9529. • {expr} (`any`)
  9530. Return: ~
  9531. (`integer`)
  9532. undofile({name}) *undofile()*
  9533. Return the name of the undo file that would be used for a file
  9534. with name {name} when writing. This uses the 'undodir'
  9535. option, finding directories that exist. It does not check if
  9536. the undo file exists.
  9537. {name} is always expanded to the full path, since that is what
  9538. is used internally.
  9539. If {name} is empty undofile() returns an empty string, since a
  9540. buffer without a file name will not write an undo file.
  9541. Useful in combination with |:wundo| and |:rundo|.
  9542. Parameters: ~
  9543. • {name} (`string`)
  9544. Return: ~
  9545. (`string`)
  9546. undotree([{buf}]) *undotree()*
  9547. Return the current state of the undo tree for the current
  9548. buffer, or for a specific buffer if {buf} is given. The
  9549. result is a dictionary with the following items:
  9550. "seq_last" The highest undo sequence number used.
  9551. "seq_cur" The sequence number of the current position in
  9552. the undo tree. This differs from "seq_last"
  9553. when some changes were undone.
  9554. "time_cur" Time last used for |:earlier| and related
  9555. commands. Use |strftime()| to convert to
  9556. something readable.
  9557. "save_last" Number of the last file write. Zero when no
  9558. write yet.
  9559. "save_cur" Number of the current position in the undo
  9560. tree.
  9561. "synced" Non-zero when the last undo block was synced.
  9562. This happens when waiting from input from the
  9563. user. See |undo-blocks|.
  9564. "entries" A list of dictionaries with information about
  9565. undo blocks.
  9566. The first item in the "entries" list is the oldest undo item.
  9567. Each List item is a |Dictionary| with these items:
  9568. "seq" Undo sequence number. Same as what appears in
  9569. |:undolist|.
  9570. "time" Timestamp when the change happened. Use
  9571. |strftime()| to convert to something readable.
  9572. "newhead" Only appears in the item that is the last one
  9573. that was added. This marks the last change
  9574. and where further changes will be added.
  9575. "curhead" Only appears in the item that is the last one
  9576. that was undone. This marks the current
  9577. position in the undo tree, the block that will
  9578. be used by a redo command. When nothing was
  9579. undone after the last change this item will
  9580. not appear anywhere.
  9581. "save" Only appears on the last block before a file
  9582. write. The number is the write count. The
  9583. first write has number 1, the last one the
  9584. "save_last" mentioned above.
  9585. "alt" Alternate entry. This is again a List of undo
  9586. blocks. Each item may again have an "alt"
  9587. item.
  9588. Parameters: ~
  9589. • {buf} (`integer|string?`)
  9590. Return: ~
  9591. (`vim.fn.undotree.ret`)
  9592. uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
  9593. Remove second and succeeding copies of repeated adjacent
  9594. {list} items in-place. Returns {list}. If you want a list
  9595. to remain unmodified make a copy first: >vim
  9596. let newlist = uniq(copy(mylist))
  9597. < The default compare function uses the string representation of
  9598. each item. For the use of {func} and {dict} see |sort()|.
  9599. Returns zero if {list} is not a |List|.
  9600. Parameters: ~
  9601. • {list} (`any`)
  9602. • {func} (`any?`)
  9603. • {dict} (`any?`)
  9604. Return: ~
  9605. (`any[]|0`)
  9606. utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()*
  9607. Same as |charidx()| but returns the UTF-16 code unit index of
  9608. the byte at {idx} in {string} (after converting it to UTF-16).
  9609. When {charidx} is present and TRUE, {idx} is used as the
  9610. character index in the String {string} instead of as the byte
  9611. index.
  9612. An {idx} in the middle of a UTF-8 sequence is rounded
  9613. downwards to the beginning of that sequence.
  9614. Returns -1 if the arguments are invalid or if there are less
  9615. than {idx} bytes in {string}. If there are exactly {idx} bytes
  9616. the length of the string in UTF-16 code units is returned.
  9617. See |byteidx()| and |byteidxcomp()| for getting the byte index
  9618. from the UTF-16 index and |charidx()| for getting the
  9619. character index from the UTF-16 index.
  9620. Refer to |string-offset-encoding| for more information.
  9621. Examples: >vim
  9622. echo utf16idx('a😊😊', 3) " returns 2
  9623. echo utf16idx('a😊😊', 7) " returns 4
  9624. echo utf16idx('a😊😊', 1, 0, 1) " returns 2
  9625. echo utf16idx('a😊😊', 2, 0, 1) " returns 4
  9626. echo utf16idx('aą́c', 6) " returns 2
  9627. echo utf16idx('aą́c', 6, 1) " returns 4
  9628. echo utf16idx('a😊😊', 9) " returns -1
  9629. <
  9630. Parameters: ~
  9631. • {string} (`string`)
  9632. • {idx} (`integer`)
  9633. • {countcc} (`boolean?`)
  9634. • {charidx} (`boolean?`)
  9635. Return: ~
  9636. (`integer`)
  9637. values({dict}) *values()*
  9638. Return a |List| with all the values of {dict}. The |List| is
  9639. in arbitrary order. Also see |items()| and |keys()|.
  9640. Returns zero if {dict} is not a |Dict|.
  9641. Parameters: ~
  9642. • {dict} (`any`)
  9643. Return: ~
  9644. (`any`)
  9645. virtcol({expr} [, {list} [, {winid}]]) *virtcol()*
  9646. The result is a Number, which is the screen column of the file
  9647. position given with {expr}. That is, the last screen position
  9648. occupied by the character at that position, when the screen
  9649. would be of unlimited width. When there is a <Tab> at the
  9650. position, the returned Number will be the column at the end of
  9651. the <Tab>. For example, for a <Tab> in column 1, with 'ts'
  9652. set to 8, it returns 8. |conceal| is ignored.
  9653. For the byte position use |col()|.
  9654. For the use of {expr} see |getpos()| and |col()|.
  9655. When {expr} is "$", it means the end of the cursor line, so
  9656. the result is the number of cells in the cursor line plus one.
  9657. When 'virtualedit' is used {expr} can be [lnum, col, off],
  9658. where "off" is the offset in screen columns from the start of
  9659. the character. E.g., a position within a <Tab> or after the
  9660. last character. When "off" is omitted zero is used. When
  9661. Virtual editing is active in the current mode, a position
  9662. beyond the end of the line can be returned. Also see
  9663. |'virtualedit'|
  9664. If {list} is present and non-zero then virtcol() returns a
  9665. List with the first and last screen position occupied by the
  9666. character.
  9667. With the optional {winid} argument the values are obtained for
  9668. that window instead of the current window.
  9669. Note that only marks in the current file can be used.
  9670. Examples: >vim
  9671. " With text "foo^Lbar" and cursor on the "^L":
  9672. echo virtcol(".") " returns 5
  9673. echo virtcol(".", 1) " returns [4, 5]
  9674. echo virtcol("$") " returns 9
  9675. " With text " there", with 't at 'h':
  9676. echo virtcol("'t") " returns 6
  9677. <
  9678. The first column is 1. 0 or [0, 0] is returned for an error.
  9679. A more advanced example that echoes the maximum length of
  9680. all lines: >vim
  9681. echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  9682. <
  9683. Parameters: ~
  9684. • {expr} (`string|any[]`)
  9685. • {list} (`boolean?`)
  9686. • {winid} (`integer?`)
  9687. Return: ~
  9688. (`any`)
  9689. virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
  9690. The result is a Number, which is the byte index of the
  9691. character in window {winid} at buffer line {lnum} and virtual
  9692. column {col}.
  9693. If buffer line {lnum} is an empty line, 0 is returned.
  9694. If {col} is greater than the last virtual column in line
  9695. {lnum}, then the byte index of the character at the last
  9696. virtual column is returned.
  9697. For a multi-byte character, the column number of the first
  9698. byte in the character is returned.
  9699. The {winid} argument can be the window number or the
  9700. |window-ID|. If this is zero, then the current window is used.
  9701. Returns -1 if the window {winid} doesn't exist or the buffer
  9702. line {lnum} or virtual column {col} is invalid.
  9703. See also |screenpos()|, |virtcol()| and |col()|.
  9704. Parameters: ~
  9705. • {winid} (`integer`)
  9706. • {lnum} (`integer`)
  9707. • {col} (`integer`)
  9708. Return: ~
  9709. (`integer`)
  9710. visualmode([{expr}]) *visualmode()*
  9711. The result is a String, which describes the last Visual mode
  9712. used in the current buffer. Initially it returns an empty
  9713. string, but once Visual mode has been used, it returns "v",
  9714. "V", or "<CTRL-V>" (a single CTRL-V character) for
  9715. character-wise, line-wise, or block-wise Visual mode
  9716. respectively.
  9717. Example: >vim
  9718. exe "normal " .. visualmode()
  9719. < This enters the same Visual mode as before. It is also useful
  9720. in scripts if you wish to act differently depending on the
  9721. Visual mode that was used.
  9722. If Visual mode is active, use |mode()| to get the Visual mode
  9723. (e.g., in a |:vmap|).
  9724. If {expr} is supplied and it evaluates to a non-zero Number or
  9725. a non-empty String, then the Visual mode will be cleared and
  9726. the old value is returned. See |non-zero-arg|.
  9727. Parameters: ~
  9728. • {expr} (`boolean?`)
  9729. Return: ~
  9730. (`string`)
  9731. wait({timeout}, {condition} [, {interval}]) *wait()*
  9732. Waits until {condition} evaluates to |TRUE|, where {condition}
  9733. is a |Funcref| or |string| containing an expression.
  9734. {timeout} is the maximum waiting time in milliseconds, -1
  9735. means forever.
  9736. Condition is evaluated on user events, internal events, and
  9737. every {interval} milliseconds (default: 200).
  9738. Returns a status integer:
  9739. 0 if the condition was satisfied before timeout
  9740. -1 if the timeout was exceeded
  9741. -2 if the function was interrupted (by |CTRL-C|)
  9742. -3 if an error occurred
  9743. Parameters: ~
  9744. • {timeout} (`integer`)
  9745. • {condition} (`any`)
  9746. • {interval} (`number?`)
  9747. Return: ~
  9748. (`any`)
  9749. wildmenumode() *wildmenumode()*
  9750. Returns |TRUE| when the wildmenu is active and |FALSE|
  9751. otherwise. See 'wildmenu' and 'wildmode'.
  9752. This can be used in mappings to handle the 'wildcharm' option
  9753. gracefully. (Makes only sense with |mapmode-c| mappings).
  9754. For example to make <c-j> work like <down> in wildmode, use: >vim
  9755. cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  9756. <
  9757. (Note: this needs the 'wildcharm' option set appropriately).
  9758. Return: ~
  9759. (`any`)
  9760. win_execute({id}, {command} [, {silent}]) *win_execute()*
  9761. Like `execute()` but in the context of window {id}.
  9762. The window will temporarily be made the current window,
  9763. without triggering autocommands or changing directory. When
  9764. executing {command} autocommands will be triggered, this may
  9765. have unexpected side effects. Use `:noautocmd` if needed.
  9766. Example: >vim
  9767. call win_execute(winid, 'syntax enable')
  9768. < Doing the same with `setwinvar()` would not trigger
  9769. autocommands and not actually show syntax highlighting.
  9770. When window {id} does not exist then no error is given and
  9771. an empty string is returned.
  9772. Parameters: ~
  9773. • {id} (`integer`)
  9774. • {command} (`string`)
  9775. • {silent} (`boolean?`)
  9776. Return: ~
  9777. (`any`)
  9778. win_findbuf({bufnr}) *win_findbuf()*
  9779. Returns a |List| with |window-ID|s for windows that contain
  9780. buffer {bufnr}. When there is none the list is empty.
  9781. Parameters: ~
  9782. • {bufnr} (`integer`)
  9783. Return: ~
  9784. (`integer[]`)
  9785. win_getid([{win} [, {tab}]]) *win_getid()*
  9786. Get the |window-ID| for the specified window.
  9787. When {win} is missing use the current window.
  9788. With {win} this is the window number. The top window has
  9789. number 1.
  9790. Without {tab} use the current tab, otherwise the tab with
  9791. number {tab}. The first tab has number one.
  9792. Return zero if the window cannot be found.
  9793. Parameters: ~
  9794. • {win} (`integer?`)
  9795. • {tab} (`integer?`)
  9796. Return: ~
  9797. (`integer`)
  9798. win_gettype([{nr}]) *win_gettype()*
  9799. Return the type of the window:
  9800. "autocmd" autocommand window. Temporary window
  9801. used to execute autocommands.
  9802. "command" command-line window |cmdwin|
  9803. (empty) normal window
  9804. "loclist" |location-list-window|
  9805. "popup" floating window |api-floatwin|
  9806. "preview" preview window |preview-window|
  9807. "quickfix" |quickfix-window|
  9808. "unknown" window {nr} not found
  9809. When {nr} is omitted return the type of the current window.
  9810. When {nr} is given return the type of this window by number or
  9811. |window-ID|.
  9812. Also see the 'buftype' option.
  9813. Parameters: ~
  9814. • {nr} (`integer?`)
  9815. Return: ~
  9816. (`'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'`)
  9817. win_gotoid({expr}) *win_gotoid()*
  9818. Go to window with ID {expr}. This may also change the current
  9819. tabpage.
  9820. Return TRUE if successful, FALSE if the window cannot be found.
  9821. Parameters: ~
  9822. • {expr} (`integer`)
  9823. Return: ~
  9824. (`0|1`)
  9825. win_id2tabwin({expr}) *win_id2tabwin()*
  9826. Return a list with the tab number and window number of window
  9827. with ID {expr}: [tabnr, winnr].
  9828. Return [0, 0] if the window cannot be found.
  9829. Parameters: ~
  9830. • {expr} (`integer`)
  9831. Return: ~
  9832. (`any`)
  9833. win_id2win({expr}) *win_id2win()*
  9834. Return the window number of window with ID {expr}.
  9835. Return 0 if the window cannot be found in the current tabpage.
  9836. Parameters: ~
  9837. • {expr} (`integer`)
  9838. Return: ~
  9839. (`integer`)
  9840. win_move_separator({nr}, {offset}) *win_move_separator()*
  9841. Move window {nr}'s vertical separator (i.e., the right border)
  9842. by {offset} columns, as if being dragged by the mouse. {nr}
  9843. can be a window number or |window-ID|. A positive {offset}
  9844. moves right and a negative {offset} moves left. Moving a
  9845. window's vertical separator will change the width of the
  9846. window and the width of other windows adjacent to the vertical
  9847. separator. The magnitude of movement may be smaller than
  9848. specified (e.g., as a consequence of maintaining
  9849. 'winminwidth'). Returns TRUE if the window can be found and
  9850. FALSE otherwise.
  9851. This will fail for the rightmost window and a full-width
  9852. window, since it has no separator on the right.
  9853. Only works for the current tab page. *E1308*
  9854. Parameters: ~
  9855. • {nr} (`integer`)
  9856. • {offset} (`integer`)
  9857. Return: ~
  9858. (`any`)
  9859. win_move_statusline({nr}, {offset}) *win_move_statusline()*
  9860. Move window {nr}'s status line (i.e., the bottom border) by
  9861. {offset} rows, as if being dragged by the mouse. {nr} can be a
  9862. window number or |window-ID|. A positive {offset} moves down
  9863. and a negative {offset} moves up. Moving a window's status
  9864. line will change the height of the window and the height of
  9865. other windows adjacent to the status line. The magnitude of
  9866. movement may be smaller than specified (e.g., as a consequence
  9867. of maintaining 'winminheight'). Returns TRUE if the window can
  9868. be found and FALSE otherwise.
  9869. Only works for the current tab page.
  9870. Parameters: ~
  9871. • {nr} (`integer`)
  9872. • {offset} (`integer`)
  9873. Return: ~
  9874. (`any`)
  9875. win_screenpos({nr}) *win_screenpos()*
  9876. Return the screen position of window {nr} as a list with two
  9877. numbers: [row, col]. The first window always has position
  9878. [1, 1], unless there is a tabline, then it is [2, 1].
  9879. {nr} can be the window number or the |window-ID|. Use zero
  9880. for the current window.
  9881. Returns [0, 0] if the window cannot be found.
  9882. Parameters: ~
  9883. • {nr} (`integer`)
  9884. Return: ~
  9885. (`any`)
  9886. win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
  9887. Temporarily switch to window {target}, then move window {nr}
  9888. to a new split adjacent to {target}.
  9889. Unlike commands such as |:split|, no new windows are created
  9890. (the |window-ID| of window {nr} is unchanged after the move).
  9891. Both {nr} and {target} can be window numbers or |window-ID|s.
  9892. Both must be in the current tab page.
  9893. Returns zero for success, non-zero for failure.
  9894. {options} is a |Dictionary| with the following optional entries:
  9895. "vertical" When TRUE, the split is created vertically,
  9896. like with |:vsplit|.
  9897. "rightbelow" When TRUE, the split is made below or to the
  9898. right (if vertical). When FALSE, it is done
  9899. above or to the left (if vertical). When not
  9900. present, the values of 'splitbelow' and
  9901. 'splitright' are used.
  9902. Parameters: ~
  9903. • {nr} (`integer`)
  9904. • {target} (`integer`)
  9905. • {options} (`table?`)
  9906. Return: ~
  9907. (`any`)
  9908. winbufnr({nr}) *winbufnr()*
  9909. The result is a Number, which is the number of the buffer
  9910. associated with window {nr}. {nr} can be the window number or
  9911. the |window-ID|.
  9912. When {nr} is zero, the number of the buffer in the current
  9913. window is returned.
  9914. When window {nr} doesn't exist, -1 is returned.
  9915. Example: >vim
  9916. echo "The file in the current window is " .. bufname(winbufnr(0))
  9917. <
  9918. Parameters: ~
  9919. • {nr} (`integer`)
  9920. Return: ~
  9921. (`integer`)
  9922. wincol() *wincol()*
  9923. The result is a Number, which is the virtual column of the
  9924. cursor in the window. This is counting screen cells from the
  9925. left side of the window. The leftmost column is one.
  9926. Return: ~
  9927. (`integer`)
  9928. windowsversion() *windowsversion()*
  9929. The result is a String. For MS-Windows it indicates the OS
  9930. version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  9931. Windows XP is "5.1". For non-MS-Windows systems the result is
  9932. an empty string.
  9933. Return: ~
  9934. (`string`)
  9935. winheight({nr}) *winheight()*
  9936. The result is a Number, which is the height of window {nr}.
  9937. {nr} can be the window number or the |window-ID|.
  9938. When {nr} is zero, the height of the current window is
  9939. returned. When window {nr} doesn't exist, -1 is returned.
  9940. An existing window always has a height of zero or more.
  9941. This excludes any window toolbar line.
  9942. Examples: >vim
  9943. echo "The current window has " .. winheight(0) .. " lines."
  9944. <
  9945. Parameters: ~
  9946. • {nr} (`integer`)
  9947. Return: ~
  9948. (`integer`)
  9949. winlayout([{tabnr}]) *winlayout()*
  9950. The result is a nested List containing the layout of windows
  9951. in a tabpage.
  9952. Without {tabnr} use the current tabpage, otherwise the tabpage
  9953. with number {tabnr}. If the tabpage {tabnr} is not found,
  9954. returns an empty list.
  9955. For a leaf window, it returns: >
  9956. ["leaf", {winid}]
  9957. <
  9958. For horizontally split windows, which form a column, it
  9959. returns: >
  9960. ["col", [{nested list of windows}]]
  9961. < For vertically split windows, which form a row, it returns: >
  9962. ["row", [{nested list of windows}]]
  9963. <
  9964. Example: >vim
  9965. " Only one window in the tab page
  9966. echo winlayout()
  9967. < >
  9968. ['leaf', 1000]
  9969. < >vim
  9970. " Two horizontally split windows
  9971. echo winlayout()
  9972. < >
  9973. ['col', [['leaf', 1000], ['leaf', 1001]]]
  9974. < >vim
  9975. " The second tab page, with three horizontally split
  9976. " windows, with two vertically split windows in the
  9977. " middle window
  9978. echo winlayout(2)
  9979. < >
  9980. ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  9981. ['leaf', 1001]]], ['leaf', 1000]]]
  9982. <
  9983. Parameters: ~
  9984. • {tabnr} (`integer?`)
  9985. Return: ~
  9986. (`any[]`)
  9987. winline() *winline()*
  9988. The result is a Number, which is the screen line of the cursor
  9989. in the window. This is counting screen lines from the top of
  9990. the window. The first line is one.
  9991. If the cursor was moved the view on the file will be updated
  9992. first, this may cause a scroll.
  9993. Return: ~
  9994. (`integer`)
  9995. winnr([{arg}]) *winnr()*
  9996. The result is a Number, which is the number of the current
  9997. window. The top window has number 1.
  9998. Returns zero for a popup window.
  9999. The optional argument {arg} supports the following values:
  10000. $ the number of the last window (the window
  10001. count).
  10002. # the number of the last accessed window (where
  10003. |CTRL-W_p| goes to). If there is no previous
  10004. window or it is in another tab page 0 is
  10005. returned. May refer to the current window in
  10006. some cases (e.g. when evaluating 'statusline'
  10007. expressions).
  10008. {N}j the number of the Nth window below the
  10009. current window (where |CTRL-W_j| goes to).
  10010. {N}k the number of the Nth window above the current
  10011. window (where |CTRL-W_k| goes to).
  10012. {N}h the number of the Nth window left of the
  10013. current window (where |CTRL-W_h| goes to).
  10014. {N}l the number of the Nth window right of the
  10015. current window (where |CTRL-W_l| goes to).
  10016. The number can be used with |CTRL-W_w| and ":wincmd w"
  10017. |:wincmd|.
  10018. When {arg} is invalid an error is given and zero is returned.
  10019. Also see |tabpagewinnr()| and |win_getid()|.
  10020. Examples: >vim
  10021. let window_count = winnr('$')
  10022. let prev_window = winnr('#')
  10023. let wnum = winnr('3k')
  10024. <
  10025. Parameters: ~
  10026. • {arg} (`string|integer?`)
  10027. Return: ~
  10028. (`integer`)
  10029. winrestcmd() *winrestcmd()*
  10030. Returns a sequence of |:resize| commands that should restore
  10031. the current window sizes. Only works properly when no windows
  10032. are opened or closed and the current window and tab page is
  10033. unchanged.
  10034. Example: >vim
  10035. let cmd = winrestcmd()
  10036. call MessWithWindowSizes()
  10037. exe cmd
  10038. <
  10039. Return: ~
  10040. (`string`)
  10041. winrestview({dict}) *winrestview()*
  10042. Uses the |Dictionary| returned by |winsaveview()| to restore
  10043. the view of the current window.
  10044. Note: The {dict} does not have to contain all values, that are
  10045. returned by |winsaveview()|. If values are missing, those
  10046. settings won't be restored. So you can use: >vim
  10047. call winrestview({'curswant': 4})
  10048. <
  10049. This will only set the curswant value (the column the cursor
  10050. wants to move on vertical movements) of the cursor to column 5
  10051. (yes, that is 5), while all other settings will remain the
  10052. same. This is useful, if you set the cursor position manually.
  10053. If you have changed the values the result is unpredictable.
  10054. If the window size changed the result won't be the same.
  10055. Parameters: ~
  10056. • {dict} (`vim.fn.winrestview.dict`)
  10057. Return: ~
  10058. (`any`)
  10059. winsaveview() *winsaveview()*
  10060. Returns a |Dictionary| that contains information to restore
  10061. the view of the current window. Use |winrestview()| to
  10062. restore the view.
  10063. This is useful if you have a mapping that jumps around in the
  10064. buffer and you want to go back to the original view.
  10065. This does not save fold information. Use the 'foldenable'
  10066. option to temporarily switch off folding, so that folds are
  10067. not opened when moving around. This may have side effects.
  10068. The return value includes:
  10069. lnum cursor line number
  10070. col cursor column (Note: the first column
  10071. zero, as opposed to what |getcurpos()|
  10072. returns)
  10073. coladd cursor column offset for 'virtualedit'
  10074. curswant column for vertical movement (Note:
  10075. the first column is zero, as opposed
  10076. to what |getcurpos()| returns). After
  10077. |$| command it will be a very large
  10078. number equal to |v:maxcol|.
  10079. topline first line in the window
  10080. topfill filler lines, only in diff mode
  10081. leftcol first column displayed; only used when
  10082. 'wrap' is off
  10083. skipcol columns skipped
  10084. Note that no option values are saved.
  10085. Return: ~
  10086. (`vim.fn.winsaveview.ret`)
  10087. winwidth({nr}) *winwidth()*
  10088. The result is a Number, which is the width of window {nr}.
  10089. {nr} can be the window number or the |window-ID|.
  10090. When {nr} is zero, the width of the current window is
  10091. returned. When window {nr} doesn't exist, -1 is returned.
  10092. An existing window always has a width of zero or more.
  10093. Examples: >vim
  10094. echo "The current window has " .. winwidth(0) .. " columns."
  10095. if winwidth(0) <= 50
  10096. 50 wincmd |
  10097. endif
  10098. < For getting the terminal or screen size, see the 'columns'
  10099. option.
  10100. Parameters: ~
  10101. • {nr} (`integer`)
  10102. Return: ~
  10103. (`integer`)
  10104. wordcount() *wordcount()*
  10105. The result is a dictionary of byte/chars/word statistics for
  10106. the current buffer. This is the same info as provided by
  10107. |g_CTRL-G|
  10108. The return value includes:
  10109. bytes Number of bytes in the buffer
  10110. chars Number of chars in the buffer
  10111. words Number of words in the buffer
  10112. cursor_bytes Number of bytes before cursor position
  10113. (not in Visual mode)
  10114. cursor_chars Number of chars before cursor position
  10115. (not in Visual mode)
  10116. cursor_words Number of words before cursor position
  10117. (not in Visual mode)
  10118. visual_bytes Number of bytes visually selected
  10119. (only in Visual mode)
  10120. visual_chars Number of chars visually selected
  10121. (only in Visual mode)
  10122. visual_words Number of words visually selected
  10123. (only in Visual mode)
  10124. Return: ~
  10125. (`any`)
  10126. writefile({object}, {fname} [, {flags}]) *writefile()*
  10127. When {object} is a |List| write it to file {fname}. Each list
  10128. item is separated with a NL. Each list item must be a String
  10129. or Number.
  10130. All NL characters are replaced with a NUL character.
  10131. Inserting CR characters needs to be done before passing {list}
  10132. to writefile().
  10133. When {object} is a |Blob| write the bytes to file {fname}
  10134. unmodified, also when binary mode is not specified.
  10135. {flags} must be a String. These characters are recognized:
  10136. 'b' Binary mode is used: There will not be a NL after the
  10137. last list item. An empty item at the end does cause the
  10138. last line in the file to end in a NL.
  10139. 'a' Append mode is used, lines are appended to the file: >vim
  10140. call writefile(["foo"], "event.log", "a")
  10141. call writefile(["bar"], "event.log", "a")
  10142. <
  10143. 'D' Delete the file when the current function ends. This
  10144. works like: >vim
  10145. defer delete({fname})
  10146. < Fails when not in a function. Also see |:defer|.
  10147. 's' fsync() is called after writing the file. This flushes
  10148. the file to disk, if possible. This takes more time but
  10149. avoids losing the file if the system crashes.
  10150. 'S' fsync() is not called, even when 'fsync' is set.
  10151. When {flags} does not contain "S" or "s" then fsync() is
  10152. called if the 'fsync' option is set.
  10153. An existing file is overwritten, if possible.
  10154. When the write fails -1 is returned, otherwise 0. There is an
  10155. error message if the file can't be created or when writing
  10156. fails.
  10157. Also see |readfile()|.
  10158. To copy a file byte for byte: >vim
  10159. let fl = readfile("foo", "b")
  10160. call writefile(fl, "foocopy", "b")
  10161. <
  10162. Parameters: ~
  10163. • {object} (`any`)
  10164. • {fname} (`string`)
  10165. • {flags} (`string?`)
  10166. Return: ~
  10167. (`any`)
  10168. xor({expr}, {expr}) *xor()*
  10169. Bitwise XOR on the two arguments. The arguments are converted
  10170. to a number. A List, Dict or Float argument causes an error.
  10171. Also see `and()` and `or()`.
  10172. Example: >vim
  10173. let bits = xor(bits, 0x80)
  10174. <
  10175. Parameters: ~
  10176. • {expr} (`integer`)
  10177. • {expr1} (`integer`)
  10178. Return: ~
  10179. (`integer`)
  10180. ==============================================================================
  10181. 2. Matching a pattern in a String *string-match*
  10182. This is common between several functions. A regexp pattern as explained at
  10183. |pattern| is normally used to find a match in the buffer lines. When a
  10184. pattern is used to find a match in a String, almost everything works in the
  10185. same way. The difference is that a String is handled like it is one line.
  10186. When it contains a "\n" character, this is not seen as a line break for the
  10187. pattern. It can be matched with a "\n" in the pattern, or with ".". Example:
  10188. >vim
  10189. let a = "aaaa\nxxxx"
  10190. echo matchstr(a, "..\n..")
  10191. " aa
  10192. " xx
  10193. echo matchstr(a, "a.x")
  10194. " a
  10195. " x
  10196. Don't forget that "^" will only match at the first character of the String and
  10197. "$" at the last character of the string. They don't match after or before a
  10198. "\n".
  10199. vim:tw=78:ts=8:noet:ft=help:norl: