builtin.txt 441 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245
  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 completion matches. Each item is a
  965. dictionary containing the entries "word",
  966. "abbr", "menu", "kind", "info" and "user_data".
  967. See |complete-items|.
  968. selected Selected item index. First index is zero.
  969. Index is -1 if no item is selected (showing
  970. typed text only, or the last completion after
  971. no item is selected when using the <Up> or
  972. <Down> keys)
  973. inserted Inserted string. [NOT IMPLEMENTED YET]
  974. preview_winid Info floating preview window id.
  975. preview_bufnr Info floating preview buffer id.
  976. *complete_info_mode*
  977. mode values are:
  978. "" Not in completion mode
  979. "keyword" Keyword completion |i_CTRL-X_CTRL-N|
  980. "ctrl_x" Just pressed CTRL-X |i_CTRL-X|
  981. "scroll" Scrolling with |i_CTRL-X_CTRL-E| or
  982. |i_CTRL-X_CTRL-Y|
  983. "whole_line" Whole lines |i_CTRL-X_CTRL-L|
  984. "files" File names |i_CTRL-X_CTRL-F|
  985. "tags" Tags |i_CTRL-X_CTRL-]|
  986. "path_defines" Definition completion |i_CTRL-X_CTRL-D|
  987. "path_patterns" Include completion |i_CTRL-X_CTRL-I|
  988. "dictionary" Dictionary |i_CTRL-X_CTRL-K|
  989. "thesaurus" Thesaurus |i_CTRL-X_CTRL-T|
  990. "cmdline" Vim Command line |i_CTRL-X_CTRL-V|
  991. "function" User defined completion |i_CTRL-X_CTRL-U|
  992. "omni" Omni completion |i_CTRL-X_CTRL-O|
  993. "spell" Spelling suggestions |i_CTRL-X_s|
  994. "eval" |complete()| completion
  995. "unknown" Other internal modes
  996. If the optional {what} list argument is supplied, then only
  997. the items listed in {what} are returned. Unsupported items in
  998. {what} are silently ignored.
  999. To get the position and size of the popup menu, see
  1000. |pum_getpos()|. It's also available in |v:event| during the
  1001. |CompleteChanged| event.
  1002. Returns an empty |Dictionary| on error.
  1003. Examples: >vim
  1004. " Get all items
  1005. call complete_info()
  1006. " Get only 'mode'
  1007. call complete_info(['mode'])
  1008. " Get only 'mode' and 'pum_visible'
  1009. call complete_info(['mode', 'pum_visible'])
  1010. <
  1011. Parameters: ~
  1012. • {what} (`any[]?`)
  1013. Return: ~
  1014. (`table`)
  1015. confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()*
  1016. confirm() offers the user a dialog, from which a choice can be
  1017. made. It returns the number of the choice. For the first
  1018. choice this is 1.
  1019. {msg} is displayed in a dialog with {choices} as the
  1020. alternatives. When {choices} is missing or empty, "&OK" is
  1021. used (and translated).
  1022. {msg} is a String, use '\n' to include a newline. Only on
  1023. some systems the string is wrapped when it doesn't fit.
  1024. {choices} is a String, with the individual choices separated
  1025. by '\n', e.g. >vim
  1026. confirm("Save changes?", "&Yes\n&No\n&Cancel")
  1027. < The letter after the '&' is the shortcut key for that choice.
  1028. Thus you can type 'c' to select "Cancel". The shortcut does
  1029. not need to be the first letter: >vim
  1030. confirm("file has been modified", "&Save\nSave &All")
  1031. < For the console, the first letter of each choice is used as
  1032. the default shortcut key. Case is ignored.
  1033. The optional {type} String argument gives the type of dialog.
  1034. It can be one of these values: "Error", "Question", "Info",
  1035. "Warning" or "Generic". Only the first character is relevant.
  1036. When {type} is omitted, "Generic" is used.
  1037. The optional {type} argument gives the type of dialog. This
  1038. is only used for the icon of the Win32 GUI. It can be one of
  1039. these values: "Error", "Question", "Info", "Warning" or
  1040. "Generic". Only the first character is relevant.
  1041. When {type} is omitted, "Generic" is used.
  1042. If the user aborts the dialog by pressing <Esc>, CTRL-C,
  1043. or another valid interrupt key, confirm() returns 0.
  1044. An example: >vim
  1045. let choice = confirm("What do you want?",
  1046. \ "&Apples\n&Oranges\n&Bananas", 2)
  1047. if choice == 0
  1048. echo "make up your mind!"
  1049. elseif choice == 3
  1050. echo "tasteful"
  1051. else
  1052. echo "I prefer bananas myself."
  1053. endif
  1054. < In a GUI dialog, buttons are used. The layout of the buttons
  1055. depends on the 'v' flag in 'guioptions'. If it is included,
  1056. the buttons are always put vertically. Otherwise, confirm()
  1057. tries to put the buttons in one horizontal line. If they
  1058. don't fit, a vertical layout is used anyway. For some systems
  1059. the horizontal layout is always used.
  1060. Parameters: ~
  1061. • {msg} (`string`)
  1062. • {choices} (`string?`)
  1063. • {default} (`integer?`)
  1064. • {type} (`string?`)
  1065. Return: ~
  1066. (`integer`)
  1067. copy({expr}) *copy()*
  1068. Make a copy of {expr}. For Numbers and Strings this isn't
  1069. different from using {expr} directly.
  1070. When {expr} is a |List| a shallow copy is created. This means
  1071. that the original |List| can be changed without changing the
  1072. copy, and vice versa. But the items are identical, thus
  1073. changing an item changes the contents of both |Lists|.
  1074. A |Dictionary| is copied in a similar way as a |List|.
  1075. Also see |deepcopy()|.
  1076. Parameters: ~
  1077. • {expr} (`any`)
  1078. Return: ~
  1079. (`any`)
  1080. cos({expr}) *cos()*
  1081. Return the cosine of {expr}, measured in radians, as a |Float|.
  1082. {expr} must evaluate to a |Float| or a |Number|.
  1083. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1084. Examples: >vim
  1085. echo cos(100)
  1086. < 0.862319 >vim
  1087. echo cos(-4.01)
  1088. < -0.646043
  1089. Parameters: ~
  1090. • {expr} (`number`)
  1091. Return: ~
  1092. (`number`)
  1093. cosh({expr}) *cosh()*
  1094. Return the hyperbolic cosine of {expr} as a |Float| in the range
  1095. [1, inf].
  1096. {expr} must evaluate to a |Float| or a |Number|.
  1097. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1098. Examples: >vim
  1099. echo cosh(0.5)
  1100. < 1.127626 >vim
  1101. echo cosh(-0.5)
  1102. < -1.127626
  1103. Parameters: ~
  1104. • {expr} (`number`)
  1105. Return: ~
  1106. (`number`)
  1107. count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E706*
  1108. Return the number of times an item with value {expr} appears
  1109. in |String|, |List| or |Dictionary| {comp}.
  1110. If {start} is given then start with the item with this index.
  1111. {start} can only be used with a |List|.
  1112. When {ic} is given and it's |TRUE| then case is ignored.
  1113. When {comp} is a string then the number of not overlapping
  1114. occurrences of {expr} is returned. Zero is returned when
  1115. {expr} is an empty string.
  1116. Parameters: ~
  1117. • {comp} (`string|table|any[]`)
  1118. • {expr} (`any`)
  1119. • {ic} (`boolean?`)
  1120. • {start} (`integer?`)
  1121. Return: ~
  1122. (`integer`)
  1123. ctxget([{index}]) *ctxget()*
  1124. Returns a |Dictionary| representing the |context| at {index}
  1125. from the top of the |context-stack| (see |context-dict|).
  1126. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1127. Parameters: ~
  1128. • {index} (`integer?`)
  1129. Return: ~
  1130. (`table`)
  1131. ctxpop() *ctxpop()*
  1132. Pops and restores the |context| at the top of the
  1133. |context-stack|.
  1134. Return: ~
  1135. (`any`)
  1136. ctxpush([{types}]) *ctxpush()*
  1137. Pushes the current editor state (|context|) on the
  1138. |context-stack|.
  1139. If {types} is given and is a |List| of |String|s, it specifies
  1140. which |context-types| to include in the pushed context.
  1141. Otherwise, all context types are included.
  1142. Parameters: ~
  1143. • {types} (`string[]?`)
  1144. Return: ~
  1145. (`any`)
  1146. ctxset({context} [, {index}]) *ctxset()*
  1147. Sets the |context| at {index} from the top of the
  1148. |context-stack| to that represented by {context}.
  1149. {context} is a Dictionary with context data (|context-dict|).
  1150. If {index} is not given, it is assumed to be 0 (i.e.: top).
  1151. Parameters: ~
  1152. • {context} (`table`)
  1153. • {index} (`integer?`)
  1154. Return: ~
  1155. (`any`)
  1156. ctxsize() *ctxsize()*
  1157. Returns the size of the |context-stack|.
  1158. Return: ~
  1159. (`any`)
  1160. cursor({lnum}, {col} [, {off}]) *cursor()*
  1161. cursor({list})
  1162. Positions the cursor at the column (byte count) {col} in the
  1163. line {lnum}. The first column is one.
  1164. When there is one argument {list} this is used as a |List|
  1165. with two, three or four item:
  1166. [{lnum}, {col}]
  1167. [{lnum}, {col}, {off}]
  1168. [{lnum}, {col}, {off}, {curswant}]
  1169. This is like the return value of |getpos()| or |getcurpos()|,
  1170. but without the first item.
  1171. To position the cursor using {col} as the character count, use
  1172. |setcursorcharpos()|.
  1173. Does not change the jumplist.
  1174. {lnum} is used like with |getline()|, except that if {lnum} is
  1175. zero, the cursor will stay in the current line.
  1176. If {lnum} is greater than the number of lines in the buffer,
  1177. the cursor will be positioned at the last line in the buffer.
  1178. If {col} is greater than the number of bytes in the line,
  1179. the cursor will be positioned at the last character in the
  1180. line.
  1181. If {col} is zero, the cursor will stay in the current column.
  1182. If {curswant} is given it is used to set the preferred column
  1183. for vertical movement. Otherwise {col} is used.
  1184. When 'virtualedit' is used {off} specifies the offset in
  1185. screen columns from the start of the character. E.g., a
  1186. position within a <Tab> or after the last character.
  1187. Returns 0 when the position could be set, -1 otherwise.
  1188. Parameters: ~
  1189. • {list} (`integer[]`)
  1190. Return: ~
  1191. (`any`)
  1192. debugbreak({pid}) *debugbreak()*
  1193. Specifically used to interrupt a program being debugged. It
  1194. will cause process {pid} to get a SIGTRAP. Behavior for other
  1195. processes is undefined. See |terminal-debug|.
  1196. (Sends a SIGINT to a process {pid} other than MS-Windows)
  1197. Returns |TRUE| if successfully interrupted the program.
  1198. Otherwise returns |FALSE|.
  1199. Parameters: ~
  1200. • {pid} (`integer`)
  1201. Return: ~
  1202. (`any`)
  1203. deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
  1204. Make a copy of {expr}. For Numbers and Strings this isn't
  1205. different from using {expr} directly.
  1206. When {expr} is a |List| a full copy is created. This means
  1207. that the original |List| can be changed without changing the
  1208. copy, and vice versa. When an item is a |List|, a copy for it
  1209. is made, recursively. Thus changing an item in the copy does
  1210. not change the contents of the original |List|.
  1211. When {noref} is omitted or zero a contained |List| or
  1212. |Dictionary| is only copied once. All references point to
  1213. this single copy. With {noref} set to 1 every occurrence of a
  1214. |List| or |Dictionary| results in a new copy. This also means
  1215. that a cyclic reference causes deepcopy() to fail.
  1216. *E724*
  1217. Nesting is possible up to 100 levels. When there is an item
  1218. that refers back to a higher level making a deep copy with
  1219. {noref} set to 1 will fail.
  1220. Also see |copy()|.
  1221. Parameters: ~
  1222. • {expr} (`any`)
  1223. • {noref} (`boolean?`)
  1224. Return: ~
  1225. (`any`)
  1226. delete({fname} [, {flags}]) *delete()*
  1227. Without {flags} or with {flags} empty: Deletes the file by the
  1228. name {fname}.
  1229. This also works when {fname} is a symbolic link. The symbolic
  1230. link itself is deleted, not what it points to.
  1231. When {flags} is "d": Deletes the directory by the name
  1232. {fname}. This fails when directory {fname} is not empty.
  1233. When {flags} is "rf": Deletes the directory by the name
  1234. {fname} and everything in it, recursively. BE CAREFUL!
  1235. Note: on MS-Windows it is not possible to delete a directory
  1236. that is being used.
  1237. The result is a Number, which is 0/false if the delete
  1238. operation was successful and -1/true when the deletion failed
  1239. or partly failed.
  1240. Parameters: ~
  1241. • {fname} (`string`)
  1242. • {flags} (`string?`)
  1243. Return: ~
  1244. (`integer`)
  1245. deletebufline({buf}, {first} [, {last}]) *deletebufline()*
  1246. Delete lines {first} to {last} (inclusive) from buffer {buf}.
  1247. If {last} is omitted then delete line {first} only.
  1248. On success 0 is returned, on failure 1 is returned.
  1249. This function works only for loaded buffers. First call
  1250. |bufload()| if needed.
  1251. For the use of {buf}, see |bufname()| above.
  1252. {first} and {last} are used like with |getline()|. Note that
  1253. when using |line()| this refers to the current buffer. Use "$"
  1254. to refer to the last line in buffer {buf}.
  1255. Parameters: ~
  1256. • {buf} (`integer|string`)
  1257. • {first} (`integer|string`)
  1258. • {last} (`integer|string?`)
  1259. Return: ~
  1260. (`any`)
  1261. dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
  1262. Adds a watcher to a dictionary. A dictionary watcher is
  1263. identified by three components:
  1264. - A dictionary({dict});
  1265. - A key pattern({pattern}).
  1266. - A function({callback}).
  1267. After this is called, every change on {dict} and on keys
  1268. matching {pattern} will result in {callback} being invoked.
  1269. For example, to watch all global variables: >vim
  1270. silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
  1271. function! OnDictChanged(d,k,z)
  1272. echomsg string(a:k) string(a:z)
  1273. endfunction
  1274. call dictwatcheradd(g:, '*', 'OnDictChanged')
  1275. <
  1276. For now {pattern} only accepts very simple patterns that can
  1277. contain a "*" at the end of the string, in which case it will
  1278. match every key that begins with the substring before the "*".
  1279. That means if "*" is not the last character of {pattern}, only
  1280. keys that are exactly equal as {pattern} will be matched.
  1281. The {callback} receives three arguments:
  1282. - The dictionary being watched.
  1283. - The key which changed.
  1284. - A dictionary containing the new and old values for the key.
  1285. The type of change can be determined by examining the keys
  1286. present on the third argument:
  1287. - If contains both `old` and `new`, the key was updated.
  1288. - If it contains only `new`, the key was added.
  1289. - If it contains only `old`, the key was deleted.
  1290. This function can be used by plugins to implement options with
  1291. validation and parsing logic.
  1292. Parameters: ~
  1293. • {dict} (`table`)
  1294. • {pattern} (`string`)
  1295. • {callback} (`function`)
  1296. Return: ~
  1297. (`any`)
  1298. dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()*
  1299. Removes a watcher added with |dictwatcheradd()|. All three
  1300. arguments must match the ones passed to |dictwatcheradd()| in
  1301. order for the watcher to be successfully deleted.
  1302. Parameters: ~
  1303. • {dict} (`any`)
  1304. • {pattern} (`string`)
  1305. • {callback} (`function`)
  1306. Return: ~
  1307. (`any`)
  1308. did_filetype() *did_filetype()*
  1309. Returns |TRUE| when autocommands are being executed and the
  1310. FileType event has been triggered at least once. Can be used
  1311. to avoid triggering the FileType event again in the scripts
  1312. that detect the file type. |FileType|
  1313. Returns |FALSE| when `:setf FALLBACK` was used.
  1314. When editing another file, the counter is reset, thus this
  1315. really checks if the FileType event has been triggered for the
  1316. current buffer. This allows an autocommand that starts
  1317. editing another buffer to set 'filetype' and load a syntax
  1318. file.
  1319. Return: ~
  1320. (`any`)
  1321. diff_filler({lnum}) *diff_filler()*
  1322. Returns the number of filler lines above line {lnum}.
  1323. These are the lines that were inserted at this point in
  1324. another diff'ed window. These filler lines are shown in the
  1325. display but don't exist in the buffer.
  1326. {lnum} is used like with |getline()|. Thus "." is the current
  1327. line, "'m" mark m, etc.
  1328. Returns 0 if the current window is not in diff mode.
  1329. Parameters: ~
  1330. • {lnum} (`integer`)
  1331. Return: ~
  1332. (`any`)
  1333. diff_hlID({lnum}, {col}) *diff_hlID()*
  1334. Returns the highlight ID for diff mode at line {lnum} column
  1335. {col} (byte index). When the current line does not have a
  1336. diff change zero is returned.
  1337. {lnum} is used like with |getline()|. Thus "." is the current
  1338. line, "'m" mark m, etc.
  1339. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  1340. line.
  1341. The highlight ID can be used with |synIDattr()| to obtain
  1342. syntax information about the highlighting.
  1343. Parameters: ~
  1344. • {lnum} (`integer`)
  1345. • {col} (`integer`)
  1346. Return: ~
  1347. (`any`)
  1348. digraph_get({chars}) *digraph_get()* *E1214*
  1349. Return the digraph of {chars}. This should be a string with
  1350. exactly two characters. If {chars} are not just two
  1351. characters, or the digraph of {chars} does not exist, an error
  1352. is given and an empty string is returned.
  1353. Also see |digraph_getlist()|.
  1354. Examples: >vim
  1355. " Get a built-in digraph
  1356. echo digraph_get('00') " Returns '∞'
  1357. " Get a user-defined digraph
  1358. call digraph_set('aa', 'あ')
  1359. echo digraph_get('aa') " Returns 'あ'
  1360. <
  1361. Parameters: ~
  1362. • {chars} (`string`)
  1363. Return: ~
  1364. (`any`)
  1365. digraph_getlist([{listall}]) *digraph_getlist()*
  1366. Return a list of digraphs. If the {listall} argument is given
  1367. and it is TRUE, return all digraphs, including the default
  1368. digraphs. Otherwise, return only user-defined digraphs.
  1369. Also see |digraph_get()|.
  1370. Examples: >vim
  1371. " Get user-defined digraphs
  1372. echo digraph_getlist()
  1373. " Get all the digraphs, including default digraphs
  1374. echo digraph_getlist(1)
  1375. <
  1376. Parameters: ~
  1377. • {listall} (`boolean?`)
  1378. Return: ~
  1379. (`any`)
  1380. digraph_set({chars}, {digraph}) *digraph_set()*
  1381. Add digraph {chars} to the list. {chars} must be a string
  1382. with two characters. {digraph} is a string with one UTF-8
  1383. encoded character. *E1215*
  1384. Be careful, composing characters are NOT ignored. This
  1385. function is similar to |:digraphs| command, but useful to add
  1386. digraphs start with a white space.
  1387. The function result is v:true if |digraph| is registered. If
  1388. this fails an error message is given and v:false is returned.
  1389. If you want to define multiple digraphs at once, you can use
  1390. |digraph_setlist()|.
  1391. Example: >vim
  1392. call digraph_set(' ', 'あ')
  1393. <
  1394. Parameters: ~
  1395. • {chars} (`string`)
  1396. • {digraph} (`string`)
  1397. Return: ~
  1398. (`any`)
  1399. digraph_setlist({digraphlist}) *digraph_setlist()*
  1400. Similar to |digraph_set()| but this function can add multiple
  1401. digraphs at once. {digraphlist} is a list composed of lists,
  1402. where each list contains two strings with {chars} and
  1403. {digraph} as in |digraph_set()|. *E1216*
  1404. Example: >vim
  1405. call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
  1406. <
  1407. It is similar to the following: >vim
  1408. for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
  1409. call digraph_set(chars, digraph)
  1410. endfor
  1411. < Except that the function returns after the first error,
  1412. following digraphs will not be added.
  1413. Parameters: ~
  1414. • {digraphlist} (`table<integer,string[]>`)
  1415. Return: ~
  1416. (`any`)
  1417. empty({expr}) *empty()*
  1418. Return the Number 1 if {expr} is empty, zero otherwise.
  1419. - A |List| or |Dictionary| is empty when it does not have any
  1420. items.
  1421. - A |String| is empty when its length is zero.
  1422. - A |Number| and |Float| are empty when their value is zero.
  1423. - |v:false| and |v:null| are empty, |v:true| is not.
  1424. - A |Blob| is empty when its length is zero.
  1425. Parameters: ~
  1426. • {expr} (`any`)
  1427. Return: ~
  1428. (`any`)
  1429. environ() *environ()*
  1430. Return all of environment variables as dictionary. You can
  1431. check if an environment variable exists like this: >vim
  1432. echo has_key(environ(), 'HOME')
  1433. < Note that the variable name may be CamelCase; to ignore case
  1434. use this: >vim
  1435. echo index(keys(environ()), 'HOME', 0, 1) != -1
  1436. <
  1437. Return: ~
  1438. (`any`)
  1439. escape({string}, {chars}) *escape()*
  1440. Escape the characters in {chars} that occur in {string} with a
  1441. backslash. Example: >vim
  1442. echo escape('c:\program files\vim', ' \')
  1443. < results in: >
  1444. c:\\program\ files\\vim
  1445. < Also see |shellescape()| and |fnameescape()|.
  1446. Parameters: ~
  1447. • {string} (`string`)
  1448. • {chars} (`string`)
  1449. Return: ~
  1450. (`any`)
  1451. eval({string}) *eval()*
  1452. Evaluate {string} and return the result. Especially useful to
  1453. turn the result of |string()| back into the original value.
  1454. This works for Numbers, Floats, Strings, Blobs and composites
  1455. of them. Also works for |Funcref|s that refer to existing
  1456. functions.
  1457. Parameters: ~
  1458. • {string} (`string`)
  1459. Return: ~
  1460. (`any`)
  1461. eventhandler() *eventhandler()*
  1462. Returns 1 when inside an event handler. That is that Vim got
  1463. interrupted while waiting for the user to type a character,
  1464. e.g., when dropping a file on Vim. This means interactive
  1465. commands cannot be used. Otherwise zero is returned.
  1466. Return: ~
  1467. (`any`)
  1468. executable({expr}) *executable()*
  1469. This function checks if an executable with the name {expr}
  1470. exists. {expr} must be the name of the program without any
  1471. arguments.
  1472. executable() uses the value of $PATH and/or the normal
  1473. searchpath for programs.
  1474. *PATHEXT*
  1475. On MS-Windows the ".exe", ".bat", etc. can optionally be
  1476. included. Then the extensions in $PATHEXT are tried. Thus if
  1477. "foo.exe" does not exist, "foo.exe.bat" can be found. If
  1478. $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot
  1479. by itself can be used in $PATHEXT to try using the name
  1480. without an extension. When 'shell' looks like a Unix shell,
  1481. then the name is also tried without adding an extension.
  1482. On MS-Windows it only checks if the file exists and is not a
  1483. directory, not if it's really executable.
  1484. On MS-Windows an executable in the same directory as the Vim
  1485. executable is always found (it's added to $PATH at |startup|).
  1486. *NoDefaultCurrentDirectoryInExePath*
  1487. On MS-Windows an executable in Vim's current working directory
  1488. is also normally found, but this can be disabled by setting
  1489. the $NoDefaultCurrentDirectoryInExePath environment variable.
  1490. The result is a Number:
  1491. 1 exists
  1492. 0 does not exist
  1493. |exepath()| can be used to get the full path of an executable.
  1494. Parameters: ~
  1495. • {expr} (`string`)
  1496. Return: ~
  1497. (`0|1`)
  1498. execute({command} [, {silent}]) *execute()*
  1499. Execute {command} and capture its output.
  1500. If {command} is a |String|, returns {command} output.
  1501. If {command} is a |List|, returns concatenated outputs.
  1502. Line continuations in {command} are not recognized.
  1503. Examples: >vim
  1504. echo execute('echon "foo"')
  1505. < foo >vim
  1506. echo execute(['echon "foo"', 'echon "bar"'])
  1507. < foobar
  1508. The optional {silent} argument can have these values:
  1509. "" no `:silent` used
  1510. "silent" `:silent` used
  1511. "silent!" `:silent!` used
  1512. The default is "silent". Note that with "silent!", unlike
  1513. `:redir`, error messages are dropped.
  1514. To get a list of lines use `split()` on the result: >vim
  1515. execute('args')->split("\n")
  1516. < This function is not available in the |sandbox|.
  1517. Note: If nested, an outer execute() will not observe output of
  1518. the inner calls.
  1519. Note: Text attributes (highlights) are not captured.
  1520. To execute a command in another window than the current one
  1521. use `win_execute()`.
  1522. Parameters: ~
  1523. • {command} (`string|string[]`)
  1524. • {silent} (`''|'silent'|'silent!'?`)
  1525. Return: ~
  1526. (`string`)
  1527. exepath({expr}) *exepath()*
  1528. Returns the full path of {expr} if it is an executable and
  1529. given as a (partial or full) path or is found in $PATH.
  1530. Returns empty string otherwise.
  1531. If {expr} starts with "./" the |current-directory| is used.
  1532. Parameters: ~
  1533. • {expr} (`string`)
  1534. Return: ~
  1535. (`string`)
  1536. exists({expr}) *exists()*
  1537. The result is a Number, which is |TRUE| if {expr} is
  1538. defined, zero otherwise.
  1539. For checking for a supported feature use |has()|.
  1540. For checking if a file exists use |filereadable()|.
  1541. The {expr} argument is a string, which contains one of these:
  1542. varname internal variable (see
  1543. dict.key |internal-variables|). Also works
  1544. list[i] for |curly-braces-names|, |Dictionary|
  1545. entries, |List| items, etc.
  1546. Beware that evaluating an index may
  1547. cause an error message for an invalid
  1548. expression. E.g.: >vim
  1549. let l = [1, 2, 3]
  1550. echo exists("l[5]")
  1551. < 0 >vim
  1552. echo exists("l[xx]")
  1553. < E121: Undefined variable: xx
  1554. 0
  1555. &option-name Vim option (only checks if it exists,
  1556. not if it really works)
  1557. +option-name Vim option that works.
  1558. $ENVNAME environment variable (could also be
  1559. done by comparing with an empty
  1560. string)
  1561. `*funcname` built-in function (see |functions|)
  1562. or user defined function (see
  1563. |user-function|). Also works for a
  1564. variable that is a Funcref.
  1565. :cmdname Ex command: built-in command, user
  1566. command or command modifier |:command|.
  1567. Returns:
  1568. 1 for match with start of a command
  1569. 2 full match with a command
  1570. 3 matches several user commands
  1571. To check for a supported command
  1572. always check the return value to be 2.
  1573. :2match The |:2match| command.
  1574. :3match The |:3match| command (but you
  1575. probably should not use it, it is
  1576. reserved for internal usage)
  1577. #event autocommand defined for this event
  1578. #event#pattern autocommand defined for this event and
  1579. pattern (the pattern is taken
  1580. literally and compared to the
  1581. autocommand patterns character by
  1582. character)
  1583. #group autocommand group exists
  1584. #group#event autocommand defined for this group and
  1585. event.
  1586. #group#event#pattern
  1587. autocommand defined for this group,
  1588. event and pattern.
  1589. ##event autocommand for this event is
  1590. supported.
  1591. Examples: >vim
  1592. echo exists("&mouse")
  1593. echo exists("$HOSTNAME")
  1594. echo exists("*strftime")
  1595. echo exists("*s:MyFunc")
  1596. echo exists("*MyFunc")
  1597. echo exists("*v:lua.Func")
  1598. echo exists("bufcount")
  1599. echo exists(":Make")
  1600. echo exists("#CursorHold")
  1601. echo exists("#BufReadPre#*.gz")
  1602. echo exists("#filetypeindent")
  1603. echo exists("#filetypeindent#FileType")
  1604. echo exists("#filetypeindent#FileType#*")
  1605. echo exists("##ColorScheme")
  1606. < There must be no space between the symbol (&/$/*/#) and the
  1607. name.
  1608. There must be no extra characters after the name, although in
  1609. a few cases this is ignored. That may become stricter in the
  1610. future, thus don't count on it!
  1611. Working example: >vim
  1612. echo exists(":make")
  1613. < NOT working example: >vim
  1614. echo exists(":make install")
  1615. < Note that the argument must be a string, not the name of the
  1616. variable itself. For example: >vim
  1617. echo exists(bufcount)
  1618. < This doesn't check for existence of the "bufcount" variable,
  1619. but gets the value of "bufcount", and checks if that exists.
  1620. Parameters: ~
  1621. • {expr} (`string`)
  1622. Return: ~
  1623. (`0|1`)
  1624. exp({expr}) *exp()*
  1625. Return the exponential of {expr} as a |Float| in the range
  1626. [0, inf].
  1627. {expr} must evaluate to a |Float| or a |Number|.
  1628. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  1629. Examples: >vim
  1630. echo exp(2)
  1631. < 7.389056 >vim
  1632. echo exp(-1)
  1633. < 0.367879
  1634. Parameters: ~
  1635. • {expr} (`number`)
  1636. Return: ~
  1637. (`any`)
  1638. expand({string} [, {nosuf} [, {list}]]) *expand()*
  1639. Expand wildcards and the following special keywords in
  1640. {string}. 'wildignorecase' applies.
  1641. If {list} is given and it is |TRUE|, a List will be returned.
  1642. Otherwise the result is a String and when there are several
  1643. matches, they are separated by <NL> characters.
  1644. If the expansion fails, the result is an empty string. A name
  1645. for a non-existing file is not included, unless {string} does
  1646. not start with '%', '#' or '<', see below.
  1647. When {string} starts with '%', '#' or '<', the expansion is
  1648. done like for the |cmdline-special| variables with their
  1649. associated modifiers. Here is a short overview:
  1650. % current file name
  1651. # alternate file name
  1652. #n alternate file name n
  1653. <cfile> file name under the cursor
  1654. <afile> autocmd file name
  1655. <abuf> autocmd buffer number (as a String!)
  1656. <amatch> autocmd matched name
  1657. <cexpr> C expression under the cursor
  1658. <sfile> sourced script file or function name
  1659. <slnum> sourced script line number or function
  1660. line number
  1661. <sflnum> script file line number, also when in
  1662. a function
  1663. <SID> "<SNR>123_" where "123" is the
  1664. current script ID |<SID>|
  1665. <script> sourced script file, or script file
  1666. where the current function was defined
  1667. <stack> call stack
  1668. <cword> word under the cursor
  1669. <cWORD> WORD under the cursor
  1670. <client> the {clientid} of the last received
  1671. message
  1672. Modifiers:
  1673. :p expand to full path
  1674. :h head (last path component removed)
  1675. :t tail (last path component only)
  1676. :r root (one extension removed)
  1677. :e extension only
  1678. Example: >vim
  1679. let &tags = expand("%:p:h") .. "/tags"
  1680. < Note that when expanding a string that starts with '%', '#' or
  1681. '<', any following text is ignored. This does NOT work: >vim
  1682. let doesntwork = expand("%:h.bak")
  1683. < Use this: >vim
  1684. let doeswork = expand("%:h") .. ".bak"
  1685. < Also note that expanding "<cfile>" and others only returns the
  1686. referenced file name without further expansion. If "<cfile>"
  1687. is "~/.cshrc", you need to do another expand() to have the
  1688. "~/" expanded into the path of the home directory: >vim
  1689. echo expand(expand("<cfile>"))
  1690. <
  1691. There cannot be white space between the variables and the
  1692. following modifier. The |fnamemodify()| function can be used
  1693. to modify normal file names.
  1694. When using '%' or '#', and the current or alternate file name
  1695. is not defined, an empty string is used. Using "%:p" in a
  1696. buffer with no name, results in the current directory, with a
  1697. '/' added.
  1698. When 'verbose' is set then expanding '%', '#' and <> items
  1699. will result in an error message if the argument cannot be
  1700. expanded.
  1701. When {string} does not start with '%', '#' or '<', it is
  1702. expanded like a file name is expanded on the command line.
  1703. 'suffixes' and 'wildignore' are used, unless the optional
  1704. {nosuf} argument is given and it is |TRUE|.
  1705. Names for non-existing files are included. The "**" item can
  1706. be used to search in a directory tree. For example, to find
  1707. all "README" files in the current directory and below: >vim
  1708. echo expand("**/README")
  1709. <
  1710. expand() can also be used to expand variables and environment
  1711. variables that are only known in a shell. But this can be
  1712. slow, because a shell may be used to do the expansion. See
  1713. |expr-env-expand|.
  1714. The expanded variable is still handled like a list of file
  1715. names. When an environment variable cannot be expanded, it is
  1716. left unchanged. Thus ":echo expand('$FOOBAR')" results in
  1717. "$FOOBAR".
  1718. See |glob()| for finding existing files. See |system()| for
  1719. getting the raw output of an external command.
  1720. Parameters: ~
  1721. • {string} (`string`)
  1722. • {nosuf} (`boolean?`)
  1723. • {list} (`nil|false?`)
  1724. Return: ~
  1725. (`string`)
  1726. expandcmd({string} [, {options}]) *expandcmd()*
  1727. Expand special items in String {string} like what is done for
  1728. an Ex command such as `:edit`. This expands special keywords,
  1729. like with |expand()|, and environment variables, anywhere in
  1730. {string}. "~user" and "~/path" are only expanded at the
  1731. start.
  1732. The following items are supported in the {options} Dict
  1733. argument:
  1734. errmsg If set to TRUE, error messages are displayed
  1735. if an error is encountered during expansion.
  1736. By default, error messages are not displayed.
  1737. Returns the expanded string. If an error is encountered
  1738. during expansion, the unmodified {string} is returned.
  1739. Example: >vim
  1740. echo expandcmd('make %<.o')
  1741. < >
  1742. make /path/runtime/doc/builtin.o
  1743. < >vim
  1744. echo expandcmd('make %<.o', {'errmsg': v:true})
  1745. <
  1746. Parameters: ~
  1747. • {string} (`string`)
  1748. • {options} (`table?`)
  1749. Return: ~
  1750. (`any`)
  1751. extend({expr1}, {expr2} [, {expr3}]) *extend()*
  1752. {expr1} and {expr2} must be both |Lists| or both
  1753. |Dictionaries|.
  1754. If they are |Lists|: Append {expr2} to {expr1}.
  1755. If {expr3} is given insert the items of {expr2} before the
  1756. item with index {expr3} in {expr1}. When {expr3} is zero
  1757. insert before the first item. When {expr3} is equal to
  1758. len({expr1}) then {expr2} is appended.
  1759. Examples: >vim
  1760. echo sort(extend(mylist, [7, 5]))
  1761. call extend(mylist, [2, 3], 1)
  1762. < When {expr1} is the same List as {expr2} then the number of
  1763. items copied is equal to the original length of the List.
  1764. E.g., when {expr3} is 1 you get N new copies of the first item
  1765. (where N is the original length of the List).
  1766. Use |add()| to concatenate one item to a list. To concatenate
  1767. two lists into a new list use the + operator: >vim
  1768. let newlist = [1, 2, 3] + [4, 5]
  1769. <
  1770. If they are |Dictionaries|:
  1771. Add all entries from {expr2} to {expr1}.
  1772. If a key exists in both {expr1} and {expr2} then {expr3} is
  1773. used to decide what to do:
  1774. {expr3} = "keep": keep the value of {expr1}
  1775. {expr3} = "force": use the value of {expr2}
  1776. {expr3} = "error": give an error message *E737*
  1777. When {expr3} is omitted then "force" is assumed.
  1778. {expr1} is changed when {expr2} is not empty. If necessary
  1779. make a copy of {expr1} first.
  1780. {expr2} remains unchanged.
  1781. When {expr1} is locked and {expr2} is not empty the operation
  1782. fails.
  1783. Returns {expr1}. Returns 0 on error.
  1784. Parameters: ~
  1785. • {expr1} (`table`)
  1786. • {expr2} (`table`)
  1787. • {expr3} (`table?`)
  1788. Return: ~
  1789. (`any`)
  1790. extendnew({expr1}, {expr2} [, {expr3}]) *extendnew()*
  1791. Like |extend()| but instead of adding items to {expr1} a new
  1792. List or Dictionary is created and returned. {expr1} remains
  1793. unchanged.
  1794. Parameters: ~
  1795. • {expr1} (`table`)
  1796. • {expr2} (`table`)
  1797. • {expr3} (`table?`)
  1798. Return: ~
  1799. (`any`)
  1800. feedkeys({string} [, {mode}]) *feedkeys()*
  1801. Characters in {string} are queued for processing as if they
  1802. come from a mapping or were typed by the user.
  1803. By default the string is added to the end of the typeahead
  1804. buffer, thus if a mapping is still being executed the
  1805. characters come after them. Use the 'i' flag to insert before
  1806. other characters, they will be executed next, before any
  1807. characters from a mapping.
  1808. The function does not wait for processing of keys contained in
  1809. {string}.
  1810. To include special keys into {string}, use double-quotes
  1811. and "\..." notation |expr-quote|. For example,
  1812. feedkeys("\<CR>") simulates pressing of the <Enter> key. But
  1813. feedkeys('\<CR>') pushes 5 characters.
  1814. The |<Ignore>| keycode may be used to exit the
  1815. wait-for-character without doing anything.
  1816. {mode} is a String, which can contain these character flags:
  1817. 'm' Remap keys. This is default. If {mode} is absent,
  1818. keys are remapped.
  1819. 'n' Do not remap keys.
  1820. 't' Handle keys as if typed; otherwise they are handled as
  1821. if coming from a mapping. This matters for undo,
  1822. opening folds, etc.
  1823. 'L' Lowlevel input. Other flags are not used.
  1824. 'i' Insert the string instead of appending (see above).
  1825. 'x' Execute commands until typeahead is empty. This is
  1826. similar to using ":normal!". You can call feedkeys()
  1827. several times without 'x' and then one time with 'x'
  1828. (possibly with an empty {string}) to execute all the
  1829. typeahead. Note that when Vim ends in Insert mode it
  1830. will behave as if <Esc> is typed, to avoid getting
  1831. stuck, waiting for a character to be typed before the
  1832. script continues.
  1833. Note that if you manage to call feedkeys() while
  1834. executing commands, thus calling it recursively, then
  1835. all typeahead will be consumed by the last call.
  1836. '!' When used with 'x' will not end Insert mode. Can be
  1837. used in a test when a timer is set to exit Insert mode
  1838. a little later. Useful for testing CursorHoldI.
  1839. Return value is always 0.
  1840. Parameters: ~
  1841. • {string} (`string`)
  1842. • {mode} (`string?`)
  1843. Return: ~
  1844. (`any`)
  1845. filecopy({from}, {to}) *filecopy()*
  1846. Copy the file pointed to by the name {from} to {to}. The
  1847. result is a Number, which is |TRUE| if the file was copied
  1848. successfully, and |FALSE| when it failed.
  1849. If a file with name {to} already exists, it will fail.
  1850. Note that it does not handle directories (yet).
  1851. This function is not available in the |sandbox|.
  1852. Parameters: ~
  1853. • {from} (`string`)
  1854. • {to} (`string`)
  1855. Return: ~
  1856. (`0|1`)
  1857. filereadable({file}) *filereadable()*
  1858. The result is a Number, which is |TRUE| when a file with the
  1859. name {file} exists, and can be read. If {file} doesn't exist,
  1860. or is a directory, the result is |FALSE|. {file} is any
  1861. expression, which is used as a String.
  1862. If you don't care about the file being readable you can use
  1863. |glob()|.
  1864. {file} is used as-is, you may want to expand wildcards first: >vim
  1865. echo filereadable('~/.vimrc')
  1866. < >
  1867. 0
  1868. < >vim
  1869. echo filereadable(expand('~/.vimrc'))
  1870. < >
  1871. 1
  1872. <
  1873. Parameters: ~
  1874. • {file} (`string`)
  1875. Return: ~
  1876. (`0|1`)
  1877. filewritable({file}) *filewritable()*
  1878. The result is a Number, which is 1 when a file with the
  1879. name {file} exists, and can be written. If {file} doesn't
  1880. exist, or is not writable, the result is 0. If {file} is a
  1881. directory, and we can write to it, the result is 2.
  1882. Parameters: ~
  1883. • {file} (`string`)
  1884. Return: ~
  1885. (`0|1`)
  1886. filter({expr1}, {expr2}) *filter()*
  1887. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  1888. For each item in {expr1} evaluate {expr2} and when the result
  1889. is zero or false remove the item from the |List| or
  1890. |Dictionary|. Similarly for each byte in a |Blob| and each
  1891. character in a |String|.
  1892. {expr2} must be a |string| or |Funcref|.
  1893. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  1894. of the current item. For a |Dictionary| |v:key| has the key
  1895. of the current item and for a |List| |v:key| has the index of
  1896. the current item. For a |Blob| |v:key| has the index of the
  1897. current byte. For a |String| |v:key| has the index of the
  1898. current character.
  1899. Examples: >vim
  1900. call filter(mylist, 'v:val !~ "OLD"')
  1901. < Removes the items where "OLD" appears. >vim
  1902. call filter(mydict, 'v:key >= 8')
  1903. < Removes the items with a key below 8. >vim
  1904. call filter(var, 0)
  1905. < Removes all the items, thus clears the |List| or |Dictionary|.
  1906. Note that {expr2} is the result of expression and is then
  1907. used as an expression again. Often it is good to use a
  1908. |literal-string| to avoid having to double backslashes.
  1909. If {expr2} is a |Funcref| it must take two arguments:
  1910. 1. the key or the index of the current item.
  1911. 2. the value of the current item.
  1912. The function must return |TRUE| if the item should be kept.
  1913. Example that keeps the odd items of a list: >vim
  1914. func Odd(idx, val)
  1915. return a:idx % 2 == 1
  1916. endfunc
  1917. call filter(mylist, function('Odd'))
  1918. < It is shorter when using a |lambda|: >vim
  1919. call filter(myList, {idx, val -> idx * val <= 42})
  1920. < If you do not use "val" you can leave it out: >vim
  1921. call filter(myList, {idx -> idx % 2 == 1})
  1922. <
  1923. For a |List| and a |Dictionary| the operation is done
  1924. in-place. If you want it to remain unmodified make a copy
  1925. first: >vim
  1926. let l = filter(copy(mylist), 'v:val =~ "KEEP"')
  1927. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  1928. or a new |Blob| or |String|.
  1929. When an error is encountered while evaluating {expr2} no
  1930. further items in {expr1} are processed.
  1931. When {expr2} is a Funcref errors inside a function are ignored,
  1932. unless it was defined with the "abort" flag.
  1933. Parameters: ~
  1934. • {expr1} (`string|table`)
  1935. • {expr2} (`string|function`)
  1936. Return: ~
  1937. (`any`)
  1938. finddir({name} [, {path} [, {count}]]) *finddir()*
  1939. Find directory {name} in {path}. Supports both downwards and
  1940. upwards recursive directory searches. See |file-searching|
  1941. for the syntax of {path}.
  1942. Returns the path of the first found match. When the found
  1943. directory is below the current directory a relative path is
  1944. returned. Otherwise a full path is returned.
  1945. If {path} is omitted or empty then 'path' is used.
  1946. If the optional {count} is given, find {count}'s occurrence of
  1947. {name} in {path} instead of the first one.
  1948. When {count} is negative return all the matches in a |List|.
  1949. Returns an empty string if the directory is not found.
  1950. This is quite similar to the ex-command `:find`.
  1951. Parameters: ~
  1952. • {name} (`string`)
  1953. • {path} (`string?`)
  1954. • {count} (`integer?`)
  1955. Return: ~
  1956. (`any`)
  1957. findfile({name} [, {path} [, {count}]]) *findfile()*
  1958. Just like |finddir()|, but find a file instead of a directory.
  1959. Uses 'suffixesadd'.
  1960. Example: >vim
  1961. echo findfile("tags.vim", ".;")
  1962. < Searches from the directory of the current file upwards until
  1963. it finds the file "tags.vim".
  1964. Parameters: ~
  1965. • {name} (`string`)
  1966. • {path} (`string?`)
  1967. • {count} (`any?`)
  1968. Return: ~
  1969. (`any`)
  1970. flatten({list} [, {maxdepth}]) *flatten()*
  1971. Flatten {list} up to {maxdepth} levels. Without {maxdepth}
  1972. the result is a |List| without nesting, as if {maxdepth} is
  1973. a very large number.
  1974. The {list} is changed in place, use |flattennew()| if you do
  1975. not want that.
  1976. *E900*
  1977. {maxdepth} means how deep in nested lists changes are made.
  1978. {list} is not modified when {maxdepth} is 0.
  1979. {maxdepth} must be positive number.
  1980. If there is an error the number zero is returned.
  1981. Example: >vim
  1982. echo flatten([1, [2, [3, 4]], 5])
  1983. < [1, 2, 3, 4, 5] >vim
  1984. echo flatten([1, [2, [3, 4]], 5], 1)
  1985. < [1, 2, [3, 4], 5]
  1986. Parameters: ~
  1987. • {list} (`any[]`)
  1988. • {maxdepth} (`integer?`)
  1989. Return: ~
  1990. (`any[]|0`)
  1991. flattennew({list} [, {maxdepth}]) *flattennew()*
  1992. Like |flatten()| but first make a copy of {list}.
  1993. Parameters: ~
  1994. • {list} (`any[]`)
  1995. • {maxdepth} (`integer?`)
  1996. Return: ~
  1997. (`any[]|0`)
  1998. float2nr({expr}) *float2nr()*
  1999. Convert {expr} to a Number by omitting the part after the
  2000. decimal point.
  2001. {expr} must evaluate to a |Float| or a |Number|.
  2002. Returns 0 if {expr} is not a |Float| or a |Number|.
  2003. When the value of {expr} is out of range for a |Number| the
  2004. result is truncated to 0x7fffffff or -0x7fffffff (or when
  2005. 64-bit Number support is enabled, 0x7fffffffffffffff or
  2006. -0x7fffffffffffffff). NaN results in -0x80000000 (or when
  2007. 64-bit Number support is enabled, -0x8000000000000000).
  2008. Examples: >vim
  2009. echo float2nr(3.95)
  2010. < 3 >vim
  2011. echo float2nr(-23.45)
  2012. < -23 >vim
  2013. echo float2nr(1.0e100)
  2014. < 2147483647 (or 9223372036854775807) >vim
  2015. echo float2nr(-1.0e150)
  2016. < -2147483647 (or -9223372036854775807) >vim
  2017. echo float2nr(1.0e-100)
  2018. < 0
  2019. Parameters: ~
  2020. • {expr} (`number`)
  2021. Return: ~
  2022. (`any`)
  2023. floor({expr}) *floor()*
  2024. Return the largest integral value less than or equal to
  2025. {expr} as a |Float| (round down).
  2026. {expr} must evaluate to a |Float| or a |Number|.
  2027. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  2028. Examples: >vim
  2029. echo floor(1.856)
  2030. < 1.0 >vim
  2031. echo floor(-5.456)
  2032. < -6.0 >vim
  2033. echo floor(4.0)
  2034. < 4.0
  2035. Parameters: ~
  2036. • {expr} (`number`)
  2037. Return: ~
  2038. (`any`)
  2039. fmod({expr1}, {expr2}) *fmod()*
  2040. Return the remainder of {expr1} / {expr2}, even if the
  2041. division is not representable. Returns {expr1} - i * {expr2}
  2042. for some integer i such that if {expr2} is non-zero, the
  2043. result has the same sign as {expr1} and magnitude less than
  2044. the magnitude of {expr2}. If {expr2} is zero, the value
  2045. returned is zero. The value returned is a |Float|.
  2046. {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
  2047. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
  2048. |Number|.
  2049. Examples: >vim
  2050. echo fmod(12.33, 1.22)
  2051. < 0.13 >vim
  2052. echo fmod(-12.33, 1.22)
  2053. < -0.13
  2054. Parameters: ~
  2055. • {expr1} (`number`)
  2056. • {expr2} (`number`)
  2057. Return: ~
  2058. (`any`)
  2059. fnameescape({string}) *fnameescape()*
  2060. Escape {string} for use as file name command argument. All
  2061. characters that have a special meaning, such as `'%'` and `'|'`
  2062. are escaped with a backslash.
  2063. For most systems the characters escaped are
  2064. " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash
  2065. appears in a filename, it depends on the value of 'isfname'.
  2066. A leading '+' and '>' is also escaped (special after |:edit|
  2067. and |:write|). And a "-" by itself (special after |:cd|).
  2068. Returns an empty string on error.
  2069. Example: >vim
  2070. let fname = '+some str%nge|name'
  2071. exe "edit " .. fnameescape(fname)
  2072. < results in executing: >vim
  2073. edit \+some\ str\%nge\|name
  2074. <
  2075. Parameters: ~
  2076. • {string} (`string`)
  2077. Return: ~
  2078. (`string`)
  2079. fnamemodify({fname}, {mods}) *fnamemodify()*
  2080. Modify file name {fname} according to {mods}. {mods} is a
  2081. string of characters like it is used for file names on the
  2082. command line. See |filename-modifiers|.
  2083. Example: >vim
  2084. echo fnamemodify("main.c", ":p:h")
  2085. < results in: >
  2086. /home/user/vim/vim/src
  2087. < If {mods} is empty or an unsupported modifier is used then
  2088. {fname} is returned.
  2089. When {fname} is empty then with {mods} ":h" returns ".", so
  2090. that `:cd` can be used with it. This is different from
  2091. expand('%:h') without a buffer name, which returns an empty
  2092. string.
  2093. Note: Environment variables don't work in {fname}, use
  2094. |expand()| first then.
  2095. Parameters: ~
  2096. • {fname} (`string`)
  2097. • {mods} (`string`)
  2098. Return: ~
  2099. (`string`)
  2100. foldclosed({lnum}) *foldclosed()*
  2101. The result is a Number. If the line {lnum} is in a closed
  2102. fold, the result is the number of the first line in that fold.
  2103. If the line {lnum} is not in a closed fold, -1 is returned.
  2104. {lnum} is used like with |getline()|. Thus "." is the current
  2105. line, "'m" mark m, etc.
  2106. Parameters: ~
  2107. • {lnum} (`integer`)
  2108. Return: ~
  2109. (`integer`)
  2110. foldclosedend({lnum}) *foldclosedend()*
  2111. The result is a Number. If the line {lnum} is in a closed
  2112. fold, the result is the number of the last line in that fold.
  2113. If the line {lnum} is not in a closed fold, -1 is returned.
  2114. {lnum} is used like with |getline()|. Thus "." is the current
  2115. line, "'m" mark m, etc.
  2116. Parameters: ~
  2117. • {lnum} (`integer`)
  2118. Return: ~
  2119. (`integer`)
  2120. foldlevel({lnum}) *foldlevel()*
  2121. The result is a Number, which is the foldlevel of line {lnum}
  2122. in the current buffer. For nested folds the deepest level is
  2123. returned. If there is no fold at line {lnum}, zero is
  2124. returned. It doesn't matter if the folds are open or closed.
  2125. When used while updating folds (from 'foldexpr') -1 is
  2126. returned for lines where folds are still to be updated and the
  2127. foldlevel is unknown. As a special case the level of the
  2128. previous line is usually available.
  2129. {lnum} is used like with |getline()|. Thus "." is the current
  2130. line, "'m" mark m, etc.
  2131. Parameters: ~
  2132. • {lnum} (`integer`)
  2133. Return: ~
  2134. (`integer`)
  2135. foldtext() *foldtext()*
  2136. Returns a String, to be displayed for a closed fold. This is
  2137. the default function used for the 'foldtext' option and should
  2138. only be called from evaluating 'foldtext'. It uses the
  2139. |v:foldstart|, |v:foldend| and |v:folddashes| variables.
  2140. The returned string looks like this: >
  2141. +-- 45 lines: abcdef
  2142. < The number of leading dashes depends on the foldlevel. The
  2143. "45" is the number of lines in the fold. "abcdef" is the text
  2144. in the first non-blank line of the fold. Leading white space,
  2145. "//" or "/*" and the text from the 'foldmarker' and
  2146. 'commentstring' options is removed.
  2147. When used to draw the actual foldtext, the rest of the line
  2148. will be filled with the fold char from the 'fillchars'
  2149. setting.
  2150. Returns an empty string when there is no fold.
  2151. Return: ~
  2152. (`string`)
  2153. foldtextresult({lnum}) *foldtextresult()*
  2154. Returns the text that is displayed for the closed fold at line
  2155. {lnum}. Evaluates 'foldtext' in the appropriate context.
  2156. When there is no closed fold at {lnum} an empty string is
  2157. returned.
  2158. {lnum} is used like with |getline()|. Thus "." is the current
  2159. line, "'m" mark m, etc.
  2160. Useful when exporting folded text, e.g., to HTML.
  2161. Parameters: ~
  2162. • {lnum} (`integer`)
  2163. Return: ~
  2164. (`string`)
  2165. foreach({expr1}, {expr2}) *foreach()*
  2166. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  2167. For each item in {expr1} execute {expr2}. {expr1} is not
  2168. modified; its values may be, as with |:lockvar| 1. |E741|
  2169. See |map()| and |filter()| to modify {expr1}.
  2170. {expr2} must be a |string| or |Funcref|.
  2171. If {expr2} is a |string|, inside {expr2} |v:val| has the value
  2172. of the current item. For a |Dictionary| |v:key| has the key
  2173. of the current item and for a |List| |v:key| has the index of
  2174. the current item. For a |Blob| |v:key| has the index of the
  2175. current byte. For a |String| |v:key| has the index of the
  2176. current character.
  2177. Examples: >vim
  2178. call foreach(mylist, 'let used[v:val] = v:true')
  2179. < This records the items that are in the {expr1} list.
  2180. Note that {expr2} is the result of expression and is then used
  2181. as a command. Often it is good to use a |literal-string| to
  2182. avoid having to double backslashes.
  2183. If {expr2} is a |Funcref| it must take two arguments:
  2184. 1. the key or the index of the current item.
  2185. 2. the value of the current item.
  2186. With a lambda you don't get an error if it only accepts one
  2187. argument.
  2188. If the function returns a value, it is ignored.
  2189. Returns {expr1} in all cases.
  2190. When an error is encountered while executing {expr2} no
  2191. further items in {expr1} are processed.
  2192. When {expr2} is a Funcref errors inside a function are ignored,
  2193. unless it was defined with the "abort" flag.
  2194. Parameters: ~
  2195. • {expr1} (`string|table`)
  2196. • {expr2} (`string|function`)
  2197. Return: ~
  2198. (`any`)
  2199. fullcommand({name}) *fullcommand()*
  2200. Get the full command name from a short abbreviated command
  2201. name; see |20.2| for details on command abbreviations.
  2202. The string argument {name} may start with a `:` and can
  2203. include a [range], these are skipped and not returned.
  2204. Returns an empty string if a command doesn't exist or if it's
  2205. ambiguous (for user-defined commands).
  2206. For example `fullcommand('s')`, `fullcommand('sub')`,
  2207. `fullcommand(':%substitute')` all return "substitute".
  2208. Parameters: ~
  2209. • {name} (`string`)
  2210. Return: ~
  2211. (`string`)
  2212. funcref({name} [, {arglist}] [, {dict}]) *funcref()*
  2213. Just like |function()|, but the returned Funcref will lookup
  2214. the function by reference, not by name. This matters when the
  2215. function {name} is redefined later.
  2216. Unlike |function()|, {name} must be an existing user function.
  2217. It only works for an autoloaded function if it has already
  2218. been loaded (to avoid mistakenly loading the autoload script
  2219. when only intending to use the function name, use |function()|
  2220. instead). {name} cannot be a builtin function.
  2221. Returns 0 on error.
  2222. Parameters: ~
  2223. • {name} (`string`)
  2224. • {arglist} (`any?`)
  2225. • {dict} (`any?`)
  2226. Return: ~
  2227. (`any`)
  2228. function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923*
  2229. Return a |Funcref| variable that refers to function {name}.
  2230. {name} can be the name of a user defined function or an
  2231. internal function.
  2232. {name} can also be a Funcref or a partial. When it is a
  2233. partial the dict stored in it will be used and the {dict}
  2234. argument is not allowed. E.g.: >vim
  2235. let FuncWithArg = function(dict.Func, [arg])
  2236. let Broken = function(dict.Func, [arg], dict)
  2237. <
  2238. When using the Funcref the function will be found by {name},
  2239. also when it was redefined later. Use |funcref()| to keep the
  2240. same function.
  2241. When {arglist} or {dict} is present this creates a partial.
  2242. That means the argument list and/or the dictionary is stored in
  2243. the Funcref and will be used when the Funcref is called.
  2244. The arguments are passed to the function in front of other
  2245. arguments, but after any argument from |method|. Example: >vim
  2246. func Callback(arg1, arg2, name)
  2247. "...
  2248. endfunc
  2249. let Partial = function('Callback', ['one', 'two'])
  2250. "...
  2251. call Partial('name')
  2252. < Invokes the function as with: >vim
  2253. call Callback('one', 'two', 'name')
  2254. < With a |method|: >vim
  2255. func Callback(one, two, three)
  2256. "...
  2257. endfunc
  2258. let Partial = function('Callback', ['two'])
  2259. "...
  2260. eval 'one'->Partial('three')
  2261. < Invokes the function as with: >vim
  2262. call Callback('one', 'two', 'three')
  2263. < The function() call can be nested to add more arguments to the
  2264. Funcref. The extra arguments are appended to the list of
  2265. arguments. Example: >vim
  2266. func Callback(arg1, arg2, name)
  2267. "...
  2268. endfunc
  2269. let Func = function('Callback', ['one'])
  2270. let Func2 = function(Func, ['two'])
  2271. "...
  2272. call Func2('name')
  2273. < Invokes the function as with: >vim
  2274. call Callback('one', 'two', 'name')
  2275. < The Dictionary is only useful when calling a "dict" function.
  2276. In that case the {dict} is passed in as "self". Example: >vim
  2277. function Callback() dict
  2278. echo "called for " .. self.name
  2279. endfunction
  2280. "...
  2281. let context = {"name": "example"}
  2282. let Func = function('Callback', context)
  2283. "...
  2284. call Func() " will echo: called for example
  2285. < The use of function() is not needed when there are no extra
  2286. arguments, these two are equivalent, if Callback() is defined
  2287. as context.Callback(): >vim
  2288. let Func = function('Callback', context)
  2289. let Func = context.Callback
  2290. < The argument list and the Dictionary can be combined: >vim
  2291. function Callback(arg1, count) dict
  2292. "...
  2293. endfunction
  2294. let context = {"name": "example"}
  2295. let Func = function('Callback', ['one'], context)
  2296. "...
  2297. call Func(500)
  2298. < Invokes the function as with: >vim
  2299. call context.Callback('one', 500)
  2300. <
  2301. Returns 0 on error.
  2302. Parameters: ~
  2303. • {name} (`string`)
  2304. • {arglist} (`any?`)
  2305. • {dict} (`any?`)
  2306. Return: ~
  2307. (`any`)
  2308. garbagecollect([{atexit}]) *garbagecollect()*
  2309. Cleanup unused |Lists| and |Dictionaries| that have circular
  2310. references.
  2311. There is hardly ever a need to invoke this function, as it is
  2312. automatically done when Vim runs out of memory or is waiting
  2313. for the user to press a key after 'updatetime'. Items without
  2314. circular references are always freed when they become unused.
  2315. This is useful if you have deleted a very big |List| and/or
  2316. |Dictionary| with circular references in a script that runs
  2317. for a long time.
  2318. When the optional {atexit} argument is one, garbage
  2319. collection will also be done when exiting Vim, if it wasn't
  2320. done before. This is useful when checking for memory leaks.
  2321. The garbage collection is not done immediately but only when
  2322. it's safe to perform. This is when waiting for the user to
  2323. type a character.
  2324. Parameters: ~
  2325. • {atexit} (`boolean?`)
  2326. Return: ~
  2327. (`any`)
  2328. get({list}, {idx} [, {default}]) *get()* *get()-list*
  2329. Get item {idx} from |List| {list}. When this item is not
  2330. available return {default}. Return zero when {default} is
  2331. omitted.
  2332. Parameters: ~
  2333. • {list} (`any[]`)
  2334. • {idx} (`integer`)
  2335. • {default} (`any?`)
  2336. Return: ~
  2337. (`any`)
  2338. get({blob}, {idx} [, {default}]) *get()-blob*
  2339. Get byte {idx} from |Blob| {blob}. When this byte is not
  2340. available return {default}. Return -1 when {default} is
  2341. omitted.
  2342. Parameters: ~
  2343. • {blob} (`string`)
  2344. • {idx} (`integer`)
  2345. • {default} (`any?`)
  2346. Return: ~
  2347. (`any`)
  2348. get({dict}, {key} [, {default}]) *get()-dict*
  2349. Get item with key {key} from |Dictionary| {dict}. When this
  2350. item is not available return {default}. Return zero when
  2351. {default} is omitted. Useful example: >vim
  2352. let val = get(g:, 'var_name', 'default')
  2353. < This gets the value of g:var_name if it exists, and uses
  2354. "default" when it does not exist.
  2355. Parameters: ~
  2356. • {dict} (`table<string,any>`)
  2357. • {key} (`string`)
  2358. • {default} (`any?`)
  2359. Return: ~
  2360. (`any`)
  2361. get({func}, {what}) *get()-func*
  2362. Get item {what} from |Funcref| {func}. Possible values for
  2363. {what} are:
  2364. "name" The function name
  2365. "func" The function
  2366. "dict" The dictionary
  2367. "args" The list with arguments
  2368. "arity" A dictionary with information about the number of
  2369. arguments accepted by the function (minus the
  2370. {arglist}) with the following fields:
  2371. required the number of positional arguments
  2372. optional the number of optional arguments,
  2373. in addition to the required ones
  2374. varargs |TRUE| if the function accepts a
  2375. variable number of arguments |...|
  2376. Note: There is no error, if the {arglist} of
  2377. the Funcref contains more arguments than the
  2378. Funcref expects, it's not validated.
  2379. Returns zero on error.
  2380. Parameters: ~
  2381. • {func} (`function`)
  2382. • {what} (`string`)
  2383. Return: ~
  2384. (`any`)
  2385. getbufinfo([{buf}]) *getbufinfo()*
  2386. getbufinfo([{dict}])
  2387. Get information about buffers as a List of Dictionaries.
  2388. Without an argument information about all the buffers is
  2389. returned.
  2390. When the argument is a |Dictionary| only the buffers matching
  2391. the specified criteria are returned. The following keys can
  2392. be specified in {dict}:
  2393. buflisted include only listed buffers.
  2394. bufloaded include only loaded buffers.
  2395. bufmodified include only modified buffers.
  2396. Otherwise, {buf} specifies a particular buffer to return
  2397. information for. For the use of {buf}, see |bufname()|
  2398. above. If the buffer is found the returned List has one item.
  2399. Otherwise the result is an empty list.
  2400. Each returned List item is a dictionary with the following
  2401. entries:
  2402. bufnr Buffer number.
  2403. changed TRUE if the buffer is modified.
  2404. changedtick Number of changes made to the buffer.
  2405. command TRUE if the buffer belongs to the
  2406. command-line window |cmdwin|.
  2407. hidden TRUE if the buffer is hidden.
  2408. lastused Timestamp in seconds, like
  2409. |localtime()|, when the buffer was
  2410. last used.
  2411. listed TRUE if the buffer is listed.
  2412. lnum Line number used for the buffer when
  2413. opened in the current window.
  2414. Only valid if the buffer has been
  2415. displayed in the window in the past.
  2416. If you want the line number of the
  2417. last known cursor position in a given
  2418. window, use |line()|: >vim
  2419. echo line('.', {winid})
  2420. <
  2421. linecount Number of lines in the buffer (only
  2422. valid when loaded)
  2423. loaded TRUE if the buffer is loaded.
  2424. name Full path to the file in the buffer.
  2425. signs List of signs placed in the buffer.
  2426. Each list item is a dictionary with
  2427. the following fields:
  2428. id sign identifier
  2429. lnum line number
  2430. name sign name
  2431. variables A reference to the dictionary with
  2432. buffer-local variables.
  2433. windows List of |window-ID|s that display this
  2434. buffer
  2435. Examples: >vim
  2436. for buf in getbufinfo()
  2437. echo buf.name
  2438. endfor
  2439. for buf in getbufinfo({'buflisted':1})
  2440. if buf.changed
  2441. " ....
  2442. endif
  2443. endfor
  2444. <
  2445. To get buffer-local options use: >vim
  2446. getbufvar({bufnr}, '&option_name')
  2447. <
  2448. Parameters: ~
  2449. • {dict} (`vim.fn.getbufinfo.dict?`)
  2450. Return: ~
  2451. (`vim.fn.getbufinfo.ret.item[]`)
  2452. getbufline({buf}, {lnum} [, {end}]) *getbufline()*
  2453. Return a |List| with the lines starting from {lnum} to {end}
  2454. (inclusive) in the buffer {buf}. If {end} is omitted, a
  2455. |List| with only the line {lnum} is returned. See
  2456. `getbufoneline()` for only getting the line.
  2457. For the use of {buf}, see |bufname()| above.
  2458. For {lnum} and {end} "$" can be used for the last line of the
  2459. buffer. Otherwise a number must be used.
  2460. When {lnum} is smaller than 1 or bigger than the number of
  2461. lines in the buffer, an empty |List| is returned.
  2462. When {end} is greater than the number of lines in the buffer,
  2463. it is treated as {end} is set to the number of lines in the
  2464. buffer. When {end} is before {lnum} an empty |List| is
  2465. returned.
  2466. This function works only for loaded buffers. For unloaded and
  2467. non-existing buffers, an empty |List| is returned.
  2468. Example: >vim
  2469. let lines = getbufline(bufnr("myfile"), 1, "$")
  2470. <
  2471. Parameters: ~
  2472. • {buf} (`integer|string`)
  2473. • {lnum} (`integer`)
  2474. • {end_} (`integer?`)
  2475. Return: ~
  2476. (`any`)
  2477. getbufoneline({buf}, {lnum}) *getbufoneline()*
  2478. Just like `getbufline()` but only get one line and return it
  2479. as a string.
  2480. Parameters: ~
  2481. • {buf} (`integer|string`)
  2482. • {lnum} (`integer`)
  2483. Return: ~
  2484. (`string`)
  2485. getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
  2486. The result is the value of option or local buffer variable
  2487. {varname} in buffer {buf}. Note that the name without "b:"
  2488. must be used.
  2489. The {varname} argument is a string.
  2490. When {varname} is empty returns a |Dictionary| with all the
  2491. buffer-local variables.
  2492. When {varname} is equal to "&" returns a |Dictionary| with all
  2493. the buffer-local options.
  2494. Otherwise, when {varname} starts with "&" returns the value of
  2495. a buffer-local option.
  2496. This also works for a global or buffer-local option, but it
  2497. doesn't work for a global variable, window-local variable or
  2498. window-local option.
  2499. For the use of {buf}, see |bufname()| above.
  2500. When the buffer or variable doesn't exist {def} or an empty
  2501. string is returned, there is no error message.
  2502. Examples: >vim
  2503. let bufmodified = getbufvar(1, "&mod")
  2504. echo "todo myvar = " .. getbufvar("todo", "myvar")
  2505. Parameters: ~
  2506. • {buf} (`integer|string`)
  2507. • {varname} (`string`)
  2508. • {def} (`any?`)
  2509. Return: ~
  2510. (`any`)
  2511. getcellwidths() *getcellwidths()*
  2512. Returns a |List| of cell widths of character ranges overridden
  2513. by |setcellwidths()|. The format is equal to the argument of
  2514. |setcellwidths()|. If no character ranges have their cell
  2515. widths overridden, an empty List is returned.
  2516. Return: ~
  2517. (`any`)
  2518. getchangelist([{buf}]) *getchangelist()*
  2519. Returns the |changelist| for the buffer {buf}. For the use
  2520. of {buf}, see |bufname()| above. If buffer {buf} doesn't
  2521. exist, an empty list is returned.
  2522. The returned list contains two entries: a list with the change
  2523. locations and the current position in the list. Each
  2524. entry in the change list is a dictionary with the following
  2525. entries:
  2526. col column number
  2527. coladd column offset for 'virtualedit'
  2528. lnum line number
  2529. If buffer {buf} is the current buffer, then the current
  2530. position refers to the position in the list. For other
  2531. buffers, it is set to the length of the list.
  2532. Parameters: ~
  2533. • {buf} (`integer|string?`)
  2534. Return: ~
  2535. (`table[]`)
  2536. getchar([{expr}]) *getchar()*
  2537. Get a single character from the user or input stream.
  2538. If {expr} is omitted, wait until a character is available.
  2539. If {expr} is 0, only get a character when one is available.
  2540. Return zero otherwise.
  2541. If {expr} is 1, only check if a character is available, it is
  2542. not consumed. Return zero if no character available.
  2543. If you prefer always getting a string use |getcharstr()|.
  2544. Without {expr} and when {expr} is 0 a whole character or
  2545. special key is returned. If it is a single character, the
  2546. result is a Number. Use |nr2char()| to convert it to a String.
  2547. Otherwise a String is returned with the encoded character.
  2548. For a special key it's a String with a sequence of bytes
  2549. starting with 0x80 (decimal: 128). This is the same value as
  2550. the String "\<Key>", e.g., "\<Left>". The returned value is
  2551. also a String when a modifier (shift, control, alt) was used
  2552. that is not included in the character.
  2553. When {expr} is 0 and Esc is typed, there will be a short delay
  2554. while Vim waits to see if this is the start of an escape
  2555. sequence.
  2556. When {expr} is 1 only the first byte is returned. For a
  2557. one-byte character it is the character itself as a number.
  2558. Use nr2char() to convert it to a String.
  2559. Use getcharmod() to obtain any additional modifiers.
  2560. When the user clicks a mouse button, the mouse event will be
  2561. returned. The position can then be found in |v:mouse_col|,
  2562. |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
  2563. |getmousepos()| can also be used. Mouse move events will be
  2564. ignored.
  2565. This example positions the mouse as it would normally happen: >vim
  2566. let c = getchar()
  2567. if c == "\<LeftMouse>" && v:mouse_win > 0
  2568. exe v:mouse_win .. "wincmd w"
  2569. exe v:mouse_lnum
  2570. exe "normal " .. v:mouse_col .. "|"
  2571. endif
  2572. <
  2573. There is no prompt, you will somehow have to make clear to the
  2574. user that a character has to be typed. The screen is not
  2575. redrawn, e.g. when resizing the window.
  2576. There is no mapping for the character.
  2577. Key codes are replaced, thus when the user presses the <Del>
  2578. key you get the code for the <Del> key, not the raw character
  2579. sequence. Examples: >vim
  2580. getchar() == "\<Del>"
  2581. getchar() == "\<S-Left>"
  2582. < This example redefines "f" to ignore case: >vim
  2583. nmap f :call FindChar()<CR>
  2584. function FindChar()
  2585. let c = nr2char(getchar())
  2586. while col('.') < col('$') - 1
  2587. normal l
  2588. if getline('.')[col('.') - 1] ==? c
  2589. break
  2590. endif
  2591. endwhile
  2592. endfunction
  2593. <
  2594. Parameters: ~
  2595. • {expr} (`0|1?`)
  2596. Return: ~
  2597. (`integer`)
  2598. getcharmod() *getcharmod()*
  2599. The result is a Number which is the state of the modifiers for
  2600. the last obtained character with getchar() or in another way.
  2601. These values are added together:
  2602. 2 shift
  2603. 4 control
  2604. 8 alt (meta)
  2605. 16 meta (when it's different from ALT)
  2606. 32 mouse double click
  2607. 64 mouse triple click
  2608. 96 mouse quadruple click (== 32 + 64)
  2609. 128 command (Mac) or super
  2610. Only the modifiers that have not been included in the
  2611. character itself are obtained. Thus Shift-a results in "A"
  2612. without a modifier. Returns 0 if no modifiers are used.
  2613. Return: ~
  2614. (`integer`)
  2615. getcharpos({expr}) *getcharpos()*
  2616. Get the position for String {expr}. Same as |getpos()| but the
  2617. column number in the returned List is a character index
  2618. instead of a byte index.
  2619. If |getpos()| returns a very large column number, equal to
  2620. |v:maxcol|, then getcharpos() will return the character index
  2621. of the last character.
  2622. Example:
  2623. With the cursor on '세' in line 5 with text "여보세요": >vim
  2624. getcharpos('.') returns [0, 5, 3, 0]
  2625. getpos('.') returns [0, 5, 7, 0]
  2626. <
  2627. Parameters: ~
  2628. • {expr} (`string`)
  2629. Return: ~
  2630. (`integer[]`)
  2631. getcharsearch() *getcharsearch()*
  2632. Return the current character search information as a {dict}
  2633. with the following entries:
  2634. char character previously used for a character
  2635. search (|t|, |f|, |T|, or |F|); empty string
  2636. if no character search has been performed
  2637. forward direction of character search; 1 for forward,
  2638. 0 for backward
  2639. until type of character search; 1 for a |t| or |T|
  2640. character search, 0 for an |f| or |F|
  2641. character search
  2642. This can be useful to always have |;| and |,| search
  2643. forward/backward regardless of the direction of the previous
  2644. character search: >vim
  2645. nnoremap <expr> ; getcharsearch().forward ? ';' : ','
  2646. nnoremap <expr> , getcharsearch().forward ? ',' : ';'
  2647. < Also see |setcharsearch()|.
  2648. Return: ~
  2649. (`table`)
  2650. getcharstr([{expr}]) *getcharstr()*
  2651. Get a single character from the user or input stream as a
  2652. string.
  2653. If {expr} is omitted, wait until a character is available.
  2654. If {expr} is 0 or false, only get a character when one is
  2655. available. Return an empty string otherwise.
  2656. If {expr} is 1 or true, only check if a character is
  2657. available, it is not consumed. Return an empty string
  2658. if no character is available.
  2659. Otherwise this works like |getchar()|, except that a number
  2660. result is converted to a string.
  2661. Parameters: ~
  2662. • {expr} (`0|1?`)
  2663. Return: ~
  2664. (`string`)
  2665. getcmdcomplpat() *getcmdcomplpat()*
  2666. Return completion pattern of the current command-line.
  2667. Only works when the command line is being edited, thus
  2668. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2669. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2670. |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
  2671. Returns an empty string when completion is not defined.
  2672. Return: ~
  2673. (`string`)
  2674. getcmdcompltype() *getcmdcompltype()*
  2675. Return the type of the current command-line completion.
  2676. Only works when the command line is being edited, thus
  2677. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2678. See |:command-completion| for the return string.
  2679. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2680. |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
  2681. Returns an empty string when completion is not defined.
  2682. Return: ~
  2683. (`string`)
  2684. getcmdline() *getcmdline()*
  2685. Return the current command-line input. Only works when the
  2686. command line is being edited, thus requires use of
  2687. |c_CTRL-\_e| or |c_CTRL-R_=|.
  2688. Example: >vim
  2689. cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
  2690. < Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
  2691. |getcmdprompt()| and |setcmdline()|.
  2692. Returns an empty string when entering a password or using
  2693. |inputsecret()|.
  2694. Return: ~
  2695. (`string`)
  2696. getcmdpos() *getcmdpos()*
  2697. Return the position of the cursor in the command line as a
  2698. byte count. The first column is 1.
  2699. Only works when editing the command line, thus requires use of
  2700. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2701. Returns 0 otherwise.
  2702. Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
  2703. |getcmdprompt()| and |setcmdline()|.
  2704. Return: ~
  2705. (`integer`)
  2706. getcmdprompt() *getcmdprompt()*
  2707. Return the current command-line prompt when using functions
  2708. like |input()| or |confirm()|.
  2709. Only works when the command line is being edited, thus
  2710. requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
  2711. Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
  2712. |setcmdpos()| and |setcmdline()|.
  2713. Return: ~
  2714. (`string`)
  2715. getcmdscreenpos() *getcmdscreenpos()*
  2716. Return the screen position of the cursor in the command line
  2717. as a byte count. The first column is 1.
  2718. Instead of |getcmdpos()|, it adds the prompt position.
  2719. Only works when editing the command line, thus requires use of
  2720. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2721. Returns 0 otherwise.
  2722. Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
  2723. |setcmdline()|.
  2724. Return: ~
  2725. (`any`)
  2726. getcmdtype() *getcmdtype()*
  2727. Return the current command-line type. Possible return values
  2728. are:
  2729. : normal Ex command
  2730. > debug mode command |debug-mode|
  2731. / forward search command
  2732. ? backward search command
  2733. @ |input()| command
  2734. `-` |:insert| or |:append| command
  2735. = |i_CTRL-R_=|
  2736. Only works when editing the command line, thus requires use of
  2737. |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  2738. Returns an empty string otherwise.
  2739. Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
  2740. Return: ~
  2741. (`':'|'>'|'/'|'?'|'@'|'-'|'='`)
  2742. getcmdwintype() *getcmdwintype()*
  2743. Return the current |command-line-window| type. Possible return
  2744. values are the same as |getcmdtype()|. Returns an empty string
  2745. when not in the command-line window.
  2746. Return: ~
  2747. (`':'|'>'|'/'|'?'|'@'|'-'|'='`)
  2748. getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
  2749. Return a list of command-line completion matches. The String
  2750. {type} argument specifies what for. The following completion
  2751. types are supported:
  2752. arglist file names in argument list
  2753. augroup autocmd groups
  2754. buffer buffer names
  2755. breakpoint |:breakadd| and |:breakdel| suboptions
  2756. cmdline |cmdline-completion| result
  2757. color color schemes
  2758. command Ex command
  2759. compiler compilers
  2760. custom,{func} custom completion, defined via {func}
  2761. customlist,{func} custom completion, defined via {func}
  2762. diff_buffer |:diffget| and |:diffput| completion
  2763. dir directory names
  2764. dir_in_path directory names in |'cdpath'|
  2765. environment environment variable names
  2766. event autocommand events
  2767. expression Vim expression
  2768. file file and directory names
  2769. file_in_path file and directory names in |'path'|
  2770. filetype filetype names |'filetype'|
  2771. function function name
  2772. help help subjects
  2773. highlight highlight groups
  2774. history |:history| suboptions
  2775. keymap keyboard mappings
  2776. locale locale names (as output of locale -a)
  2777. mapclear buffer argument
  2778. mapping mapping name
  2779. menu menus
  2780. messages |:messages| suboptions
  2781. option options
  2782. packadd optional package |pack-add| names
  2783. runtime |:runtime| completion
  2784. scriptnames sourced script names |:scriptnames|
  2785. shellcmd Shell command
  2786. shellcmdline Shell command line with filename arguments
  2787. sign |:sign| suboptions
  2788. syntax syntax file names |'syntax'|
  2789. syntime |:syntime| suboptions
  2790. tag tags
  2791. tag_listfiles tags, file names
  2792. user user names
  2793. var user variables
  2794. If {pat} is an empty string, then all the matches are
  2795. returned. Otherwise only items matching {pat} are returned.
  2796. See |wildcards| for the use of special characters in {pat}.
  2797. If the optional {filtered} flag is set to 1, then 'wildignore'
  2798. is applied to filter the results. Otherwise all the matches
  2799. are returned. The 'wildignorecase' option always applies.
  2800. If the 'wildoptions' option contains "fuzzy", then fuzzy
  2801. matching is used to get the completion matches. Otherwise
  2802. regular expression matching is used. Thus this function
  2803. follows the user preference, what happens on the command line.
  2804. If you do not want this you can make 'wildoptions' empty
  2805. before calling getcompletion() and restore it afterwards.
  2806. If {type} is "cmdline", then the |cmdline-completion| result is
  2807. returned. For example, to complete the possible values after
  2808. a ":call" command: >vim
  2809. echo getcompletion('call ', 'cmdline')
  2810. <
  2811. If there are no matches, an empty list is returned. An
  2812. invalid value for {type} produces an error.
  2813. Parameters: ~
  2814. • {pat} (`string`)
  2815. • {type} (`string`)
  2816. • {filtered} (`boolean?`)
  2817. Return: ~
  2818. (`string[]`)
  2819. getcurpos([{winid}]) *getcurpos()*
  2820. Get the position of the cursor. This is like getpos('.'), but
  2821. includes an extra "curswant" item in the list:
  2822. [0, lnum, col, off, curswant] ~
  2823. The "curswant" number is the preferred column when moving the
  2824. cursor vertically. After |$| command it will be a very large
  2825. number equal to |v:maxcol|. Also see |getcursorcharpos()| and
  2826. |getpos()|.
  2827. The first "bufnum" item is always zero. The byte position of
  2828. the cursor is returned in "col". To get the character
  2829. position, use |getcursorcharpos()|.
  2830. The optional {winid} argument can specify the window. It can
  2831. be the window number or the |window-ID|. The last known
  2832. cursor position is returned, this may be invalid for the
  2833. current value of the buffer if it is not the current window.
  2834. If {winid} is invalid a list with zeroes is returned.
  2835. This can be used to save and restore the cursor position: >vim
  2836. let save_cursor = getcurpos()
  2837. MoveTheCursorAround
  2838. call setpos('.', save_cursor)
  2839. < Note that this only works within the window. See
  2840. |winrestview()| for restoring more state.
  2841. Parameters: ~
  2842. • {winid} (`integer?`)
  2843. Return: ~
  2844. (`any`)
  2845. getcursorcharpos([{winid}]) *getcursorcharpos()*
  2846. Same as |getcurpos()| but the column number in the returned
  2847. List is a character index instead of a byte index.
  2848. Example:
  2849. With the cursor on '보' in line 3 with text "여보세요": >vim
  2850. getcursorcharpos() " returns [0, 3, 2, 0, 3]
  2851. getcurpos() " returns [0, 3, 4, 0, 3]
  2852. <
  2853. Parameters: ~
  2854. • {winid} (`integer?`)
  2855. Return: ~
  2856. (`any`)
  2857. getcwd([{winnr} [, {tabnr}]]) *getcwd()*
  2858. With no arguments, returns the name of the effective
  2859. |current-directory|. With {winnr} or {tabnr} the working
  2860. directory of that scope is returned, and 'autochdir' is
  2861. ignored.
  2862. Tabs and windows are identified by their respective numbers,
  2863. 0 means current tab or window. Missing tab number implies 0.
  2864. Thus the following are equivalent: >vim
  2865. getcwd(0)
  2866. getcwd(0, 0)
  2867. < If {winnr} is -1 it is ignored, only the tab is resolved.
  2868. {winnr} can be the window number or the |window-ID|.
  2869. If both {winnr} and {tabnr} are -1 the global working
  2870. directory is returned.
  2871. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  2872. Parameters: ~
  2873. • {winnr} (`integer?`)
  2874. • {tabnr} (`integer?`)
  2875. Return: ~
  2876. (`string`)
  2877. getenv({name}) *getenv()*
  2878. Return the value of environment variable {name}. The {name}
  2879. argument is a string, without a leading '$'. Example: >vim
  2880. myHome = getenv('HOME')
  2881. < When the variable does not exist |v:null| is returned. That
  2882. is different from a variable set to an empty string.
  2883. See also |expr-env|.
  2884. Parameters: ~
  2885. • {name} (`string`)
  2886. Return: ~
  2887. (`string`)
  2888. getfontname([{name}]) *getfontname()*
  2889. Without an argument returns the name of the normal font being
  2890. used. Like what is used for the Normal highlight group
  2891. |hl-Normal|.
  2892. With an argument a check is done whether String {name} is a
  2893. valid font name. If not then an empty string is returned.
  2894. Otherwise the actual font name is returned, or {name} if the
  2895. GUI does not support obtaining the real name.
  2896. Only works when the GUI is running, thus not in your vimrc or
  2897. gvimrc file. Use the |GUIEnter| autocommand to use this
  2898. function just after the GUI has started.
  2899. Parameters: ~
  2900. • {name} (`string?`)
  2901. Return: ~
  2902. (`string`)
  2903. getfperm({fname}) *getfperm()*
  2904. The result is a String, which is the read, write, and execute
  2905. permissions of the given file {fname}.
  2906. If {fname} does not exist or its directory cannot be read, an
  2907. empty string is returned.
  2908. The result is of the form "rwxrwxrwx", where each group of
  2909. "rwx" flags represent, in turn, the permissions of the owner
  2910. of the file, the group the file belongs to, and other users.
  2911. If a user does not have a given permission the flag for this
  2912. is replaced with the string "-". Examples: >vim
  2913. echo getfperm("/etc/passwd")
  2914. echo getfperm(expand("~/.config/nvim/init.vim"))
  2915. < This will hopefully (from a security point of view) display
  2916. the string "rw-r--r--" or even "rw-------".
  2917. For setting permissions use |setfperm()|.
  2918. Parameters: ~
  2919. • {fname} (`string`)
  2920. Return: ~
  2921. (`string`)
  2922. getfsize({fname}) *getfsize()*
  2923. The result is a Number, which is the size in bytes of the
  2924. given file {fname}.
  2925. If {fname} is a directory, 0 is returned.
  2926. If the file {fname} can't be found, -1 is returned.
  2927. If the size of {fname} is too big to fit in a Number then -2
  2928. is returned.
  2929. Parameters: ~
  2930. • {fname} (`string`)
  2931. Return: ~
  2932. (`integer`)
  2933. getftime({fname}) *getftime()*
  2934. The result is a Number, which is the last modification time of
  2935. the given file {fname}. The value is measured as seconds
  2936. since 1st Jan 1970, and may be passed to strftime(). See also
  2937. |localtime()| and |strftime()|.
  2938. If the file {fname} can't be found -1 is returned.
  2939. Parameters: ~
  2940. • {fname} (`string`)
  2941. Return: ~
  2942. (`integer`)
  2943. getftype({fname}) *getftype()*
  2944. The result is a String, which is a description of the kind of
  2945. file of the given file {fname}.
  2946. If {fname} does not exist an empty string is returned.
  2947. Here is a table over different kinds of files and their
  2948. results:
  2949. Normal file "file"
  2950. Directory "dir"
  2951. Symbolic link "link"
  2952. Block device "bdev"
  2953. Character device "cdev"
  2954. Socket "socket"
  2955. FIFO "fifo"
  2956. All other "other"
  2957. Example: >vim
  2958. getftype("/home")
  2959. < Note that a type such as "link" will only be returned on
  2960. systems that support it. On some systems only "dir" and
  2961. "file" are returned.
  2962. Parameters: ~
  2963. • {fname} (`string`)
  2964. Return: ~
  2965. (`'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'`)
  2966. getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
  2967. Returns the |jumplist| for the specified window.
  2968. Without arguments use the current window.
  2969. With {winnr} only use this window in the current tab page.
  2970. {winnr} can also be a |window-ID|.
  2971. With {winnr} and {tabnr} use the window in the specified tab
  2972. page. If {winnr} or {tabnr} is invalid, an empty list is
  2973. returned.
  2974. The returned list contains two entries: a list with the jump
  2975. locations and the last used jump position number in the list.
  2976. Each entry in the jump location list is a dictionary with
  2977. the following entries:
  2978. bufnr buffer number
  2979. col column number
  2980. coladd column offset for 'virtualedit'
  2981. filename filename if available
  2982. lnum line number
  2983. Parameters: ~
  2984. • {winnr} (`integer?`)
  2985. • {tabnr} (`integer?`)
  2986. Return: ~
  2987. (`vim.fn.getjumplist.ret`)
  2988. getline({lnum} [, {end}]) *getline()*
  2989. Without {end} the result is a String, which is line {lnum}
  2990. from the current buffer. Example: >vim
  2991. getline(1)
  2992. < When {lnum} is a String that doesn't start with a
  2993. digit, |line()| is called to translate the String into a Number.
  2994. To get the line under the cursor: >vim
  2995. getline(".")
  2996. < When {lnum} is a number smaller than 1 or bigger than the
  2997. number of lines in the buffer, an empty string is returned.
  2998. When {end} is given the result is a |List| where each item is
  2999. a line from the current buffer in the range {lnum} to {end},
  3000. including line {end}.
  3001. {end} is used in the same way as {lnum}.
  3002. Non-existing lines are silently omitted.
  3003. When {end} is before {lnum} an empty |List| is returned.
  3004. Example: >vim
  3005. let start = line('.')
  3006. let end = search("^$") - 1
  3007. let lines = getline(start, end)
  3008. < To get lines from another buffer see |getbufline()| and
  3009. |getbufoneline()|
  3010. Parameters: ~
  3011. • {lnum} (`integer|string`)
  3012. • {end_} (`nil|false?`)
  3013. Return: ~
  3014. (`string`)
  3015. getloclist({nr} [, {what}]) *getloclist()*
  3016. Returns a |List| with all the entries in the location list for
  3017. window {nr}. {nr} can be the window number or the |window-ID|.
  3018. When {nr} is zero the current window is used.
  3019. For a location list window, the displayed location list is
  3020. returned. For an invalid window number {nr}, an empty list is
  3021. returned. Otherwise, same as |getqflist()|.
  3022. If the optional {what} dictionary argument is supplied, then
  3023. returns the items listed in {what} as a dictionary. Refer to
  3024. |getqflist()| for the supported items in {what}.
  3025. In addition to the items supported by |getqflist()| in {what},
  3026. the following item is supported by |getloclist()|:
  3027. filewinid id of the window used to display files
  3028. from the location list. This field is
  3029. applicable only when called from a
  3030. location list window. See
  3031. |location-list-file-window| for more
  3032. details.
  3033. Returns a |Dictionary| with default values if there is no
  3034. location list for the window {nr}.
  3035. Returns an empty Dictionary if window {nr} does not exist.
  3036. Examples (See also |getqflist-examples|): >vim
  3037. echo getloclist(3, {'all': 0})
  3038. echo getloclist(5, {'filewinid': 0})
  3039. <
  3040. Parameters: ~
  3041. • {nr} (`integer`)
  3042. • {what} (`table?`)
  3043. Return: ~
  3044. (`any`)
  3045. getmarklist([{buf}]) *getmarklist()*
  3046. Without the {buf} argument returns a |List| with information
  3047. about all the global marks. |mark|
  3048. If the optional {buf} argument is specified, returns the
  3049. local marks defined in buffer {buf}. For the use of {buf},
  3050. see |bufname()|. If {buf} is invalid, an empty list is
  3051. returned.
  3052. Each item in the returned List is a |Dict| with the following:
  3053. mark name of the mark prefixed by "'"
  3054. pos a |List| with the position of the mark:
  3055. [bufnum, lnum, col, off]
  3056. Refer to |getpos()| for more information.
  3057. file file name
  3058. Refer to |getpos()| for getting information about a specific
  3059. mark.
  3060. Parameters: ~
  3061. • {buf} (`integer??`)
  3062. Return: ~
  3063. (`vim.fn.getmarklist.ret.item[]`)
  3064. getmatches([{win}]) *getmatches()*
  3065. Returns a |List| with all matches previously defined for the
  3066. current window by |matchadd()| and the |:match| commands.
  3067. |getmatches()| is useful in combination with |setmatches()|,
  3068. as |setmatches()| can restore a list of matches saved by
  3069. |getmatches()|.
  3070. If {win} is specified, use the window with this number or
  3071. window ID instead of the current window. If {win} is invalid,
  3072. an empty list is returned.
  3073. Example: >vim
  3074. echo getmatches()
  3075. < >
  3076. [{"group": "MyGroup1", "pattern": "TODO",
  3077. "priority": 10, "id": 1}, {"group": "MyGroup2",
  3078. "pattern": "FIXME", "priority": 10, "id": 2}]
  3079. < >vim
  3080. let m = getmatches()
  3081. call clearmatches()
  3082. echo getmatches()
  3083. < >
  3084. []
  3085. < >vim
  3086. call setmatches(m)
  3087. echo getmatches()
  3088. < >
  3089. [{"group": "MyGroup1", "pattern": "TODO",
  3090. "priority": 10, "id": 1}, {"group": "MyGroup2",
  3091. "pattern": "FIXME", "priority": 10, "id": 2}]
  3092. < >vim
  3093. unlet m
  3094. <
  3095. Parameters: ~
  3096. • {win} (`integer?`)
  3097. Return: ~
  3098. (`any`)
  3099. getmousepos() *getmousepos()*
  3100. Returns a |Dictionary| with the last known position of the
  3101. mouse. This can be used in a mapping for a mouse click. The
  3102. items are:
  3103. screenrow screen row
  3104. screencol screen column
  3105. winid Window ID of the click
  3106. winrow row inside "winid"
  3107. wincol column inside "winid"
  3108. line text line inside "winid"
  3109. column text column inside "winid"
  3110. coladd offset (in screen columns) from the
  3111. start of the clicked char
  3112. All numbers are 1-based.
  3113. If not over a window, e.g. when in the command line, then only
  3114. "screenrow" and "screencol" are valid, the others are zero.
  3115. When on the status line below a window or the vertical
  3116. separator right of a window, the "line" and "column" values
  3117. are zero.
  3118. When the position is after the text then "column" is the
  3119. length of the text in bytes plus one.
  3120. If the mouse is over a focusable floating window then that
  3121. window is used.
  3122. When using |getchar()| the Vim variables |v:mouse_lnum|,
  3123. |v:mouse_col| and |v:mouse_winid| also provide these values.
  3124. Return: ~
  3125. (`vim.fn.getmousepos.ret`)
  3126. getpid() *getpid()*
  3127. Return a Number which is the process ID of the Vim process.
  3128. This is a unique number, until Vim exits.
  3129. Return: ~
  3130. (`integer`)
  3131. getpos({expr}) *getpos()*
  3132. Get the position for String {expr}.
  3133. The accepted values for {expr} are:
  3134. . The cursor position.
  3135. $ The last line in the current buffer.
  3136. 'x Position of mark x (if the mark is not set, 0 is
  3137. returned for all values).
  3138. w0 First line visible in current window (one if the
  3139. display isn't updated, e.g. in silent Ex mode).
  3140. w$ Last line visible in current window (this is one
  3141. less than "w0" if no lines are visible).
  3142. v When not in Visual mode, returns the cursor
  3143. position. In Visual mode, returns the other end
  3144. of the Visual area. A good way to think about
  3145. this is that in Visual mode "v" and "." complement
  3146. each other. While "." refers to the cursor
  3147. position, "v" refers to where |v_o| would move the
  3148. cursor. As a result, you can use "v" and "."
  3149. together to work on all of a selection in
  3150. characterwise Visual mode. If the cursor is at
  3151. the end of a characterwise Visual area, "v" refers
  3152. to the start of the same Visual area. And if the
  3153. cursor is at the start of a characterwise Visual
  3154. area, "v" refers to the end of the same Visual
  3155. area. "v" differs from |'<| and |'>| in that it's
  3156. updated right away.
  3157. Note that a mark in another file can be used. The line number
  3158. then applies to another buffer.
  3159. The result is a |List| with four numbers:
  3160. [bufnum, lnum, col, off]
  3161. "bufnum" is zero, unless a mark like '0 or 'A is used, then it
  3162. is the buffer number of the mark.
  3163. "lnum" and "col" are the position in the buffer. The first
  3164. column is 1.
  3165. The "off" number is zero, unless 'virtualedit' is used. Then
  3166. it is the offset in screen columns from the start of the
  3167. character. E.g., a position within a <Tab> or after the last
  3168. character.
  3169. For getting the cursor position see |getcurpos()|.
  3170. The column number in the returned List is the byte position
  3171. within the line. To get the character position in the line,
  3172. use |getcharpos()|.
  3173. Note that for '< and '> Visual mode matters: when it is "V"
  3174. (visual line mode) the column of '< is zero and the column of
  3175. '> is a large number equal to |v:maxcol|.
  3176. A very large column number equal to |v:maxcol| can be returned,
  3177. in which case it means "after the end of the line".
  3178. If {expr} is invalid, returns a list with all zeros.
  3179. This can be used to save and restore the position of a mark: >vim
  3180. let save_a_mark = getpos("'a")
  3181. " ...
  3182. call setpos("'a", save_a_mark)
  3183. <
  3184. Also see |getcharpos()|, |getcurpos()| and |setpos()|.
  3185. Parameters: ~
  3186. • {expr} (`string`)
  3187. Return: ~
  3188. (`integer[]`)
  3189. getqflist([{what}]) *getqflist()*
  3190. Returns a |List| with all the current quickfix errors. Each
  3191. list item is a dictionary with these entries:
  3192. bufnr number of buffer that has the file name, use
  3193. bufname() to get the name
  3194. module module name
  3195. lnum line number in the buffer (first line is 1)
  3196. end_lnum
  3197. end of line number if the item is multiline
  3198. col column number (first column is 1)
  3199. end_col end of column number if the item has range
  3200. vcol |TRUE|: "col" is visual column
  3201. |FALSE|: "col" is byte index
  3202. nr error number
  3203. pattern search pattern used to locate the error
  3204. text description of the error
  3205. type type of the error, 'E', '1', etc.
  3206. valid |TRUE|: recognized error message
  3207. user_data
  3208. custom data associated with the item, can be
  3209. any type.
  3210. When there is no error list or it's empty, an empty list is
  3211. returned. Quickfix list entries with a non-existing buffer
  3212. number are returned with "bufnr" set to zero (Note: some
  3213. functions accept buffer number zero for the alternate buffer,
  3214. you may need to explicitly check for zero).
  3215. Useful application: Find pattern matches in multiple files and
  3216. do something with them: >vim
  3217. vimgrep /theword/jg *.c
  3218. for d in getqflist()
  3219. echo bufname(d.bufnr) ':' d.lnum '=' d.text
  3220. endfor
  3221. <
  3222. If the optional {what} dictionary argument is supplied, then
  3223. returns only the items listed in {what} as a dictionary. The
  3224. following string items are supported in {what}:
  3225. changedtick get the total number of changes made
  3226. to the list |quickfix-changedtick|
  3227. context get the |quickfix-context|
  3228. efm errorformat to use when parsing "lines". If
  3229. not present, then the 'errorformat' option
  3230. value is used.
  3231. id get information for the quickfix list with
  3232. |quickfix-ID|; zero means the id for the
  3233. current list or the list specified by "nr"
  3234. idx get information for the quickfix entry at this
  3235. index in the list specified by "id" or "nr".
  3236. If set to zero, then uses the current entry.
  3237. See |quickfix-index|
  3238. items quickfix list entries
  3239. lines parse a list of lines using 'efm' and return
  3240. the resulting entries. Only a |List| type is
  3241. accepted. The current quickfix list is not
  3242. modified. See |quickfix-parse|.
  3243. nr get information for this quickfix list; zero
  3244. means the current quickfix list and "$" means
  3245. the last quickfix list
  3246. qfbufnr number of the buffer displayed in the quickfix
  3247. window. Returns 0 if the quickfix buffer is
  3248. not present. See |quickfix-buffer|.
  3249. size number of entries in the quickfix list
  3250. title get the list title |quickfix-title|
  3251. winid get the quickfix |window-ID|
  3252. all all of the above quickfix properties
  3253. Non-string items in {what} are ignored. To get the value of a
  3254. particular item, set it to zero.
  3255. If "nr" is not present then the current quickfix list is used.
  3256. If both "nr" and a non-zero "id" are specified, then the list
  3257. specified by "id" is used.
  3258. To get the number of lists in the quickfix stack, set "nr" to
  3259. "$" in {what}. The "nr" value in the returned dictionary
  3260. contains the quickfix stack size.
  3261. When "lines" is specified, all the other items except "efm"
  3262. are ignored. The returned dictionary contains the entry
  3263. "items" with the list of entries.
  3264. The returned dictionary contains the following entries:
  3265. changedtick total number of changes made to the
  3266. list |quickfix-changedtick|
  3267. context quickfix list context. See |quickfix-context|
  3268. If not present, set to "".
  3269. id quickfix list ID |quickfix-ID|. If not
  3270. present, set to 0.
  3271. idx index of the quickfix entry in the list. If not
  3272. present, set to 0.
  3273. items quickfix list entries. If not present, set to
  3274. an empty list.
  3275. nr quickfix list number. If not present, set to 0
  3276. qfbufnr number of the buffer displayed in the quickfix
  3277. window. If not present, set to 0.
  3278. size number of entries in the quickfix list. If not
  3279. present, set to 0.
  3280. title quickfix list title text. If not present, set
  3281. to "".
  3282. winid quickfix |window-ID|. If not present, set to 0
  3283. Examples (See also |getqflist-examples|): >vim
  3284. echo getqflist({'all': 1})
  3285. echo getqflist({'nr': 2, 'title': 1})
  3286. echo getqflist({'lines' : ["F1:10:L10"]})
  3287. <
  3288. Parameters: ~
  3289. • {what} (`table?`)
  3290. Return: ~
  3291. (`any`)
  3292. getreg([{regname} [, 1 [, {list}]]]) *getreg()*
  3293. The result is a String, which is the contents of register
  3294. {regname}. Example: >vim
  3295. let cliptext = getreg('*')
  3296. < When register {regname} was not set the result is an empty
  3297. string.
  3298. The {regname} argument must be a string.
  3299. getreg('=') returns the last evaluated value of the expression
  3300. register. (For use in maps.)
  3301. getreg('=', 1) returns the expression itself, so that it can
  3302. be restored with |setreg()|. For other registers the extra
  3303. argument is ignored, thus you can always give it.
  3304. If {list} is present and |TRUE|, the result type is changed
  3305. to |List|. Each list item is one text line. Use it if you care
  3306. about zero bytes possibly present inside register: without
  3307. third argument both NLs and zero bytes are represented as NLs
  3308. (see |NL-used-for-Nul|).
  3309. When the register was not set an empty list is returned.
  3310. If {regname} is not specified, |v:register| is used.
  3311. Parameters: ~
  3312. • {regname} (`string?`)
  3313. • {list} (`nil|false?`)
  3314. Return: ~
  3315. (`string`)
  3316. getreginfo([{regname}]) *getreginfo()*
  3317. Returns detailed information about register {regname} as a
  3318. Dictionary with the following entries:
  3319. regcontents List of lines contained in register
  3320. {regname}, like
  3321. getreg({regname}, 1, 1).
  3322. regtype the type of register {regname}, as in
  3323. |getregtype()|.
  3324. isunnamed Boolean flag, v:true if this register
  3325. is currently pointed to by the unnamed
  3326. register.
  3327. points_to for the unnamed register, gives the
  3328. single letter name of the register
  3329. currently pointed to (see |quotequote|).
  3330. For example, after deleting a line
  3331. with `dd`, this field will be "1",
  3332. which is the register that got the
  3333. deleted text.
  3334. The {regname} argument is a string. If {regname} is invalid
  3335. or not set, an empty Dictionary will be returned.
  3336. If {regname} is not specified, |v:register| is used.
  3337. The returned Dictionary can be passed to |setreg()|.
  3338. Parameters: ~
  3339. • {regname} (`string?`)
  3340. Return: ~
  3341. (`table`)
  3342. getregion({pos1}, {pos2} [, {opts}]) *getregion()*
  3343. Returns the list of strings from {pos1} to {pos2} from a
  3344. buffer.
  3345. {pos1} and {pos2} must both be |List|s with four numbers.
  3346. See |getpos()| for the format of the list. It's possible
  3347. to specify positions from a different buffer, but please
  3348. note the limitations at |getregion-notes|.
  3349. The optional argument {opts} is a Dict and supports the
  3350. following items:
  3351. type Specify the region's selection type.
  3352. See |getregtype()| for possible values,
  3353. except that the width can be omitted
  3354. and an empty string cannot be used.
  3355. (default: "v")
  3356. exclusive If |TRUE|, use exclusive selection
  3357. for the end position.
  3358. (default: follow 'selection')
  3359. You can get the last selection type by |visualmode()|.
  3360. If Visual mode is active, use |mode()| to get the Visual mode
  3361. (e.g., in a |:vmap|).
  3362. This function is useful to get text starting and ending in
  3363. different columns, such as a |charwise-visual| selection.
  3364. *getregion-notes*
  3365. Note that:
  3366. - Order of {pos1} and {pos2} doesn't matter, it will always
  3367. return content from the upper left position to the lower
  3368. right position.
  3369. - If 'virtualedit' is enabled and the region is past the end
  3370. of the lines, resulting lines are padded with spaces.
  3371. - If the region is blockwise and it starts or ends in the
  3372. middle of a multi-cell character, it is not included but
  3373. its selected part is substituted with spaces.
  3374. - If {pos1} and {pos2} are not in the same buffer, an empty
  3375. list is returned.
  3376. - {pos1} and {pos2} must belong to a |bufloaded()| buffer.
  3377. - It is evaluated in current window context, which makes a
  3378. difference if the buffer is displayed in a window with
  3379. different 'virtualedit' or 'list' values.
  3380. Examples: >vim
  3381. xnoremap <CR>
  3382. \ <Cmd>echom getregion(
  3383. \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
  3384. <
  3385. Parameters: ~
  3386. • {pos1} (`table`)
  3387. • {pos2} (`table`)
  3388. • {opts} (`table?`)
  3389. Return: ~
  3390. (`string[]`)
  3391. getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
  3392. Same as |getregion()|, but returns a list of positions
  3393. describing the buffer text segments bound by {pos1} and
  3394. {pos2}.
  3395. The segments are a pair of positions for every line: >
  3396. [[{start_pos}, {end_pos}], ...]
  3397. <
  3398. The position is a |List| with four numbers:
  3399. [bufnum, lnum, col, off]
  3400. "bufnum" is the buffer number.
  3401. "lnum" and "col" are the position in the buffer. The first
  3402. column is 1.
  3403. If the "off" number of a starting position is non-zero, it is
  3404. the offset in screen columns from the start of the character.
  3405. E.g., a position within a <Tab> or after the last character.
  3406. If the "off" number of an ending position is non-zero, it is
  3407. the offset of the character's first cell not included in the
  3408. selection, otherwise all its cells are included.
  3409. Apart from the options supported by |getregion()|, {opts} also
  3410. supports the following:
  3411. eol If |TRUE|, indicate positions beyond
  3412. the end of a line with "col" values
  3413. one more than the length of the line.
  3414. If |FALSE|, positions are limited
  3415. within their lines, and if a line is
  3416. empty or the selection is entirely
  3417. beyond the end of a line, a "col"
  3418. value of 0 is used for both positions.
  3419. (default: |FALSE|)
  3420. Parameters: ~
  3421. • {pos1} (`table`)
  3422. • {pos2} (`table`)
  3423. • {opts} (`table?`)
  3424. Return: ~
  3425. (`integer[][][]`)
  3426. getregtype([{regname}]) *getregtype()*
  3427. The result is a String, which is type of register {regname}.
  3428. The value will be one of:
  3429. "v" for |charwise| text
  3430. "V" for |linewise| text
  3431. "<CTRL-V>{width}" for |blockwise-visual| text
  3432. "" for an empty or unknown register
  3433. <CTRL-V> is one character with value 0x16.
  3434. The {regname} argument is a string. If {regname} is not
  3435. specified, |v:register| is used.
  3436. Parameters: ~
  3437. • {regname} (`string?`)
  3438. Return: ~
  3439. (`string`)
  3440. getscriptinfo([{opts}]) *getscriptinfo()*
  3441. Returns a |List| with information about all the sourced Vim
  3442. scripts in the order they were sourced, like what
  3443. `:scriptnames` shows.
  3444. The optional Dict argument {opts} supports the following
  3445. optional items:
  3446. name Script name match pattern. If specified,
  3447. and "sid" is not specified, information about
  3448. scripts with a name that match the pattern
  3449. "name" are returned.
  3450. sid Script ID |<SID>|. If specified, only
  3451. information about the script with ID "sid" is
  3452. returned and "name" is ignored.
  3453. Each item in the returned List is a |Dict| with the following
  3454. items:
  3455. autoload Always set to FALSE.
  3456. functions List of script-local function names defined in
  3457. the script. Present only when a particular
  3458. script is specified using the "sid" item in
  3459. {opts}.
  3460. name Vim script file name.
  3461. sid Script ID |<SID>|.
  3462. variables A dictionary with the script-local variables.
  3463. Present only when a particular script is
  3464. specified using the "sid" item in {opts}.
  3465. Note that this is a copy, the value of
  3466. script-local variables cannot be changed using
  3467. this dictionary.
  3468. version Vim script version, always 1
  3469. Examples: >vim
  3470. echo getscriptinfo({'name': 'myscript'})
  3471. echo getscriptinfo({'sid': 15})[0].variables
  3472. <
  3473. Parameters: ~
  3474. • {opts} (`table?`)
  3475. Return: ~
  3476. (`vim.fn.getscriptinfo.ret[]`)
  3477. gettabinfo([{tabnr}]) *gettabinfo()*
  3478. If {tabnr} is not specified, then information about all the
  3479. tab pages is returned as a |List|. Each List item is a
  3480. |Dictionary|. Otherwise, {tabnr} specifies the tab page
  3481. number and information about that one is returned. If the tab
  3482. page does not exist an empty List is returned.
  3483. Each List item is a |Dictionary| with the following entries:
  3484. tabnr tab page number.
  3485. variables a reference to the dictionary with
  3486. tabpage-local variables
  3487. windows List of |window-ID|s in the tab page.
  3488. Parameters: ~
  3489. • {tabnr} (`integer?`)
  3490. Return: ~
  3491. (`any`)
  3492. gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
  3493. Get the value of a tab-local variable {varname} in tab page
  3494. {tabnr}. |t:var|
  3495. Tabs are numbered starting with one.
  3496. The {varname} argument is a string. When {varname} is empty a
  3497. dictionary with all tab-local variables is returned.
  3498. Note that the name without "t:" must be used.
  3499. When the tab or variable doesn't exist {def} or an empty
  3500. string is returned, there is no error message.
  3501. Parameters: ~
  3502. • {tabnr} (`integer`)
  3503. • {varname} (`string`)
  3504. • {def} (`any?`)
  3505. Return: ~
  3506. (`any`)
  3507. gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
  3508. Get the value of window-local variable {varname} in window
  3509. {winnr} in tab page {tabnr}.
  3510. The {varname} argument is a string. When {varname} is empty a
  3511. dictionary with all window-local variables is returned.
  3512. When {varname} is equal to "&" get the values of all
  3513. window-local options in a |Dictionary|.
  3514. Otherwise, when {varname} starts with "&" get the value of a
  3515. window-local option.
  3516. Note that {varname} must be the name without "w:".
  3517. Tabs are numbered starting with one. For the current tabpage
  3518. use |getwinvar()|.
  3519. {winnr} can be the window number or the |window-ID|.
  3520. When {winnr} is zero the current window is used.
  3521. This also works for a global option, buffer-local option and
  3522. window-local option, but it doesn't work for a global variable
  3523. or buffer-local variable.
  3524. When the tab, window or variable doesn't exist {def} or an
  3525. empty string is returned, there is no error message.
  3526. Examples: >vim
  3527. let list_is_on = gettabwinvar(1, 2, '&list')
  3528. echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
  3529. <
  3530. To obtain all window-local variables use: >vim
  3531. gettabwinvar({tabnr}, {winnr}, '&')
  3532. <
  3533. Parameters: ~
  3534. • {tabnr} (`integer`)
  3535. • {winnr} (`integer`)
  3536. • {varname} (`string`)
  3537. • {def} (`any?`)
  3538. Return: ~
  3539. (`any`)
  3540. gettagstack([{winnr}]) *gettagstack()*
  3541. The result is a Dict, which is the tag stack of window {winnr}.
  3542. {winnr} can be the window number or the |window-ID|.
  3543. When {winnr} is not specified, the current window is used.
  3544. When window {winnr} doesn't exist, an empty Dict is returned.
  3545. The returned dictionary contains the following entries:
  3546. curidx Current index in the stack. When at
  3547. top of the stack, set to (length + 1).
  3548. Index of bottom of the stack is 1.
  3549. items List of items in the stack. Each item
  3550. is a dictionary containing the
  3551. entries described below.
  3552. length Number of entries in the stack.
  3553. Each item in the stack is a dictionary with the following
  3554. entries:
  3555. bufnr buffer number of the current jump
  3556. from cursor position before the tag jump.
  3557. See |getpos()| for the format of the
  3558. returned list.
  3559. matchnr current matching tag number. Used when
  3560. multiple matching tags are found for a
  3561. name.
  3562. tagname name of the tag
  3563. See |tagstack| for more information about the tag stack.
  3564. Parameters: ~
  3565. • {winnr} (`integer?`)
  3566. Return: ~
  3567. (`any`)
  3568. gettext({text}) *gettext()*
  3569. Translate String {text} if possible.
  3570. This is mainly for use in the distributed Vim scripts. When
  3571. generating message translations the {text} is extracted by
  3572. xgettext, the translator can add the translated message in the
  3573. .po file and Vim will lookup the translation when gettext() is
  3574. called.
  3575. For {text} double quoted strings are preferred, because
  3576. xgettext does not understand escaping in single quoted
  3577. strings.
  3578. Parameters: ~
  3579. • {text} (`string`)
  3580. Return: ~
  3581. (`any`)
  3582. getwininfo([{winid}]) *getwininfo()*
  3583. Returns information about windows as a |List| with Dictionaries.
  3584. If {winid} is given Information about the window with that ID
  3585. is returned, as a |List| with one item. If the window does not
  3586. exist the result is an empty list.
  3587. Without {winid} information about all the windows in all the
  3588. tab pages is returned.
  3589. Each List item is a |Dictionary| with the following entries:
  3590. botline last complete displayed buffer line
  3591. bufnr number of buffer in the window
  3592. height window height (excluding winbar)
  3593. loclist 1 if showing a location list
  3594. quickfix 1 if quickfix or location list window
  3595. terminal 1 if a terminal window
  3596. tabnr tab page number
  3597. topline first displayed buffer line
  3598. variables a reference to the dictionary with
  3599. window-local variables
  3600. width window width
  3601. winbar 1 if the window has a toolbar, 0
  3602. otherwise
  3603. wincol leftmost screen column of the window;
  3604. "col" from |win_screenpos()|
  3605. textoff number of columns occupied by any
  3606. 'foldcolumn', 'signcolumn' and line
  3607. number in front of the text
  3608. winid |window-ID|
  3609. winnr window number
  3610. winrow topmost screen line of the window;
  3611. "row" from |win_screenpos()|
  3612. Parameters: ~
  3613. • {winid} (`integer?`)
  3614. Return: ~
  3615. (`vim.fn.getwininfo.ret.item[]`)
  3616. getwinpos([{timeout}]) *getwinpos()*
  3617. The result is a |List| with two numbers, the result of
  3618. |getwinposx()| and |getwinposy()| combined:
  3619. [x-pos, y-pos]
  3620. {timeout} can be used to specify how long to wait in msec for
  3621. a response from the terminal. When omitted 100 msec is used.
  3622. Use a longer time for a remote terminal.
  3623. When using a value less than 10 and no response is received
  3624. within that time, a previously reported position is returned,
  3625. if available. This can be used to poll for the position and
  3626. do some work in the meantime: >vim
  3627. while 1
  3628. let res = getwinpos(1)
  3629. if res[0] >= 0
  3630. break
  3631. endif
  3632. " Do some work here
  3633. endwhile
  3634. <
  3635. Parameters: ~
  3636. • {timeout} (`integer?`)
  3637. Return: ~
  3638. (`any`)
  3639. getwinposx() *getwinposx()*
  3640. The result is a Number, which is the X coordinate in pixels of
  3641. the left hand side of the GUI Vim window. The result will be
  3642. -1 if the information is not available.
  3643. The value can be used with `:winpos`.
  3644. Return: ~
  3645. (`integer`)
  3646. getwinposy() *getwinposy()*
  3647. The result is a Number, which is the Y coordinate in pixels of
  3648. the top of the GUI Vim window. The result will be -1 if the
  3649. information is not available.
  3650. The value can be used with `:winpos`.
  3651. Return: ~
  3652. (`integer`)
  3653. getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
  3654. Like |gettabwinvar()| for the current tabpage.
  3655. Examples: >vim
  3656. let list_is_on = getwinvar(2, '&list')
  3657. echo "myvar = " .. getwinvar(1, 'myvar')
  3658. Parameters: ~
  3659. • {winnr} (`integer`)
  3660. • {varname} (`string`)
  3661. • {def} (`any?`)
  3662. Return: ~
  3663. (`any`)
  3664. glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
  3665. Expand the file wildcards in {expr}. See |wildcards| for the
  3666. use of special characters.
  3667. Unless the optional {nosuf} argument is given and is |TRUE|,
  3668. the 'suffixes' and 'wildignore' options apply: Names matching
  3669. one of the patterns in 'wildignore' will be skipped and
  3670. 'suffixes' affect the ordering of matches.
  3671. 'wildignorecase' always applies.
  3672. When {list} is present and it is |TRUE| the result is a |List|
  3673. with all matching files. The advantage of using a List is,
  3674. you also get filenames containing newlines correctly.
  3675. Otherwise the result is a String and when there are several
  3676. matches, they are separated by <NL> characters.
  3677. If the expansion fails, the result is an empty String or List.
  3678. You can also use |readdir()| if you need to do complicated
  3679. things, such as limiting the number of matches.
  3680. A name for a non-existing file is not included. A symbolic
  3681. link is only included if it points to an existing file.
  3682. However, when the {alllinks} argument is present and it is
  3683. |TRUE| then all symbolic links are included.
  3684. For most systems backticks can be used to get files names from
  3685. any external command. Example: >vim
  3686. let tagfiles = glob("`find . -name tags -print`")
  3687. let &tags = substitute(tagfiles, "\n", ",", "g")
  3688. < The result of the program inside the backticks should be one
  3689. item per line. Spaces inside an item are allowed.
  3690. See |expand()| for expanding special Vim variables. See
  3691. |system()| for getting the raw output of an external command.
  3692. Parameters: ~
  3693. • {expr} (`string`)
  3694. • {nosuf} (`boolean?`)
  3695. • {list} (`boolean?`)
  3696. • {alllinks} (`boolean?`)
  3697. Return: ~
  3698. (`any`)
  3699. glob2regpat({string}) *glob2regpat()*
  3700. Convert a file pattern, as used by glob(), into a search
  3701. pattern. The result can be used to match with a string that
  3702. is a file name. E.g. >vim
  3703. if filename =~ glob2regpat('Make*.mak')
  3704. " ...
  3705. endif
  3706. < This is equivalent to: >vim
  3707. if filename =~ '^Make.*\.mak$'
  3708. " ...
  3709. endif
  3710. < When {string} is an empty string the result is "^$", match an
  3711. empty string.
  3712. Note that the result depends on the system. On MS-Windows
  3713. a backslash usually means a path separator.
  3714. Parameters: ~
  3715. • {string} (`string`)
  3716. Return: ~
  3717. (`any`)
  3718. globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()*
  3719. Perform glob() for String {expr} on all directories in {path}
  3720. and concatenate the results. Example: >vim
  3721. echo globpath(&rtp, "syntax/c.vim")
  3722. <
  3723. {path} is a comma-separated list of directory names. Each
  3724. directory name is prepended to {expr} and expanded like with
  3725. |glob()|. A path separator is inserted when needed.
  3726. To add a comma inside a directory name escape it with a
  3727. backslash. Note that on MS-Windows a directory may have a
  3728. trailing backslash, remove it if you put a comma after it.
  3729. If the expansion fails for one of the directories, there is no
  3730. error message.
  3731. Unless the optional {nosuf} argument is given and is |TRUE|,
  3732. the 'suffixes' and 'wildignore' options apply: Names matching
  3733. one of the patterns in 'wildignore' will be skipped and
  3734. 'suffixes' affect the ordering of matches.
  3735. When {list} is present and it is |TRUE| the result is a |List|
  3736. with all matching files. The advantage of using a List is, you
  3737. also get filenames containing newlines correctly. Otherwise
  3738. the result is a String and when there are several matches,
  3739. they are separated by <NL> characters. Example: >vim
  3740. echo globpath(&rtp, "syntax/c.vim", 0, 1)
  3741. <
  3742. {allinks} is used as with |glob()|.
  3743. The "**" item can be used to search in a directory tree.
  3744. For example, to find all "README.txt" files in the directories
  3745. in 'runtimepath' and below: >vim
  3746. echo globpath(&rtp, "**/README.txt")
  3747. < Upwards search and limiting the depth of "**" is not
  3748. supported, thus using 'path' will not always work properly.
  3749. Parameters: ~
  3750. • {path} (`string`)
  3751. • {expr} (`string`)
  3752. • {nosuf} (`boolean?`)
  3753. • {list} (`boolean?`)
  3754. • {allinks} (`boolean?`)
  3755. Return: ~
  3756. (`any`)
  3757. has({feature}) *has()*
  3758. Returns 1 if {feature} is supported, 0 otherwise. The
  3759. {feature} argument is a feature name like "nvim-0.2.1" or
  3760. "win32", see below. See also |exists()|.
  3761. To get the system name use |vim.uv|.os_uname() in Lua: >lua
  3762. print(vim.uv.os_uname().sysname)
  3763. < If the code has a syntax error then Vimscript may skip the
  3764. rest of the line. Put |:if| and |:endif| on separate lines to
  3765. avoid the syntax error: >vim
  3766. if has('feature')
  3767. let x = this_breaks_without_the_feature()
  3768. endif
  3769. <
  3770. Vim's compile-time feature-names (prefixed with "+") are not
  3771. recognized because Nvim is always compiled with all possible
  3772. features. |feature-compile|
  3773. Feature names can be:
  3774. 1. Nvim version. For example the "nvim-0.2.1" feature means
  3775. that Nvim is version 0.2.1 or later: >vim
  3776. if has("nvim-0.2.1")
  3777. " ...
  3778. endif
  3779. < 2. Runtime condition or other pseudo-feature. For example the
  3780. "win32" feature checks if the current system is Windows: >vim
  3781. if has("win32")
  3782. " ...
  3783. endif
  3784. < *feature-list*
  3785. List of supported pseudo-feature names:
  3786. acl |ACL| support.
  3787. bsd BSD system (not macOS, use "mac" for that).
  3788. clipboard |clipboard| provider is available.
  3789. fname_case Case in file names matters (for Darwin and MS-Windows
  3790. this is not present).
  3791. gui_running Nvim has a GUI.
  3792. iconv Can use |iconv()| for conversion.
  3793. linux Linux system.
  3794. mac MacOS system.
  3795. nvim This is Nvim.
  3796. python3 Legacy Vim |python3| interface. |has-python|
  3797. pythonx Legacy Vim |python_x| interface. |has-pythonx|
  3798. sun SunOS system.
  3799. ttyin input is a terminal (tty).
  3800. ttyout output is a terminal (tty).
  3801. unix Unix system.
  3802. *vim_starting* True during |startup|.
  3803. win32 Windows system (32 or 64 bit).
  3804. win64 Windows system (64 bit).
  3805. wsl WSL (Windows Subsystem for Linux) system.
  3806. *has-patch*
  3807. 3. Vim patch. For example the "patch123" feature means that
  3808. Vim patch 123 at the current |v:version| was included: >vim
  3809. if v:version > 602 || v:version == 602 && has("patch148")
  3810. " ...
  3811. endif
  3812. < 4. Vim version. For example the "patch-7.4.237" feature means
  3813. that Nvim is Vim-compatible to version 7.4.237 or later. >vim
  3814. if has("patch-7.4.237")
  3815. " ...
  3816. endif
  3817. <
  3818. Parameters: ~
  3819. • {feature} (`string`)
  3820. Return: ~
  3821. (`0|1`)
  3822. has_key({dict}, {key}) *has_key()*
  3823. The result is a Number, which is TRUE if |Dictionary| {dict}
  3824. has an entry with key {key}. FALSE otherwise. The {key}
  3825. argument is a string.
  3826. Parameters: ~
  3827. • {dict} (`table`)
  3828. • {key} (`string`)
  3829. Return: ~
  3830. (`0|1`)
  3831. haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
  3832. The result is a Number, which is 1 when the window has set a
  3833. local path via |:lcd| or when {winnr} is -1 and the tabpage
  3834. has set a local path via |:tcd|, otherwise 0.
  3835. Tabs and windows are identified by their respective numbers,
  3836. 0 means current tab or window. Missing argument implies 0.
  3837. Thus the following are equivalent: >vim
  3838. echo haslocaldir()
  3839. echo haslocaldir(0)
  3840. echo haslocaldir(0, 0)
  3841. < With {winnr} use that window in the current tabpage.
  3842. With {winnr} and {tabnr} use the window in that tabpage.
  3843. {winnr} can be the window number or the |window-ID|.
  3844. If {winnr} is -1 it is ignored, only the tab is resolved.
  3845. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  3846. Parameters: ~
  3847. • {winnr} (`integer?`)
  3848. • {tabnr} (`integer?`)
  3849. Return: ~
  3850. (`0|1`)
  3851. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
  3852. The result is a Number, which is TRUE if there is a mapping
  3853. that contains {what} in somewhere in the rhs (what it is
  3854. mapped to) and this mapping exists in one of the modes
  3855. indicated by {mode}.
  3856. The arguments {what} and {mode} are strings.
  3857. When {abbr} is there and it is |TRUE| use abbreviations
  3858. instead of mappings. Don't forget to specify Insert and/or
  3859. Command-line mode.
  3860. Both the global mappings and the mappings local to the current
  3861. buffer are checked for a match.
  3862. If no matching mapping is found FALSE is returned.
  3863. The following characters are recognized in {mode}:
  3864. n Normal mode
  3865. v Visual and Select mode
  3866. x Visual mode
  3867. s Select mode
  3868. o Operator-pending mode
  3869. i Insert mode
  3870. l Language-Argument ("r", "f", "t", etc.)
  3871. c Command-line mode
  3872. When {mode} is omitted, "nvo" is used.
  3873. This function is useful to check if a mapping already exists
  3874. to a function in a Vim script. Example: >vim
  3875. if !hasmapto('\ABCdoit')
  3876. map <Leader>d \ABCdoit
  3877. endif
  3878. < This installs the mapping to "\ABCdoit" only if there isn't
  3879. already a mapping to "\ABCdoit".
  3880. Parameters: ~
  3881. • {what} (`any`)
  3882. • {mode} (`string?`)
  3883. • {abbr} (`boolean?`)
  3884. Return: ~
  3885. (`0|1`)
  3886. histadd({history}, {item}) *histadd()*
  3887. Add the String {item} to the history {history} which can be
  3888. one of: *hist-names*
  3889. "cmd" or ":" command line history
  3890. "search" or "/" search pattern history
  3891. "expr" or "=" typed expression history
  3892. "input" or "@" input line history
  3893. "debug" or ">" debug command history
  3894. empty the current or last used history
  3895. The {history} string does not need to be the whole name, one
  3896. character is sufficient.
  3897. If {item} does already exist in the history, it will be
  3898. shifted to become the newest entry.
  3899. The result is a Number: TRUE if the operation was successful,
  3900. otherwise FALSE is returned.
  3901. Example: >vim
  3902. call histadd("input", strftime("%Y %b %d"))
  3903. let date=input("Enter date: ")
  3904. < This function is not available in the |sandbox|.
  3905. Parameters: ~
  3906. • {history} (`string`)
  3907. • {item} (`any`)
  3908. Return: ~
  3909. (`0|1`)
  3910. histdel({history} [, {item}]) *histdel()*
  3911. Clear {history}, i.e. delete all its entries. See |hist-names|
  3912. for the possible values of {history}.
  3913. If the parameter {item} evaluates to a String, it is used as a
  3914. regular expression. All entries matching that expression will
  3915. be removed from the history (if there are any).
  3916. Upper/lowercase must match, unless "\c" is used |/\c|.
  3917. If {item} evaluates to a Number, it will be interpreted as
  3918. an index, see |:history-indexing|. The respective entry will
  3919. be removed if it exists.
  3920. The result is TRUE for a successful operation, otherwise FALSE
  3921. is returned.
  3922. Examples:
  3923. Clear expression register history: >vim
  3924. call histdel("expr")
  3925. <
  3926. Remove all entries starting with "*" from the search history: >vim
  3927. call histdel("/", '^\*')
  3928. <
  3929. The following three are equivalent: >vim
  3930. call histdel("search", histnr("search"))
  3931. call histdel("search", -1)
  3932. call histdel("search", '^' .. histget("search", -1) .. '$')
  3933. <
  3934. To delete the last search pattern and use the last-but-one for
  3935. the "n" command and 'hlsearch': >vim
  3936. call histdel("search", -1)
  3937. let @/ = histget("search", -1)
  3938. <
  3939. Parameters: ~
  3940. • {history} (`string`)
  3941. • {item} (`any?`)
  3942. Return: ~
  3943. (`0|1`)
  3944. histget({history} [, {index}]) *histget()*
  3945. The result is a String, the entry with Number {index} from
  3946. {history}. See |hist-names| for the possible values of
  3947. {history}, and |:history-indexing| for {index}. If there is
  3948. no such entry, an empty String is returned. When {index} is
  3949. omitted, the most recent item from the history is used.
  3950. Examples:
  3951. Redo the second last search from history. >vim
  3952. execute '/' .. histget("search", -2)
  3953. < Define an Ex command ":H {num}" that supports re-execution of
  3954. the {num}th entry from the output of |:history|. >vim
  3955. command -nargs=1 H execute histget("cmd", 0+<args>)
  3956. <
  3957. Parameters: ~
  3958. • {history} (`string`)
  3959. • {index} (`integer|string?`)
  3960. Return: ~
  3961. (`string`)
  3962. histnr({history}) *histnr()*
  3963. The result is the Number of the current entry in {history}.
  3964. See |hist-names| for the possible values of {history}.
  3965. If an error occurred, -1 is returned.
  3966. Example: >vim
  3967. let inp_index = histnr("expr")
  3968. <
  3969. Parameters: ~
  3970. • {history} (`string`)
  3971. Return: ~
  3972. (`integer`)
  3973. hlID({name}) *hlID()*
  3974. The result is a Number, which is the ID of the highlight group
  3975. with name {name}. When the highlight group doesn't exist,
  3976. zero is returned.
  3977. This can be used to retrieve information about the highlight
  3978. group. For example, to get the background color of the
  3979. "Comment" group: >vim
  3980. echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  3981. <
  3982. Parameters: ~
  3983. • {name} (`string`)
  3984. Return: ~
  3985. (`integer`)
  3986. hlexists({name}) *hlexists()*
  3987. The result is a Number, which is TRUE if a highlight group
  3988. called {name} exists. This is when the group has been
  3989. defined in some way. Not necessarily when highlighting has
  3990. been defined for it, it may also have been used for a syntax
  3991. item.
  3992. Parameters: ~
  3993. • {name} (`string`)
  3994. Return: ~
  3995. (`0|1`)
  3996. hostname() *hostname()*
  3997. The result is a String, which is the name of the machine on
  3998. which Vim is currently running. Machine names greater than
  3999. 256 characters long are truncated.
  4000. Return: ~
  4001. (`string`)
  4002. iconv({string}, {from}, {to}) *iconv()*
  4003. The result is a String, which is the text {string} converted
  4004. from encoding {from} to encoding {to}.
  4005. When the conversion completely fails an empty string is
  4006. returned. When some characters could not be converted they
  4007. are replaced with "?".
  4008. The encoding names are whatever the iconv() library function
  4009. can accept, see ":!man 3 iconv".
  4010. Note that Vim uses UTF-8 for all Unicode encodings, conversion
  4011. from/to UCS-2 is automatically changed to use UTF-8. You
  4012. cannot use UCS-2 in a string anyway, because of the NUL bytes.
  4013. Parameters: ~
  4014. • {string} (`string`)
  4015. • {from} (`string`)
  4016. • {to} (`string`)
  4017. Return: ~
  4018. (`any`)
  4019. id({expr}) *id()*
  4020. Returns a |String| which is a unique identifier of the
  4021. container type (|List|, |Dict|, |Blob| and |Partial|). It is
  4022. guaranteed that for the mentioned types `id(v1) ==# id(v2)`
  4023. returns true iff `type(v1) == type(v2) && v1 is v2`.
  4024. Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
  4025. `v:_null_blob` have the same `id()` with different types
  4026. because they are internally represented as NULL pointers.
  4027. `id()` returns a hexadecimal representation of the pointers to
  4028. the containers (i.e. like `0x994a40`), same as `printf("%p",
  4029. {expr})`, but it is advised against counting on the exact
  4030. format of the return value.
  4031. It is not guaranteed that `id(no_longer_existing_container)`
  4032. will not be equal to some other `id()`: new containers may
  4033. reuse identifiers of the garbage-collected ones.
  4034. Parameters: ~
  4035. • {expr} (`any`)
  4036. Return: ~
  4037. (`any`)
  4038. indent({lnum}) *indent()*
  4039. The result is a Number, which is indent of line {lnum} in the
  4040. current buffer. The indent is counted in spaces, the value
  4041. of 'tabstop' is relevant. {lnum} is used just like in
  4042. |getline()|.
  4043. When {lnum} is invalid -1 is returned.
  4044. Parameters: ~
  4045. • {lnum} (`integer|string`)
  4046. Return: ~
  4047. (`integer`)
  4048. index({object}, {expr} [, {start} [, {ic}]]) *index()*
  4049. Find {expr} in {object} and return its index. See
  4050. |indexof()| for using a lambda to select the item.
  4051. If {object} is a |List| return the lowest index where the item
  4052. has a value equal to {expr}. There is no automatic
  4053. conversion, so the String "4" is different from the Number 4.
  4054. And the Number 4 is different from the Float 4.0. The value
  4055. of 'ignorecase' is not used here, case matters as indicated by
  4056. the {ic} argument.
  4057. If {object} is a |Blob| return the lowest index where the byte
  4058. value is equal to {expr}.
  4059. If {start} is given then start looking at the item with index
  4060. {start} (may be negative for an item relative to the end).
  4061. When {ic} is given and it is |TRUE|, ignore case. Otherwise
  4062. case must match.
  4063. -1 is returned when {expr} is not found in {object}.
  4064. Example: >vim
  4065. let idx = index(words, "the")
  4066. if index(numbers, 123) >= 0
  4067. " ...
  4068. endif
  4069. <
  4070. Parameters: ~
  4071. • {object} (`any`)
  4072. • {expr} (`any`)
  4073. • {start} (`integer?`)
  4074. • {ic} (`boolean?`)
  4075. Return: ~
  4076. (`any`)
  4077. indexof({object}, {expr} [, {opts}]) *indexof()*
  4078. Returns the index of an item in {object} where {expr} is
  4079. v:true. {object} must be a |List| or a |Blob|.
  4080. If {object} is a |List|, evaluate {expr} for each item in the
  4081. List until the expression is v:true and return the index of
  4082. this item.
  4083. If {object} is a |Blob| evaluate {expr} for each byte in the
  4084. Blob until the expression is v:true and return the index of
  4085. this byte.
  4086. {expr} must be a |string| or |Funcref|.
  4087. If {expr} is a |string|: If {object} is a |List|, inside
  4088. {expr} |v:key| has the index of the current List item and
  4089. |v:val| has the value of the item. If {object} is a |Blob|,
  4090. inside {expr} |v:key| has the index of the current byte and
  4091. |v:val| has the byte value.
  4092. If {expr} is a |Funcref| it must take two arguments:
  4093. 1. the key or the index of the current item.
  4094. 2. the value of the current item.
  4095. The function must return |TRUE| if the item is found and the
  4096. search should stop.
  4097. The optional argument {opts} is a Dict and supports the
  4098. following items:
  4099. startidx start evaluating {expr} at the item with this
  4100. index; may be negative for an item relative to
  4101. the end
  4102. Returns -1 when {expr} evaluates to v:false for all the items.
  4103. Example: >vim
  4104. let l = [#{n: 10}, #{n: 20}, #{n: 30}]
  4105. echo indexof(l, "v:val.n == 20")
  4106. echo indexof(l, {i, v -> v.n == 30})
  4107. echo indexof(l, "v:val.n == 20", #{startidx: 1})
  4108. <
  4109. Parameters: ~
  4110. • {object} (`any`)
  4111. • {expr} (`any`)
  4112. • {opts} (`table?`)
  4113. Return: ~
  4114. (`any`)
  4115. input({prompt} [, {text} [, {completion}]]) *input()*
  4116. Parameters: ~
  4117. • {prompt} (`string`)
  4118. • {text} (`string?`)
  4119. • {completion} (`string?`)
  4120. Return: ~
  4121. (`any`)
  4122. input({opts})
  4123. The result is a String, which is whatever the user typed on
  4124. the command-line. The {prompt} argument is either a prompt
  4125. string, or a blank string (for no prompt). A '\n' can be used
  4126. in the prompt to start a new line.
  4127. In the second form it accepts a single dictionary with the
  4128. following keys, any of which may be omitted:
  4129. Key Default Description ~
  4130. prompt "" Same as {prompt} in the first form.
  4131. default "" Same as {text} in the first form.
  4132. completion nothing Same as {completion} in the first form.
  4133. cancelreturn "" The value returned when the dialog is
  4134. cancelled.
  4135. highlight nothing Highlight handler: |Funcref|.
  4136. The highlighting set with |:echohl| is used for the prompt.
  4137. The input is entered just like a command-line, with the same
  4138. editing commands and mappings. There is a separate history
  4139. for lines typed for input().
  4140. Example: >vim
  4141. if input("Coffee or beer? ") == "beer"
  4142. echo "Cheers!"
  4143. endif
  4144. <
  4145. If the optional {text} argument is present and not empty, this
  4146. is used for the default reply, as if the user typed this.
  4147. Example: >vim
  4148. let color = input("Color? ", "white")
  4149. < The optional {completion} argument specifies the type of
  4150. completion supported for the input. Without it completion is
  4151. not performed. The supported completion types are the same as
  4152. that can be supplied to a user-defined command using the
  4153. "-complete=" argument. Refer to |:command-completion| for
  4154. more information. Example: >vim
  4155. let fname = input("File: ", "", "file")
  4156. < *input()-highlight* *E5400* *E5402*
  4157. The optional `highlight` key allows specifying function which
  4158. will be used for highlighting user input. This function
  4159. receives user input as its only argument and must return
  4160. a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
  4161. where
  4162. hl_start_col is the first highlighted column,
  4163. hl_end_col is the last highlighted column (+ 1!),
  4164. hl_group is |:hi| group used for highlighting.
  4165. *E5403* *E5404* *E5405* *E5406*
  4166. Both hl_start_col and hl_end_col + 1 must point to the start
  4167. of the multibyte character (highlighting must not break
  4168. multibyte characters), hl_end_col + 1 may be equal to the
  4169. input length. Start column must be in range [0, len(input)),
  4170. end column must be in range (hl_start_col, len(input)],
  4171. sections must be ordered so that next hl_start_col is greater
  4172. then or equal to previous hl_end_col.
  4173. Example (try some input with parentheses): >vim
  4174. highlight RBP1 guibg=Red ctermbg=red
  4175. highlight RBP2 guibg=Yellow ctermbg=yellow
  4176. highlight RBP3 guibg=Green ctermbg=green
  4177. highlight RBP4 guibg=Blue ctermbg=blue
  4178. let g:rainbow_levels = 4
  4179. function! RainbowParens(cmdline)
  4180. let ret = []
  4181. let i = 0
  4182. let lvl = 0
  4183. while i < len(a:cmdline)
  4184. if a:cmdline[i] is# '('
  4185. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4186. let lvl += 1
  4187. elseif a:cmdline[i] is# ')'
  4188. let lvl -= 1
  4189. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4190. endif
  4191. let i += 1
  4192. endwhile
  4193. return ret
  4194. endfunction
  4195. call input({'prompt':'>','highlight':'RainbowParens'})
  4196. <
  4197. Highlight function is called at least once for each new
  4198. displayed input string, before command-line is redrawn. It is
  4199. expected that function is pure for the duration of one input()
  4200. call, i.e. it produces the same output for the same input, so
  4201. output may be memoized. Function is run like under |:silent|
  4202. modifier. If the function causes any errors, it will be
  4203. skipped for the duration of the current input() call.
  4204. Highlighting is disabled if command-line contains arabic
  4205. characters.
  4206. NOTE: This function must not be used in a startup file, for
  4207. the versions that only run in GUI mode (e.g., the Win32 GUI).
  4208. Note: When input() is called from within a mapping it will
  4209. consume remaining characters from that mapping, because a
  4210. mapping is handled like the characters were typed.
  4211. Use |inputsave()| before input() and |inputrestore()|
  4212. after input() to avoid that. Another solution is to avoid
  4213. that further characters follow in the mapping, e.g., by using
  4214. |:execute| or |:normal|.
  4215. Example with a mapping: >vim
  4216. nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
  4217. function GetFoo()
  4218. call inputsave()
  4219. let g:Foo = input("enter search pattern: ")
  4220. call inputrestore()
  4221. endfunction
  4222. <
  4223. Parameters: ~
  4224. • {opts} (`table`)
  4225. Return: ~
  4226. (`any`)
  4227. inputlist({textlist}) *inputlist()*
  4228. {textlist} must be a |List| of strings. This |List| is
  4229. displayed, one string per line. The user will be prompted to
  4230. enter a number, which is returned.
  4231. The user can also select an item by clicking on it with the
  4232. mouse, if the mouse is enabled in the command line ('mouse' is
  4233. "a" or includes "c"). For the first string 0 is returned.
  4234. When clicking above the first item a negative number is
  4235. returned. When clicking on the prompt one more than the
  4236. length of {textlist} is returned.
  4237. Make sure {textlist} has less than 'lines' entries, otherwise
  4238. it won't work. It's a good idea to put the entry number at
  4239. the start of the string. And put a prompt in the first item.
  4240. Example: >vim
  4241. let color = inputlist(['Select color:', '1. red',
  4242. \ '2. green', '3. blue'])
  4243. Parameters: ~
  4244. • {textlist} (`string[]`)
  4245. Return: ~
  4246. (`any`)
  4247. inputrestore() *inputrestore()*
  4248. Restore typeahead that was saved with a previous |inputsave()|.
  4249. Should be called the same number of times inputsave() is
  4250. called. Calling it more often is harmless though.
  4251. Returns TRUE when there is nothing to restore, FALSE otherwise.
  4252. Return: ~
  4253. (`any`)
  4254. inputsave() *inputsave()*
  4255. Preserve typeahead (also from mappings) and clear it, so that
  4256. a following prompt gets input from the user. Should be
  4257. followed by a matching inputrestore() after the prompt. Can
  4258. be used several times, in which case there must be just as
  4259. many inputrestore() calls.
  4260. Returns TRUE when out of memory, FALSE otherwise.
  4261. Return: ~
  4262. (`any`)
  4263. inputsecret({prompt} [, {text}]) *inputsecret()*
  4264. This function acts much like the |input()| function with but
  4265. two exceptions:
  4266. a) the user's response will be displayed as a sequence of
  4267. asterisks ("*") thereby keeping the entry secret, and
  4268. b) the user's response will not be recorded on the input
  4269. |history| stack.
  4270. The result is a String, which is whatever the user actually
  4271. typed on the command-line in response to the issued prompt.
  4272. NOTE: Command-line completion is not supported.
  4273. Parameters: ~
  4274. • {prompt} (`string`)
  4275. • {text} (`string?`)
  4276. Return: ~
  4277. (`any`)
  4278. insert({object}, {item} [, {idx}]) *insert()*
  4279. When {object} is a |List| or a |Blob| insert {item} at the start
  4280. of it.
  4281. If {idx} is specified insert {item} before the item with index
  4282. {idx}. If {idx} is zero it goes before the first item, just
  4283. like omitting {idx}. A negative {idx} is also possible, see
  4284. |list-index|. -1 inserts just before the last item.
  4285. Returns the resulting |List| or |Blob|. Examples: >vim
  4286. let mylist = insert([2, 3, 5], 1)
  4287. call insert(mylist, 4, -1)
  4288. call insert(mylist, 6, len(mylist))
  4289. < The last example can be done simpler with |add()|.
  4290. Note that when {item} is a |List| it is inserted as a single
  4291. item. Use |extend()| to concatenate |Lists|.
  4292. Parameters: ~
  4293. • {object} (`any`)
  4294. • {item} (`any`)
  4295. • {idx} (`integer?`)
  4296. Return: ~
  4297. (`any`)
  4298. interrupt() *interrupt()*
  4299. Interrupt script execution. It works more or less like the
  4300. user typing CTRL-C, most commands won't execute and control
  4301. returns to the user. This is useful to abort execution
  4302. from lower down, e.g. in an autocommand. Example: >vim
  4303. function s:check_typoname(file)
  4304. if fnamemodify(a:file, ':t') == '['
  4305. echomsg 'Maybe typo'
  4306. call interrupt()
  4307. endif
  4308. endfunction
  4309. au BufWritePre * call s:check_typoname(expand('<amatch>'))
  4310. <
  4311. Return: ~
  4312. (`any`)
  4313. invert({expr}) *invert()*
  4314. Bitwise invert. The argument is converted to a number. A
  4315. List, Dict or Float argument causes an error. Example: >vim
  4316. let bits = invert(bits)
  4317. <
  4318. Parameters: ~
  4319. • {expr} (`number`)
  4320. Return: ~
  4321. (`any`)
  4322. isabsolutepath({path}) *isabsolutepath()*
  4323. The result is a Number, which is |TRUE| when {path} is an
  4324. absolute path.
  4325. On Unix, a path is considered absolute when it starts with '/'.
  4326. On MS-Windows, it is considered absolute when it starts with an
  4327. optional drive prefix and is followed by a '\' or '/'. UNC paths
  4328. are always absolute.
  4329. Example: >vim
  4330. echo isabsolutepath('/usr/share/') " 1
  4331. echo isabsolutepath('./foobar') " 0
  4332. echo isabsolutepath('C:\Windows') " 1
  4333. echo isabsolutepath('foobar') " 0
  4334. echo isabsolutepath('\\remote\file') " 1
  4335. <
  4336. Parameters: ~
  4337. • {path} (`string`)
  4338. Return: ~
  4339. (`0|1`)
  4340. isdirectory({directory}) *isdirectory()*
  4341. The result is a Number, which is |TRUE| when a directory
  4342. with the name {directory} exists. If {directory} doesn't
  4343. exist, or isn't a directory, the result is |FALSE|. {directory}
  4344. is any expression, which is used as a String.
  4345. Parameters: ~
  4346. • {directory} (`string`)
  4347. Return: ~
  4348. (`0|1`)
  4349. isinf({expr}) *isinf()*
  4350. Return 1 if {expr} is a positive infinity, or -1 a negative
  4351. infinity, otherwise 0. >vim
  4352. echo isinf(1.0 / 0.0)
  4353. < 1 >vim
  4354. echo isinf(-1.0 / 0.0)
  4355. < -1
  4356. Parameters: ~
  4357. • {expr} (`number`)
  4358. Return: ~
  4359. (`1|0|-1`)
  4360. islocked({expr}) *islocked()* *E786*
  4361. The result is a Number, which is |TRUE| when {expr} is the
  4362. name of a locked variable.
  4363. The string argument {expr} must be the name of a variable,
  4364. |List| item or |Dictionary| entry, not the variable itself!
  4365. Example: >vim
  4366. let alist = [0, ['a', 'b'], 2, 3]
  4367. lockvar 1 alist
  4368. echo islocked('alist') " 1
  4369. echo islocked('alist[1]') " 0
  4370. < When {expr} is a variable that does not exist you get an error
  4371. message. Use |exists()| to check for existence.
  4372. Parameters: ~
  4373. • {expr} (`any`)
  4374. Return: ~
  4375. (`0|1`)
  4376. isnan({expr}) *isnan()*
  4377. Return |TRUE| if {expr} is a float with value NaN. >vim
  4378. echo isnan(0.0 / 0.0)
  4379. < 1
  4380. Parameters: ~
  4381. • {expr} (`number`)
  4382. Return: ~
  4383. (`0|1`)
  4384. items({dict}) *items()*
  4385. Return a |List| with all the key-value pairs of {dict}. Each
  4386. |List| item is a list with two items: the key of a {dict}
  4387. entry and the value of this entry. The |List| is in arbitrary
  4388. order. Also see |keys()| and |values()|.
  4389. Example: >vim
  4390. for [key, value] in items(mydict)
  4391. echo key .. ': ' .. value
  4392. endfor
  4393. <
  4394. A List or a String argument is also supported. In these
  4395. cases, items() returns a List with the index and the value at
  4396. the index.
  4397. Parameters: ~
  4398. • {dict} (`any`)
  4399. Return: ~
  4400. (`any`)
  4401. jobpid({job}) *jobpid()*
  4402. Return the PID (process id) of |job-id| {job}.
  4403. Parameters: ~
  4404. • {job} (`integer`)
  4405. Return: ~
  4406. (`integer`)
  4407. jobresize({job}, {width}, {height}) *jobresize()*
  4408. Resize the pseudo terminal window of |job-id| {job} to {width}
  4409. columns and {height} rows.
  4410. Fails if the job was not started with `"pty":v:true`.
  4411. Parameters: ~
  4412. • {job} (`integer`)
  4413. • {width} (`integer`)
  4414. • {height} (`integer`)
  4415. Return: ~
  4416. (`any`)
  4417. jobstart({cmd} [, {opts}]) *jobstart()*
  4418. Note: Prefer |vim.system()| in Lua (unless using the `pty` option).
  4419. Spawns {cmd} as a job.
  4420. If {cmd} is a List it runs directly (no 'shell').
  4421. If {cmd} is a String it runs in the 'shell', like this: >vim
  4422. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  4423. < (See |shell-unquoting| for details.)
  4424. Example: >vim
  4425. call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
  4426. <
  4427. Returns |job-id| on success, 0 on invalid arguments (or job
  4428. table is full), -1 if {cmd}[0] or 'shell' is not executable.
  4429. The returned job-id is a valid |channel-id| representing the
  4430. job's stdio streams. Use |chansend()| (or |rpcnotify()| and
  4431. |rpcrequest()| if "rpc" was enabled) to send data to stdin and
  4432. |chanclose()| to close the streams without stopping the job.
  4433. See |job-control| and |RPC|.
  4434. NOTE: on Windows if {cmd} is a List:
  4435. - cmd[0] must be an executable (not a "built-in"). If it is
  4436. in $PATH it can be called by name, without an extension: >vim
  4437. call jobstart(['ping', 'neovim.io'])
  4438. < If it is a full or partial path, extension is required: >vim
  4439. call jobstart(['System32\ping.exe', 'neovim.io'])
  4440. < - {cmd} is collapsed to a string of quoted args as expected
  4441. by CommandLineToArgvW https://msdn.microsoft.com/bb776391
  4442. unless cmd[0] is some form of "cmd.exe".
  4443. *jobstart-env*
  4444. The job environment is initialized as follows:
  4445. $NVIM is set to |v:servername| of the parent Nvim
  4446. $NVIM_LISTEN_ADDRESS is unset
  4447. $NVIM_LOG_FILE is unset
  4448. $VIM is unset
  4449. $VIMRUNTIME is unset
  4450. You can set these with the `env` option.
  4451. *jobstart-options*
  4452. {opts} is a dictionary with these keys:
  4453. clear_env: (boolean) `env` defines the job environment
  4454. exactly, instead of merging current environment.
  4455. cwd: (string, default=|current-directory|) Working
  4456. directory of the job.
  4457. detach: (boolean) Detach the job process: it will not be
  4458. killed when Nvim exits. If the process exits
  4459. before Nvim, `on_exit` will be invoked.
  4460. env: (dict) Map of environment variable name:value
  4461. pairs extending (or replace with "clear_env")
  4462. the current environment. |jobstart-env|
  4463. height: (number) Height of the `pty` terminal.
  4464. |on_exit|: (function) Callback invoked when the job exits.
  4465. |on_stdout|: (function) Callback invoked when the job emits
  4466. stdout data.
  4467. |on_stderr|: (function) Callback invoked when the job emits
  4468. stderr data.
  4469. overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
  4470. stdio passed to the child process. Only on
  4471. MS-Windows; ignored on other platforms.
  4472. pty: (boolean) Connect the job to a new pseudo
  4473. terminal, and its streams to the master file
  4474. descriptor. `on_stdout` receives all output,
  4475. `on_stderr` is ignored. |terminal-start|
  4476. rpc: (boolean) Use |msgpack-rpc| to communicate with
  4477. the job over stdio. Then `on_stdout` is ignored,
  4478. but `on_stderr` can still be used.
  4479. stderr_buffered: (boolean) Collect data until EOF (stream closed)
  4480. before invoking `on_stderr`. |channel-buffered|
  4481. stdout_buffered: (boolean) Collect data until EOF (stream
  4482. closed) before invoking `on_stdout`. |channel-buffered|
  4483. stdin: (string) Either "pipe" (default) to connect the
  4484. job's stdin to a channel or "null" to disconnect
  4485. stdin.
  4486. width: (number) Width of the `pty` terminal.
  4487. {opts} is passed as |self| dictionary to the callback; the
  4488. caller may set other keys to pass application-specific data.
  4489. Returns:
  4490. - |channel-id| on success
  4491. - 0 on invalid arguments
  4492. - -1 if {cmd}[0] is not executable.
  4493. See also |job-control|, |channel|, |msgpack-rpc|.
  4494. Parameters: ~
  4495. • {cmd} (`string|string[]`)
  4496. • {opts} (`table?`)
  4497. Return: ~
  4498. (`any`)
  4499. jobstop({id}) *jobstop()*
  4500. Stop |job-id| {id} by sending SIGTERM to the job process. If
  4501. the process does not terminate after a timeout then SIGKILL
  4502. will be sent. When the job terminates its |on_exit| handler
  4503. (if any) will be invoked.
  4504. See |job-control|.
  4505. Returns 1 for valid job id, 0 for invalid id, including jobs have
  4506. exited or stopped.
  4507. Parameters: ~
  4508. • {id} (`integer`)
  4509. Return: ~
  4510. (`any`)
  4511. jobwait({jobs} [, {timeout}]) *jobwait()*
  4512. Waits for jobs and their |on_exit| handlers to complete.
  4513. {jobs} is a List of |job-id|s to wait for.
  4514. {timeout} is the maximum waiting time in milliseconds. If
  4515. omitted or -1, wait forever.
  4516. Timeout of 0 can be used to check the status of a job: >vim
  4517. let running = jobwait([{job-id}], 0)[0] == -1
  4518. <
  4519. During jobwait() callbacks for jobs not in the {jobs} list may
  4520. be invoked. The screen will not redraw unless |:redraw| is
  4521. invoked by a callback.
  4522. Returns a list of len({jobs}) integers, where each integer is
  4523. the status of the corresponding job:
  4524. Exit-code, if the job exited
  4525. -1 if the timeout was exceeded
  4526. -2 if the job was interrupted (by |CTRL-C|)
  4527. -3 if the job-id is invalid
  4528. Parameters: ~
  4529. • {jobs} (`integer[]`)
  4530. • {timeout} (`integer?`)
  4531. Return: ~
  4532. (`any`)
  4533. join({list} [, {sep}]) *join()*
  4534. Join the items in {list} together into one String.
  4535. When {sep} is specified it is put in between the items. If
  4536. {sep} is omitted a single space is used.
  4537. Note that {sep} is not added at the end. You might want to
  4538. add it there too: >vim
  4539. let lines = join(mylist, "\n") .. "\n"
  4540. < String items are used as-is. |Lists| and |Dictionaries| are
  4541. converted into a string like with |string()|.
  4542. The opposite function is |split()|.
  4543. Parameters: ~
  4544. • {list} (`any[]`)
  4545. • {sep} (`string?`)
  4546. Return: ~
  4547. (`any`)
  4548. json_decode({expr}) *json_decode()*
  4549. Convert {expr} from JSON object. Accepts |readfile()|-style
  4550. list as the input, as well as regular string. May output any
  4551. Vim value. In the following cases it will output
  4552. |msgpack-special-dict|:
  4553. 1. Dictionary contains duplicate key.
  4554. 2. String contains NUL byte. Two special dictionaries: for
  4555. dictionary and for string will be emitted in case string
  4556. with NUL byte was a dictionary key.
  4557. Note: function treats its input as UTF-8 always. The JSON
  4558. standard allows only a few encodings, of which UTF-8 is
  4559. recommended and the only one required to be supported.
  4560. Non-UTF-8 characters are an error.
  4561. Parameters: ~
  4562. • {expr} (`any`)
  4563. Return: ~
  4564. (`any`)
  4565. json_encode({expr}) *json_encode()*
  4566. Convert {expr} into a JSON string. Accepts
  4567. |msgpack-special-dict| as the input. Will not convert
  4568. |Funcref|s, mappings with non-string keys (can be created as
  4569. |msgpack-special-dict|), values with self-referencing
  4570. containers, strings which contain non-UTF-8 characters,
  4571. pseudo-UTF-8 strings which contain codepoints reserved for
  4572. surrogate pairs (such strings are not valid UTF-8 strings).
  4573. Non-printable characters are converted into "\u1234" escapes
  4574. or special escapes like "\t", other are dumped as-is.
  4575. |Blob|s are converted to arrays of the individual bytes.
  4576. Parameters: ~
  4577. • {expr} (`any`)
  4578. Return: ~
  4579. (`any`)
  4580. keys({dict}) *keys()*
  4581. Return a |List| with all the keys of {dict}. The |List| is in
  4582. arbitrary order. Also see |items()| and |values()|.
  4583. Parameters: ~
  4584. • {dict} (`table`)
  4585. Return: ~
  4586. (`any`)
  4587. keytrans({string}) *keytrans()*
  4588. Turn the internal byte representation of keys into a form that
  4589. can be used for |:map|. E.g. >vim
  4590. let xx = "\<C-Home>"
  4591. echo keytrans(xx)
  4592. < <C-Home>
  4593. Parameters: ~
  4594. • {string} (`string`)
  4595. Return: ~
  4596. (`any`)
  4597. len({expr}) *len()* *E701*
  4598. The result is a Number, which is the length of the argument.
  4599. When {expr} is a String or a Number the length in bytes is
  4600. used, as with |strlen()|.
  4601. When {expr} is a |List| the number of items in the |List| is
  4602. returned.
  4603. When {expr} is a |Blob| the number of bytes is returned.
  4604. When {expr} is a |Dictionary| the number of entries in the
  4605. |Dictionary| is returned.
  4606. Otherwise an error is given and returns zero.
  4607. Parameters: ~
  4608. • {expr} (`any`)
  4609. Return: ~
  4610. (`any`)
  4611. libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E368*
  4612. Call function {funcname} in the run-time library {libname}
  4613. with single argument {argument}.
  4614. This is useful to call functions in a library that you
  4615. especially made to be used with Vim. Since only one argument
  4616. is possible, calling standard library functions is rather
  4617. limited.
  4618. The result is the String returned by the function. If the
  4619. function returns NULL, this will appear as an empty string ""
  4620. to Vim.
  4621. If the function returns a number, use libcallnr()!
  4622. If {argument} is a number, it is passed to the function as an
  4623. int; if {argument} is a string, it is passed as a
  4624. null-terminated string.
  4625. libcall() allows you to write your own 'plug-in' extensions to
  4626. Vim without having to recompile the program. It is NOT a
  4627. means to call system functions! If you try to do so Vim will
  4628. very probably crash.
  4629. For Win32, the functions you write must be placed in a DLL
  4630. and use the normal C calling convention (NOT Pascal which is
  4631. used in Windows System DLLs). The function must take exactly
  4632. one parameter, either a character pointer or a long integer,
  4633. and must return a character pointer or NULL. The character
  4634. pointer returned must point to memory that will remain valid
  4635. after the function has returned (e.g. in static data in the
  4636. DLL). If it points to allocated memory, that memory will
  4637. leak away. Using a static buffer in the function should work,
  4638. it's then freed when the DLL is unloaded.
  4639. WARNING: If the function returns a non-valid pointer, Vim may
  4640. crash! This also happens if the function returns a number,
  4641. because Vim thinks it's a pointer.
  4642. For Win32 systems, {libname} should be the filename of the DLL
  4643. without the ".DLL" suffix. A full path is only required if
  4644. the DLL is not in the usual places.
  4645. For Unix: When compiling your own plugins, remember that the
  4646. object code must be compiled as position-independent ('PIC').
  4647. Examples: >vim
  4648. echo libcall("libc.so", "getenv", "HOME")
  4649. Parameters: ~
  4650. • {libname} (`string`)
  4651. • {funcname} (`string`)
  4652. • {argument} (`any`)
  4653. Return: ~
  4654. (`any`)
  4655. libcallnr({libname}, {funcname}, {argument}) *libcallnr()*
  4656. Just like |libcall()|, but used for a function that returns an
  4657. int instead of a string.
  4658. Examples: >vim
  4659. echo libcallnr("/usr/lib/libc.so", "getpid", "")
  4660. call libcallnr("libc.so", "printf", "Hello World!\n")
  4661. call libcallnr("libc.so", "sleep", 10)
  4662. <
  4663. Parameters: ~
  4664. • {libname} (`string`)
  4665. • {funcname} (`string`)
  4666. • {argument} (`any`)
  4667. Return: ~
  4668. (`any`)
  4669. line({expr} [, {winid}]) *line()*
  4670. See |getpos()| for accepted positions.
  4671. To get the column number use |col()|. To get both use
  4672. |getpos()|.
  4673. With the optional {winid} argument the values are obtained for
  4674. that window instead of the current window.
  4675. Returns 0 for invalid values of {expr} and {winid}.
  4676. Examples: >vim
  4677. echo line(".") " line number of the cursor
  4678. echo line(".", winid) " idem, in window "winid"
  4679. echo line("'t") " line number of mark t
  4680. echo line("'" .. marker) " line number of mark marker
  4681. <
  4682. To jump to the last known position when opening a file see
  4683. |last-position-jump|.
  4684. Parameters: ~
  4685. • {expr} (`string|integer[]`)
  4686. • {winid} (`integer?`)
  4687. Return: ~
  4688. (`integer`)
  4689. line2byte({lnum}) *line2byte()*
  4690. Return the byte count from the start of the buffer for line
  4691. {lnum}. This includes the end-of-line character, depending on
  4692. the 'fileformat' option for the current buffer. The first
  4693. line returns 1. UTF-8 encoding is used, 'fileencoding' is
  4694. ignored. This can also be used to get the byte count for the
  4695. line just below the last line: >vim
  4696. echo line2byte(line("$") + 1)
  4697. < This is the buffer size plus one. If 'fileencoding' is empty
  4698. it is the file size plus one. {lnum} is used like with
  4699. |getline()|. When {lnum} is invalid -1 is returned.
  4700. Also see |byte2line()|, |go| and |:goto|.
  4701. Parameters: ~
  4702. • {lnum} (`integer`)
  4703. Return: ~
  4704. (`integer`)
  4705. lispindent({lnum}) *lispindent()*
  4706. Get the amount of indent for line {lnum} according the lisp
  4707. indenting rules, as with 'lisp'.
  4708. The indent is counted in spaces, the value of 'tabstop' is
  4709. relevant. {lnum} is used just like in |getline()|.
  4710. When {lnum} is invalid, -1 is returned.
  4711. Parameters: ~
  4712. • {lnum} (`integer`)
  4713. Return: ~
  4714. (`any`)
  4715. list2blob({list}) *list2blob()*
  4716. Return a Blob concatenating all the number values in {list}.
  4717. Examples: >vim
  4718. echo list2blob([1, 2, 3, 4]) " returns 0z01020304
  4719. echo list2blob([]) " returns 0z
  4720. < Returns an empty Blob on error. If one of the numbers is
  4721. negative or more than 255 error *E1239* is given.
  4722. |blob2list()| does the opposite.
  4723. Parameters: ~
  4724. • {list} (`any[]`)
  4725. Return: ~
  4726. (`any`)
  4727. list2str({list} [, {utf8}]) *list2str()*
  4728. Convert each number in {list} to a character string can
  4729. concatenate them all. Examples: >vim
  4730. echo list2str([32]) " returns " "
  4731. echo list2str([65, 66, 67]) " returns "ABC"
  4732. < The same can be done (slowly) with: >vim
  4733. echo join(map(list, {nr, val -> nr2char(val)}), '')
  4734. < |str2list()| does the opposite.
  4735. UTF-8 encoding is always used, {utf8} option has no effect,
  4736. and exists only for backwards-compatibility.
  4737. With UTF-8 composing characters work as expected: >vim
  4738. echo list2str([97, 769]) " returns "á"
  4739. <
  4740. Returns an empty string on error.
  4741. Parameters: ~
  4742. • {list} (`any[]`)
  4743. • {utf8} (`boolean?`)
  4744. Return: ~
  4745. (`any`)
  4746. localtime() *localtime()*
  4747. Return the current time, measured as seconds since 1st Jan
  4748. 1970. See also |strftime()|, |strptime()| and |getftime()|.
  4749. Return: ~
  4750. (`any`)
  4751. log({expr}) *log()*
  4752. Return the natural logarithm (base e) of {expr} as a |Float|.
  4753. {expr} must evaluate to a |Float| or a |Number| in the range
  4754. (0, inf].
  4755. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4756. Examples: >vim
  4757. echo log(10)
  4758. < 2.302585 >vim
  4759. echo log(exp(5))
  4760. < 5.0
  4761. Parameters: ~
  4762. • {expr} (`number`)
  4763. Return: ~
  4764. (`any`)
  4765. log10({expr}) *log10()*
  4766. Return the logarithm of Float {expr} to base 10 as a |Float|.
  4767. {expr} must evaluate to a |Float| or a |Number|.
  4768. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4769. Examples: >vim
  4770. echo log10(1000)
  4771. < 3.0 >vim
  4772. echo log10(0.01)
  4773. < -2.0
  4774. Parameters: ~
  4775. • {expr} (`number`)
  4776. Return: ~
  4777. (`any`)
  4778. luaeval({expr} [, {expr}]) *luaeval()*
  4779. Evaluate Lua expression {expr} and return its result converted
  4780. to Vim data structures. See |lua-eval| for more details.
  4781. Parameters: ~
  4782. • {expr} (`string`)
  4783. • {expr1} (`any[]?`)
  4784. Return: ~
  4785. (`any`)
  4786. map({expr1}, {expr2}) *map()*
  4787. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  4788. When {expr1} is a |List| or |Dictionary|, replace each
  4789. item in {expr1} with the result of evaluating {expr2}.
  4790. For a |Blob| each byte is replaced.
  4791. For a |String|, each character, including composing
  4792. characters, is replaced.
  4793. If the item type changes you may want to use |mapnew()| to
  4794. create a new List or Dictionary.
  4795. {expr2} must be a |String| or |Funcref|.
  4796. If {expr2} is a |String|, inside {expr2} |v:val| has the value
  4797. of the current item. For a |Dictionary| |v:key| has the key
  4798. of the current item and for a |List| |v:key| has the index of
  4799. the current item. For a |Blob| |v:key| has the index of the
  4800. current byte. For a |String| |v:key| has the index of the
  4801. current character.
  4802. Example: >vim
  4803. call map(mylist, '"> " .. v:val .. " <"')
  4804. < This puts "> " before and " <" after each item in "mylist".
  4805. Note that {expr2} is the result of an expression and is then
  4806. used as an expression again. Often it is good to use a
  4807. |literal-string| to avoid having to double backslashes. You
  4808. still have to double ' quotes
  4809. If {expr2} is a |Funcref| it is called with two arguments:
  4810. 1. The key or the index of the current item.
  4811. 2. the value of the current item.
  4812. The function must return the new value of the item. Example
  4813. that changes each value by "key-value": >vim
  4814. func KeyValue(key, val)
  4815. return a:key .. '-' .. a:val
  4816. endfunc
  4817. call map(myDict, function('KeyValue'))
  4818. < It is shorter when using a |lambda|: >vim
  4819. call map(myDict, {key, val -> key .. '-' .. val})
  4820. < If you do not use "val" you can leave it out: >vim
  4821. call map(myDict, {key -> 'item: ' .. key})
  4822. < If you do not use "key" you can use a short name: >vim
  4823. call map(myDict, {_, val -> 'item: ' .. val})
  4824. <
  4825. The operation is done in-place for a |List| and |Dictionary|.
  4826. If you want it to remain unmodified make a copy first: >vim
  4827. let tlist = map(copy(mylist), ' v:val .. "\t"')
  4828. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  4829. or a new |Blob| or |String|.
  4830. When an error is encountered while evaluating {expr2} no
  4831. further items in {expr1} are processed.
  4832. When {expr2} is a Funcref errors inside a function are ignored,
  4833. unless it was defined with the "abort" flag.
  4834. Parameters: ~
  4835. • {expr1} (`string|table|any[]`)
  4836. • {expr2} (`string|function`)
  4837. Return: ~
  4838. (`any`)
  4839. maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
  4840. When {dict} is omitted or zero: Return the rhs of mapping
  4841. {name} in mode {mode}. The returned String has special
  4842. characters translated like in the output of the ":map" command
  4843. listing. When {dict} is TRUE a dictionary is returned, see
  4844. below. To get a list of all mappings see |maplist()|.
  4845. When there is no mapping for {name}, an empty String is
  4846. returned if {dict} is FALSE, otherwise returns an empty Dict.
  4847. When the mapping for {name} is empty, then "<Nop>" is
  4848. returned.
  4849. The {name} can have special key names, like in the ":map"
  4850. command.
  4851. {mode} can be one of these strings:
  4852. "n" Normal
  4853. "v" Visual (including Select)
  4854. "o" Operator-pending
  4855. "i" Insert
  4856. "c" Cmd-line
  4857. "s" Select
  4858. "x" Visual
  4859. "l" langmap |language-mapping|
  4860. "t" Terminal
  4861. "" Normal, Visual and Operator-pending
  4862. When {mode} is omitted, the modes for "" are used.
  4863. When {abbr} is there and it is |TRUE| use abbreviations
  4864. instead of mappings.
  4865. When {dict} is there and it is |TRUE| return a dictionary
  4866. containing all the information of the mapping with the
  4867. following items: *mapping-dict*
  4868. "lhs" The {lhs} of the mapping as it would be typed
  4869. "lhsraw" The {lhs} of the mapping as raw bytes
  4870. "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
  4871. form, only present when it differs from "lhsraw"
  4872. "rhs" The {rhs} of the mapping as typed.
  4873. "callback" Lua function, if RHS was defined as such.
  4874. "silent" 1 for a |:map-silent| mapping, else 0.
  4875. "noremap" 1 if the {rhs} of the mapping is not remappable.
  4876. "script" 1 if mapping was defined with <script>.
  4877. "expr" 1 for an expression mapping (|:map-<expr>|).
  4878. "buffer" 1 for a buffer local mapping (|:map-local|).
  4879. "mode" Modes for which the mapping is defined. In
  4880. addition to the modes mentioned above, these
  4881. characters will be used:
  4882. " " Normal, Visual and Operator-pending
  4883. "!" Insert and Commandline mode
  4884. (|mapmode-ic|)
  4885. "sid" The script local ID, used for <sid> mappings
  4886. (|<SID>|). Negative for special contexts.
  4887. "scriptversion" The version of the script, always 1.
  4888. "lnum" The line number in "sid", zero if unknown.
  4889. "nowait" Do not wait for other, longer mappings.
  4890. (|:map-<nowait>|).
  4891. "abbr" True if this is an |abbreviation|.
  4892. "mode_bits" Nvim's internal binary representation of "mode".
  4893. |mapset()| ignores this; only "mode" is used.
  4894. See |maplist()| for usage examples. The values
  4895. are from src/nvim/state_defs.h and may change in
  4896. the future.
  4897. The dictionary can be used to restore a mapping with
  4898. |mapset()|.
  4899. The mappings local to the current buffer are checked first,
  4900. then the global mappings.
  4901. This function can be used to map a key even when it's already
  4902. mapped, and have it do the original mapping too. Sketch: >vim
  4903. exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
  4904. <
  4905. Parameters: ~
  4906. • {name} (`string`)
  4907. • {mode} (`string?`)
  4908. • {abbr} (`boolean?`)
  4909. • {dict} (`false?`)
  4910. Return: ~
  4911. (`string`)
  4912. mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
  4913. Check if there is a mapping that matches with {name} in mode
  4914. {mode}. See |maparg()| for {mode} and special names in
  4915. {name}.
  4916. When {abbr} is there and it is non-zero use abbreviations
  4917. instead of mappings.
  4918. A match happens with a mapping that starts with {name} and
  4919. with a mapping which is equal to the start of {name}.
  4920. matches mapping "a" "ab" "abc" ~
  4921. mapcheck("a") yes yes yes
  4922. mapcheck("abc") yes yes yes
  4923. mapcheck("ax") yes no no
  4924. mapcheck("b") no no no
  4925. The difference with maparg() is that mapcheck() finds a
  4926. mapping that matches with {name}, while maparg() only finds a
  4927. mapping for {name} exactly.
  4928. When there is no mapping that starts with {name}, an empty
  4929. String is returned. If there is one, the RHS of that mapping
  4930. is returned. If there are several mappings that start with
  4931. {name}, the RHS of one of them is returned. This will be
  4932. "<Nop>" if the RHS is empty.
  4933. The mappings local to the current buffer are checked first,
  4934. then the global mappings.
  4935. This function can be used to check if a mapping can be added
  4936. without being ambiguous. Example: >vim
  4937. if mapcheck("_vv") == ""
  4938. map _vv :set guifont=7x13<CR>
  4939. endif
  4940. < This avoids adding the "_vv" mapping when there already is a
  4941. mapping for "_v" or for "_vvv".
  4942. Parameters: ~
  4943. • {name} (`string`)
  4944. • {mode} (`string?`)
  4945. • {abbr} (`boolean?`)
  4946. Return: ~
  4947. (`any`)
  4948. maplist([{abbr}]) *maplist()*
  4949. Returns a |List| of all mappings. Each List item is a |Dict|,
  4950. the same as what is returned by |maparg()|, see
  4951. |mapping-dict|. When {abbr} is there and it is |TRUE| use
  4952. abbreviations instead of mappings.
  4953. Example to show all mappings with "MultiMatch" in rhs: >vim
  4954. echo maplist()->filter({_, m ->
  4955. \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
  4956. \ })
  4957. < It can be tricky to find mappings for particular |:map-modes|.
  4958. |mapping-dict|'s "mode_bits" can simplify this. For example,
  4959. the mode_bits for Normal, Insert or Command-line modes are
  4960. 0x19. To find all the mappings available in those modes you
  4961. can do: >vim
  4962. let saved_maps = []
  4963. for m in maplist()
  4964. if and(m.mode_bits, 0x19) != 0
  4965. eval saved_maps->add(m)
  4966. endif
  4967. endfor
  4968. echo saved_maps->mapnew({_, m -> m.lhs})
  4969. < The values of the mode_bits are defined in Nvim's
  4970. src/nvim/state_defs.h file and they can be discovered at
  4971. runtime using |:map-commands| and "maplist()". Example: >vim
  4972. omap xyzzy <Nop>
  4973. let op_bit = maplist()->filter(
  4974. \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
  4975. ounmap xyzzy
  4976. echo printf("Operator-pending mode bit: 0x%x", op_bit)
  4977. <
  4978. Parameters: ~
  4979. • {abbr} (`0|1?`)
  4980. Return: ~
  4981. (`table[]`)
  4982. mapnew({expr1}, {expr2}) *mapnew()*
  4983. Like |map()| but instead of replacing items in {expr1} a new
  4984. List or Dictionary is created and returned. {expr1} remains
  4985. unchanged. Items can still be changed by {expr2}, if you
  4986. don't want that use |deepcopy()| first.
  4987. Parameters: ~
  4988. • {expr1} (`any`)
  4989. • {expr2} (`any`)
  4990. Return: ~
  4991. (`any`)
  4992. mapset({mode}, {abbr}, {dict}) *mapset()*
  4993. mapset({dict})
  4994. Restore a mapping from a dictionary, possibly returned by
  4995. |maparg()| or |maplist()|. A buffer mapping, when dict.buffer
  4996. is true, is set on the current buffer; it is up to the caller
  4997. to ensure that the intended buffer is the current buffer. This
  4998. feature allows copying mappings from one buffer to another.
  4999. The dict.mode value may restore a single mapping that covers
  5000. more than one mode, like with mode values of '!', ' ', "nox",
  5001. or 'v'. *E1276*
  5002. In the first form, {mode} and {abbr} should be the same as
  5003. for the call to |maparg()|. *E460*
  5004. {mode} is used to define the mode in which the mapping is set,
  5005. not the "mode" entry in {dict}.
  5006. Example for saving and restoring a mapping: >vim
  5007. let save_map = maparg('K', 'n', 0, 1)
  5008. nnoremap K somethingelse
  5009. " ...
  5010. call mapset('n', 0, save_map)
  5011. < Note that if you are going to replace a map in several modes,
  5012. e.g. with `:map!`, you need to save/restore the mapping for
  5013. all of them, when they might differ.
  5014. In the second form, with {dict} as the only argument, mode
  5015. and abbr are taken from the dict.
  5016. Example: >vim
  5017. let save_maps = maplist()->filter(
  5018. \ {_, m -> m.lhs == 'K'})
  5019. nnoremap K somethingelse
  5020. cnoremap K somethingelse2
  5021. " ...
  5022. unmap K
  5023. for d in save_maps
  5024. call mapset(d)
  5025. endfor
  5026. <
  5027. Parameters: ~
  5028. • {dict} (`boolean`)
  5029. Return: ~
  5030. (`any`)
  5031. match({expr}, {pat} [, {start} [, {count}]]) *match()*
  5032. When {expr} is a |List| then this returns the index of the
  5033. first item where {pat} matches. Each item is used as a
  5034. String, |Lists| and |Dictionaries| are used as echoed.
  5035. Otherwise, {expr} is used as a String. The result is a
  5036. Number, which gives the index (byte offset) in {expr} where
  5037. {pat} matches.
  5038. A match at the first character or |List| item returns zero.
  5039. If there is no match -1 is returned.
  5040. For getting submatches see |matchlist()|.
  5041. Example: >vim
  5042. echo match("testing", "ing") " results in 4
  5043. echo match([1, 'x'], '\a') " results in 1
  5044. < See |string-match| for how {pat} is used.
  5045. *strpbrk()*
  5046. Vim doesn't have a strpbrk() function. But you can do: >vim
  5047. let sepidx = match(line, '[.,;: \t]')
  5048. < *strcasestr()*
  5049. Vim doesn't have a strcasestr() function. But you can add
  5050. "\c" to the pattern to ignore case: >vim
  5051. let idx = match(haystack, '\cneedle')
  5052. <
  5053. If {start} is given, the search starts from byte index
  5054. {start} in a String or item {start} in a |List|.
  5055. The result, however, is still the index counted from the
  5056. first character/item. Example: >vim
  5057. echo match("testing", "ing", 2)
  5058. < result is again "4". >vim
  5059. echo match("testing", "ing", 4)
  5060. < result is again "4". >vim
  5061. echo match("testing", "t", 2)
  5062. < result is "3".
  5063. For a String, if {start} > 0 then it is like the string starts
  5064. {start} bytes later, thus "^" will match at {start}. Except
  5065. when {count} is given, then it's like matches before the
  5066. {start} byte are ignored (this is a bit complicated to keep it
  5067. backwards compatible).
  5068. For a String, if {start} < 0, it will be set to 0. For a list
  5069. the index is counted from the end.
  5070. If {start} is out of range ({start} > strlen({expr}) for a
  5071. String or {start} > len({expr}) for a |List|) -1 is returned.
  5072. When {count} is given use the {count}th match. When a match
  5073. is found in a String the search for the next one starts one
  5074. character further. Thus this example results in 1: >vim
  5075. echo match("testing", "..", 0, 2)
  5076. < In a |List| the search continues in the next item.
  5077. Note that when {count} is added the way {start} works changes,
  5078. see above.
  5079. *match-pattern*
  5080. See |pattern| for the patterns that are accepted.
  5081. The 'ignorecase' option is used to set the ignore-caseness of
  5082. the pattern. 'smartcase' is NOT used. The matching is always
  5083. done like 'magic' is set and 'cpoptions' is empty.
  5084. Note that a match at the start is preferred, thus when the
  5085. pattern is using "*" (any number of matches) it tends to find
  5086. zero matches at the start instead of a number of matches
  5087. further down in the text.
  5088. Parameters: ~
  5089. • {expr} (`string|any[]`)
  5090. • {pat} (`string`)
  5091. • {start} (`integer?`)
  5092. • {count} (`integer?`)
  5093. Return: ~
  5094. (`any`)
  5095. *matchadd()* *E798* *E799* *E801* *E957*
  5096. matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
  5097. Defines a pattern to be highlighted in the current window (a
  5098. "match"). It will be highlighted with {group}. Returns an
  5099. identification number (ID), which can be used to delete the
  5100. match using |matchdelete()|. The ID is bound to the window.
  5101. Matching is case sensitive and magic, unless case sensitivity
  5102. or magicness are explicitly overridden in {pattern}. The
  5103. 'magic', 'smartcase' and 'ignorecase' options are not used.
  5104. The "Conceal" value is special, it causes the match to be
  5105. concealed.
  5106. The optional {priority} argument assigns a priority to the
  5107. match. A match with a high priority will have its
  5108. highlighting overrule that of a match with a lower priority.
  5109. A priority is specified as an integer (negative numbers are no
  5110. exception). If the {priority} argument is not specified, the
  5111. default priority is 10. The priority of 'hlsearch' is zero,
  5112. hence all matches with a priority greater than zero will
  5113. overrule it. Syntax highlighting (see 'syntax') is a separate
  5114. mechanism, and regardless of the chosen priority a match will
  5115. always overrule syntax highlighting.
  5116. The optional {id} argument allows the request for a specific
  5117. match ID. If a specified ID is already taken, an error
  5118. message will appear and the match will not be added. An ID
  5119. is specified as a positive integer (zero excluded). IDs 1, 2
  5120. and 3 are reserved for |:match|, |:2match| and |:3match|,
  5121. respectively. 3 is reserved for use by the |matchparen|
  5122. plugin.
  5123. If the {id} argument is not specified or -1, |matchadd()|
  5124. automatically chooses a free ID, which is at least 1000.
  5125. The optional {dict} argument allows for further custom
  5126. values. Currently this is used to specify a match specific
  5127. conceal character that will be shown for |hl-Conceal|
  5128. highlighted matches. The dict can have the following members:
  5129. conceal Special character to show instead of the
  5130. match (only for |hl-Conceal| highlighted
  5131. matches, see |:syn-cchar|)
  5132. window Instead of the current window use the
  5133. window with this number or window ID.
  5134. The number of matches is not limited, as it is the case with
  5135. the |:match| commands.
  5136. Returns -1 on error.
  5137. Example: >vim
  5138. highlight MyGroup ctermbg=green guibg=green
  5139. let m = matchadd("MyGroup", "TODO")
  5140. < Deletion of the pattern: >vim
  5141. call matchdelete(m)
  5142. < A list of matches defined by |matchadd()| and |:match| are
  5143. available from |getmatches()|. All matches can be deleted in
  5144. one operation by |clearmatches()|.
  5145. Parameters: ~
  5146. • {group} (`integer|string`)
  5147. • {pattern} (`string`)
  5148. • {priority} (`integer?`)
  5149. • {id} (`integer?`)
  5150. • {dict} (`string?`)
  5151. Return: ~
  5152. (`any`)
  5153. matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
  5154. Same as |matchadd()|, but requires a list of positions {pos}
  5155. instead of a pattern. This command is faster than |matchadd()|
  5156. because it does not handle regular expressions and it sets
  5157. buffer line boundaries to redraw screen. It is supposed to be
  5158. used when fast match additions and deletions are required, for
  5159. example to highlight matching parentheses.
  5160. *E5030* *E5031*
  5161. {pos} is a list of positions. Each position can be one of
  5162. these:
  5163. - A number. This whole line will be highlighted. The first
  5164. line has number 1.
  5165. - A list with one number, e.g., [23]. The whole line with this
  5166. number will be highlighted.
  5167. - A list with two numbers, e.g., [23, 11]. The first number is
  5168. the line number, the second one is the column number (first
  5169. column is 1, the value must correspond to the byte index as
  5170. |col()| would return). The character at this position will
  5171. be highlighted.
  5172. - A list with three numbers, e.g., [23, 11, 3]. As above, but
  5173. the third number gives the length of the highlight in bytes.
  5174. Entries with zero and negative line numbers are silently
  5175. ignored, as well as entries with negative column numbers and
  5176. lengths.
  5177. Returns -1 on error.
  5178. Example: >vim
  5179. highlight MyGroup ctermbg=green guibg=green
  5180. let m = matchaddpos("MyGroup", [[23, 24], 34])
  5181. < Deletion of the pattern: >vim
  5182. call matchdelete(m)
  5183. < Matches added by |matchaddpos()| are returned by
  5184. |getmatches()|.
  5185. Parameters: ~
  5186. • {group} (`integer|string`)
  5187. • {pos} (`any[]`)
  5188. • {priority} (`integer?`)
  5189. • {id} (`integer?`)
  5190. • {dict} (`string?`)
  5191. Return: ~
  5192. (`any`)
  5193. matcharg({nr}) *matcharg()*
  5194. Selects the {nr} match item, as set with a |:match|,
  5195. |:2match| or |:3match| command.
  5196. Return a |List| with two elements:
  5197. The name of the highlight group used
  5198. The pattern used.
  5199. When {nr} is not 1, 2 or 3 returns an empty |List|.
  5200. When there is no match item set returns ['', ''].
  5201. This is useful to save and restore a |:match|.
  5202. Highlighting matches using the |:match| commands are limited
  5203. to three matches. |matchadd()| does not have this limitation.
  5204. Parameters: ~
  5205. • {nr} (`integer`)
  5206. Return: ~
  5207. (`any`)
  5208. matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
  5209. Returns the |List| of matches in lines from {lnum} to {end} in
  5210. buffer {buf} where {pat} matches.
  5211. {lnum} and {end} can either be a line number or the string "$"
  5212. to refer to the last line in {buf}.
  5213. The {dict} argument supports following items:
  5214. submatches include submatch information (|/\(|)
  5215. For each match, a |Dict| with the following items is returned:
  5216. byteidx starting byte index of the match
  5217. lnum line number where there is a match
  5218. text matched string
  5219. Note that there can be multiple matches in a single line.
  5220. This function works only for loaded buffers. First call
  5221. |bufload()| if needed.
  5222. See |match-pattern| for information about the effect of some
  5223. option settings on the pattern.
  5224. When {buf} is not a valid buffer, the buffer is not loaded or
  5225. {lnum} or {end} is not valid then an error is given and an
  5226. empty |List| is returned.
  5227. Examples: >vim
  5228. " Assuming line 3 in buffer 5 contains "a"
  5229. echo matchbufline(5, '\<\k\+\>', 3, 3)
  5230. < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
  5231. " Assuming line 4 in buffer 10 contains "tik tok"
  5232. echo matchbufline(10, '\<\k\+\>', 1, 4)
  5233. < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
  5234. If {submatch} is present and is v:true, then submatches like
  5235. "\1", "\2", etc. are also returned. Example: >vim
  5236. " Assuming line 2 in buffer 2 contains "acd"
  5237. echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
  5238. \ {'submatches': v:true})
  5239. < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5240. The "submatches" List always contains 9 items. If a submatch
  5241. is not found, then an empty string is returned for that
  5242. submatch.
  5243. Parameters: ~
  5244. • {buf} (`string|integer`)
  5245. • {pat} (`string`)
  5246. • {lnum} (`string|integer`)
  5247. • {end_} (`string|integer`)
  5248. • {dict} (`table?`)
  5249. Return: ~
  5250. (`any`)
  5251. matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
  5252. Deletes a match with ID {id} previously defined by |matchadd()|
  5253. or one of the |:match| commands. Returns 0 if successful,
  5254. otherwise -1. See example for |matchadd()|. All matches can
  5255. be deleted in one operation by |clearmatches()|.
  5256. If {win} is specified, use the window with this number or
  5257. window ID instead of the current window.
  5258. Parameters: ~
  5259. • {id} (`integer`)
  5260. • {win} (`integer?`)
  5261. Return: ~
  5262. (`any`)
  5263. matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
  5264. Same as |match()|, but return the index of first character
  5265. after the match. Example: >vim
  5266. echo matchend("testing", "ing")
  5267. < results in "7".
  5268. *strspn()* *strcspn()*
  5269. Vim doesn't have a strspn() or strcspn() function, but you can
  5270. do it with matchend(): >vim
  5271. let span = matchend(line, '[a-zA-Z]')
  5272. let span = matchend(line, '[^a-zA-Z]')
  5273. < Except that -1 is returned when there are no matches.
  5274. The {start}, if given, has the same meaning as for |match()|. >vim
  5275. echo matchend("testing", "ing", 2)
  5276. < results in "7". >vim
  5277. echo matchend("testing", "ing", 5)
  5278. < result is "-1".
  5279. When {expr} is a |List| the result is equal to |match()|.
  5280. Parameters: ~
  5281. • {expr} (`any`)
  5282. • {pat} (`string`)
  5283. • {start} (`integer?`)
  5284. • {count} (`integer?`)
  5285. Return: ~
  5286. (`any`)
  5287. matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
  5288. If {list} is a list of strings, then returns a |List| with all
  5289. the strings in {list} that fuzzy match {str}. The strings in
  5290. the returned list are sorted based on the matching score.
  5291. The optional {dict} argument always supports the following
  5292. items:
  5293. matchseq When this item is present return only matches
  5294. that contain the characters in {str} in the
  5295. given sequence.
  5296. limit Maximum number of matches in {list} to be
  5297. returned. Zero means no limit.
  5298. If {list} is a list of dictionaries, then the optional {dict}
  5299. argument supports the following additional items:
  5300. key Key of the item which is fuzzy matched against
  5301. {str}. The value of this item should be a
  5302. string.
  5303. text_cb |Funcref| that will be called for every item
  5304. in {list} to get the text for fuzzy matching.
  5305. This should accept a dictionary item as the
  5306. argument and return the text for that item to
  5307. use for fuzzy matching.
  5308. {str} is treated as a literal string and regular expression
  5309. matching is NOT supported. The maximum supported {str} length
  5310. is 256.
  5311. When {str} has multiple words each separated by white space,
  5312. then the list of strings that have all the words is returned.
  5313. If there are no matching strings or there is an error, then an
  5314. empty list is returned. If length of {str} is greater than
  5315. 256, then returns an empty list.
  5316. When {limit} is given, matchfuzzy() will find up to this
  5317. number of matches in {list} and return them in sorted order.
  5318. Refer to |fuzzy-matching| for more information about fuzzy
  5319. matching strings.
  5320. Example: >vim
  5321. echo matchfuzzy(["clay", "crow"], "cay")
  5322. < results in ["clay"]. >vim
  5323. echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
  5324. < results in a list of buffer names fuzzy matching "ndl". >vim
  5325. echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
  5326. < results in a list of buffer information dicts with buffer
  5327. names fuzzy matching "ndl". >vim
  5328. echo getbufinfo()->matchfuzzy("spl",
  5329. \ {'text_cb' : {v -> v.name}})
  5330. < results in a list of buffer information dicts with buffer
  5331. names fuzzy matching "spl". >vim
  5332. echo v:oldfiles->matchfuzzy("test")
  5333. < results in a list of file names fuzzy matching "test". >vim
  5334. let l = readfile("buffer.c")->matchfuzzy("str")
  5335. < results in a list of lines in "buffer.c" fuzzy matching "str". >vim
  5336. echo ['one two', 'two one']->matchfuzzy('two one')
  5337. < results in `['two one', 'one two']` . >vim
  5338. echo ['one two', 'two one']->matchfuzzy('two one',
  5339. \ {'matchseq': 1})
  5340. < results in `['two one']`.
  5341. Parameters: ~
  5342. • {list} (`any[]`)
  5343. • {str} (`string`)
  5344. • {dict} (`string?`)
  5345. Return: ~
  5346. (`any`)
  5347. matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
  5348. Same as |matchfuzzy()|, but returns the list of matched
  5349. strings, the list of character positions where characters
  5350. in {str} matches and a list of matching scores. You can
  5351. use |byteidx()| to convert a character position to a byte
  5352. position.
  5353. If {str} matches multiple times in a string, then only the
  5354. positions for the best match is returned.
  5355. If there are no matching strings or there is an error, then a
  5356. list with three empty list items is returned.
  5357. Example: >vim
  5358. echo matchfuzzypos(['testing'], 'tsg')
  5359. < results in [["testing"], [[0, 2, 6]], [99]] >vim
  5360. echo matchfuzzypos(['clay', 'lacy'], 'la')
  5361. < results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
  5362. echo [{'text': 'hello', 'id' : 10}]
  5363. \ ->matchfuzzypos('ll', {'key' : 'text'})
  5364. < results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
  5365. Parameters: ~
  5366. • {list} (`any[]`)
  5367. • {str} (`string`)
  5368. • {dict} (`string?`)
  5369. Return: ~
  5370. (`any`)
  5371. matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
  5372. Same as |match()|, but return a |List|. The first item in the
  5373. list is the matched string, same as what matchstr() would
  5374. return. Following items are submatches, like "\1", "\2", etc.
  5375. in |:substitute|. When an optional submatch didn't match an
  5376. empty string is used. Example: >vim
  5377. echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
  5378. < Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
  5379. When there is no match an empty list is returned.
  5380. You can pass in a List, but that is not very useful.
  5381. Parameters: ~
  5382. • {expr} (`any`)
  5383. • {pat} (`string`)
  5384. • {start} (`integer?`)
  5385. • {count} (`integer?`)
  5386. Return: ~
  5387. (`any`)
  5388. matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
  5389. Same as |match()|, but return the matched string. Example: >vim
  5390. echo matchstr("testing", "ing")
  5391. < results in "ing".
  5392. When there is no match "" is returned.
  5393. The {start}, if given, has the same meaning as for |match()|. >vim
  5394. echo matchstr("testing", "ing", 2)
  5395. < results in "ing". >vim
  5396. echo matchstr("testing", "ing", 5)
  5397. < result is "".
  5398. When {expr} is a |List| then the matching item is returned.
  5399. The type isn't changed, it's not necessarily a String.
  5400. Parameters: ~
  5401. • {expr} (`any`)
  5402. • {pat} (`string`)
  5403. • {start} (`integer?`)
  5404. • {count} (`integer?`)
  5405. Return: ~
  5406. (`any`)
  5407. matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
  5408. Returns the |List| of matches in {list} where {pat} matches.
  5409. {list} is a |List| of strings. {pat} is matched against each
  5410. string in {list}.
  5411. The {dict} argument supports following items:
  5412. submatches include submatch information (|/\(|)
  5413. For each match, a |Dict| with the following items is returned:
  5414. byteidx starting byte index of the match.
  5415. idx index in {list} of the match.
  5416. text matched string
  5417. submatches a List of submatches. Present only if
  5418. "submatches" is set to v:true in {dict}.
  5419. See |match-pattern| for information about the effect of some
  5420. option settings on the pattern.
  5421. Example: >vim
  5422. echo matchstrlist(['tik tok'], '\<\k\+\>')
  5423. < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
  5424. echo matchstrlist(['a', 'b'], '\<\k\+\>')
  5425. < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
  5426. If "submatches" is present and is v:true, then submatches like
  5427. "\1", "\2", etc. are also returned. Example: >vim
  5428. echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
  5429. \ #{submatches: v:true})
  5430. < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5431. The "submatches" List always contains 9 items. If a submatch
  5432. is not found, then an empty string is returned for that
  5433. submatch.
  5434. Parameters: ~
  5435. • {list} (`string[]`)
  5436. • {pat} (`string`)
  5437. • {dict} (`table?`)
  5438. Return: ~
  5439. (`any`)
  5440. matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
  5441. Same as |matchstr()|, but return the matched string, the start
  5442. position and the end position of the match. Example: >vim
  5443. echo matchstrpos("testing", "ing")
  5444. < results in ["ing", 4, 7].
  5445. When there is no match ["", -1, -1] is returned.
  5446. The {start}, if given, has the same meaning as for |match()|. >vim
  5447. echo matchstrpos("testing", "ing", 2)
  5448. < results in ["ing", 4, 7]. >vim
  5449. echo matchstrpos("testing", "ing", 5)
  5450. < result is ["", -1, -1].
  5451. When {expr} is a |List| then the matching item, the index
  5452. of first item where {pat} matches, the start position and the
  5453. end position of the match are returned. >vim
  5454. echo matchstrpos([1, '__x'], '\a')
  5455. < result is ["x", 1, 2, 3].
  5456. The type isn't changed, it's not necessarily a String.
  5457. Parameters: ~
  5458. • {expr} (`any`)
  5459. • {pat} (`string`)
  5460. • {start} (`integer?`)
  5461. • {count} (`integer?`)
  5462. Return: ~
  5463. (`any`)
  5464. max({expr}) *max()*
  5465. Return the maximum value of all items in {expr}. Example: >vim
  5466. echo max([apples, pears, oranges])
  5467. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5468. it returns the maximum of all values in the Dictionary.
  5469. If {expr} is neither a List nor a Dictionary, or one of the
  5470. items in {expr} cannot be used as a Number this results in
  5471. an error. An empty |List| or |Dictionary| results in zero.
  5472. Parameters: ~
  5473. • {expr} (`any`)
  5474. Return: ~
  5475. (`any`)
  5476. menu_get({path} [, {modes}]) *menu_get()*
  5477. Returns a |List| of |Dictionaries| describing |menus| (defined
  5478. by |:menu|, |:amenu|, …), including |hidden-menus|.
  5479. {path} matches a menu by name, or all menus if {path} is an
  5480. empty string. Example: >vim
  5481. echo menu_get('File','')
  5482. echo menu_get('')
  5483. <
  5484. {modes} is a string of zero or more modes (see |maparg()| or
  5485. |creating-menus| for the list of modes). "a" means "all".
  5486. Example: >vim
  5487. nnoremenu &Test.Test inormal
  5488. inoremenu Test.Test insert
  5489. vnoremenu Test.Test x
  5490. echo menu_get("")
  5491. < returns something like this: >
  5492. [ {
  5493. "hidden": 0,
  5494. "name": "Test",
  5495. "priority": 500,
  5496. "shortcut": 84,
  5497. "submenus": [ {
  5498. "hidden": 0,
  5499. "mappings": {
  5500. i": {
  5501. "enabled": 1,
  5502. "noremap": 1,
  5503. "rhs": "insert",
  5504. "sid": 1,
  5505. "silent": 0
  5506. },
  5507. n": { ... },
  5508. s": { ... },
  5509. v": { ... }
  5510. },
  5511. "name": "Test",
  5512. "priority": 500,
  5513. "shortcut": 0
  5514. } ]
  5515. } ]
  5516. <
  5517. Parameters: ~
  5518. • {path} (`string`)
  5519. • {modes} (`string?`)
  5520. Return: ~
  5521. (`any`)
  5522. menu_info({name} [, {mode}]) *menu_info()*
  5523. Return information about the specified menu {name} in
  5524. mode {mode}. The menu name should be specified without the
  5525. shortcut character ('&'). If {name} is "", then the top-level
  5526. menu names are returned.
  5527. {mode} can be one of these strings:
  5528. "n" Normal
  5529. "v" Visual (including Select)
  5530. "o" Operator-pending
  5531. "i" Insert
  5532. "c" Cmd-line
  5533. "s" Select
  5534. "x" Visual
  5535. "t" Terminal-Job
  5536. "" Normal, Visual and Operator-pending
  5537. "!" Insert and Cmd-line
  5538. When {mode} is omitted, the modes for "" are used.
  5539. Returns a |Dictionary| containing the following items:
  5540. accel menu item accelerator text |menu-text|
  5541. display display name (name without '&')
  5542. enabled v:true if this menu item is enabled
  5543. Refer to |:menu-enable|
  5544. icon name of the icon file (for toolbar)
  5545. |toolbar-icon|
  5546. iconidx index of a built-in icon
  5547. modes modes for which the menu is defined. In
  5548. addition to the modes mentioned above, these
  5549. characters will be used:
  5550. " " Normal, Visual and Operator-pending
  5551. name menu item name.
  5552. noremenu v:true if the {rhs} of the menu item is not
  5553. remappable else v:false.
  5554. priority menu order priority |menu-priority|
  5555. rhs right-hand-side of the menu item. The returned
  5556. string has special characters translated like
  5557. in the output of the ":menu" command listing.
  5558. When the {rhs} of a menu item is empty, then
  5559. "<Nop>" is returned.
  5560. script v:true if script-local remapping of {rhs} is
  5561. allowed else v:false. See |:menu-script|.
  5562. shortcut shortcut key (character after '&' in
  5563. the menu name) |menu-shortcut|
  5564. silent v:true if the menu item is created
  5565. with <silent> argument |:menu-silent|
  5566. submenus |List| containing the names of
  5567. all the submenus. Present only if the menu
  5568. item has submenus.
  5569. Returns an empty dictionary if the menu item is not found.
  5570. Examples: >vim
  5571. echo menu_info('Edit.Cut')
  5572. echo menu_info('File.Save', 'n')
  5573. " Display the entire menu hierarchy in a buffer
  5574. func ShowMenu(name, pfx)
  5575. let m = menu_info(a:name)
  5576. call append(line('$'), a:pfx .. m.display)
  5577. for child in m->get('submenus', [])
  5578. call ShowMenu(a:name .. '.' .. escape(child, '.'),
  5579. \ a:pfx .. ' ')
  5580. endfor
  5581. endfunc
  5582. new
  5583. for topmenu in menu_info('').submenus
  5584. call ShowMenu(topmenu, '')
  5585. endfor
  5586. <
  5587. Parameters: ~
  5588. • {name} (`string`)
  5589. • {mode} (`string?`)
  5590. Return: ~
  5591. (`any`)
  5592. min({expr}) *min()*
  5593. Return the minimum value of all items in {expr}. Example: >vim
  5594. echo min([apples, pears, oranges])
  5595. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5596. it returns the minimum of all values in the Dictionary.
  5597. If {expr} is neither a List nor a Dictionary, or one of the
  5598. items in {expr} cannot be used as a Number this results in
  5599. an error. An empty |List| or |Dictionary| results in zero.
  5600. Parameters: ~
  5601. • {expr} (`any`)
  5602. Return: ~
  5603. (`any`)
  5604. mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
  5605. Create directory {name}.
  5606. When {flags} is present it must be a string. An empty string
  5607. has no effect.
  5608. {flags} can contain these character flags:
  5609. "p" intermediate directories will be created as necessary
  5610. "D" {name} will be deleted at the end of the current
  5611. function, but not recursively |:defer|
  5612. "R" {name} will be deleted recursively at the end of the
  5613. current function |:defer|
  5614. Note that when {name} has more than one part and "p" is used
  5615. some directories may already exist. Only the first one that
  5616. is created and what it contains is scheduled to be deleted.
  5617. E.g. when using: >vim
  5618. call mkdir('subdir/tmp/autoload', 'pR')
  5619. < and "subdir" already exists then "subdir/tmp" will be
  5620. scheduled for deletion, like with: >vim
  5621. defer delete('subdir/tmp', 'rf')
  5622. <
  5623. If {prot} is given it is used to set the protection bits of
  5624. the new directory. The default is 0o755 (rwxr-xr-x: r/w for
  5625. the user, readable for others). Use 0o700 to make it
  5626. unreadable for others.
  5627. {prot} is applied for all parts of {name}. Thus if you create
  5628. /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
  5629. call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
  5630. < This function is not available in the |sandbox|.
  5631. If you try to create an existing directory with {flags} set to
  5632. "p" mkdir() will silently exit.
  5633. The function result is a Number, which is TRUE if the call was
  5634. successful or FALSE if the directory creation failed or partly
  5635. failed.
  5636. Parameters: ~
  5637. • {name} (`string`)
  5638. • {flags} (`string?`)
  5639. • {prot} (`string?`)
  5640. Return: ~
  5641. (`any`)
  5642. mode([{expr}]) *mode()*
  5643. Return a string that indicates the current mode.
  5644. If {expr} is supplied and it evaluates to a non-zero Number or
  5645. a non-empty String (|non-zero-arg|), then the full mode is
  5646. returned, otherwise only the first letter is returned.
  5647. Also see |state()|.
  5648. n Normal
  5649. no Operator-pending
  5650. nov Operator-pending (forced charwise |o_v|)
  5651. noV Operator-pending (forced linewise |o_V|)
  5652. noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
  5653. CTRL-V is one character
  5654. niI Normal using |i_CTRL-O| in |Insert-mode|
  5655. niR Normal using |i_CTRL-O| in |Replace-mode|
  5656. niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
  5657. nt Normal in |terminal-emulator| (insert goes to
  5658. Terminal mode)
  5659. ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
  5660. v Visual by character
  5661. vs Visual by character using |v_CTRL-O| in Select mode
  5662. V Visual by line
  5663. Vs Visual by line using |v_CTRL-O| in Select mode
  5664. CTRL-V Visual blockwise
  5665. CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
  5666. s Select by character
  5667. S Select by line
  5668. CTRL-S Select blockwise
  5669. i Insert
  5670. ic Insert mode completion |compl-generic|
  5671. ix Insert mode |i_CTRL-X| completion
  5672. R Replace |R|
  5673. Rc Replace mode completion |compl-generic|
  5674. Rx Replace mode |i_CTRL-X| completion
  5675. Rv Virtual Replace |gR|
  5676. Rvc Virtual Replace mode completion |compl-generic|
  5677. Rvx Virtual Replace mode |i_CTRL-X| completion
  5678. c Command-line editing
  5679. cr Command-line editing overstrike mode |c_<Insert>|
  5680. cv Vim Ex mode |gQ|
  5681. cvr Vim Ex mode while in overstrike mode |c_<Insert>|
  5682. r Hit-enter prompt
  5683. rm The -- more -- prompt
  5684. r? A |:confirm| query of some sort
  5685. ! Shell or external command is executing
  5686. t Terminal mode: keys go to the job
  5687. This is useful in the 'statusline' option or RPC calls. In
  5688. most other places it always returns "c" or "n".
  5689. Note that in the future more modes and more specific modes may
  5690. be added. It's better not to compare the whole string but only
  5691. the leading character(s).
  5692. Also see |visualmode()|.
  5693. Parameters: ~
  5694. • {expr} (`any?`)
  5695. Return: ~
  5696. (`any`)
  5697. msgpackdump({list} [, {type}]) *msgpackdump()*
  5698. Convert a list of Vimscript objects to msgpack. Returned value is a
  5699. |readfile()|-style list. When {type} contains "B", a |Blob| is
  5700. returned instead. Example: >vim
  5701. call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
  5702. < or, using a |Blob|: >vim
  5703. call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
  5704. <
  5705. This will write the single 0x80 byte to a `fname.mpack` file
  5706. (dictionary with zero items is represented by 0x80 byte in
  5707. messagepack).
  5708. Limitations: *E5004* *E5005*
  5709. 1. |Funcref|s cannot be dumped.
  5710. 2. Containers that reference themselves cannot be dumped.
  5711. 3. Dictionary keys are always dumped as STR strings.
  5712. 4. Other strings and |Blob|s are always dumped as BIN strings.
  5713. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
  5714. Parameters: ~
  5715. • {list} (`any`)
  5716. • {type} (`any?`)
  5717. Return: ~
  5718. (`any`)
  5719. msgpackparse({data}) *msgpackparse()*
  5720. Convert a |readfile()|-style list or a |Blob| to a list of
  5721. Vimscript objects.
  5722. Example: >vim
  5723. let fname = expand('~/.config/nvim/shada/main.shada')
  5724. let mpack = readfile(fname, 'b')
  5725. let shada_objects = msgpackparse(mpack)
  5726. < This will read ~/.config/nvim/shada/main.shada file to
  5727. `shada_objects` list.
  5728. Limitations:
  5729. 1. Mapping ordering is not preserved unless messagepack
  5730. mapping is dumped using generic mapping
  5731. (|msgpack-special-map|).
  5732. 2. Since the parser aims to preserve all data untouched
  5733. (except for 1.) some strings are parsed to
  5734. |msgpack-special-dict| format which is not convenient to
  5735. use.
  5736. *msgpack-special-dict*
  5737. Some messagepack strings may be parsed to special
  5738. dictionaries. Special dictionaries are dictionaries which
  5739. 1. Contain exactly two keys: `_TYPE` and `_VAL`.
  5740. 2. `_TYPE` key is one of the types found in |v:msgpack_types|
  5741. variable.
  5742. 3. Value for `_VAL` has the following format (Key column
  5743. contains name of the key from |v:msgpack_types|):
  5744. Key Value ~
  5745. nil Zero, ignored when dumping. Not returned by
  5746. |msgpackparse()| since |v:null| was introduced.
  5747. boolean One or zero. When dumping it is only checked that
  5748. value is a |Number|. Not returned by |msgpackparse()|
  5749. since |v:true| and |v:false| were introduced.
  5750. integer |List| with four numbers: sign (-1 or 1), highest two
  5751. bits, number with bits from 62nd to 31st, lowest 31
  5752. bits. I.e. to get actual number one will need to use
  5753. code like >
  5754. _VAL[0] * ((_VAL[1] << 62)
  5755. & (_VAL[2] << 31)
  5756. & _VAL[3])
  5757. < Special dictionary with this type will appear in
  5758. |msgpackparse()| output under one of the following
  5759. circumstances:
  5760. 1. |Number| is 32-bit and value is either above
  5761. INT32_MAX or below INT32_MIN.
  5762. 2. |Number| is 64-bit and value is above INT64_MAX. It
  5763. cannot possibly be below INT64_MIN because msgpack
  5764. C parser does not support such values.
  5765. float |Float|. This value cannot possibly appear in
  5766. |msgpackparse()| output.
  5767. string |String|, or |Blob| if binary string contains zero
  5768. byte. This value cannot appear in |msgpackparse()|
  5769. output since blobs were introduced.
  5770. array |List|. This value cannot appear in |msgpackparse()|
  5771. output.
  5772. *msgpack-special-map*
  5773. map |List| of |List|s with two items (key and value) each.
  5774. This value will appear in |msgpackparse()| output if
  5775. parsed mapping contains one of the following keys:
  5776. 1. Any key that is not a string (including keys which
  5777. are binary strings).
  5778. 2. String with NUL byte inside.
  5779. 3. Duplicate key.
  5780. ext |List| with two values: first is a signed integer
  5781. representing extension type. Second is
  5782. |readfile()|-style list of strings.
  5783. Parameters: ~
  5784. • {data} (`any`)
  5785. Return: ~
  5786. (`any`)
  5787. nextnonblank({lnum}) *nextnonblank()*
  5788. Return the line number of the first line at or below {lnum}
  5789. that is not blank. Example: >vim
  5790. if getline(nextnonblank(1)) =~ "Java" | endif
  5791. < When {lnum} is invalid or there is no non-blank line at or
  5792. below it, zero is returned.
  5793. {lnum} is used like with |getline()|.
  5794. See also |prevnonblank()|.
  5795. Parameters: ~
  5796. • {lnum} (`integer`)
  5797. Return: ~
  5798. (`any`)
  5799. nr2char({expr} [, {utf8}]) *nr2char()*
  5800. Return a string with a single character, which has the number
  5801. value {expr}. Examples: >vim
  5802. echo nr2char(64) " returns '@'
  5803. echo nr2char(32) " returns ' '
  5804. < Example for "utf-8": >vim
  5805. echo nr2char(300) " returns I with bow character
  5806. <
  5807. UTF-8 encoding is always used, {utf8} option has no effect,
  5808. and exists only for backwards-compatibility.
  5809. Note that a NUL character in the file is specified with
  5810. nr2char(10), because NULs are represented with newline
  5811. characters. nr2char(0) is a real NUL and terminates the
  5812. string, thus results in an empty string.
  5813. Parameters: ~
  5814. • {expr} (`integer`)
  5815. • {utf8} (`boolean?`)
  5816. Return: ~
  5817. (`any`)
  5818. nvim_...({...}) *nvim_...()* *E5555* *eval-api*
  5819. Call nvim |api| functions. The type checking of arguments will
  5820. be stricter than for most other builtins. For instance,
  5821. if Integer is expected, a |Number| must be passed in, a
  5822. |String| will not be autoconverted.
  5823. Buffer numbers, as returned by |bufnr()| could be used as
  5824. first argument to nvim_buf_... functions. All functions
  5825. expecting an object (buffer, window or tabpage) can
  5826. also take the numerical value 0 to indicate the current
  5827. (focused) object.
  5828. Parameters: ~
  5829. • {...} (`any`)
  5830. Return: ~
  5831. (`any`)
  5832. or({expr}, {expr}) *or()*
  5833. Bitwise OR on the two arguments. The arguments are converted
  5834. to a number. A List, Dict or Float argument causes an error.
  5835. Also see `and()` and `xor()`.
  5836. Example: >vim
  5837. let bits = or(bits, 0x80)
  5838. < Rationale: The reason this is a function and not using the "|"
  5839. character like many languages, is that Vi has always used "|"
  5840. to separate commands. In many places it would not be clear if
  5841. "|" is an operator or a command separator.
  5842. Parameters: ~
  5843. • {expr} (`number`)
  5844. • {expr1} (`number`)
  5845. Return: ~
  5846. (`any`)
  5847. pathshorten({path} [, {len}]) *pathshorten()*
  5848. Shorten directory names in the path {path} and return the
  5849. result. The tail, the file name, is kept as-is. The other
  5850. components in the path are reduced to {len} letters in length.
  5851. If {len} is omitted or smaller than 1 then 1 is used (single
  5852. letters). Leading '~' and '.' characters are kept. Examples: >vim
  5853. echo pathshorten('~/.config/nvim/autoload/file1.vim')
  5854. < ~/.c/n/a/file1.vim ~
  5855. >vim
  5856. echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
  5857. < ~/.co/nv/au/file2.vim ~
  5858. It doesn't matter if the path exists or not.
  5859. Returns an empty string on error.
  5860. Parameters: ~
  5861. • {path} (`string`)
  5862. • {len} (`integer?`)
  5863. Return: ~
  5864. (`any`)
  5865. perleval({expr}) *perleval()*
  5866. Evaluate |perl| expression {expr} and return its result
  5867. converted to Vim data structures.
  5868. Numbers and strings are returned as they are (strings are
  5869. copied though).
  5870. Lists are represented as Vim |List| type.
  5871. Dictionaries are represented as Vim |Dictionary| type,
  5872. non-string keys result in error.
  5873. Note: If you want an array or hash, {expr} must return a
  5874. reference to it.
  5875. Example: >vim
  5876. echo perleval('[1 .. 4]')
  5877. < [1, 2, 3, 4]
  5878. Parameters: ~
  5879. • {expr} (`any`)
  5880. Return: ~
  5881. (`any`)
  5882. pow({x}, {y}) *pow()*
  5883. Return the power of {x} to the exponent {y} as a |Float|.
  5884. {x} and {y} must evaluate to a |Float| or a |Number|.
  5885. Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
  5886. Examples: >vim
  5887. echo pow(3, 3)
  5888. < 27.0 >vim
  5889. echo pow(2, 16)
  5890. < 65536.0 >vim
  5891. echo pow(32, 0.20)
  5892. < 2.0
  5893. Parameters: ~
  5894. • {x} (`number`)
  5895. • {y} (`number`)
  5896. Return: ~
  5897. (`any`)
  5898. prevnonblank({lnum}) *prevnonblank()*
  5899. Return the line number of the first line at or above {lnum}
  5900. that is not blank. Example: >vim
  5901. let ind = indent(prevnonblank(v:lnum - 1))
  5902. < When {lnum} is invalid or there is no non-blank line at or
  5903. above it, zero is returned.
  5904. {lnum} is used like with |getline()|.
  5905. Also see |nextnonblank()|.
  5906. Parameters: ~
  5907. • {lnum} (`integer`)
  5908. Return: ~
  5909. (`any`)
  5910. printf({fmt}, {expr1} ...) *printf()*
  5911. Return a String with {fmt}, where "%" items are replaced by
  5912. the formatted form of their respective arguments. Example: >vim
  5913. echo printf("%4d: E%d %.30s", lnum, errno, msg)
  5914. < May result in:
  5915. " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
  5916. When used as a |method| the base is passed as the second
  5917. argument: >vim
  5918. Compute()->printf("result: %d")
  5919. <
  5920. You can use `call()` to pass the items as a list.
  5921. Often used items are:
  5922. %s string
  5923. %6S string right-aligned in 6 display cells
  5924. %6s string right-aligned in 6 bytes
  5925. %.9s string truncated to 9 bytes
  5926. %c single byte
  5927. %d decimal number
  5928. %5d decimal number padded with spaces to 5 characters
  5929. %b binary number
  5930. %08b binary number padded with zeros to at least 8 characters
  5931. %B binary number using upper case letters
  5932. %x hex number
  5933. %04x hex number padded with zeros to at least 4 characters
  5934. %X hex number using upper case letters
  5935. %o octal number
  5936. %f floating point number as 12.23, inf, -inf or nan
  5937. %F floating point number as 12.23, INF, -INF or NAN
  5938. %e floating point number as 1.23e3, inf, -inf or nan
  5939. %E floating point number as 1.23E3, INF, -INF or NAN
  5940. %g floating point number, as %f or %e depending on value
  5941. %G floating point number, as %F or %E depending on value
  5942. %% the % character itself
  5943. %p representation of the pointer to the container
  5944. Conversion specifications start with '%' and end with the
  5945. conversion type. All other characters are copied unchanged to
  5946. the result.
  5947. The "%" starts a conversion specification. The following
  5948. arguments appear in sequence:
  5949. % [pos-argument] [flags] [field-width] [.precision] type
  5950. pos-argument
  5951. At most one positional argument specifier. These
  5952. take the form {n$}, where n is >= 1.
  5953. flags
  5954. Zero or more of the following flags:
  5955. # The value should be converted to an "alternate
  5956. form". For c, d, and s conversions, this option
  5957. has no effect. For o conversions, the precision
  5958. of the number is increased to force the first
  5959. character of the output string to a zero (except
  5960. if a zero value is printed with an explicit
  5961. precision of zero).
  5962. For x and X conversions, a non-zero result has
  5963. the string "0x" (or "0X" for X conversions)
  5964. prepended to it.
  5965. 0 (zero) Zero padding. For all conversions the converted
  5966. value is padded on the left with zeros rather
  5967. than blanks. If a precision is given with a
  5968. numeric conversion (d, o, x, and X), the 0 flag
  5969. is ignored.
  5970. - A negative field width flag; the converted value
  5971. is to be left adjusted on the field boundary.
  5972. The converted value is padded on the right with
  5973. blanks, rather than on the left with blanks or
  5974. zeros. A - overrides a 0 if both are given.
  5975. ' ' (space) A blank should be left before a positive
  5976. number produced by a signed conversion (d).
  5977. + A sign must always be placed before a number
  5978. produced by a signed conversion. A + overrides
  5979. a space if both are used.
  5980. field-width
  5981. An optional decimal digit string specifying a minimum
  5982. field width. If the converted value has fewer bytes
  5983. than the field width, it will be padded with spaces on
  5984. the left (or right, if the left-adjustment flag has
  5985. been given) to fill out the field width. For the S
  5986. conversion the count is in cells.
  5987. .precision
  5988. An optional precision, in the form of a period '.'
  5989. followed by an optional digit string. If the digit
  5990. string is omitted, the precision is taken as zero.
  5991. This gives the minimum number of digits to appear for
  5992. d, o, x, and X conversions, the maximum number of
  5993. bytes to be printed from a string for s conversions,
  5994. or the maximum number of cells to be printed from a
  5995. string for S conversions.
  5996. For floating point it is the number of digits after
  5997. the decimal point.
  5998. type
  5999. A character that specifies the type of conversion to
  6000. be applied, see below.
  6001. A field width or precision, or both, may be indicated by an
  6002. asterisk "*" instead of a digit string. In this case, a
  6003. Number argument supplies the field width or precision. A
  6004. negative field width is treated as a left adjustment flag
  6005. followed by a positive field width; a negative precision is
  6006. treated as though it were missing. Example: >vim
  6007. echo printf("%d: %.*s", nr, width, line)
  6008. < This limits the length of the text used from "line" to
  6009. "width" bytes.
  6010. If the argument to be formatted is specified using a
  6011. positional argument specifier, and a '*' is used to indicate
  6012. that a number argument is to be used to specify the width or
  6013. precision, the argument(s) to be used must also be specified
  6014. using a {n$} positional argument specifier. See |printf-$|.
  6015. The conversion specifiers and their meanings are:
  6016. *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
  6017. dbBoxX The Number argument is converted to signed decimal (d),
  6018. unsigned binary (b and B), unsigned octal (o), or
  6019. unsigned hexadecimal (x and X) notation. The letters
  6020. "abcdef" are used for x conversions; the letters
  6021. "ABCDEF" are used for X conversions. The precision, if
  6022. any, gives the minimum number of digits that must
  6023. appear; if the converted value requires fewer digits, it
  6024. is padded on the left with zeros. In no case does a
  6025. non-existent or small field width cause truncation of a
  6026. numeric field; if the result of a conversion is wider
  6027. than the field width, the field is expanded to contain
  6028. the conversion result.
  6029. The 'h' modifier indicates the argument is 16 bits.
  6030. The 'l' modifier indicates the argument is a long
  6031. integer. The size will be 32 bits or 64 bits
  6032. depending on your platform.
  6033. The "ll" modifier indicates the argument is 64 bits.
  6034. The b and B conversion specifiers never take a width
  6035. modifier and always assume their argument is a 64 bit
  6036. integer.
  6037. Generally, these modifiers are not useful. They are
  6038. ignored when type is known from the argument.
  6039. i alias for d
  6040. D alias for ld
  6041. U alias for lu
  6042. O alias for lo
  6043. *printf-c*
  6044. c The Number argument is converted to a byte, and the
  6045. resulting character is written.
  6046. *printf-s*
  6047. s The text of the String argument is used. If a
  6048. precision is specified, no more bytes than the number
  6049. specified are used.
  6050. If the argument is not a String type, it is
  6051. automatically converted to text with the same format
  6052. as ":echo".
  6053. *printf-S*
  6054. S The text of the String argument is used. If a
  6055. precision is specified, no more display cells than the
  6056. number specified are used.
  6057. *printf-f* *E807*
  6058. f F The Float argument is converted into a string of the
  6059. form 123.456. The precision specifies the number of
  6060. digits after the decimal point. When the precision is
  6061. zero the decimal point is omitted. When the precision
  6062. is not specified 6 is used. A really big number
  6063. (out of range or dividing by zero) results in "inf"
  6064. or "-inf" with %f (INF or -INF with %F).
  6065. "0.0 / 0.0" results in "nan" with %f (NAN with %F).
  6066. Example: >vim
  6067. echo printf("%.2f", 12.115)
  6068. < 12.12
  6069. Note that roundoff depends on the system libraries.
  6070. Use |round()| when in doubt.
  6071. *printf-e* *printf-E*
  6072. e E The Float argument is converted into a string of the
  6073. form 1.234e+03 or 1.234E+03 when using 'E'. The
  6074. precision specifies the number of digits after the
  6075. decimal point, like with 'f'.
  6076. *printf-g* *printf-G*
  6077. g G The Float argument is converted like with 'f' if the
  6078. value is between 0.001 (inclusive) and 10000000.0
  6079. (exclusive). Otherwise 'e' is used for 'g' and 'E'
  6080. for 'G'. When no precision is specified superfluous
  6081. zeroes and '+' signs are removed, except for the zero
  6082. immediately after the decimal point. Thus 10000000.0
  6083. results in 1.0e7.
  6084. *printf-%*
  6085. % A '%' is written. No argument is converted. The
  6086. complete conversion specification is "%%".
  6087. When a Number argument is expected a String argument is also
  6088. accepted and automatically converted.
  6089. When a Float or String argument is expected a Number argument
  6090. is also accepted and automatically converted.
  6091. Any other argument type results in an error message.
  6092. *E766* *E767*
  6093. The number of {exprN} arguments must exactly match the number
  6094. of "%" items. If there are not sufficient or too many
  6095. arguments an error is given. Up to 18 arguments can be used.
  6096. *printf-$*
  6097. In certain languages, error and informative messages are
  6098. more readable when the order of words is different from the
  6099. corresponding message in English. To accommodate translations
  6100. having a different word order, positional arguments may be
  6101. used to indicate this. For instance: >vim
  6102. #, c-format
  6103. msgid "%s returning %s"
  6104. msgstr "waarde %2$s komt terug van %1$s"
  6105. <
  6106. In this example, the sentence has its 2 string arguments
  6107. reversed in the output. >vim
  6108. echo printf(
  6109. "In The Netherlands, vim's creator's name is: %1$s %2$s",
  6110. "Bram", "Moolenaar")
  6111. < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim
  6112. echo printf(
  6113. "In Belgium, vim's creator's name is: %2$s %1$s",
  6114. "Bram", "Moolenaar")
  6115. < In Belgium, vim's creator's name is: Moolenaar Bram
  6116. Width (and precision) can be specified using the '*' specifier.
  6117. In this case, you must specify the field width position in the
  6118. argument list. >vim
  6119. echo printf("%1$*2$.*3$d", 1, 2, 3)
  6120. < 001 >vim
  6121. echo printf("%2$*3$.*1$d", 1, 2, 3)
  6122. < 2 >vim
  6123. echo printf("%3$*1$.*2$d", 1, 2, 3)
  6124. < 03 >vim
  6125. echo printf("%1$*2$.*3$g", 1.4142, 2, 3)
  6126. < 1.414
  6127. You can mix specifying the width and/or precision directly
  6128. and via positional arguments: >vim
  6129. echo printf("%1$4.*2$f", 1.4142135, 6)
  6130. < 1.414214 >vim
  6131. echo printf("%1$*2$.4f", 1.4142135, 6)
  6132. < 1.4142 >vim
  6133. echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
  6134. < 1.41
  6135. You will get an overflow error |E1510|, when the field-width
  6136. or precision will result in a string longer than 6400 chars.
  6137. *E1500*
  6138. You cannot mix positional and non-positional arguments: >vim
  6139. echo printf("%s%1$s", "One", "Two")
  6140. < E1500: Cannot mix positional and non-positional arguments:
  6141. %s%1$s
  6142. *E1501*
  6143. You cannot skip a positional argument in a format string: >vim
  6144. echo printf("%3$s%1$s", "One", "Two", "Three")
  6145. < E1501: format argument 2 unused in $-style format:
  6146. %3$s%1$s
  6147. *E1502*
  6148. You can re-use a [field-width] (or [precision]) argument: >vim
  6149. echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
  6150. < 1 at width 2 is: 01
  6151. However, you can't use it as a different type: >vim
  6152. echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
  6153. < E1502: Positional argument 2 used as field width reused as
  6154. different type: long int/int
  6155. *E1503*
  6156. When a positional argument is used, but not the correct number
  6157. or arguments is given, an error is raised: >vim
  6158. echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
  6159. < E1503: Positional argument 3 out of bounds: %1$d at width
  6160. %2$d is: %01$*2$.*3$d
  6161. Only the first error is reported: >vim
  6162. echo printf("%01$*2$.*3$d %4$d", 1, 2)
  6163. < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
  6164. %4$d
  6165. *E1504*
  6166. A positional argument can be used more than once: >vim
  6167. echo printf("%1$s %2$s %1$s", "One", "Two")
  6168. < One Two One
  6169. However, you can't use a different type the second time: >vim
  6170. echo printf("%1$s %2$s %1$d", "One", "Two")
  6171. < E1504: Positional argument 1 type used inconsistently:
  6172. int/string
  6173. *E1505*
  6174. Various other errors that lead to a format string being
  6175. wrongly formatted lead to: >vim
  6176. echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
  6177. < E1505: Invalid format specifier: %1$d at width %2$d is:
  6178. %01$*2$.3$d
  6179. *E1507*
  6180. This internal error indicates that the logic to parse a
  6181. positional format argument ran into a problem that couldn't be
  6182. otherwise reported. Please file a bug against Vim if you run
  6183. into this, copying the exact format string and parameters that
  6184. were used.
  6185. Parameters: ~
  6186. • {fmt} (`string`)
  6187. • {expr1} (`any?`)
  6188. Return: ~
  6189. (`string`)
  6190. prompt_getprompt({buf}) *prompt_getprompt()*
  6191. Returns the effective prompt text for buffer {buf}. {buf} can
  6192. be a buffer name or number. See |prompt-buffer|.
  6193. If the buffer doesn't exist or isn't a prompt buffer, an empty
  6194. string is returned.
  6195. Parameters: ~
  6196. • {buf} (`integer|string`)
  6197. Return: ~
  6198. (`any`)
  6199. prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
  6200. Set prompt callback for buffer {buf} to {expr}. When {expr}
  6201. is an empty string the callback is removed. This has only
  6202. effect if {buf} has 'buftype' set to "prompt".
  6203. The callback is invoked when pressing Enter. The current
  6204. buffer will always be the prompt buffer. A new line for a
  6205. prompt is added before invoking the callback, thus the prompt
  6206. for which the callback was invoked will be in the last but one
  6207. line.
  6208. If the callback wants to add text to the buffer, it must
  6209. insert it above the last line, since that is where the current
  6210. prompt is. This can also be done asynchronously.
  6211. The callback is invoked with one argument, which is the text
  6212. that was entered at the prompt. This can be an empty string
  6213. if the user only typed Enter.
  6214. Example: >vim
  6215. func s:TextEntered(text)
  6216. if a:text == 'exit' || a:text == 'quit'
  6217. stopinsert
  6218. " Reset 'modified' to allow the buffer to be closed.
  6219. " We assume there is nothing useful to be saved.
  6220. set nomodified
  6221. close
  6222. else
  6223. " Do something useful with "a:text". In this example
  6224. " we just repeat it.
  6225. call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
  6226. endif
  6227. endfunc
  6228. call prompt_setcallback(bufnr(), function('s:TextEntered'))
  6229. Parameters: ~
  6230. • {buf} (`integer|string`)
  6231. • {expr} (`string|function`)
  6232. Return: ~
  6233. (`any`)
  6234. prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
  6235. Set a callback for buffer {buf} to {expr}. When {expr} is an
  6236. empty string the callback is removed. This has only effect if
  6237. {buf} has 'buftype' set to "prompt".
  6238. This callback will be invoked when pressing CTRL-C in Insert
  6239. mode. Without setting a callback Vim will exit Insert mode,
  6240. as in any buffer.
  6241. Parameters: ~
  6242. • {buf} (`integer|string`)
  6243. • {expr} (`string|function`)
  6244. Return: ~
  6245. (`any`)
  6246. prompt_setprompt({buf}, {text}) *prompt_setprompt()*
  6247. Set prompt for buffer {buf} to {text}. You most likely want
  6248. {text} to end in a space.
  6249. The result is only visible if {buf} has 'buftype' set to
  6250. "prompt". Example: >vim
  6251. call prompt_setprompt(bufnr(''), 'command: ')
  6252. <
  6253. Parameters: ~
  6254. • {buf} (`integer|string`)
  6255. • {text} (`string`)
  6256. Return: ~
  6257. (`any`)
  6258. pum_getpos() *pum_getpos()*
  6259. If the popup menu (see |ins-completion-menu|) is not visible,
  6260. returns an empty |Dictionary|, otherwise, returns a
  6261. |Dictionary| with the following keys:
  6262. height nr of items visible
  6263. width screen cells
  6264. row top screen row (0 first row)
  6265. col leftmost screen column (0 first col)
  6266. size total nr of items
  6267. scrollbar |TRUE| if scrollbar is visible
  6268. The values are the same as in |v:event| during |CompleteChanged|.
  6269. Return: ~
  6270. (`any`)
  6271. pumvisible() *pumvisible()*
  6272. Returns non-zero when the popup menu is visible, zero
  6273. otherwise. See |ins-completion-menu|.
  6274. This can be used to avoid some things that would remove the
  6275. popup menu.
  6276. Return: ~
  6277. (`any`)
  6278. py3eval({expr}) *py3eval()*
  6279. Evaluate Python expression {expr} and return its result
  6280. converted to Vim data structures.
  6281. Numbers and strings are returned as they are (strings are
  6282. copied though, Unicode strings are additionally converted to
  6283. UTF-8).
  6284. Lists are represented as Vim |List| type.
  6285. Dictionaries are represented as Vim |Dictionary| type with
  6286. keys converted to strings.
  6287. Parameters: ~
  6288. • {expr} (`any`)
  6289. Return: ~
  6290. (`any`)
  6291. pyeval({expr}) *pyeval()* *E858* *E859*
  6292. Evaluate Python expression {expr} and return its result
  6293. converted to Vim data structures.
  6294. Numbers and strings are returned as they are (strings are
  6295. copied though).
  6296. Lists are represented as Vim |List| type.
  6297. Dictionaries are represented as Vim |Dictionary| type,
  6298. non-string keys result in error.
  6299. Parameters: ~
  6300. • {expr} (`any`)
  6301. Return: ~
  6302. (`any`)
  6303. pyxeval({expr}) *pyxeval()*
  6304. Evaluate Python expression {expr} and return its result
  6305. converted to Vim data structures.
  6306. Uses Python 2 or 3, see |python_x| and 'pyxversion'.
  6307. See also: |pyeval()|, |py3eval()|
  6308. Parameters: ~
  6309. • {expr} (`any`)
  6310. Return: ~
  6311. (`any`)
  6312. rand([{expr}]) *rand()*
  6313. Return a pseudo-random Number generated with an xoshiro128**
  6314. algorithm using seed {expr}. The returned number is 32 bits,
  6315. also on 64 bits systems, for consistency.
  6316. {expr} can be initialized by |srand()| and will be updated by
  6317. rand(). If {expr} is omitted, an internal seed value is used
  6318. and updated.
  6319. Returns -1 if {expr} is invalid.
  6320. Examples: >vim
  6321. echo rand()
  6322. let seed = srand()
  6323. echo rand(seed)
  6324. echo rand(seed) % 16 " random number 0 - 15
  6325. <
  6326. Parameters: ~
  6327. • {expr} (`number?`)
  6328. Return: ~
  6329. (`any`)
  6330. range({expr} [, {max} [, {stride}]]) *range()* *E726* *E727*
  6331. Returns a |List| with Numbers:
  6332. - If only {expr} is specified: [0, 1, ..., {expr} - 1]
  6333. - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
  6334. - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
  6335. {max}] (increasing {expr} with {stride} each time, not
  6336. producing a value past {max}).
  6337. When the maximum is one before the start the result is an
  6338. empty list. When the maximum is more than one before the
  6339. start this is an error.
  6340. Examples: >vim
  6341. echo range(4) " [0, 1, 2, 3]
  6342. echo range(2, 4) " [2, 3, 4]
  6343. echo range(2, 9, 3) " [2, 5, 8]
  6344. echo range(2, -2, -1) " [2, 1, 0, -1, -2]
  6345. echo range(0) " []
  6346. echo range(2, 0) " error!
  6347. <
  6348. Parameters: ~
  6349. • {expr} (`any`)
  6350. • {max} (`integer?`)
  6351. • {stride} (`integer?`)
  6352. Return: ~
  6353. (`any`)
  6354. readblob({fname} [, {offset} [, {size}]]) *readblob()*
  6355. Read file {fname} in binary mode and return a |Blob|.
  6356. If {offset} is specified, read the file from the specified
  6357. offset. If it is a negative value, it is used as an offset
  6358. from the end of the file. E.g., to read the last 12 bytes: >vim
  6359. echo readblob('file.bin', -12)
  6360. < If {size} is specified, only the specified size will be read.
  6361. E.g. to read the first 100 bytes of a file: >vim
  6362. echo readblob('file.bin', 0, 100)
  6363. < If {size} is -1 or omitted, the whole data starting from
  6364. {offset} will be read.
  6365. This can be also used to read the data from a character device
  6366. on Unix when {size} is explicitly set. Only if the device
  6367. supports seeking {offset} can be used. Otherwise it should be
  6368. zero. E.g. to read 10 bytes from a serial console: >vim
  6369. echo readblob('/dev/ttyS0', 0, 10)
  6370. < When the file can't be opened an error message is given and
  6371. the result is an empty |Blob|.
  6372. When the offset is beyond the end of the file the result is an
  6373. empty blob.
  6374. When trying to read more bytes than are available the result
  6375. is truncated.
  6376. Also see |readfile()| and |writefile()|.
  6377. Parameters: ~
  6378. • {fname} (`string`)
  6379. • {offset} (`integer?`)
  6380. • {size} (`integer?`)
  6381. Return: ~
  6382. (`any`)
  6383. readdir({directory} [, {expr}]) *readdir()*
  6384. Return a list with file and directory names in {directory}.
  6385. You can also use |glob()| if you don't need to do complicated
  6386. things, such as limiting the number of matches.
  6387. When {expr} is omitted all entries are included.
  6388. When {expr} is given, it is evaluated to check what to do:
  6389. If {expr} results in -1 then no further entries will
  6390. be handled.
  6391. If {expr} results in 0 then this entry will not be
  6392. added to the list.
  6393. If {expr} results in 1 then this entry will be added
  6394. to the list.
  6395. Each time {expr} is evaluated |v:val| is set to the entry name.
  6396. When {expr} is a function the name is passed as the argument.
  6397. For example, to get a list of files ending in ".txt": >vim
  6398. echo readdir(dirname, {n -> n =~ '.txt$'})
  6399. < To skip hidden and backup files: >vim
  6400. echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
  6401. < If you want to get a directory tree: >vim
  6402. function! s:tree(dir)
  6403. return {a:dir : map(readdir(a:dir),
  6404. \ {_, x -> isdirectory(x) ?
  6405. \ {x : s:tree(a:dir .. '/' .. x)} : x})}
  6406. endfunction
  6407. echo s:tree(".")
  6408. <
  6409. Returns an empty List on error.
  6410. Parameters: ~
  6411. • {directory} (`string`)
  6412. • {expr} (`integer?`)
  6413. Return: ~
  6414. (`any`)
  6415. readfile({fname} [, {type} [, {max}]]) *readfile()*
  6416. Read file {fname} and return a |List|, each line of the file
  6417. as an item. Lines are broken at NL characters. Macintosh
  6418. files separated with CR will result in a single long line
  6419. (unless a NL appears somewhere).
  6420. All NUL characters are replaced with a NL character.
  6421. When {type} contains "b" binary mode is used:
  6422. - When the last line ends in a NL an extra empty list item is
  6423. added.
  6424. - No CR characters are removed.
  6425. Otherwise:
  6426. - CR characters that appear before a NL are removed.
  6427. - Whether the last line ends in a NL or not does not matter.
  6428. - Any UTF-8 byte order mark is removed from the text.
  6429. When {max} is given this specifies the maximum number of lines
  6430. to be read. Useful if you only want to check the first ten
  6431. lines of a file: >vim
  6432. for line in readfile(fname, '', 10)
  6433. if line =~ 'Date' | echo line | endif
  6434. endfor
  6435. < When {max} is negative -{max} lines from the end of the file
  6436. are returned, or as many as there are.
  6437. When {max} is zero the result is an empty list.
  6438. Note that without {max} the whole file is read into memory.
  6439. Also note that there is no recognition of encoding. Read a
  6440. file into a buffer if you need to.
  6441. Deprecated (use |readblob()| instead): When {type} contains
  6442. "B" a |Blob| is returned with the binary data of the file
  6443. unmodified.
  6444. When the file can't be opened an error message is given and
  6445. the result is an empty list.
  6446. Also see |writefile()|.
  6447. Parameters: ~
  6448. • {fname} (`string`)
  6449. • {type} (`string?`)
  6450. • {max} (`integer?`)
  6451. Return: ~
  6452. (`any`)
  6453. reduce({object}, {func} [, {initial}]) *reduce()* *E998*
  6454. {func} is called for every item in {object}, which can be a
  6455. |String|, |List| or a |Blob|. {func} is called with two
  6456. arguments: the result so far and current item. After
  6457. processing all items the result is returned.
  6458. {initial} is the initial result. When omitted, the first item
  6459. in {object} is used and {func} is first called for the second
  6460. item. If {initial} is not given and {object} is empty no
  6461. result can be computed, an E998 error is given.
  6462. Examples: >vim
  6463. echo reduce([1, 3, 5], { acc, val -> acc + val })
  6464. echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
  6465. echo reduce(0z1122, { acc, val -> 2 * acc + val })
  6466. echo reduce('xyz', { acc, val -> acc .. ',' .. val })
  6467. <
  6468. Parameters: ~
  6469. • {object} (`any`)
  6470. • {func} (`function`)
  6471. • {initial} (`any?`)
  6472. Return: ~
  6473. (`any`)
  6474. reg_executing() *reg_executing()*
  6475. Returns the single letter name of the register being executed.
  6476. Returns an empty string when no register is being executed.
  6477. See |@|.
  6478. Return: ~
  6479. (`any`)
  6480. reg_recorded() *reg_recorded()*
  6481. Returns the single letter name of the last recorded register.
  6482. Returns an empty string when nothing was recorded yet.
  6483. See |q| and |Q|.
  6484. Return: ~
  6485. (`any`)
  6486. reg_recording() *reg_recording()*
  6487. Returns the single letter name of the register being recorded.
  6488. Returns an empty string when not recording. See |q|.
  6489. Return: ~
  6490. (`any`)
  6491. reltime() *reltime()*
  6492. reltime({start})
  6493. reltime({start}, {end})
  6494. Return an item that represents a time value. The item is a
  6495. list with items that depend on the system.
  6496. The item can be passed to |reltimestr()| to convert it to a
  6497. string or |reltimefloat()| to convert to a Float.
  6498. Without an argument it returns the current "relative time", an
  6499. implementation-defined value meaningful only when used as an
  6500. argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
  6501. With one argument it returns the time passed since the time
  6502. specified in the argument.
  6503. With two arguments it returns the time passed between {start}
  6504. and {end}.
  6505. The {start} and {end} arguments must be values returned by
  6506. reltime(). Returns zero on error.
  6507. Note: |localtime()| returns the current (non-relative) time.
  6508. Parameters: ~
  6509. • {start} (`any?`)
  6510. • {end_} (`any?`)
  6511. Return: ~
  6512. (`any`)
  6513. reltimefloat({time}) *reltimefloat()*
  6514. Return a Float that represents the time value of {time}.
  6515. Unit of time is seconds.
  6516. Example:
  6517. let start = reltime()
  6518. call MyFunction()
  6519. let seconds = reltimefloat(reltime(start))
  6520. See the note of reltimestr() about overhead.
  6521. Also see |profiling|.
  6522. If there is an error an empty string is returned
  6523. Parameters: ~
  6524. • {time} (`any`)
  6525. Return: ~
  6526. (`any`)
  6527. reltimestr({time}) *reltimestr()*
  6528. Return a String that represents the time value of {time}.
  6529. This is the number of seconds, a dot and the number of
  6530. microseconds. Example: >vim
  6531. let start = reltime()
  6532. call MyFunction()
  6533. echo reltimestr(reltime(start))
  6534. < Note that overhead for the commands will be added to the time.
  6535. Leading spaces are used to make the string align nicely. You
  6536. can use split() to remove it. >vim
  6537. echo split(reltimestr(reltime(start)))[0]
  6538. < Also see |profiling|.
  6539. If there is an error an empty string is returned
  6540. Parameters: ~
  6541. • {time} (`any`)
  6542. Return: ~
  6543. (`any`)
  6544. remove({list}, {idx}) *remove()*
  6545. remove({list}, {idx}, {end})
  6546. Without {end}: Remove the item at {idx} from |List| {list} and
  6547. return the item.
  6548. With {end}: Remove items from {idx} to {end} (inclusive) and
  6549. return a |List| with these items. When {idx} points to the same
  6550. item as {end} a list with one item is returned. When {end}
  6551. points to an item before {idx} this is an error.
  6552. See |list-index| for possible values of {idx} and {end}.
  6553. Returns zero on error.
  6554. Example: >vim
  6555. echo "last item: " .. remove(mylist, -1)
  6556. call remove(mylist, 0, 9)
  6557. <
  6558. Use |delete()| to remove a file.
  6559. Parameters: ~
  6560. • {list} (`any[]`)
  6561. • {idx} (`integer`)
  6562. • {end_} (`integer?`)
  6563. Return: ~
  6564. (`any`)
  6565. remove({blob}, {idx})
  6566. remove({blob}, {idx}, {end})
  6567. Without {end}: Remove the byte at {idx} from |Blob| {blob} and
  6568. return the byte.
  6569. With {end}: Remove bytes from {idx} to {end} (inclusive) and
  6570. return a |Blob| with these bytes. When {idx} points to the same
  6571. byte as {end} a |Blob| with one byte is returned. When {end}
  6572. points to a byte before {idx} this is an error.
  6573. Returns zero on error.
  6574. Example: >vim
  6575. echo "last byte: " .. remove(myblob, -1)
  6576. call remove(mylist, 0, 9)
  6577. <
  6578. Parameters: ~
  6579. • {blob} (`any`)
  6580. • {idx} (`integer`)
  6581. • {end_} (`integer?`)
  6582. Return: ~
  6583. (`any`)
  6584. remove({dict}, {key})
  6585. Remove the entry from {dict} with key {key} and return it.
  6586. Example: >vim
  6587. echo "removed " .. remove(dict, "one")
  6588. < If there is no {key} in {dict} this is an error.
  6589. Returns zero on error.
  6590. Parameters: ~
  6591. • {dict} (`any`)
  6592. • {key} (`string`)
  6593. Return: ~
  6594. (`any`)
  6595. rename({from}, {to}) *rename()*
  6596. Rename the file by the name {from} to the name {to}. This
  6597. should also work to move files across file systems. The
  6598. result is a Number, which is 0 if the file was renamed
  6599. successfully, and non-zero when the renaming failed.
  6600. NOTE: If {to} exists it is overwritten without warning.
  6601. This function is not available in the |sandbox|.
  6602. Parameters: ~
  6603. • {from} (`string`)
  6604. • {to} (`string`)
  6605. Return: ~
  6606. (`any`)
  6607. repeat({expr}, {count}) *repeat()*
  6608. Repeat {expr} {count} times and return the concatenated
  6609. result. Example: >vim
  6610. let separator = repeat('-', 80)
  6611. < When {count} is zero or negative the result is empty.
  6612. When {expr} is a |List| or a |Blob| the result is {expr}
  6613. concatenated {count} times. Example: >vim
  6614. let longlist = repeat(['a', 'b'], 3)
  6615. < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
  6616. Parameters: ~
  6617. • {expr} (`any`)
  6618. • {count} (`integer`)
  6619. Return: ~
  6620. (`any`)
  6621. resolve({filename}) *resolve()* *E655*
  6622. On MS-Windows, when {filename} is a shortcut (a .lnk file),
  6623. returns the path the shortcut points to in a simplified form.
  6624. On Unix, repeat resolving symbolic links in all path
  6625. components of {filename} and return the simplified result.
  6626. To cope with link cycles, resolving of symbolic links is
  6627. stopped after 100 iterations.
  6628. On other systems, return the simplified {filename}.
  6629. The simplification step is done as by |simplify()|.
  6630. resolve() keeps a leading path component specifying the
  6631. current directory (provided the result is still a relative
  6632. path name) and also keeps a trailing path separator.
  6633. Parameters: ~
  6634. • {filename} (`string`)
  6635. Return: ~
  6636. (`any`)
  6637. reverse({object}) *reverse()*
  6638. Reverse the order of items in {object}. {object} can be a
  6639. |List|, a |Blob| or a |String|. For a List and a Blob the
  6640. items are reversed in-place and {object} is returned.
  6641. For a String a new String is returned.
  6642. Returns zero if {object} is not a List, Blob or a String.
  6643. If you want a List or Blob to remain unmodified make a copy
  6644. first: >vim
  6645. let revlist = reverse(copy(mylist))
  6646. <
  6647. Parameters: ~
  6648. • {object} (`any`)
  6649. Return: ~
  6650. (`any`)
  6651. round({expr}) *round()*
  6652. Round off {expr} to the nearest integral value and return it
  6653. as a |Float|. If {expr} lies halfway between two integral
  6654. values, then use the larger one (away from zero).
  6655. {expr} must evaluate to a |Float| or a |Number|.
  6656. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6657. Examples: >vim
  6658. echo round(0.456)
  6659. < 0.0 >vim
  6660. echo round(4.5)
  6661. < 5.0 >vim
  6662. echo round(-4.5)
  6663. < -5.0
  6664. Parameters: ~
  6665. • {expr} (`number`)
  6666. Return: ~
  6667. (`any`)
  6668. rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()*
  6669. Sends {event} to {channel} via |RPC| and returns immediately.
  6670. If {channel} is 0, the event is broadcast to all channels.
  6671. Example: >vim
  6672. au VimLeave call rpcnotify(0, "leaving")
  6673. <
  6674. Parameters: ~
  6675. • {channel} (`integer`)
  6676. • {event} (`string`)
  6677. • {args} (`any?`)
  6678. Return: ~
  6679. (`any`)
  6680. rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()*
  6681. Sends a request to {channel} to invoke {method} via
  6682. |RPC| and blocks until a response is received.
  6683. Example: >vim
  6684. let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
  6685. <
  6686. Parameters: ~
  6687. • {channel} (`integer`)
  6688. • {method} (`string`)
  6689. • {args} (`any?`)
  6690. Return: ~
  6691. (`any`)
  6692. rubyeval({expr}) *rubyeval()*
  6693. Evaluate Ruby expression {expr} and return its result
  6694. converted to Vim data structures.
  6695. Numbers, floats and strings are returned as they are (strings
  6696. are copied though).
  6697. Arrays are represented as Vim |List| type.
  6698. Hashes are represented as Vim |Dictionary| type.
  6699. Other objects are represented as strings resulted from their
  6700. "Object#to_s" method.
  6701. Parameters: ~
  6702. • {expr} (`any`)
  6703. Return: ~
  6704. (`any`)
  6705. screenattr({row}, {col}) *screenattr()*
  6706. Like |screenchar()|, but return the attribute. This is a rather
  6707. arbitrary number that can only be used to compare to the
  6708. attribute at other positions.
  6709. Returns -1 when row or col is out of range.
  6710. Parameters: ~
  6711. • {row} (`integer`)
  6712. • {col} (`integer`)
  6713. Return: ~
  6714. (`any`)
  6715. screenchar({row}, {col}) *screenchar()*
  6716. The result is a Number, which is the character at position
  6717. [row, col] on the screen. This works for every possible
  6718. screen position, also status lines, window separators and the
  6719. command line. The top left position is row one, column one
  6720. The character excludes composing characters. For double-byte
  6721. encodings it may only be the first byte.
  6722. This is mainly to be used for testing.
  6723. Returns -1 when row or col is out of range.
  6724. Parameters: ~
  6725. • {row} (`integer`)
  6726. • {col} (`integer`)
  6727. Return: ~
  6728. (`any`)
  6729. screenchars({row}, {col}) *screenchars()*
  6730. The result is a |List| of Numbers. The first number is the same
  6731. as what |screenchar()| returns. Further numbers are
  6732. composing characters on top of the base character.
  6733. This is mainly to be used for testing.
  6734. Returns an empty List when row or col is out of range.
  6735. Parameters: ~
  6736. • {row} (`integer`)
  6737. • {col} (`integer`)
  6738. Return: ~
  6739. (`any`)
  6740. screencol() *screencol()*
  6741. The result is a Number, which is the current screen column of
  6742. the cursor. The leftmost column has number 1.
  6743. This function is mainly used for testing.
  6744. Note: Always returns the current screen column, thus if used
  6745. in a command (e.g. ":echo screencol()") it will return the
  6746. column inside the command line, which is 1 when the command is
  6747. executed. To get the cursor position in the file use one of
  6748. the following mappings: >vim
  6749. nnoremap <expr> GG ":echom " .. screencol() .. "\n"
  6750. nnoremap <silent> GG :echom screencol()<CR>
  6751. noremap GG <Cmd>echom screencol()<CR>
  6752. <
  6753. Return: ~
  6754. (`any`)
  6755. screenpos({winid}, {lnum}, {col}) *screenpos()*
  6756. The result is a Dict with the screen position of the text
  6757. character in window {winid} at buffer line {lnum} and column
  6758. {col}. {col} is a one-based byte index.
  6759. The Dict has these members:
  6760. row screen row
  6761. col first screen column
  6762. endcol last screen column
  6763. curscol cursor screen column
  6764. If the specified position is not visible, all values are zero.
  6765. The "endcol" value differs from "col" when the character
  6766. occupies more than one screen cell. E.g. for a Tab "col" can
  6767. be 1 and "endcol" can be 8.
  6768. The "curscol" value is where the cursor would be placed. For
  6769. a Tab it would be the same as "endcol", while for a double
  6770. width character it would be the same as "col".
  6771. The |conceal| feature is ignored here, the column numbers are
  6772. as if 'conceallevel' is zero. You can set the cursor to the
  6773. right position and use |screencol()| to get the value with
  6774. |conceal| taken into account.
  6775. If the position is in a closed fold the screen position of the
  6776. first character is returned, {col} is not used.
  6777. Returns an empty Dict if {winid} is invalid.
  6778. Parameters: ~
  6779. • {winid} (`integer`)
  6780. • {lnum} (`integer`)
  6781. • {col} (`integer`)
  6782. Return: ~
  6783. (`any`)
  6784. screenrow() *screenrow()*
  6785. The result is a Number, which is the current screen row of the
  6786. cursor. The top line has number one.
  6787. This function is mainly used for testing.
  6788. Alternatively you can use |winline()|.
  6789. Note: Same restrictions as with |screencol()|.
  6790. Return: ~
  6791. (`any`)
  6792. screenstring({row}, {col}) *screenstring()*
  6793. The result is a String that contains the base character and
  6794. any composing characters at position [row, col] on the screen.
  6795. This is like |screenchars()| but returning a String with the
  6796. characters.
  6797. This is mainly to be used for testing.
  6798. Returns an empty String when row or col is out of range.
  6799. Parameters: ~
  6800. • {row} (`integer`)
  6801. • {col} (`integer`)
  6802. Return: ~
  6803. (`any`)
  6804. search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
  6805. Search for regexp pattern {pattern}. The search starts at the
  6806. cursor position (you can use |cursor()| to set it).
  6807. When a match has been found its line number is returned.
  6808. If there is no match a 0 is returned and the cursor doesn't
  6809. move. No error message is given.
  6810. To get the matched string, use |matchbufline()|.
  6811. {flags} is a String, which can contain these character flags:
  6812. 'b' search Backward instead of forward
  6813. 'c' accept a match at the Cursor position
  6814. 'e' move to the End of the match
  6815. 'n' do Not move the cursor
  6816. 'p' return number of matching sub-Pattern (see below)
  6817. 's' Set the ' mark at the previous location of the cursor
  6818. 'w' Wrap around the end of the file
  6819. 'W' don't Wrap around the end of the file
  6820. 'z' start searching at the cursor column instead of Zero
  6821. If neither 'w' or 'W' is given, the 'wrapscan' option applies.
  6822. If the 's' flag is supplied, the ' mark is set, only if the
  6823. cursor is moved. The 's' flag cannot be combined with the 'n'
  6824. flag.
  6825. 'ignorecase', 'smartcase' and 'magic' are used.
  6826. When the 'z' flag is not given, forward searching always
  6827. starts in column zero and then matches before the cursor are
  6828. skipped. When the 'c' flag is present in 'cpo' the next
  6829. search starts after the match. Without the 'c' flag the next
  6830. search starts one column after the start of the match. This
  6831. matters for overlapping matches. See |cpo-c|. You can also
  6832. insert "\ze" to change where the match ends, see |/\ze|.
  6833. When searching backwards and the 'z' flag is given then the
  6834. search starts in column zero, thus no match in the current
  6835. line will be found (unless wrapping around the end of the
  6836. file).
  6837. When the {stopline} argument is given then the search stops
  6838. after searching this line. This is useful to restrict the
  6839. search to a range of lines. Examples: >vim
  6840. let match = search('(', 'b', line("w0"))
  6841. let end = search('END', '', line("w$"))
  6842. < When {stopline} is used and it is not zero this also implies
  6843. that the search does not wrap around the end of the file.
  6844. A zero value is equal to not giving the argument.
  6845. When the {timeout} argument is given the search stops when
  6846. more than this many milliseconds have passed. Thus when
  6847. {timeout} is 500 the search stops after half a second.
  6848. The value must not be negative. A zero value is like not
  6849. giving the argument.
  6850. Note: the timeout is only considered when searching, not
  6851. while evaluating the {skip} expression.
  6852. If the {skip} expression is given it is evaluated with the
  6853. cursor positioned on the start of a match. If it evaluates to
  6854. non-zero this match is skipped. This can be used, for
  6855. example, to skip a match in a comment or a string.
  6856. {skip} can be a string, which is evaluated as an expression, a
  6857. function reference or a lambda.
  6858. When {skip} is omitted or empty, every match is accepted.
  6859. When evaluating {skip} causes an error the search is aborted
  6860. and -1 returned.
  6861. *search()-sub-match*
  6862. With the 'p' flag the returned value is one more than the
  6863. first sub-match in \(\). One if none of them matched but the
  6864. whole pattern did match.
  6865. To get the column number too use |searchpos()|.
  6866. The cursor will be positioned at the match, unless the 'n'
  6867. flag is used.
  6868. Example (goes over all files in the argument list): >vim
  6869. let n = 1
  6870. while n <= argc() " loop over all files in arglist
  6871. exe "argument " .. n
  6872. " start at the last char in the file and wrap for the
  6873. " first search to find match at start of file
  6874. normal G$
  6875. let flags = "w"
  6876. while search("foo", flags) > 0
  6877. s/foo/bar/g
  6878. let flags = "W"
  6879. endwhile
  6880. update " write the file if modified
  6881. let n = n + 1
  6882. endwhile
  6883. <
  6884. Example for using some flags: >vim
  6885. echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
  6886. < This will search for the keywords "if", "else", and "endif"
  6887. under or after the cursor. Because of the 'p' flag, it
  6888. returns 1, 2, or 3 depending on which keyword is found, or 0
  6889. if the search fails. With the cursor on the first word of the
  6890. line:
  6891. if (foo == 0) | let foo = foo + 1 | endif ~
  6892. the function returns 1. Without the 'c' flag, the function
  6893. finds the "endif" and returns 3. The same thing happens
  6894. without the 'e' flag if the cursor is on the "f" of "if".
  6895. The 'n' flag tells the function not to move the cursor.
  6896. Parameters: ~
  6897. • {pattern} (`string`)
  6898. • {flags} (`string?`)
  6899. • {stopline} (`integer?`)
  6900. • {timeout} (`integer?`)
  6901. • {skip} (`string|function?`)
  6902. Return: ~
  6903. (`any`)
  6904. searchcount([{options}]) *searchcount()*
  6905. Get or update the last search count, like what is displayed
  6906. without the "S" flag in 'shortmess'. This works even if
  6907. 'shortmess' does contain the "S" flag.
  6908. This returns a |Dictionary|. The dictionary is empty if the
  6909. previous pattern was not set and "pattern" was not specified.
  6910. key type meaning ~
  6911. current |Number| current position of match;
  6912. 0 if the cursor position is
  6913. before the first match
  6914. exact_match |Boolean| 1 if "current" is matched on
  6915. "pos", otherwise 0
  6916. total |Number| total count of matches found
  6917. incomplete |Number| 0: search was fully completed
  6918. 1: recomputing was timed out
  6919. 2: max count exceeded
  6920. For {options} see further down.
  6921. To get the last search count when |n| or |N| was pressed, call
  6922. this function with `recompute: 0` . This sometimes returns
  6923. wrong information because |n| and |N|'s maximum count is 99.
  6924. If it exceeded 99 the result must be max count + 1 (100). If
  6925. you want to get correct information, specify `recompute: 1`: >vim
  6926. " result == maxcount + 1 (100) when many matches
  6927. let result = searchcount(#{recompute: 0})
  6928. " Below returns correct result (recompute defaults
  6929. " to 1)
  6930. let result = searchcount()
  6931. <
  6932. The function is useful to add the count to 'statusline': >vim
  6933. function! LastSearchCount() abort
  6934. let result = searchcount(#{recompute: 0})
  6935. if empty(result)
  6936. return ''
  6937. endif
  6938. if result.incomplete ==# 1 " timed out
  6939. return printf(' /%s [?/??]', @/)
  6940. elseif result.incomplete ==# 2 " max count exceeded
  6941. if result.total > result.maxcount &&
  6942. \ result.current > result.maxcount
  6943. return printf(' /%s [>%d/>%d]', @/,
  6944. \ result.current, result.total)
  6945. elseif result.total > result.maxcount
  6946. return printf(' /%s [%d/>%d]', @/,
  6947. \ result.current, result.total)
  6948. endif
  6949. endif
  6950. return printf(' /%s [%d/%d]', @/,
  6951. \ result.current, result.total)
  6952. endfunction
  6953. let &statusline ..= '%{LastSearchCount()}'
  6954. " Or if you want to show the count only when
  6955. " 'hlsearch' was on
  6956. " let &statusline ..=
  6957. " \ '%{v:hlsearch ? LastSearchCount() : ""}'
  6958. <
  6959. You can also update the search count, which can be useful in a
  6960. |CursorMoved| or |CursorMovedI| autocommand: >vim
  6961. autocmd CursorMoved,CursorMovedI *
  6962. \ let s:searchcount_timer = timer_start(
  6963. \ 200, function('s:update_searchcount'))
  6964. function! s:update_searchcount(timer) abort
  6965. if a:timer ==# s:searchcount_timer
  6966. call searchcount(#{
  6967. \ recompute: 1, maxcount: 0, timeout: 100})
  6968. redrawstatus
  6969. endif
  6970. endfunction
  6971. <
  6972. This can also be used to count matched texts with specified
  6973. pattern in the current buffer using "pattern": >vim
  6974. " Count '\<foo\>' in this buffer
  6975. " (Note that it also updates search count)
  6976. let result = searchcount(#{pattern: '\<foo\>'})
  6977. " To restore old search count by old pattern,
  6978. " search again
  6979. call searchcount()
  6980. <
  6981. {options} must be a |Dictionary|. It can contain:
  6982. key type meaning ~
  6983. recompute |Boolean| if |TRUE|, recompute the count
  6984. like |n| or |N| was executed.
  6985. otherwise returns the last
  6986. computed result (when |n| or
  6987. |N| was used when "S" is not
  6988. in 'shortmess', or this
  6989. function was called).
  6990. (default: |TRUE|)
  6991. pattern |String| recompute if this was given
  6992. and different with |@/|.
  6993. this works as same as the
  6994. below command is executed
  6995. before calling this function >vim
  6996. let @/ = pattern
  6997. < (default: |@/|)
  6998. timeout |Number| 0 or negative number is no
  6999. timeout. timeout milliseconds
  7000. for recomputing the result
  7001. (default: 0)
  7002. maxcount |Number| 0 or negative number is no
  7003. limit. max count of matched
  7004. text while recomputing the
  7005. result. if search exceeded
  7006. total count, "total" value
  7007. becomes `maxcount + 1`
  7008. (default: 0)
  7009. pos |List| `[lnum, col, off]` value
  7010. when recomputing the result.
  7011. this changes "current" result
  7012. value. see |cursor()|, |getpos()|
  7013. (default: cursor's position)
  7014. Parameters: ~
  7015. • {options} (`table?`)
  7016. Return: ~
  7017. (`any`)
  7018. searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
  7019. Search for the declaration of {name}.
  7020. With a non-zero {global} argument it works like |gD|, find
  7021. first match in the file. Otherwise it works like |gd|, find
  7022. first match in the function.
  7023. With a non-zero {thisblock} argument matches in a {} block
  7024. that ends before the cursor position are ignored. Avoids
  7025. finding variable declarations only valid in another scope.
  7026. Moves the cursor to the found match.
  7027. Returns zero for success, non-zero for failure.
  7028. Example: >vim
  7029. if searchdecl('myvar') == 0
  7030. echo getline('.')
  7031. endif
  7032. <
  7033. Parameters: ~
  7034. • {name} (`string`)
  7035. • {global} (`boolean?`)
  7036. • {thisblock} (`boolean?`)
  7037. Return: ~
  7038. (`any`)
  7039. *searchpair()*
  7040. searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7041. Search for the match of a nested start-end pair. This can be
  7042. used to find the "endif" that matches an "if", while other
  7043. if/endif pairs in between are ignored.
  7044. The search starts at the cursor. The default is to search
  7045. forward, include 'b' in {flags} to search backward.
  7046. If a match is found, the cursor is positioned at it and the
  7047. line number is returned. If no match is found 0 or -1 is
  7048. returned and the cursor doesn't move. No error message is
  7049. given.
  7050. {start}, {middle} and {end} are patterns, see |pattern|. They
  7051. must not contain \( \) pairs. Use of \%( \) is allowed. When
  7052. {middle} is not empty, it is found when searching from either
  7053. direction, but only when not in a nested start-end pair. A
  7054. typical use is: >vim
  7055. echo searchpair('\<if\>', '\<else\>', '\<endif\>')
  7056. < By leaving {middle} empty the "else" is skipped.
  7057. {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
  7058. |search()|. Additionally:
  7059. 'r' Repeat until no more matches found; will find the
  7060. outer pair. Implies the 'W' flag.
  7061. 'm' Return number of matches instead of line number with
  7062. the match; will be > 1 when 'r' is used.
  7063. Note: it's nearly always a good idea to use the 'W' flag, to
  7064. avoid wrapping around the end of the file.
  7065. When a match for {start}, {middle} or {end} is found, the
  7066. {skip} expression is evaluated with the cursor positioned on
  7067. the start of the match. It should return non-zero if this
  7068. match is to be skipped. E.g., because it is inside a comment
  7069. or a string.
  7070. When {skip} is omitted or empty, every match is accepted.
  7071. When evaluating {skip} causes an error the search is aborted
  7072. and -1 returned.
  7073. {skip} can be a string, a lambda, a funcref or a partial.
  7074. Anything else makes the function fail.
  7075. For {stopline} and {timeout} see |search()|.
  7076. The value of 'ignorecase' is used. 'magic' is ignored, the
  7077. patterns are used like it's on.
  7078. The search starts exactly at the cursor. A match with
  7079. {start}, {middle} or {end} at the next character, in the
  7080. direction of searching, is the first one found. Example: >vim
  7081. if 1
  7082. if 2
  7083. endif 2
  7084. endif 1
  7085. < When starting at the "if 2", with the cursor on the "i", and
  7086. searching forwards, the "endif 2" is found. When starting on
  7087. the character just before the "if 2", the "endif 1" will be
  7088. found. That's because the "if 2" will be found first, and
  7089. then this is considered to be a nested if/endif from "if 2" to
  7090. "endif 2".
  7091. When searching backwards and {end} is more than one character,
  7092. it may be useful to put "\zs" at the end of the pattern, so
  7093. that when the cursor is inside a match with the end it finds
  7094. the matching start.
  7095. Example, to find the "endif" command in a Vim script: >vim
  7096. echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
  7097. \ 'getline(".") =~ "^\\s*\""')
  7098. < The cursor must be at or after the "if" for which a match is
  7099. to be found. Note that single-quote strings are used to avoid
  7100. having to double the backslashes. The skip expression only
  7101. catches comments at the start of a line, not after a command.
  7102. Also, a word "en" or "if" halfway through a line is considered
  7103. a match.
  7104. Another example, to search for the matching "{" of a "}": >vim
  7105. echo searchpair('{', '', '}', 'bW')
  7106. < This works when the cursor is at or before the "}" for which a
  7107. match is to be found. To reject matches that syntax
  7108. highlighting recognized as strings: >vim
  7109. echo searchpair('{', '', '}', 'bW',
  7110. \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
  7111. <
  7112. Parameters: ~
  7113. • {start} (`string`)
  7114. • {middle} (`string`)
  7115. • {end_} (`string`)
  7116. • {flags} (`string?`)
  7117. • {skip} (`string|function?`)
  7118. • {stopline} (`integer?`)
  7119. • {timeout} (`integer?`)
  7120. Return: ~
  7121. (`integer`)
  7122. *searchpairpos()*
  7123. searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7124. Same as |searchpair()|, but returns a |List| with the line and
  7125. column position of the match. The first element of the |List|
  7126. is the line number and the second element is the byte index of
  7127. the column position of the match. If no match is found,
  7128. returns [0, 0]. >vim
  7129. let [lnum,col] = searchpairpos('{', '', '}', 'n')
  7130. <
  7131. See |match-parens| for a bigger and more useful example.
  7132. Parameters: ~
  7133. • {start} (`string`)
  7134. • {middle} (`string`)
  7135. • {end_} (`string`)
  7136. • {flags} (`string?`)
  7137. • {skip} (`string|function?`)
  7138. • {stopline} (`integer?`)
  7139. • {timeout} (`integer?`)
  7140. Return: ~
  7141. (`[integer, integer]`)
  7142. *searchpos()*
  7143. searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  7144. Same as |search()|, but returns a |List| with the line and
  7145. column position of the match. The first element of the |List|
  7146. is the line number and the second element is the byte index of
  7147. the column position of the match. If no match is found,
  7148. returns [0, 0].
  7149. Example: >vim
  7150. let [lnum, col] = searchpos('mypattern', 'n')
  7151. < When the 'p' flag is given then there is an extra item with
  7152. the sub-pattern match number |search()-sub-match|. Example: >vim
  7153. let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
  7154. < In this example "submatch" is 2 when a lowercase letter is
  7155. found |/\l|, 3 when an uppercase letter is found |/\u|.
  7156. Parameters: ~
  7157. • {pattern} (`string`)
  7158. • {flags} (`string?`)
  7159. • {stopline} (`integer?`)
  7160. • {timeout} (`integer?`)
  7161. • {skip} (`string|function?`)
  7162. Return: ~
  7163. (`any`)
  7164. serverlist() *serverlist()*
  7165. Returns a list of server addresses, or empty if all servers
  7166. were stopped. |serverstart()| |serverstop()|
  7167. Example: >vim
  7168. echo serverlist()
  7169. <
  7170. Return: ~
  7171. (`any`)
  7172. serverstart([{address}]) *serverstart()*
  7173. Opens a socket or named pipe at {address} and listens for
  7174. |RPC| messages. Clients can send |API| commands to the
  7175. returned address to control Nvim.
  7176. Returns the address string (which may differ from the
  7177. {address} argument, see below).
  7178. - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
  7179. where the last ":" separates host and port (empty or zero
  7180. assigns a random port).
  7181. - Else {address} is the path to a named pipe (except on Windows).
  7182. - If {address} has no slashes ("/") it is treated as the
  7183. "name" part of a generated path in this format: >vim
  7184. stdpath("run").."/{name}.{pid}.{counter}"
  7185. < - If {address} is omitted the name is "nvim". >vim
  7186. echo serverstart()
  7187. < >
  7188. => /tmp/nvim.bram/oknANW/nvim.15430.5
  7189. <
  7190. Example bash command to list all Nvim servers: >bash
  7191. ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
  7192. < Example named pipe: >vim
  7193. if has('win32')
  7194. echo serverstart('\\.\pipe\nvim-pipe-1234')
  7195. else
  7196. echo serverstart('nvim.sock')
  7197. endif
  7198. <
  7199. Example TCP/IP address: >vim
  7200. echo serverstart('::1:12345')
  7201. <
  7202. Parameters: ~
  7203. • {address} (`string?`)
  7204. Return: ~
  7205. (`any`)
  7206. serverstop({address}) *serverstop()*
  7207. Closes the pipe or socket at {address}.
  7208. Returns TRUE if {address} is valid, else FALSE.
  7209. If |v:servername| is stopped it is set to the next available
  7210. address in |serverlist()|.
  7211. Parameters: ~
  7212. • {address} (`string`)
  7213. Return: ~
  7214. (`any`)
  7215. setbufline({buf}, {lnum}, {text}) *setbufline()*
  7216. Set line {lnum} to {text} in buffer {buf}. This works like
  7217. |setline()| for the specified buffer.
  7218. This function works only for loaded buffers. First call
  7219. |bufload()| if needed.
  7220. To insert lines use |appendbufline()|.
  7221. {text} can be a string to set one line, or a List of strings
  7222. to set multiple lines. If the List extends below the last
  7223. line then those lines are added. If the List is empty then
  7224. nothing is changed and zero is returned.
  7225. For the use of {buf}, see |bufname()| above.
  7226. {lnum} is used like with |setline()|.
  7227. Use "$" to refer to the last line in buffer {buf}.
  7228. When {lnum} is just below the last line the {text} will be
  7229. added below the last line.
  7230. On success 0 is returned, on failure 1 is returned.
  7231. If {buf} is not a valid buffer or {lnum} is not valid, an
  7232. error message is given.
  7233. Parameters: ~
  7234. • {buf} (`integer|string`)
  7235. • {lnum} (`integer`)
  7236. • {text} (`string|string[]`)
  7237. Return: ~
  7238. (`any`)
  7239. setbufvar({buf}, {varname}, {val}) *setbufvar()*
  7240. Set option or local variable {varname} in buffer {buf} to
  7241. {val}.
  7242. This also works for a global or local window option, but it
  7243. doesn't work for a global or local window variable.
  7244. For a local window option the global value is unchanged.
  7245. For the use of {buf}, see |bufname()| above.
  7246. The {varname} argument is a string.
  7247. Note that the variable name without "b:" must be used.
  7248. Examples: >vim
  7249. call setbufvar(1, "&mod", 1)
  7250. call setbufvar("todo", "myvar", "foobar")
  7251. < This function is not available in the |sandbox|.
  7252. Parameters: ~
  7253. • {buf} (`integer|string`)
  7254. • {varname} (`string`)
  7255. • {val} (`any`)
  7256. Return: ~
  7257. (`any`)
  7258. setcellwidths({list}) *setcellwidths()*
  7259. Specify overrides for cell widths of character ranges. This
  7260. tells Vim how wide characters are when displayed in the
  7261. terminal, counted in screen cells. The values override
  7262. 'ambiwidth'. Example: >vim
  7263. call setcellwidths([
  7264. \ [0x111, 0x111, 1],
  7265. \ [0x2194, 0x2199, 2],
  7266. \ ])
  7267. < The {list} argument is a List of Lists with each three
  7268. numbers: [{low}, {high}, {width}]. *E1109* *E1110*
  7269. {low} and {high} can be the same, in which case this refers to
  7270. one character. Otherwise it is the range of characters from
  7271. {low} to {high} (inclusive). *E1111* *E1114*
  7272. Only characters with value 0x80 and higher can be used.
  7273. {width} must be either 1 or 2, indicating the character width
  7274. in screen cells. *E1112*
  7275. An error is given if the argument is invalid, also when a
  7276. range overlaps with another. *E1113*
  7277. If the new value causes 'fillchars' or 'listchars' to become
  7278. invalid it is rejected and an error is given.
  7279. To clear the overrides pass an empty {list}: >vim
  7280. call setcellwidths([])
  7281. < You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
  7282. the effect for known emoji characters. Move the cursor
  7283. through the text to check if the cell widths of your terminal
  7284. match with what Vim knows about each emoji. If it doesn't
  7285. look right you need to adjust the {list} argument.
  7286. Parameters: ~
  7287. • {list} (`any[]`)
  7288. Return: ~
  7289. (`any`)
  7290. setcharpos({expr}, {list}) *setcharpos()*
  7291. Same as |setpos()| but uses the specified column number as the
  7292. character index instead of the byte index in the line.
  7293. Example:
  7294. With the text "여보세요" in line 8: >vim
  7295. call setcharpos('.', [0, 8, 4, 0])
  7296. < positions the cursor on the fourth character '요'. >vim
  7297. call setpos('.', [0, 8, 4, 0])
  7298. < positions the cursor on the second character '보'.
  7299. Parameters: ~
  7300. • {expr} (`string`)
  7301. • {list} (`integer[]`)
  7302. Return: ~
  7303. (`any`)
  7304. setcharsearch({dict}) *setcharsearch()*
  7305. Set the current character search information to {dict},
  7306. which contains one or more of the following entries:
  7307. char character which will be used for a subsequent
  7308. |,| or |;| command; an empty string clears the
  7309. character search
  7310. forward direction of character search; 1 for forward,
  7311. 0 for backward
  7312. until type of character search; 1 for a |t| or |T|
  7313. character search, 0 for an |f| or |F|
  7314. character search
  7315. This can be useful to save/restore a user's character search
  7316. from a script: >vim
  7317. let prevsearch = getcharsearch()
  7318. " Perform a command which clobbers user's search
  7319. call setcharsearch(prevsearch)
  7320. < Also see |getcharsearch()|.
  7321. Parameters: ~
  7322. • {dict} (`string`)
  7323. Return: ~
  7324. (`any`)
  7325. setcmdline({str} [, {pos}]) *setcmdline()*
  7326. Set the command line to {str} and set the cursor position to
  7327. {pos}.
  7328. If {pos} is omitted, the cursor is positioned after the text.
  7329. Returns 0 when successful, 1 when not editing the command
  7330. line.
  7331. Parameters: ~
  7332. • {str} (`string`)
  7333. • {pos} (`integer?`)
  7334. Return: ~
  7335. (`any`)
  7336. setcmdpos({pos}) *setcmdpos()*
  7337. Set the cursor position in the command line to byte position
  7338. {pos}. The first position is 1.
  7339. Use |getcmdpos()| to obtain the current position.
  7340. Only works while editing the command line, thus you must use
  7341. |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
  7342. |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
  7343. set after the command line is set to the expression. For
  7344. |c_CTRL-R_=| it is set after evaluating the expression but
  7345. before inserting the resulting text.
  7346. When the number is too big the cursor is put at the end of the
  7347. line. A number smaller than one has undefined results.
  7348. Returns 0 when successful, 1 when not editing the command
  7349. line.
  7350. Parameters: ~
  7351. • {pos} (`integer`)
  7352. Return: ~
  7353. (`any`)
  7354. setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()*
  7355. setcursorcharpos({list})
  7356. Same as |cursor()| but uses the specified column number as the
  7357. character index instead of the byte index in the line.
  7358. Example:
  7359. With the text "여보세요" in line 4: >vim
  7360. call setcursorcharpos(4, 3)
  7361. < positions the cursor on the third character '세'. >vim
  7362. call cursor(4, 3)
  7363. < positions the cursor on the first character '여'.
  7364. Parameters: ~
  7365. • {list} (`integer[]`)
  7366. Return: ~
  7367. (`any`)
  7368. setenv({name}, {val}) *setenv()*
  7369. Set environment variable {name} to {val}. Example: >vim
  7370. call setenv('HOME', '/home/myhome')
  7371. < When {val} is |v:null| the environment variable is deleted.
  7372. See also |expr-env|.
  7373. Parameters: ~
  7374. • {name} (`string`)
  7375. • {val} (`string`)
  7376. Return: ~
  7377. (`any`)
  7378. setfperm({fname}, {mode}) *setfperm()* *chmod*
  7379. Set the file permissions for {fname} to {mode}.
  7380. {mode} must be a string with 9 characters. It is of the form
  7381. "rwxrwxrwx", where each group of "rwx" flags represent, in
  7382. turn, the permissions of the owner of the file, the group the
  7383. file belongs to, and other users. A '-' character means the
  7384. permission is off, any other character means on. Multi-byte
  7385. characters are not supported.
  7386. For example "rw-r-----" means read-write for the user,
  7387. readable by the group, not accessible by others. "xx-x-----"
  7388. would do the same thing.
  7389. Returns non-zero for success, zero for failure.
  7390. To read permissions see |getfperm()|.
  7391. Parameters: ~
  7392. • {fname} (`string`)
  7393. • {mode} (`string`)
  7394. Return: ~
  7395. (`any`)
  7396. setline({lnum}, {text}) *setline()*
  7397. Set line {lnum} of the current buffer to {text}. To insert
  7398. lines use |append()|. To set lines in another buffer use
  7399. |setbufline()|.
  7400. {lnum} is used like with |getline()|.
  7401. When {lnum} is just below the last line the {text} will be
  7402. added below the last line.
  7403. {text} can be any type or a List of any type, each item is
  7404. converted to a String. When {text} is an empty List then
  7405. nothing is changed and FALSE is returned.
  7406. If this succeeds, FALSE is returned. If this fails (most likely
  7407. because {lnum} is invalid) TRUE is returned.
  7408. Example: >vim
  7409. call setline(5, strftime("%c"))
  7410. < When {text} is a |List| then line {lnum} and following lines
  7411. will be set to the items in the list. Example: >vim
  7412. call setline(5, ['aaa', 'bbb', 'ccc'])
  7413. < This is equivalent to: >vim
  7414. for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
  7415. call setline(n, l)
  7416. endfor
  7417. < Note: The '[ and '] marks are not set.
  7418. Parameters: ~
  7419. • {lnum} (`integer`)
  7420. • {text} (`any`)
  7421. Return: ~
  7422. (`any`)
  7423. setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
  7424. Create or replace or add to the location list for window {nr}.
  7425. {nr} can be the window number or the |window-ID|.
  7426. When {nr} is zero the current window is used.
  7427. For a location list window, the displayed location list is
  7428. modified. For an invalid window number {nr}, -1 is returned.
  7429. Otherwise, same as |setqflist()|.
  7430. Also see |location-list|.
  7431. For {action} see |setqflist-action|.
  7432. If the optional {what} dictionary argument is supplied, then
  7433. only the items listed in {what} are set. Refer to |setqflist()|
  7434. for the list of supported keys in {what}.
  7435. Parameters: ~
  7436. • {nr} (`integer`)
  7437. • {list} (`any`)
  7438. • {action} (`string?`)
  7439. • {what} (`table?`)
  7440. Return: ~
  7441. (`any`)
  7442. setmatches({list} [, {win}]) *setmatches()*
  7443. Restores a list of matches saved by |getmatches()| for the
  7444. current window. Returns 0 if successful, otherwise -1. All
  7445. current matches are cleared before the list is restored. See
  7446. example for |getmatches()|.
  7447. If {win} is specified, use the window with this number or
  7448. window ID instead of the current window.
  7449. Parameters: ~
  7450. • {list} (`any`)
  7451. • {win} (`integer?`)
  7452. Return: ~
  7453. (`any`)
  7454. setpos({expr}, {list}) *setpos()*
  7455. Set the position for String {expr}. Possible values:
  7456. . the cursor
  7457. 'x mark x
  7458. {list} must be a |List| with four or five numbers:
  7459. [bufnum, lnum, col, off]
  7460. [bufnum, lnum, col, off, curswant]
  7461. "bufnum" is the buffer number. Zero can be used for the
  7462. current buffer. When setting an uppercase mark "bufnum" is
  7463. used for the mark position. For other marks it specifies the
  7464. buffer to set the mark in. You can use the |bufnr()| function
  7465. to turn a file name into a buffer number.
  7466. For setting the cursor and the ' mark "bufnum" is ignored,
  7467. since these are associated with a window, not a buffer.
  7468. Does not change the jumplist.
  7469. "lnum" and "col" are the position in the buffer. The first
  7470. column is 1. Use a zero "lnum" to delete a mark. If "col" is
  7471. smaller than 1 then 1 is used. To use the character count
  7472. instead of the byte count, use |setcharpos()|.
  7473. The "off" number is only used when 'virtualedit' is set. Then
  7474. it is the offset in screen columns from the start of the
  7475. character. E.g., a position within a <Tab> or after the last
  7476. character.
  7477. The "curswant" number is only used when setting the cursor
  7478. position. It sets the preferred column for when moving the
  7479. cursor vertically. When the "curswant" number is missing the
  7480. preferred column is not set. When it is present and setting a
  7481. mark position it is not used.
  7482. Note that for '< and '> changing the line number may result in
  7483. the marks to be effectively be swapped, so that '< is always
  7484. before '>.
  7485. Returns 0 when the position could be set, -1 otherwise.
  7486. An error message is given if {expr} is invalid.
  7487. Also see |setcharpos()|, |getpos()| and |getcurpos()|.
  7488. This does not restore the preferred column for moving
  7489. vertically; if you set the cursor position with this, |j| and
  7490. |k| motions will jump to previous columns! Use |cursor()| to
  7491. also set the preferred column. Also see the "curswant" key in
  7492. |winrestview()|.
  7493. Parameters: ~
  7494. • {expr} (`string`)
  7495. • {list} (`integer[]`)
  7496. Return: ~
  7497. (`any`)
  7498. setqflist({list} [, {action} [, {what}]]) *setqflist()*
  7499. Create or replace or add to the quickfix list.
  7500. If the optional {what} dictionary argument is supplied, then
  7501. only the items listed in {what} are set. The first {list}
  7502. argument is ignored. See below for the supported items in
  7503. {what}.
  7504. *setqflist-what*
  7505. When {what} is not present, the items in {list} are used. Each
  7506. item must be a dictionary. Non-dictionary items in {list} are
  7507. ignored. Each dictionary item can contain the following
  7508. entries:
  7509. bufnr buffer number; must be the number of a valid
  7510. buffer
  7511. filename name of a file; only used when "bufnr" is not
  7512. present or it is invalid.
  7513. module name of a module; if given it will be used in
  7514. quickfix error window instead of the filename.
  7515. lnum line number in the file
  7516. end_lnum end of lines, if the item spans multiple lines
  7517. pattern search pattern used to locate the error
  7518. col column number
  7519. vcol when non-zero: "col" is visual column
  7520. when zero: "col" is byte index
  7521. end_col end column, if the item spans multiple columns
  7522. nr error number
  7523. text description of the error
  7524. type single-character error type, 'E', 'W', etc.
  7525. valid recognized error message
  7526. user_data
  7527. custom data associated with the item, can be
  7528. any type.
  7529. The "col", "vcol", "nr", "type" and "text" entries are
  7530. optional. Either "lnum" or "pattern" entry can be used to
  7531. locate a matching error line.
  7532. If the "filename" and "bufnr" entries are not present or
  7533. neither the "lnum" or "pattern" entries are present, then the
  7534. item will not be handled as an error line.
  7535. If both "pattern" and "lnum" are present then "pattern" will
  7536. be used.
  7537. If the "valid" entry is not supplied, then the valid flag is
  7538. set when "bufnr" is a valid buffer or "filename" exists.
  7539. If you supply an empty {list}, the quickfix list will be
  7540. cleared.
  7541. Note that the list is not exactly the same as what
  7542. |getqflist()| returns.
  7543. {action} values: *setqflist-action* *E927*
  7544. 'a' The items from {list} are added to the existing
  7545. quickfix list. If there is no existing list, then a
  7546. new list is created.
  7547. 'r' The items from the current quickfix list are replaced
  7548. with the items from {list}. This can also be used to
  7549. clear the list: >vim
  7550. call setqflist([], 'r')
  7551. <
  7552. 'u' Like 'r', but tries to preserve the current selection
  7553. in the quickfix list.
  7554. 'f' All the quickfix lists in the quickfix stack are
  7555. freed.
  7556. If {action} is not present or is set to ' ', then a new list
  7557. is created. The new quickfix list is added after the current
  7558. quickfix list in the stack and all the following lists are
  7559. freed. To add a new quickfix list at the end of the stack,
  7560. set "nr" in {what} to "$".
  7561. The following items can be specified in dictionary {what}:
  7562. context quickfix list context. See |quickfix-context|
  7563. efm errorformat to use when parsing text from
  7564. "lines". If this is not present, then the
  7565. 'errorformat' option value is used.
  7566. See |quickfix-parse|
  7567. id quickfix list identifier |quickfix-ID|
  7568. idx index of the current entry in the quickfix
  7569. list specified by "id" or "nr". If set to '$',
  7570. then the last entry in the list is set as the
  7571. current entry. See |quickfix-index|
  7572. items list of quickfix entries. Same as the {list}
  7573. argument.
  7574. lines use 'errorformat' to parse a list of lines and
  7575. add the resulting entries to the quickfix list
  7576. {nr} or {id}. Only a |List| value is supported.
  7577. See |quickfix-parse|
  7578. nr list number in the quickfix stack; zero
  7579. means the current quickfix list and "$" means
  7580. the last quickfix list.
  7581. quickfixtextfunc
  7582. function to get the text to display in the
  7583. quickfix window. The value can be the name of
  7584. a function or a funcref or a lambda. Refer to
  7585. |quickfix-window-function| for an explanation
  7586. of how to write the function and an example.
  7587. title quickfix list title text. See |quickfix-title|
  7588. Unsupported keys in {what} are ignored.
  7589. If the "nr" item is not present, then the current quickfix list
  7590. is modified. When creating a new quickfix list, "nr" can be
  7591. set to a value one greater than the quickfix stack size.
  7592. When modifying a quickfix list, to guarantee that the correct
  7593. list is modified, "id" should be used instead of "nr" to
  7594. specify the list.
  7595. Examples (See also |setqflist-examples|): >vim
  7596. call setqflist([], 'r', {'title': 'My search'})
  7597. call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
  7598. call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
  7599. <
  7600. Returns zero for success, -1 for failure.
  7601. This function can be used to create a quickfix list
  7602. independent of the 'errorformat' setting. Use a command like
  7603. `:cc 1` to jump to the first position.
  7604. Parameters: ~
  7605. • {list} (`vim.quickfix.entry[]`)
  7606. • {action} (`string?`)
  7607. • {what} (`vim.fn.setqflist.what?`)
  7608. Return: ~
  7609. (`any`)
  7610. setreg({regname}, {value} [, {options}]) *setreg()*
  7611. Set the register {regname} to {value}.
  7612. If {regname} is "" or "@", the unnamed register '"' is used.
  7613. The {regname} argument is a string.
  7614. {value} may be any value returned by |getreg()| or
  7615. |getreginfo()|, including a |List| or |Dict|.
  7616. If {options} contains "a" or {regname} is upper case,
  7617. then the value is appended.
  7618. {options} can also contain a register type specification:
  7619. "c" or "v" |charwise| mode
  7620. "l" or "V" |linewise| mode
  7621. "b" or "<CTRL-V>" |blockwise-visual| mode
  7622. If a number immediately follows "b" or "<CTRL-V>" then this is
  7623. used as the width of the selection - if it is not specified
  7624. then the width of the block is set to the number of characters
  7625. in the longest line (counting a <Tab> as 1 character).
  7626. If {options} contains "u" or '"', then the unnamed register is
  7627. set to point to register {regname}.
  7628. If {options} contains no register settings, then the default
  7629. is to use character mode unless {value} ends in a <NL> for
  7630. string {value} and linewise mode for list {value}. Blockwise
  7631. mode is never selected automatically.
  7632. Returns zero for success, non-zero for failure.
  7633. *E883*
  7634. Note: you may not use |List| containing more than one item to
  7635. set search and expression registers. Lists containing no
  7636. items act like empty strings.
  7637. Examples: >vim
  7638. call setreg(v:register, @*)
  7639. call setreg('*', @%, 'ac')
  7640. call setreg('a', "1\n2\n3", 'b5')
  7641. call setreg('"', { 'points_to': 'a'})
  7642. < This example shows using the functions to save and restore a
  7643. register: >vim
  7644. let var_a = getreginfo()
  7645. call setreg('a', var_a)
  7646. < or: >vim
  7647. let var_a = getreg('a', 1, 1)
  7648. let var_amode = getregtype('a')
  7649. " ....
  7650. call setreg('a', var_a, var_amode)
  7651. < Note: you may not reliably restore register value
  7652. without using the third argument to |getreg()| as without it
  7653. newlines are represented as newlines AND Nul bytes are
  7654. represented as newlines as well, see |NL-used-for-Nul|.
  7655. You can also change the type of a register by appending
  7656. nothing: >vim
  7657. call setreg('a', '', 'al')
  7658. Parameters: ~
  7659. • {regname} (`string`)
  7660. • {value} (`any`)
  7661. • {options} (`string?`)
  7662. Return: ~
  7663. (`any`)
  7664. settabvar({tabnr}, {varname}, {val}) *settabvar()*
  7665. Set tab-local variable {varname} to {val} in tab page {tabnr}.
  7666. |t:var|
  7667. The {varname} argument is a string.
  7668. Note that the variable name without "t:" must be used.
  7669. Tabs are numbered starting with one.
  7670. This function is not available in the |sandbox|.
  7671. Parameters: ~
  7672. • {tabnr} (`integer`)
  7673. • {varname} (`string`)
  7674. • {val} (`any`)
  7675. Return: ~
  7676. (`any`)
  7677. settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
  7678. Set option or local variable {varname} in window {winnr} to
  7679. {val}.
  7680. Tabs are numbered starting with one. For the current tabpage
  7681. use |setwinvar()|.
  7682. {winnr} can be the window number or the |window-ID|.
  7683. When {winnr} is zero the current window is used.
  7684. This also works for a global or local buffer option, but it
  7685. doesn't work for a global or local buffer variable.
  7686. For a local buffer option the global value is unchanged.
  7687. Note that the variable name without "w:" must be used.
  7688. Examples: >vim
  7689. call settabwinvar(1, 1, "&list", 0)
  7690. call settabwinvar(3, 2, "myvar", "foobar")
  7691. < This function is not available in the |sandbox|.
  7692. Parameters: ~
  7693. • {tabnr} (`integer`)
  7694. • {winnr} (`integer`)
  7695. • {varname} (`string`)
  7696. • {val} (`any`)
  7697. Return: ~
  7698. (`any`)
  7699. settagstack({nr}, {dict} [, {action}]) *settagstack()*
  7700. Modify the tag stack of the window {nr} using {dict}.
  7701. {nr} can be the window number or the |window-ID|.
  7702. For a list of supported items in {dict}, refer to
  7703. |gettagstack()|. "curidx" takes effect before changing the tag
  7704. stack.
  7705. *E962*
  7706. How the tag stack is modified depends on the {action}
  7707. argument:
  7708. - If {action} is not present or is set to 'r', then the tag
  7709. stack is replaced.
  7710. - If {action} is set to 'a', then new entries from {dict} are
  7711. pushed (added) onto the tag stack.
  7712. - If {action} is set to 't', then all the entries from the
  7713. current entry in the tag stack or "curidx" in {dict} are
  7714. removed and then new entries are pushed to the stack.
  7715. The current index is set to one after the length of the tag
  7716. stack after the modification.
  7717. Returns zero for success, -1 for failure.
  7718. Examples (for more examples see |tagstack-examples|):
  7719. Empty the tag stack of window 3: >vim
  7720. call settagstack(3, {'items' : []})
  7721. < Save and restore the tag stack: >vim
  7722. let stack = gettagstack(1003)
  7723. " do something else
  7724. call settagstack(1003, stack)
  7725. unlet stack
  7726. <
  7727. Parameters: ~
  7728. • {nr} (`integer`)
  7729. • {dict} (`any`)
  7730. • {action} (`string?`)
  7731. Return: ~
  7732. (`any`)
  7733. setwinvar({nr}, {varname}, {val}) *setwinvar()*
  7734. Like |settabwinvar()| for the current tab page.
  7735. Examples: >vim
  7736. call setwinvar(1, "&list", 0)
  7737. call setwinvar(2, "myvar", "foobar")
  7738. Parameters: ~
  7739. • {nr} (`integer`)
  7740. • {varname} (`string`)
  7741. • {val} (`any`)
  7742. Return: ~
  7743. (`any`)
  7744. sha256({string}) *sha256()*
  7745. Returns a String with 64 hex characters, which is the SHA256
  7746. checksum of {string}.
  7747. Parameters: ~
  7748. • {string} (`string`)
  7749. Return: ~
  7750. (`any`)
  7751. shellescape({string} [, {special}]) *shellescape()*
  7752. Escape {string} for use as a shell command argument.
  7753. On Windows when 'shellslash' is not set, encloses {string} in
  7754. double-quotes and doubles all double-quotes within {string}.
  7755. Otherwise encloses {string} in single-quotes and replaces all
  7756. "'" with "'\''".
  7757. The {special} argument adds additional escaping of keywords
  7758. used in Vim commands. If it is a |non-zero-arg|:
  7759. - Special items such as "!", "%", "#" and "<cword>" (as listed
  7760. in |expand()|) will be preceded by a backslash.
  7761. The backslash will be removed again by the |:!| command.
  7762. - The <NL> character is escaped.
  7763. If 'shell' contains "csh" in the tail:
  7764. - The "!" character will be escaped. This is because csh and
  7765. tcsh use "!" for history replacement even in single-quotes.
  7766. - The <NL> character is escaped (twice if {special} is
  7767. a |non-zero-arg|).
  7768. If 'shell' contains "fish" in the tail, the "\" character will
  7769. be escaped because in fish it is used as an escape character
  7770. inside single quotes.
  7771. Example of use with a |:!| command: >vim
  7772. exe '!dir ' .. shellescape(expand('<cfile>'), 1)
  7773. < This results in a directory listing for the file under the
  7774. cursor. Example of use with |system()|: >vim
  7775. call system("chmod +w -- " .. shellescape(expand("%")))
  7776. < See also |::S|.
  7777. Parameters: ~
  7778. • {string} (`string`)
  7779. • {special} (`boolean?`)
  7780. Return: ~
  7781. (`any`)
  7782. shiftwidth([{col}]) *shiftwidth()*
  7783. Returns the effective value of 'shiftwidth'. This is the
  7784. 'shiftwidth' value unless it is zero, in which case it is the
  7785. 'tabstop' value. To be backwards compatible in indent
  7786. plugins, use this: >vim
  7787. if exists('*shiftwidth')
  7788. func s:sw()
  7789. return shiftwidth()
  7790. endfunc
  7791. else
  7792. func s:sw()
  7793. return &sw
  7794. endfunc
  7795. endif
  7796. < And then use s:sw() instead of &sw.
  7797. When there is one argument {col} this is used as column number
  7798. for which to return the 'shiftwidth' value. This matters for the
  7799. 'vartabstop' feature. If no {col} argument is given, column 1
  7800. will be assumed.
  7801. Parameters: ~
  7802. • {col} (`integer?`)
  7803. Return: ~
  7804. (`integer`)
  7805. sign_define({name} [, {dict}]) *sign_define()*
  7806. sign_define({list})
  7807. Define a new sign named {name} or modify the attributes of an
  7808. existing sign. This is similar to the |:sign-define| command.
  7809. Prefix {name} with a unique text to avoid name collisions.
  7810. There is no {group} like with placing signs.
  7811. The {name} can be a String or a Number. The optional {dict}
  7812. argument specifies the sign attributes. The following values
  7813. are supported:
  7814. icon full path to the bitmap file for the sign.
  7815. linehl highlight group used for the whole line the
  7816. sign is placed in.
  7817. priority default priority value of the sign
  7818. numhl highlight group used for the line number where
  7819. the sign is placed.
  7820. text text that is displayed when there is no icon
  7821. or the GUI is not being used.
  7822. texthl highlight group used for the text item
  7823. culhl highlight group used for the text item when
  7824. the cursor is on the same line as the sign and
  7825. 'cursorline' is enabled.
  7826. If the sign named {name} already exists, then the attributes
  7827. of the sign are updated.
  7828. The one argument {list} can be used to define a list of signs.
  7829. Each list item is a dictionary with the above items in {dict}
  7830. and a "name" item for the sign name.
  7831. Returns 0 on success and -1 on failure. When the one argument
  7832. {list} is used, then returns a List of values one for each
  7833. defined sign.
  7834. Examples: >vim
  7835. call sign_define("mySign", {
  7836. \ "text" : "=>",
  7837. \ "texthl" : "Error",
  7838. \ "linehl" : "Search"})
  7839. call sign_define([
  7840. \ {'name' : 'sign1',
  7841. \ 'text' : '=>'},
  7842. \ {'name' : 'sign2',
  7843. \ 'text' : '!!'}
  7844. \ ])
  7845. <
  7846. Parameters: ~
  7847. • {list} (`vim.fn.sign_define.dict[]`)
  7848. Return: ~
  7849. (`(0|-1)[]`)
  7850. sign_getdefined([{name}]) *sign_getdefined()*
  7851. Get a list of defined signs and their attributes.
  7852. This is similar to the |:sign-list| command.
  7853. If the {name} is not supplied, then a list of all the defined
  7854. signs is returned. Otherwise the attribute of the specified
  7855. sign is returned.
  7856. Each list item in the returned value is a dictionary with the
  7857. following entries:
  7858. icon full path to the bitmap file of the sign
  7859. linehl highlight group used for the whole line the
  7860. sign is placed in; not present if not set.
  7861. name name of the sign
  7862. priority default priority value of the sign
  7863. numhl highlight group used for the line number where
  7864. the sign is placed; not present if not set.
  7865. text text that is displayed when there is no icon
  7866. or the GUI is not being used.
  7867. texthl highlight group used for the text item; not
  7868. present if not set.
  7869. culhl highlight group used for the text item when
  7870. the cursor is on the same line as the sign and
  7871. 'cursorline' is enabled; not present if not
  7872. set.
  7873. Returns an empty List if there are no signs and when {name} is
  7874. not found.
  7875. Examples: >vim
  7876. " Get a list of all the defined signs
  7877. echo sign_getdefined()
  7878. " Get the attribute of the sign named mySign
  7879. echo sign_getdefined("mySign")
  7880. <
  7881. Parameters: ~
  7882. • {name} (`string?`)
  7883. Return: ~
  7884. (`vim.fn.sign_getdefined.ret.item[]`)
  7885. sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
  7886. Return a list of signs placed in a buffer or all the buffers.
  7887. This is similar to the |:sign-place-list| command.
  7888. If the optional buffer name {buf} is specified, then only the
  7889. list of signs placed in that buffer is returned. For the use
  7890. of {buf}, see |bufname()|. The optional {dict} can contain
  7891. the following entries:
  7892. group select only signs in this group
  7893. id select sign with this identifier
  7894. lnum select signs placed in this line. For the use
  7895. of {lnum}, see |line()|.
  7896. If {group} is "*", then signs in all the groups including the
  7897. global group are returned. If {group} is not supplied or is an
  7898. empty string, then only signs in the global group are
  7899. returned. If no arguments are supplied, then signs in the
  7900. global group placed in all the buffers are returned.
  7901. See |sign-group|.
  7902. Each list item in the returned value is a dictionary with the
  7903. following entries:
  7904. bufnr number of the buffer with the sign
  7905. signs list of signs placed in {bufnr}. Each list
  7906. item is a dictionary with the below listed
  7907. entries
  7908. The dictionary for each sign contains the following entries:
  7909. group sign group. Set to '' for the global group.
  7910. id identifier of the sign
  7911. lnum line number where the sign is placed
  7912. name name of the defined sign
  7913. priority sign priority
  7914. The returned signs in a buffer are ordered by their line
  7915. number and priority.
  7916. Returns an empty list on failure or if there are no placed
  7917. signs.
  7918. Examples: >vim
  7919. " Get a List of signs placed in eval.c in the
  7920. " global group
  7921. echo sign_getplaced("eval.c")
  7922. " Get a List of signs in group 'g1' placed in eval.c
  7923. echo sign_getplaced("eval.c", {'group' : 'g1'})
  7924. " Get a List of signs placed at line 10 in eval.c
  7925. echo sign_getplaced("eval.c", {'lnum' : 10})
  7926. " Get sign with identifier 10 placed in a.py
  7927. echo sign_getplaced("a.py", {'id' : 10})
  7928. " Get sign with id 20 in group 'g1' placed in a.py
  7929. echo sign_getplaced("a.py", {'group' : 'g1',
  7930. \ 'id' : 20})
  7931. " Get a List of all the placed signs
  7932. echo sign_getplaced()
  7933. <
  7934. Parameters: ~
  7935. • {buf} (`integer|string?`)
  7936. • {dict} (`vim.fn.sign_getplaced.dict?`)
  7937. Return: ~
  7938. (`vim.fn.sign_getplaced.ret.item[]`)
  7939. sign_jump({id}, {group}, {buf}) *sign_jump()*
  7940. Open the buffer {buf} or jump to the window that contains
  7941. {buf} and position the cursor at sign {id} in group {group}.
  7942. This is similar to the |:sign-jump| command.
  7943. If {group} is an empty string, then the global group is used.
  7944. For the use of {buf}, see |bufname()|.
  7945. Returns the line number of the sign. Returns -1 if the
  7946. arguments are invalid.
  7947. Example: >vim
  7948. " Jump to sign 10 in the current buffer
  7949. call sign_jump(10, '', '')
  7950. <
  7951. Parameters: ~
  7952. • {id} (`integer`)
  7953. • {group} (`string`)
  7954. • {buf} (`integer|string`)
  7955. Return: ~
  7956. (`integer`)
  7957. sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()*
  7958. Place the sign defined as {name} at line {lnum} in file or
  7959. buffer {buf} and assign {id} and {group} to sign. This is
  7960. similar to the |:sign-place| command.
  7961. If the sign identifier {id} is zero, then a new identifier is
  7962. allocated. Otherwise the specified number is used. {group} is
  7963. the sign group name. To use the global sign group, use an
  7964. empty string. {group} functions as a namespace for {id}, thus
  7965. two groups can use the same IDs. Refer to |sign-identifier|
  7966. and |sign-group| for more information.
  7967. {name} refers to a defined sign.
  7968. {buf} refers to a buffer name or number. For the accepted
  7969. values, see |bufname()|.
  7970. The optional {dict} argument supports the following entries:
  7971. lnum line number in the file or buffer
  7972. {buf} where the sign is to be placed.
  7973. For the accepted values, see |line()|.
  7974. priority priority of the sign. See
  7975. |sign-priority| for more information.
  7976. If the optional {dict} is not specified, then it modifies the
  7977. placed sign {id} in group {group} to use the defined sign
  7978. {name}.
  7979. Returns the sign identifier on success and -1 on failure.
  7980. Examples: >vim
  7981. " Place a sign named sign1 with id 5 at line 20 in
  7982. " buffer json.c
  7983. call sign_place(5, '', 'sign1', 'json.c',
  7984. \ {'lnum' : 20})
  7985. " Updates sign 5 in buffer json.c to use sign2
  7986. call sign_place(5, '', 'sign2', 'json.c')
  7987. " Place a sign named sign3 at line 30 in
  7988. " buffer json.c with a new identifier
  7989. let id = sign_place(0, '', 'sign3', 'json.c',
  7990. \ {'lnum' : 30})
  7991. " Place a sign named sign4 with id 10 in group 'g3'
  7992. " at line 40 in buffer json.c with priority 90
  7993. call sign_place(10, 'g3', 'sign4', 'json.c',
  7994. \ {'lnum' : 40, 'priority' : 90})
  7995. <
  7996. Parameters: ~
  7997. • {id} (`integer`)
  7998. • {group} (`string`)
  7999. • {name} (`string`)
  8000. • {buf} (`integer|string`)
  8001. • {dict} (`vim.fn.sign_place.dict?`)
  8002. Return: ~
  8003. (`integer`)
  8004. sign_placelist({list}) *sign_placelist()*
  8005. Place one or more signs. This is similar to the
  8006. |sign_place()| function. The {list} argument specifies the
  8007. List of signs to place. Each list item is a dict with the
  8008. following sign attributes:
  8009. buffer Buffer name or number. For the accepted
  8010. values, see |bufname()|.
  8011. group Sign group. {group} functions as a namespace
  8012. for {id}, thus two groups can use the same
  8013. IDs. If not specified or set to an empty
  8014. string, then the global group is used. See
  8015. |sign-group| for more information.
  8016. id Sign identifier. If not specified or zero,
  8017. then a new unique identifier is allocated.
  8018. Otherwise the specified number is used. See
  8019. |sign-identifier| for more information.
  8020. lnum Line number in the buffer where the sign is to
  8021. be placed. For the accepted values, see
  8022. |line()|.
  8023. name Name of the sign to place. See |sign_define()|
  8024. for more information.
  8025. priority Priority of the sign. When multiple signs are
  8026. placed on a line, the sign with the highest
  8027. priority is used. If not specified, the
  8028. default value of 10 is used, unless specified
  8029. otherwise by the sign definition. See
  8030. |sign-priority| for more information.
  8031. If {id} refers to an existing sign, then the existing sign is
  8032. modified to use the specified {name} and/or {priority}.
  8033. Returns a List of sign identifiers. If failed to place a
  8034. sign, the corresponding list item is set to -1.
  8035. Examples: >vim
  8036. " Place sign s1 with id 5 at line 20 and id 10 at line
  8037. " 30 in buffer a.c
  8038. let [n1, n2] = sign_placelist([
  8039. \ {'id' : 5,
  8040. \ 'name' : 's1',
  8041. \ 'buffer' : 'a.c',
  8042. \ 'lnum' : 20},
  8043. \ {'id' : 10,
  8044. \ 'name' : 's1',
  8045. \ 'buffer' : 'a.c',
  8046. \ 'lnum' : 30}
  8047. \ ])
  8048. " Place sign s1 in buffer a.c at line 40 and 50
  8049. " with auto-generated identifiers
  8050. let [n1, n2] = sign_placelist([
  8051. \ {'name' : 's1',
  8052. \ 'buffer' : 'a.c',
  8053. \ 'lnum' : 40},
  8054. \ {'name' : 's1',
  8055. \ 'buffer' : 'a.c',
  8056. \ 'lnum' : 50}
  8057. \ ])
  8058. <
  8059. Parameters: ~
  8060. • {list} (`vim.fn.sign_placelist.list.item[]`)
  8061. Return: ~
  8062. (`integer[]`)
  8063. sign_undefine([{name}]) *sign_undefine()*
  8064. sign_undefine({list})
  8065. Deletes a previously defined sign {name}. This is similar to
  8066. the |:sign-undefine| command. If {name} is not supplied, then
  8067. deletes all the defined signs.
  8068. The one argument {list} can be used to undefine a list of
  8069. signs. Each list item is the name of a sign.
  8070. Returns 0 on success and -1 on failure. For the one argument
  8071. {list} call, returns a list of values one for each undefined
  8072. sign.
  8073. Examples: >vim
  8074. " Delete a sign named mySign
  8075. call sign_undefine("mySign")
  8076. " Delete signs 'sign1' and 'sign2'
  8077. call sign_undefine(["sign1", "sign2"])
  8078. " Delete all the signs
  8079. call sign_undefine()
  8080. <
  8081. Parameters: ~
  8082. • {list} (`string[]?`)
  8083. Return: ~
  8084. (`integer[]`)
  8085. sign_unplace({group} [, {dict}]) *sign_unplace()*
  8086. Remove a previously placed sign in one or more buffers. This
  8087. is similar to the |:sign-unplace| command.
  8088. {group} is the sign group name. To use the global sign group,
  8089. use an empty string. If {group} is set to "*", then all the
  8090. groups including the global group are used.
  8091. The signs in {group} are selected based on the entries in
  8092. {dict}. The following optional entries in {dict} are
  8093. supported:
  8094. buffer buffer name or number. See |bufname()|.
  8095. id sign identifier
  8096. If {dict} is not supplied, then all the signs in {group} are
  8097. removed.
  8098. Returns 0 on success and -1 on failure.
  8099. Examples: >vim
  8100. " Remove sign 10 from buffer a.vim
  8101. call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
  8102. " Remove sign 20 in group 'g1' from buffer 3
  8103. call sign_unplace('g1', {'buffer' : 3, 'id' : 20})
  8104. " Remove all the signs in group 'g2' from buffer 10
  8105. call sign_unplace('g2', {'buffer' : 10})
  8106. " Remove sign 30 in group 'g3' from all the buffers
  8107. call sign_unplace('g3', {'id' : 30})
  8108. " Remove all the signs placed in buffer 5
  8109. call sign_unplace('*', {'buffer' : 5})
  8110. " Remove the signs in group 'g4' from all the buffers
  8111. call sign_unplace('g4')
  8112. " Remove sign 40 from all the buffers
  8113. call sign_unplace('*', {'id' : 40})
  8114. " Remove all the placed signs from all the buffers
  8115. call sign_unplace('*')
  8116. Parameters: ~
  8117. • {group} (`string`)
  8118. • {dict} (`vim.fn.sign_unplace.dict?`)
  8119. Return: ~
  8120. (`0|-1`)
  8121. sign_unplacelist({list}) *sign_unplacelist()*
  8122. Remove previously placed signs from one or more buffers. This
  8123. is similar to the |sign_unplace()| function.
  8124. The {list} argument specifies the List of signs to remove.
  8125. Each list item is a dict with the following sign attributes:
  8126. buffer buffer name or number. For the accepted
  8127. values, see |bufname()|. If not specified,
  8128. then the specified sign is removed from all
  8129. the buffers.
  8130. group sign group name. If not specified or set to an
  8131. empty string, then the global sign group is
  8132. used. If set to "*", then all the groups
  8133. including the global group are used.
  8134. id sign identifier. If not specified, then all
  8135. the signs in the specified group are removed.
  8136. Returns a List where an entry is set to 0 if the corresponding
  8137. sign was successfully removed or -1 on failure.
  8138. Example: >vim
  8139. " Remove sign with id 10 from buffer a.vim and sign
  8140. " with id 20 from buffer b.vim
  8141. call sign_unplacelist([
  8142. \ {'id' : 10, 'buffer' : "a.vim"},
  8143. \ {'id' : 20, 'buffer' : 'b.vim'},
  8144. \ ])
  8145. <
  8146. Parameters: ~
  8147. • {list} (`vim.fn.sign_unplacelist.list.item`)
  8148. Return: ~
  8149. (`(0|-1)[]`)
  8150. simplify({filename}) *simplify()*
  8151. Simplify the file name as much as possible without changing
  8152. the meaning. Shortcuts (on MS-Windows) or symbolic links (on
  8153. Unix) are not resolved. If the first path component in
  8154. {filename} designates the current directory, this will be
  8155. valid for the result as well. A trailing path separator is
  8156. not removed either. On Unix "//path" is unchanged, but
  8157. "///path" is simplified to "/path" (this follows the Posix
  8158. standard).
  8159. Example: >vim
  8160. simplify("./dir/.././/file/") == "./file/"
  8161. < Note: The combination "dir/.." is only removed if "dir" is
  8162. a searchable directory or does not exist. On Unix, it is also
  8163. removed when "dir" is a symbolic link within the same
  8164. directory. In order to resolve all the involved symbolic
  8165. links before simplifying the path name, use |resolve()|.
  8166. Parameters: ~
  8167. • {filename} (`string`)
  8168. Return: ~
  8169. (`any`)
  8170. sin({expr}) *sin()*
  8171. Return the sine of {expr}, measured in radians, as a |Float|.
  8172. {expr} must evaluate to a |Float| or a |Number|.
  8173. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8174. Examples: >vim
  8175. echo sin(100)
  8176. < -0.506366 >vim
  8177. echo sin(-4.01)
  8178. < 0.763301
  8179. Parameters: ~
  8180. • {expr} (`number`)
  8181. Return: ~
  8182. (`any`)
  8183. sinh({expr}) *sinh()*
  8184. Return the hyperbolic sine of {expr} as a |Float| in the range
  8185. [-inf, inf].
  8186. {expr} must evaluate to a |Float| or a |Number|.
  8187. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8188. Examples: >vim
  8189. echo sinh(0.5)
  8190. < 0.521095 >vim
  8191. echo sinh(-0.9)
  8192. < -1.026517
  8193. Parameters: ~
  8194. • {expr} (`number`)
  8195. Return: ~
  8196. (`any`)
  8197. slice({expr}, {start} [, {end}]) *slice()*
  8198. Similar to using a |slice| "expr[start : end]", but "end" is
  8199. used exclusive. And for a string the indexes are used as
  8200. character indexes instead of byte indexes.
  8201. Also, composing characters are treated as a part of the
  8202. preceding base character.
  8203. When {end} is omitted the slice continues to the last item.
  8204. When {end} is -1 the last item is omitted.
  8205. Returns an empty value if {start} or {end} are invalid.
  8206. Parameters: ~
  8207. • {expr} (`any`)
  8208. • {start} (`integer`)
  8209. • {end_} (`integer?`)
  8210. Return: ~
  8211. (`any`)
  8212. sockconnect({mode}, {address} [, {opts}]) *sockconnect()*
  8213. Connect a socket to an address. If {mode} is "pipe" then
  8214. {address} should be the path of a local domain socket (on
  8215. unix) or named pipe (on Windows). If {mode} is "tcp" then
  8216. {address} should be of the form "host:port" where the host
  8217. should be an ip address or host name, and port the port
  8218. number.
  8219. For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see
  8220. |luv-tcp-handle|.
  8221. Returns a |channel| ID. Close the socket with |chanclose()|.
  8222. Use |chansend()| to send data over a bytes socket, and
  8223. |rpcrequest()| and |rpcnotify()| to communicate with a RPC
  8224. socket.
  8225. {opts} is an optional dictionary with these keys:
  8226. |on_data| : callback invoked when data was read from socket
  8227. data_buffered : read socket data in |channel-buffered| mode.
  8228. rpc : If set, |msgpack-rpc| will be used to communicate
  8229. over the socket.
  8230. Returns:
  8231. - The channel ID on success (greater than zero)
  8232. - 0 on invalid arguments or connection failure.
  8233. Parameters: ~
  8234. • {mode} (`string`)
  8235. • {address} (`string`)
  8236. • {opts} (`table?`)
  8237. Return: ~
  8238. (`any`)
  8239. sort({list} [, {how} [, {dict}]]) *sort()* *E702*
  8240. Sort the items in {list} in-place. Returns {list}.
  8241. If you want a list to remain unmodified make a copy first: >vim
  8242. let sortedlist = sort(copy(mylist))
  8243. < When {how} is omitted or is a string, then sort() uses the
  8244. string representation of each item to sort on. Numbers sort
  8245. after Strings, |Lists| after Numbers. For sorting text in the
  8246. current buffer use |:sort|.
  8247. When {how} is given and it is 'i' then case is ignored.
  8248. For backwards compatibility, the value one can be used to
  8249. ignore case. Zero means to not ignore case.
  8250. When {how} is given and it is 'l' then the current collation
  8251. locale is used for ordering. Implementation details: strcoll()
  8252. is used to compare strings. See |:language| check or set the
  8253. collation locale. |v:collate| can also be used to check the
  8254. current locale. Sorting using the locale typically ignores
  8255. case. Example: >vim
  8256. " ö is sorted similarly to o with English locale.
  8257. language collate en_US.UTF8
  8258. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8259. < ['n', 'o', 'O', 'ö', 'p', 'z'] ~
  8260. >vim
  8261. " ö is sorted after z with Swedish locale.
  8262. language collate sv_SE.UTF8
  8263. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8264. < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
  8265. This does not work properly on Mac.
  8266. When {how} is given and it is 'n' then all items will be
  8267. sorted numerical (Implementation detail: this uses the
  8268. strtod() function to parse numbers, Strings, Lists, Dicts and
  8269. Funcrefs will be considered as being 0).
  8270. When {how} is given and it is 'N' then all items will be
  8271. sorted numerical. This is like 'n' but a string containing
  8272. digits will be used as the number they represent.
  8273. When {how} is given and it is 'f' then all items will be
  8274. sorted numerical. All values must be a Number or a Float.
  8275. When {how} is a |Funcref| or a function name, this function
  8276. is called to compare items. The function is invoked with two
  8277. items as argument and must return zero if they are equal, 1 or
  8278. bigger if the first one sorts after the second one, -1 or
  8279. smaller if the first one sorts before the second one.
  8280. {dict} is for functions with the "dict" attribute. It will be
  8281. used to set the local variable "self". |Dictionary-function|
  8282. The sort is stable, items which compare equal (as number or as
  8283. string) will keep their relative position. E.g., when sorting
  8284. on numbers, text strings will sort next to each other, in the
  8285. same order as they were originally.
  8286. Example: >vim
  8287. func MyCompare(i1, i2)
  8288. return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
  8289. endfunc
  8290. eval mylist->sort("MyCompare")
  8291. < A shorter compare version for this specific simple case, which
  8292. ignores overflow: >vim
  8293. func MyCompare(i1, i2)
  8294. return a:i1 - a:i2
  8295. endfunc
  8296. < For a simple expression you can use a lambda: >vim
  8297. eval mylist->sort({i1, i2 -> i1 - i2})
  8298. <
  8299. Parameters: ~
  8300. • {list} (`any`)
  8301. • {how} (`string|function?`)
  8302. • {dict} (`any?`)
  8303. Return: ~
  8304. (`any`)
  8305. soundfold({word}) *soundfold()*
  8306. Return the sound-folded equivalent of {word}. Uses the first
  8307. language in 'spelllang' for the current window that supports
  8308. soundfolding. 'spell' must be set. When no sound folding is
  8309. possible the {word} is returned unmodified.
  8310. This can be used for making spelling suggestions. Note that
  8311. the method can be quite slow.
  8312. Parameters: ~
  8313. • {word} (`string`)
  8314. Return: ~
  8315. (`any`)
  8316. spellbadword([{sentence}]) *spellbadword()*
  8317. Without argument: The result is the badly spelled word under
  8318. or after the cursor. The cursor is moved to the start of the
  8319. bad word. When no bad word is found in the cursor line the
  8320. result is an empty string and the cursor doesn't move.
  8321. With argument: The result is the first word in {sentence} that
  8322. is badly spelled. If there are no spelling mistakes the
  8323. result is an empty string.
  8324. The return value is a list with two items:
  8325. - The badly spelled word or an empty string.
  8326. - The type of the spelling error:
  8327. "bad" spelling mistake
  8328. "rare" rare word
  8329. "local" word only valid in another region
  8330. "caps" word should start with Capital
  8331. Example: >vim
  8332. echo spellbadword("the quik brown fox")
  8333. < ['quik', 'bad'] ~
  8334. The spelling information for the current window and the value
  8335. of 'spelllang' are used.
  8336. Parameters: ~
  8337. • {sentence} (`string?`)
  8338. Return: ~
  8339. (`any`)
  8340. spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()*
  8341. Return a |List| with spelling suggestions to replace {word}.
  8342. When {max} is given up to this number of suggestions are
  8343. returned. Otherwise up to 25 suggestions are returned.
  8344. When the {capital} argument is given and it's non-zero only
  8345. suggestions with a leading capital will be given. Use this
  8346. after a match with 'spellcapcheck'.
  8347. {word} can be a badly spelled word followed by other text.
  8348. This allows for joining two words that were split. The
  8349. suggestions also include the following text, thus you can
  8350. replace a line.
  8351. {word} may also be a good word. Similar words will then be
  8352. returned. {word} itself is not included in the suggestions,
  8353. although it may appear capitalized.
  8354. The spelling information for the current window is used. The
  8355. values of 'spelllang' and 'spellsuggest' are used.
  8356. Parameters: ~
  8357. • {word} (`string`)
  8358. • {max} (`integer?`)
  8359. • {capital} (`boolean?`)
  8360. Return: ~
  8361. (`any`)
  8362. split({string} [, {pattern} [, {keepempty}]]) *split()*
  8363. Make a |List| out of {string}. When {pattern} is omitted or
  8364. empty each white space separated sequence of characters
  8365. becomes an item.
  8366. Otherwise the string is split where {pattern} matches,
  8367. removing the matched characters. 'ignorecase' is not used
  8368. here, add \c to ignore case. |/\c|
  8369. When the first or last item is empty it is omitted, unless the
  8370. {keepempty} argument is given and it's non-zero.
  8371. Other empty items are kept when {pattern} matches at least one
  8372. character or when {keepempty} is non-zero.
  8373. Example: >vim
  8374. let words = split(getline('.'), '\W\+')
  8375. < To split a string in individual characters: >vim
  8376. for c in split(mystring, '\zs') | endfor
  8377. < If you want to keep the separator you can also use '\zs' at
  8378. the end of the pattern: >vim
  8379. echo split('abc:def:ghi', ':\zs')
  8380. < >
  8381. ['abc:', 'def:', 'ghi']
  8382. <
  8383. Splitting a table where the first element can be empty: >vim
  8384. let items = split(line, ':', 1)
  8385. < The opposite function is |join()|.
  8386. Parameters: ~
  8387. • {string} (`string`)
  8388. • {pattern} (`string?`)
  8389. • {keepempty} (`boolean?`)
  8390. Return: ~
  8391. (`any`)
  8392. sqrt({expr}) *sqrt()*
  8393. Return the non-negative square root of Float {expr} as a
  8394. |Float|.
  8395. {expr} must evaluate to a |Float| or a |Number|. When {expr}
  8396. is negative the result is NaN (Not a Number). Returns 0.0 if
  8397. {expr} is not a |Float| or a |Number|.
  8398. Examples: >vim
  8399. echo sqrt(100)
  8400. < 10.0 >vim
  8401. echo sqrt(-4.01)
  8402. < str2float("nan")
  8403. NaN may be different, it depends on system libraries.
  8404. Parameters: ~
  8405. • {expr} (`number`)
  8406. Return: ~
  8407. (`any`)
  8408. srand([{expr}]) *srand()*
  8409. Initialize seed used by |rand()|:
  8410. - If {expr} is not given, seed values are initialized by
  8411. reading from /dev/urandom, if possible, or using time(NULL)
  8412. a.k.a. epoch time otherwise; this only has second accuracy.
  8413. - If {expr} is given it must be a Number. It is used to
  8414. initialize the seed values. This is useful for testing or
  8415. when a predictable sequence is intended.
  8416. Examples: >vim
  8417. let seed = srand()
  8418. let seed = srand(userinput)
  8419. echo rand(seed)
  8420. <
  8421. Parameters: ~
  8422. • {expr} (`number?`)
  8423. Return: ~
  8424. (`any`)
  8425. state([{what}]) *state()*
  8426. Return a string which contains characters indicating the
  8427. current state. Mostly useful in callbacks that want to do
  8428. work that may not always be safe. Roughly this works like:
  8429. - callback uses state() to check if work is safe to do.
  8430. Yes: then do it right away.
  8431. No: add to work queue and add a |SafeState| autocommand.
  8432. - When SafeState is triggered and executes your autocommand,
  8433. check with `state()` if the work can be done now, and if yes
  8434. remove it from the queue and execute.
  8435. Remove the autocommand if the queue is now empty.
  8436. Also see |mode()|.
  8437. When {what} is given only characters in this string will be
  8438. added. E.g, this checks if the screen has scrolled: >vim
  8439. if state('s') == ''
  8440. " screen has not scrolled
  8441. <
  8442. These characters indicate the state, generally indicating that
  8443. something is busy:
  8444. m halfway a mapping, :normal command, feedkeys() or
  8445. stuffed command
  8446. o operator pending, e.g. after |d|
  8447. a Insert mode autocomplete active
  8448. x executing an autocommand
  8449. S not triggering SafeState, e.g. after |f| or a count
  8450. c callback invoked, including timer (repeats for
  8451. recursiveness up to "ccc")
  8452. s screen has scrolled for messages
  8453. Parameters: ~
  8454. • {what} (`string?`)
  8455. Return: ~
  8456. (`any`)
  8457. stdioopen({opts}) *stdioopen()*
  8458. With |--headless| this opens stdin and stdout as a |channel|.
  8459. May be called only once. See |channel-stdio|. stderr is not
  8460. handled by this function, see |v:stderr|.
  8461. Close the stdio handles with |chanclose()|. Use |chansend()|
  8462. to send data to stdout, and |rpcrequest()| and |rpcnotify()|
  8463. to communicate over RPC.
  8464. {opts} is a dictionary with these keys:
  8465. |on_stdin| : callback invoked when stdin is written to.
  8466. on_print : callback invoked when Nvim needs to print a
  8467. message, with the message (whose type is string)
  8468. as sole argument.
  8469. stdin_buffered : read stdin in |channel-buffered| mode.
  8470. rpc : If set, |msgpack-rpc| will be used to communicate
  8471. over stdio
  8472. Returns:
  8473. - |channel-id| on success (value is always 1)
  8474. - 0 on invalid arguments
  8475. Parameters: ~
  8476. • {opts} (`table`)
  8477. Return: ~
  8478. (`any`)
  8479. stdpath({what}) *stdpath()* *E6100*
  8480. Returns |standard-path| locations of various default files and
  8481. directories.
  8482. {what} Type Description ~
  8483. cache String Cache directory: arbitrary temporary
  8484. storage for plugins, etc.
  8485. config String User configuration directory. |init.vim|
  8486. is stored here.
  8487. config_dirs List Other configuration directories.
  8488. data String User data directory.
  8489. data_dirs List Other data directories.
  8490. log String Logs directory (for use by plugins too).
  8491. run String Run directory: temporary, local storage
  8492. for sockets, named pipes, etc.
  8493. state String Session state directory: storage for file
  8494. drafts, swap, undo, |shada|.
  8495. Example: >vim
  8496. echo stdpath("config")
  8497. <
  8498. Parameters: ~
  8499. • {what}
  8500. (`'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'`)
  8501. Return: ~
  8502. (`string|string[]`)
  8503. str2float({string} [, {quoted}]) *str2float()*
  8504. Convert String {string} to a Float. This mostly works the
  8505. same as when using a floating point number in an expression,
  8506. see |floating-point-format|. But it's a bit more permissive.
  8507. E.g., "1e40" is accepted, while in an expression you need to
  8508. write "1.0e40". The hexadecimal form "0x123" is also
  8509. accepted, but not others, like binary or octal.
  8510. When {quoted} is present and non-zero then embedded single
  8511. quotes before the dot are ignored, thus "1'000.0" is a
  8512. thousand.
  8513. Text after the number is silently ignored.
  8514. The decimal point is always '.', no matter what the locale is
  8515. set to. A comma ends the number: "12,345.67" is converted to
  8516. 12.0. You can strip out thousands separators with
  8517. |substitute()|: >vim
  8518. let f = str2float(substitute(text, ',', '', 'g'))
  8519. <
  8520. Returns 0.0 if the conversion fails.
  8521. Parameters: ~
  8522. • {string} (`string`)
  8523. • {quoted} (`boolean?`)
  8524. Return: ~
  8525. (`any`)
  8526. str2list({string} [, {utf8}]) *str2list()*
  8527. Return a list containing the number values which represent
  8528. each character in String {string}. Examples: >vim
  8529. echo str2list(" ") " returns [32]
  8530. echo str2list("ABC") " returns [65, 66, 67]
  8531. < |list2str()| does the opposite.
  8532. UTF-8 encoding is always used, {utf8} option has no effect,
  8533. and exists only for backwards-compatibility.
  8534. With UTF-8 composing characters are handled properly: >vim
  8535. echo str2list("á") " returns [97, 769]
  8536. Parameters: ~
  8537. • {string} (`string`)
  8538. • {utf8} (`boolean?`)
  8539. Return: ~
  8540. (`any`)
  8541. str2nr({string} [, {base}]) *str2nr()*
  8542. Convert string {string} to a number.
  8543. {base} is the conversion base, it can be 2, 8, 10 or 16.
  8544. When {quoted} is present and non-zero then embedded single
  8545. quotes are ignored, thus "1'000'000" is a million.
  8546. When {base} is omitted base 10 is used. This also means that
  8547. a leading zero doesn't cause octal conversion to be used, as
  8548. with the default String to Number conversion. Example: >vim
  8549. let nr = str2nr('0123')
  8550. <
  8551. When {base} is 16 a leading "0x" or "0X" is ignored. With a
  8552. different base the result will be zero. Similarly, when
  8553. {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
  8554. {base} is 2 a leading "0b" or "0B" is ignored.
  8555. Text after the number is silently ignored.
  8556. Returns 0 if {string} is empty or on error.
  8557. Parameters: ~
  8558. • {string} (`string`)
  8559. • {base} (`integer?`)
  8560. Return: ~
  8561. (`any`)
  8562. strcharlen({string}) *strcharlen()*
  8563. The result is a Number, which is the number of characters
  8564. in String {string}. Composing characters are ignored.
  8565. |strchars()| can count the number of characters, counting
  8566. composing characters separately.
  8567. Returns 0 if {string} is empty or on error.
  8568. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8569. Parameters: ~
  8570. • {string} (`string`)
  8571. Return: ~
  8572. (`any`)
  8573. strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
  8574. Like |strpart()| but using character index and length instead
  8575. of byte index and length.
  8576. When {skipcc} is omitted or zero, composing characters are
  8577. counted separately.
  8578. When {skipcc} set to 1, composing characters are treated as a
  8579. part of the preceding base character, similar to |slice()|.
  8580. When a character index is used where a character does not
  8581. exist it is omitted and counted as one character. For
  8582. example: >vim
  8583. echo strcharpart('abc', -1, 2)
  8584. < results in 'a'.
  8585. Returns an empty string on error.
  8586. Parameters: ~
  8587. • {src} (`string`)
  8588. • {start} (`integer`)
  8589. • {len} (`integer?`)
  8590. • {skipcc} (`boolean?`)
  8591. Return: ~
  8592. (`any`)
  8593. strchars({string} [, {skipcc}]) *strchars()*
  8594. The result is a Number, which is the number of characters
  8595. in String {string}.
  8596. When {skipcc} is omitted or zero, composing characters are
  8597. counted separately.
  8598. When {skipcc} set to 1, composing characters are ignored.
  8599. |strcharlen()| always does this.
  8600. Returns zero on error.
  8601. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8602. {skipcc} is only available after 7.4.755. For backward
  8603. compatibility, you can define a wrapper function: >vim
  8604. if has("patch-7.4.755")
  8605. function s:strchars(str, skipcc)
  8606. return strchars(a:str, a:skipcc)
  8607. endfunction
  8608. else
  8609. function s:strchars(str, skipcc)
  8610. if a:skipcc
  8611. return strlen(substitute(a:str, ".", "x", "g"))
  8612. else
  8613. return strchars(a:str)
  8614. endif
  8615. endfunction
  8616. endif
  8617. <
  8618. Parameters: ~
  8619. • {string} (`string`)
  8620. • {skipcc} (`boolean?`)
  8621. Return: ~
  8622. (`integer`)
  8623. strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
  8624. The result is a Number, which is the number of display cells
  8625. String {string} occupies on the screen when it starts at {col}
  8626. (first column is zero). When {col} is omitted zero is used.
  8627. Otherwise it is the screen column where to start. This
  8628. matters for Tab characters.
  8629. The option settings of the current window are used. This
  8630. matters for anything that's displayed differently, such as
  8631. 'tabstop' and 'display'.
  8632. When {string} contains characters with East Asian Width Class
  8633. Ambiguous, this function's return value depends on 'ambiwidth'.
  8634. Returns zero on error.
  8635. Also see |strlen()|, |strwidth()| and |strchars()|.
  8636. Parameters: ~
  8637. • {string} (`string`)
  8638. • {col} (`integer?`)
  8639. Return: ~
  8640. (`integer`)
  8641. strftime({format} [, {time}]) *strftime()*
  8642. The result is a String, which is a formatted date and time, as
  8643. specified by the {format} string. The given {time} is used,
  8644. or the current time if no time is given. The accepted
  8645. {format} depends on your system, thus this is not portable!
  8646. See the manual page of the C function strftime() for the
  8647. format. The maximum length of the result is 80 characters.
  8648. See also |localtime()|, |getftime()| and |strptime()|.
  8649. The language can be changed with the |:language| command.
  8650. Examples: >vim
  8651. echo strftime("%c") " Sun Apr 27 11:49:23 1997
  8652. echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
  8653. echo strftime("%y%m%d %T") " 970427 11:53:55
  8654. echo strftime("%H:%M") " 11:55
  8655. echo strftime("%c", getftime("file.c"))
  8656. " Show mod time of file.c.
  8657. Parameters: ~
  8658. • {format} (`string`)
  8659. • {time} (`number?`)
  8660. Return: ~
  8661. (`string`)
  8662. strgetchar({str}, {index}) *strgetchar()*
  8663. Get a Number corresponding to the character at {index} in
  8664. {str}. This uses a zero-based character index, not a byte
  8665. index. Composing characters are considered separate
  8666. characters here. Use |nr2char()| to convert the Number to a
  8667. String.
  8668. Returns -1 if {index} is invalid.
  8669. Also see |strcharpart()| and |strchars()|.
  8670. Parameters: ~
  8671. • {str} (`string`)
  8672. • {index} (`integer`)
  8673. Return: ~
  8674. (`integer`)
  8675. stridx({haystack}, {needle} [, {start}]) *stridx()*
  8676. The result is a Number, which gives the byte index in
  8677. {haystack} of the first occurrence of the String {needle}.
  8678. If {start} is specified, the search starts at index {start}.
  8679. This can be used to find a second match: >vim
  8680. let colon1 = stridx(line, ":")
  8681. let colon2 = stridx(line, ":", colon1 + 1)
  8682. < The search is done case-sensitive.
  8683. For pattern searches use |match()|.
  8684. -1 is returned if the {needle} does not occur in {haystack}.
  8685. See also |strridx()|.
  8686. Examples: >vim
  8687. echo stridx("An Example", "Example") " 3
  8688. echo stridx("Starting point", "Start") " 0
  8689. echo stridx("Starting point", "start") " -1
  8690. < *strstr()* *strchr()*
  8691. stridx() works similar to the C function strstr(). When used
  8692. with a single character it works similar to strchr().
  8693. Parameters: ~
  8694. • {haystack} (`string`)
  8695. • {needle} (`string`)
  8696. • {start} (`integer?`)
  8697. Return: ~
  8698. (`integer`)
  8699. string({expr}) *string()*
  8700. Return {expr} converted to a String. If {expr} is a Number,
  8701. Float, String, Blob or a composition of them, then the result
  8702. can be parsed back with |eval()|.
  8703. {expr} type result ~
  8704. String 'string'
  8705. Number 123
  8706. Float 123.123456 or 1.123456e8 or
  8707. `str2float('inf')`
  8708. Funcref `function('name')`
  8709. Blob 0z00112233.44556677.8899
  8710. List [item, item]
  8711. Dictionary `{key: value, key: value}`
  8712. Note that in String values the ' character is doubled.
  8713. Also see |strtrans()|.
  8714. Note 2: Output format is mostly compatible with YAML, except
  8715. for infinite and NaN floating-point values representations
  8716. which use |str2float()|. Strings are also dumped literally,
  8717. only single quote is escaped, which does not allow using YAML
  8718. for parsing back binary strings. |eval()| should always work
  8719. for strings and floats though, and this is the only official
  8720. method. Use |msgpackdump()| or |json_encode()| if you need to
  8721. share data with other applications.
  8722. Parameters: ~
  8723. • {expr} (`any`)
  8724. Return: ~
  8725. (`string`)
  8726. strlen({string}) *strlen()*
  8727. The result is a Number, which is the length of the String
  8728. {string} in bytes.
  8729. If the argument is a Number it is first converted to a String.
  8730. For other types an error is given and zero is returned.
  8731. If you want to count the number of multibyte characters use
  8732. |strchars()|.
  8733. Also see |len()|, |strdisplaywidth()| and |strwidth()|.
  8734. Parameters: ~
  8735. • {string} (`string`)
  8736. Return: ~
  8737. (`integer`)
  8738. strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
  8739. The result is a String, which is part of {src}, starting from
  8740. byte {start}, with the byte length {len}.
  8741. When {chars} is present and TRUE then {len} is the number of
  8742. characters positions (composing characters are not counted
  8743. separately, thus "1" means one base character and any
  8744. following composing characters).
  8745. To count {start} as characters instead of bytes use
  8746. |strcharpart()|.
  8747. When bytes are selected which do not exist, this doesn't
  8748. result in an error, the bytes are simply omitted.
  8749. If {len} is missing, the copy continues from {start} till the
  8750. end of the {src}. >vim
  8751. echo strpart("abcdefg", 3, 2) " returns 'de'
  8752. echo strpart("abcdefg", -2, 4) " returns 'ab'
  8753. echo strpart("abcdefg", 5, 4) " returns 'fg'
  8754. echo strpart("abcdefg", 3) " returns 'defg'
  8755. < Note: To get the first character, {start} must be 0. For
  8756. example, to get the character under the cursor: >vim
  8757. strpart(getline("."), col(".") - 1, 1, v:true)
  8758. <
  8759. Returns an empty string on error.
  8760. Parameters: ~
  8761. • {src} (`string`)
  8762. • {start} (`integer`)
  8763. • {len} (`integer?`)
  8764. • {chars} (`0|1?`)
  8765. Return: ~
  8766. (`string`)
  8767. strptime({format}, {timestring}) *strptime()*
  8768. The result is a Number, which is a unix timestamp representing
  8769. the date and time in {timestring}, which is expected to match
  8770. the format specified in {format}.
  8771. The accepted {format} depends on your system, thus this is not
  8772. portable! See the manual page of the C function strptime()
  8773. for the format. Especially avoid "%c". The value of $TZ also
  8774. matters.
  8775. If the {timestring} cannot be parsed with {format} zero is
  8776. returned. If you do not know the format of {timestring} you
  8777. can try different {format} values until you get a non-zero
  8778. result.
  8779. See also |strftime()|.
  8780. Examples: >vim
  8781. echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
  8782. < 862156163 >vim
  8783. echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
  8784. < Sun Apr 27 11:53:55 1997 >vim
  8785. echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
  8786. < Sun Apr 27 12:53:55 1997
  8787. Parameters: ~
  8788. • {format} (`string`)
  8789. • {timestring} (`string`)
  8790. Return: ~
  8791. (`integer`)
  8792. strridx({haystack}, {needle} [, {start}]) *strridx()*
  8793. The result is a Number, which gives the byte index in
  8794. {haystack} of the last occurrence of the String {needle}.
  8795. When {start} is specified, matches beyond this index are
  8796. ignored. This can be used to find a match before a previous
  8797. match: >vim
  8798. let lastcomma = strridx(line, ",")
  8799. let comma2 = strridx(line, ",", lastcomma - 1)
  8800. < The search is done case-sensitive.
  8801. For pattern searches use |match()|.
  8802. -1 is returned if the {needle} does not occur in {haystack}.
  8803. If the {needle} is empty the length of {haystack} is returned.
  8804. See also |stridx()|. Examples: >vim
  8805. echo strridx("an angry armadillo", "an") 3
  8806. < *strrchr()*
  8807. When used with a single character it works similar to the C
  8808. function strrchr().
  8809. Parameters: ~
  8810. • {haystack} (`string`)
  8811. • {needle} (`string`)
  8812. • {start} (`integer?`)
  8813. Return: ~
  8814. (`integer`)
  8815. strtrans({string}) *strtrans()*
  8816. The result is a String, which is {string} with all unprintable
  8817. characters translated into printable characters |'isprint'|.
  8818. Like they are shown in a window. Example: >vim
  8819. echo strtrans(@a)
  8820. < This displays a newline in register a as "^@" instead of
  8821. starting a new line.
  8822. Returns an empty string on error.
  8823. Parameters: ~
  8824. • {string} (`string`)
  8825. Return: ~
  8826. (`string`)
  8827. strutf16len({string} [, {countcc}]) *strutf16len()*
  8828. The result is a Number, which is the number of UTF-16 code
  8829. units in String {string} (after converting it to UTF-16).
  8830. When {countcc} is TRUE, composing characters are counted
  8831. separately.
  8832. When {countcc} is omitted or FALSE, composing characters are
  8833. ignored.
  8834. Returns zero on error.
  8835. Also see |strlen()| and |strcharlen()|.
  8836. Examples: >vim
  8837. echo strutf16len('a') " returns 1
  8838. echo strutf16len('©') " returns 1
  8839. echo strutf16len('😊') " returns 2
  8840. echo strutf16len('ą́') " returns 1
  8841. echo strutf16len('ą́', v:true) " returns 3
  8842. <
  8843. Parameters: ~
  8844. • {string} (`string`)
  8845. • {countcc} (`0|1?`)
  8846. Return: ~
  8847. (`integer`)
  8848. strwidth({string}) *strwidth()*
  8849. The result is a Number, which is the number of display cells
  8850. String {string} occupies. A Tab character is counted as one
  8851. cell, alternatively use |strdisplaywidth()|.
  8852. When {string} contains characters with East Asian Width Class
  8853. Ambiguous, this function's return value depends on 'ambiwidth'.
  8854. Returns zero on error.
  8855. Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
  8856. Parameters: ~
  8857. • {string} (`string`)
  8858. Return: ~
  8859. (`integer`)
  8860. submatch({nr} [, {list}]) *submatch()* *E935*
  8861. Only for an expression in a |:substitute| command or
  8862. substitute() function.
  8863. Returns the {nr}th submatch of the matched text. When {nr}
  8864. is 0 the whole matched text is returned.
  8865. Note that a NL in the string can stand for a line break of a
  8866. multi-line match or a NUL character in the text.
  8867. Also see |sub-replace-expression|.
  8868. If {list} is present and non-zero then submatch() returns
  8869. a list of strings, similar to |getline()| with two arguments.
  8870. NL characters in the text represent NUL characters in the
  8871. text.
  8872. Only returns more than one item for |:substitute|, inside
  8873. |substitute()| this list will always contain one or zero
  8874. items, since there are no real line breaks.
  8875. When substitute() is used recursively only the submatches in
  8876. the current (deepest) call can be obtained.
  8877. Returns an empty string or list on error.
  8878. Examples: >vim
  8879. s/\d\+/\=submatch(0) + 1/
  8880. echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
  8881. < This finds the first number in the line and adds one to it.
  8882. A line break is included as a newline character.
  8883. Parameters: ~
  8884. • {nr} (`integer`)
  8885. • {list} (`nil?`)
  8886. Return: ~
  8887. (`string`)
  8888. substitute({string}, {pat}, {sub}, {flags}) *substitute()*
  8889. The result is a String, which is a copy of {string}, in which
  8890. the first match of {pat} is replaced with {sub}.
  8891. When {flags} is "g", all matches of {pat} in {string} are
  8892. replaced. Otherwise {flags} should be "".
  8893. This works like the ":substitute" command (without any flags).
  8894. But the matching with {pat} is always done like the 'magic'
  8895. option is set and 'cpoptions' is empty (to make scripts
  8896. portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
  8897. if you want to ignore or match case and ignore 'ignorecase'.
  8898. 'smartcase' is not used. See |string-match| for how {pat} is
  8899. used.
  8900. A "~" in {sub} is not replaced with the previous {sub}.
  8901. Note that some codes in {sub} have a special meaning
  8902. |sub-replace-special|. For example, to replace something with
  8903. "\n" (two characters), use "\\\\n" or '\\n'.
  8904. When {pat} does not match in {string}, {string} is returned
  8905. unmodified.
  8906. Example: >vim
  8907. let &path = substitute(&path, ",\\=[^,]*$", "", "")
  8908. < This removes the last component of the 'path' option. >vim
  8909. echo substitute("testing", ".*", "\\U\\0", "")
  8910. < results in "TESTING".
  8911. When {sub} starts with "\=", the remainder is interpreted as
  8912. an expression. See |sub-replace-expression|. Example: >vim
  8913. echo substitute(s, '%\(\x\x\)',
  8914. \ '\=nr2char("0x" .. submatch(1))', 'g')
  8915. < When {sub} is a Funcref that function is called, with one
  8916. optional argument. Example: >vim
  8917. echo substitute(s, '%\(\x\x\)', SubNr, 'g')
  8918. < The optional argument is a list which contains the whole
  8919. matched string and up to nine submatches, like what
  8920. |submatch()| returns. Example: >vim
  8921. echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
  8922. < Returns an empty string on error.
  8923. Parameters: ~
  8924. • {string} (`string`)
  8925. • {pat} (`string`)
  8926. • {sub} (`string`)
  8927. • {flags} (`string`)
  8928. Return: ~
  8929. (`string`)
  8930. swapfilelist() *swapfilelist()*
  8931. Returns a list of swap file names, like what "vim -r" shows.
  8932. See the |-r| command argument. The 'directory' option is used
  8933. for the directories to inspect. If you only want to get a
  8934. list of swap files in the current directory then temporarily
  8935. set 'directory' to a dot: >vim
  8936. let save_dir = &directory
  8937. let &directory = '.'
  8938. let swapfiles = swapfilelist()
  8939. let &directory = save_dir
  8940. Return: ~
  8941. (`string[]`)
  8942. swapinfo({fname}) *swapinfo()*
  8943. The result is a dictionary, which holds information about the
  8944. swapfile {fname}. The available fields are:
  8945. version Vim version
  8946. user user name
  8947. host host name
  8948. fname original file name
  8949. pid PID of the Nvim process that created the swap
  8950. file, or zero if not running.
  8951. mtime last modification time in seconds
  8952. inode Optional: INODE number of the file
  8953. dirty 1 if file was modified, 0 if not
  8954. In case of failure an "error" item is added with the reason:
  8955. Cannot open file: file not found or in accessible
  8956. Cannot read file: cannot read first block
  8957. Not a swap file: does not contain correct block ID
  8958. Magic number mismatch: Info in first block is invalid
  8959. Parameters: ~
  8960. • {fname} (`string`)
  8961. Return: ~
  8962. (`any`)
  8963. swapname({buf}) *swapname()*
  8964. The result is the swap file path of the buffer {buf}.
  8965. For the use of {buf}, see |bufname()| above.
  8966. If buffer {buf} is the current buffer, the result is equal to
  8967. |:swapname| (unless there is no swap file).
  8968. If buffer {buf} has no swap file, returns an empty string.
  8969. Parameters: ~
  8970. • {buf} (`integer|string`)
  8971. Return: ~
  8972. (`string`)
  8973. synID({lnum}, {col}, {trans}) *synID()*
  8974. The result is a Number, which is the syntax ID at the position
  8975. {lnum} and {col} in the current window.
  8976. The syntax ID can be used with |synIDattr()| and
  8977. |synIDtrans()| to obtain syntax information about text.
  8978. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  8979. line. 'synmaxcol' applies, in a longer line zero is returned.
  8980. Note that when the position is after the last character,
  8981. that's where the cursor can be in Insert mode, synID() returns
  8982. zero. {lnum} is used like with |getline()|.
  8983. When {trans} is |TRUE|, transparent items are reduced to the
  8984. item that they reveal. This is useful when wanting to know
  8985. the effective color. When {trans} is |FALSE|, the transparent
  8986. item is returned. This is useful when wanting to know which
  8987. syntax item is effective (e.g. inside parens).
  8988. Warning: This function can be very slow. Best speed is
  8989. obtained by going through the file in forward direction.
  8990. Returns zero on error.
  8991. Example (echoes the name of the syntax item under the cursor): >vim
  8992. echo synIDattr(synID(line("."), col("."), 1), "name")
  8993. <
  8994. Parameters: ~
  8995. • {lnum} (`integer`)
  8996. • {col} (`integer`)
  8997. • {trans} (`0|1`)
  8998. Return: ~
  8999. (`integer`)
  9000. synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
  9001. The result is a String, which is the {what} attribute of
  9002. syntax ID {synID}. This can be used to obtain information
  9003. about a syntax item.
  9004. {mode} can be "gui" or "cterm", to get the attributes
  9005. for that mode. When {mode} is omitted, or an invalid value is
  9006. used, the attributes for the currently active highlighting are
  9007. used (GUI or cterm).
  9008. Use synIDtrans() to follow linked highlight groups.
  9009. {what} result
  9010. "name" the name of the syntax item
  9011. "fg" foreground color (GUI: color name used to set
  9012. the color, cterm: color number as a string,
  9013. term: empty string)
  9014. "bg" background color (as with "fg")
  9015. "font" font name (only available in the GUI)
  9016. |highlight-font|
  9017. "sp" special color (as with "fg") |guisp|
  9018. "fg#" like "fg", but for the GUI and the GUI is
  9019. running the name in "#RRGGBB" form
  9020. "bg#" like "fg#" for "bg"
  9021. "sp#" like "fg#" for "sp"
  9022. "bold" "1" if bold
  9023. "italic" "1" if italic
  9024. "reverse" "1" if reverse
  9025. "inverse" "1" if inverse (= reverse)
  9026. "standout" "1" if standout
  9027. "underline" "1" if underlined
  9028. "undercurl" "1" if undercurled
  9029. "underdouble" "1" if double underlined
  9030. "underdotted" "1" if dotted underlined
  9031. "underdashed" "1" if dashed underlined
  9032. "strikethrough" "1" if struckthrough
  9033. "altfont" "1" if alternative font
  9034. "nocombine" "1" if nocombine
  9035. Returns an empty string on error.
  9036. Example (echoes the color of the syntax item under the
  9037. cursor): >vim
  9038. echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  9039. <
  9040. Can also be used as a |method|: >vim
  9041. echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  9042. <
  9043. Parameters: ~
  9044. • {synID} (`integer`)
  9045. • {what} (`string`)
  9046. • {mode} (`string?`)
  9047. Return: ~
  9048. (`string`)
  9049. synIDtrans({synID}) *synIDtrans()*
  9050. The result is a Number, which is the translated syntax ID of
  9051. {synID}. This is the syntax group ID of what is being used to
  9052. highlight the character. Highlight links given with
  9053. ":highlight link" are followed.
  9054. Returns zero on error.
  9055. Parameters: ~
  9056. • {synID} (`integer`)
  9057. Return: ~
  9058. (`integer`)
  9059. synconcealed({lnum}, {col}) *synconcealed()*
  9060. The result is a |List| with currently three items:
  9061. 1. The first item in the list is 0 if the character at the
  9062. position {lnum} and {col} is not part of a concealable
  9063. region, 1 if it is. {lnum} is used like with |getline()|.
  9064. 2. The second item in the list is a string. If the first item
  9065. is 1, the second item contains the text which will be
  9066. displayed in place of the concealed text, depending on the
  9067. current setting of 'conceallevel' and 'listchars'.
  9068. 3. The third and final item in the list is a number
  9069. representing the specific syntax region matched in the
  9070. line. When the character is not concealed the value is
  9071. zero. This allows detection of the beginning of a new
  9072. concealable region if there are two consecutive regions
  9073. with the same replacement character. For an example, if
  9074. the text is "123456" and both "23" and "45" are concealed
  9075. and replaced by the character "X", then:
  9076. call returns ~
  9077. synconcealed(lnum, 1) [0, '', 0]
  9078. synconcealed(lnum, 2) [1, 'X', 1]
  9079. synconcealed(lnum, 3) [1, 'X', 1]
  9080. synconcealed(lnum, 4) [1, 'X', 2]
  9081. synconcealed(lnum, 5) [1, 'X', 2]
  9082. synconcealed(lnum, 6) [0, '', 0]
  9083. Note: Doesn't consider |matchadd()| highlighting items,
  9084. since syntax and matching highlighting are two different
  9085. mechanisms |syntax-vs-match|.
  9086. Parameters: ~
  9087. • {lnum} (`integer`)
  9088. • {col} (`integer`)
  9089. Return: ~
  9090. (`[integer, string, integer]`)
  9091. synstack({lnum}, {col}) *synstack()*
  9092. Return a |List|, which is the stack of syntax items at the
  9093. position {lnum} and {col} in the current window. {lnum} is
  9094. used like with |getline()|. Each item in the List is an ID
  9095. like what |synID()| returns.
  9096. The first item in the List is the outer region, following are
  9097. items contained in that one. The last one is what |synID()|
  9098. returns, unless not the whole item is highlighted or it is a
  9099. transparent item.
  9100. This function is useful for debugging a syntax file.
  9101. Example that shows the syntax stack under the cursor: >vim
  9102. for id in synstack(line("."), col("."))
  9103. echo synIDattr(id, "name")
  9104. endfor
  9105. < When the position specified with {lnum} and {col} is invalid
  9106. an empty list is returned. The position just after the last
  9107. character in a line and the first column in an empty line are
  9108. valid positions.
  9109. Parameters: ~
  9110. • {lnum} (`integer`)
  9111. • {col} (`integer`)
  9112. Return: ~
  9113. (`integer[]`)
  9114. system({cmd} [, {input}]) *system()* *E677*
  9115. Note: Prefer |vim.system()| in Lua.
  9116. Gets the output of {cmd} as a |string| (|systemlist()| returns
  9117. a |List|) and sets |v:shell_error| to the error code.
  9118. {cmd} is treated as in |jobstart()|:
  9119. If {cmd} is a List it runs directly (no 'shell').
  9120. If {cmd} is a String it runs in the 'shell', like this: >vim
  9121. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  9122. < Not to be used for interactive commands.
  9123. Result is a String, filtered to avoid platform-specific quirks:
  9124. - <CR><NL> is replaced with <NL>
  9125. - NUL characters are replaced with SOH (0x01)
  9126. Example: >vim
  9127. echo system(['ls', expand('%:h')])
  9128. < If {input} is a string it is written to a pipe and passed as
  9129. stdin to the command. The string is written as-is, line
  9130. separators are not changed.
  9131. If {input} is a |List| it is written to the pipe as
  9132. |writefile()| does with {binary} set to "b" (i.e. with
  9133. a newline between each list item, and newlines inside list
  9134. items converted to NULs).
  9135. When {input} is given and is a valid buffer id, the content of
  9136. the buffer is written to the file line by line, each line
  9137. terminated by NL (and NUL where the text has NL).
  9138. *E5677*
  9139. Note: system() cannot write to or read from backgrounded ("&")
  9140. shell commands, e.g.: >vim
  9141. echo system("cat - &", "foo")
  9142. < which is equivalent to: >
  9143. $ echo foo | bash -c 'cat - &'
  9144. < The pipes are disconnected (unless overridden by shell
  9145. redirection syntax) before input can reach it. Use
  9146. |jobstart()| instead.
  9147. Note: Use |shellescape()| or |::S| with |expand()| or
  9148. |fnamemodify()| to escape special characters in a command
  9149. argument. 'shellquote' and 'shellxquote' must be properly
  9150. configured. Example: >vim
  9151. echo system('ls '..shellescape(expand('%:h')))
  9152. echo system('ls '..expand('%:h:S'))
  9153. < Unlike ":!cmd" there is no automatic check for changed files.
  9154. Use |:checktime| to force a check.
  9155. Parameters: ~
  9156. • {cmd} (`string|string[]`)
  9157. • {input} (`string|string[]|integer?`)
  9158. Return: ~
  9159. (`string`)
  9160. systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
  9161. Same as |system()|, but returns a |List| with lines (parts of
  9162. output separated by NL) with NULs transformed into NLs. Output
  9163. is the same as |readfile()| will output with {binary} argument
  9164. set to "b", except that a final newline is not preserved,
  9165. unless {keepempty} is non-zero.
  9166. Note that on MS-Windows you may get trailing CR characters.
  9167. To see the difference between "echo hello" and "echo -n hello"
  9168. use |system()| and |split()|: >vim
  9169. echo split(system('echo hello'), '\n', 1)
  9170. <
  9171. Returns an empty string on error.
  9172. Parameters: ~
  9173. • {cmd} (`string|string[]`)
  9174. • {input} (`string|string[]|integer?`)
  9175. • {keepempty} (`integer?`)
  9176. Return: ~
  9177. (`string[]`)
  9178. tabpagebuflist([{arg}]) *tabpagebuflist()*
  9179. The result is a |List|, where each item is the number of the
  9180. buffer associated with each window in the current tab page.
  9181. {arg} specifies the number of the tab page to be used. When
  9182. omitted the current tab page is used.
  9183. When {arg} is invalid the number zero is returned.
  9184. To get a list of all buffers in all tabs use this: >vim
  9185. let buflist = []
  9186. for i in range(tabpagenr('$'))
  9187. call extend(buflist, tabpagebuflist(i + 1))
  9188. endfor
  9189. < Note that a buffer may appear in more than one window.
  9190. Parameters: ~
  9191. • {arg} (`integer?`)
  9192. Return: ~
  9193. (`any`)
  9194. tabpagenr([{arg}]) *tabpagenr()*
  9195. The result is a Number, which is the number of the current
  9196. tab page. The first tab page has number 1.
  9197. The optional argument {arg} supports the following values:
  9198. $ the number of the last tab page (the tab page
  9199. count).
  9200. # the number of the last accessed tab page
  9201. (where |g<Tab>| goes to). If there is no
  9202. previous tab page, 0 is returned.
  9203. The number can be used with the |:tab| command.
  9204. Returns zero on error.
  9205. Parameters: ~
  9206. • {arg} (`'$'|'#'?`)
  9207. Return: ~
  9208. (`integer`)
  9209. tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
  9210. Like |winnr()| but for tab page {tabarg}.
  9211. {tabarg} specifies the number of tab page to be used.
  9212. {arg} is used like with |winnr()|:
  9213. - When omitted the current window number is returned. This is
  9214. the window which will be used when going to this tab page.
  9215. - When "$" the number of windows is returned.
  9216. - When "#" the previous window nr is returned.
  9217. Useful examples: >vim
  9218. tabpagewinnr(1) " current window of tab page 1
  9219. tabpagewinnr(4, '$') " number of windows in tab page 4
  9220. < When {tabarg} is invalid zero is returned.
  9221. Parameters: ~
  9222. • {tabarg} (`integer`)
  9223. • {arg} (`'$'|'#'?`)
  9224. Return: ~
  9225. (`integer`)
  9226. tagfiles() *tagfiles()*
  9227. Returns a |List| with the file names used to search for tags
  9228. for the current buffer. This is the 'tags' option expanded.
  9229. Return: ~
  9230. (`string[]`)
  9231. taglist({expr} [, {filename}]) *taglist()*
  9232. Returns a |List| of tags matching the regular expression {expr}.
  9233. If {filename} is passed it is used to prioritize the results
  9234. in the same way that |:tselect| does. See |tag-priority|.
  9235. {filename} should be the full path of the file.
  9236. Each list item is a dictionary with at least the following
  9237. entries:
  9238. name Name of the tag.
  9239. filename Name of the file where the tag is
  9240. defined. It is either relative to the
  9241. current directory or a full path.
  9242. cmd Ex command used to locate the tag in
  9243. the file.
  9244. kind Type of the tag. The value for this
  9245. entry depends on the language specific
  9246. kind values. Only available when
  9247. using a tags file generated by
  9248. Universal/Exuberant ctags or hdrtag.
  9249. static A file specific tag. Refer to
  9250. |static-tag| for more information.
  9251. More entries may be present, depending on the content of the
  9252. tags file: access, implementation, inherits and signature.
  9253. Refer to the ctags documentation for information about these
  9254. fields. For C code the fields "struct", "class" and "enum"
  9255. may appear, they give the name of the entity the tag is
  9256. contained in.
  9257. The ex-command "cmd" can be either an ex search pattern, a
  9258. line number or a line number followed by a byte number.
  9259. If there are no matching tags, then an empty list is returned.
  9260. To get an exact tag match, the anchors '^' and '$' should be
  9261. used in {expr}. This also make the function work faster.
  9262. Refer to |tag-regexp| for more information about the tag
  9263. search regular expression pattern.
  9264. Refer to |'tags'| for information about how the tags file is
  9265. located by Vim. Refer to |tags-file-format| for the format of
  9266. the tags file generated by the different ctags tools.
  9267. Parameters: ~
  9268. • {expr} (`any`)
  9269. • {filename} (`string?`)
  9270. Return: ~
  9271. (`any`)
  9272. tan({expr}) *tan()*
  9273. Return the tangent of {expr}, measured in radians, as a |Float|
  9274. in the range [-inf, inf].
  9275. {expr} must evaluate to a |Float| or a |Number|.
  9276. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9277. Examples: >vim
  9278. echo tan(10)
  9279. < 0.648361 >vim
  9280. echo tan(-4.01)
  9281. < -1.181502
  9282. Parameters: ~
  9283. • {expr} (`number`)
  9284. Return: ~
  9285. (`number`)
  9286. tanh({expr}) *tanh()*
  9287. Return the hyperbolic tangent of {expr} as a |Float| in the
  9288. range [-1, 1].
  9289. {expr} must evaluate to a |Float| or a |Number|.
  9290. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9291. Examples: >vim
  9292. echo tanh(0.5)
  9293. < 0.462117 >vim
  9294. echo tanh(-1)
  9295. < -0.761594
  9296. Parameters: ~
  9297. • {expr} (`number`)
  9298. Return: ~
  9299. (`number`)
  9300. tempname() *tempname()*
  9301. Generates a (non-existent) filename located in the Nvim root
  9302. |tempdir|. Scripts can use the filename as a temporary file.
  9303. Example: >vim
  9304. let tmpfile = tempname()
  9305. exe "redir > " .. tmpfile
  9306. <
  9307. Return: ~
  9308. (`string`)
  9309. termopen({cmd} [, {opts}]) *termopen()*
  9310. Spawns {cmd} in a new pseudo-terminal session connected
  9311. to the current (unmodified) buffer. Parameters and behavior
  9312. are the same as |jobstart()| except "pty", "width", "height",
  9313. and "TERM" are ignored: "height" and "width" are taken from
  9314. the current window. Note that termopen() implies a "pty" arg
  9315. to jobstart(), and thus has the implications documented at
  9316. |jobstart()|.
  9317. Returns the same values as jobstart().
  9318. Terminal environment is initialized as in |jobstart-env|,
  9319. except $TERM is set to "xterm-256color". Full behavior is
  9320. described in |terminal|.
  9321. Parameters: ~
  9322. • {cmd} (`string|string[]`)
  9323. • {opts} (`table?`)
  9324. Return: ~
  9325. (`any`)
  9326. test_garbagecollect_now() *test_garbagecollect_now()*
  9327. Like |garbagecollect()|, but executed right away. This must
  9328. only be called directly to avoid any structure to exist
  9329. internally, and |v:testing| must have been set before calling
  9330. any function. *E1142*
  9331. Return: ~
  9332. (`any`)
  9333. timer_info([{id}]) *timer_info()*
  9334. Return a list with information about timers.
  9335. When {id} is given only information about this timer is
  9336. returned. When timer {id} does not exist an empty list is
  9337. returned.
  9338. When {id} is omitted information about all timers is returned.
  9339. For each timer the information is stored in a |Dictionary| with
  9340. these items:
  9341. "id" the timer ID
  9342. "time" time the timer was started with
  9343. "repeat" number of times the timer will still fire;
  9344. -1 means forever
  9345. "callback" the callback
  9346. Parameters: ~
  9347. • {id} (`integer?`)
  9348. Return: ~
  9349. (`any`)
  9350. timer_pause({timer}, {paused}) *timer_pause()*
  9351. Pause or unpause a timer. A paused timer does not invoke its
  9352. callback when its time expires. Unpausing a timer may cause
  9353. the callback to be invoked almost immediately if enough time
  9354. has passed.
  9355. Pausing a timer is useful to avoid the callback to be called
  9356. for a short time.
  9357. If {paused} evaluates to a non-zero Number or a non-empty
  9358. String, then the timer is paused, otherwise it is unpaused.
  9359. See |non-zero-arg|.
  9360. Parameters: ~
  9361. • {timer} (`integer`)
  9362. • {paused} (`boolean`)
  9363. Return: ~
  9364. (`any`)
  9365. timer_start({time}, {callback} [, {options}]) *timer_start()* *timer*
  9366. Create a timer and return the timer ID.
  9367. {time} is the waiting time in milliseconds. This is the
  9368. minimum time before invoking the callback. When the system is
  9369. busy or Vim is not waiting for input the time will be longer.
  9370. Zero can be used to execute the callback when Vim is back in
  9371. the main loop.
  9372. {callback} is the function to call. It can be the name of a
  9373. function or a |Funcref|. It is called with one argument, which
  9374. is the timer ID. The callback is only invoked when Vim is
  9375. waiting for input.
  9376. {options} is a dictionary. Supported entries:
  9377. "repeat" Number of times to repeat the callback.
  9378. -1 means forever. Default is 1.
  9379. If the timer causes an error three times in a
  9380. row the repeat is cancelled.
  9381. Returns -1 on error.
  9382. Example: >vim
  9383. func MyHandler(timer)
  9384. echo 'Handler called'
  9385. endfunc
  9386. let timer = timer_start(500, 'MyHandler',
  9387. \ {'repeat': 3})
  9388. < This invokes MyHandler() three times at 500 msec intervals.
  9389. Parameters: ~
  9390. • {time} (`number`)
  9391. • {callback} (`string|function`)
  9392. • {options} (`table?`)
  9393. Return: ~
  9394. (`any`)
  9395. timer_stop({timer}) *timer_stop()*
  9396. Stop a timer. The timer callback will no longer be invoked.
  9397. {timer} is an ID returned by timer_start(), thus it must be a
  9398. Number. If {timer} does not exist there is no error.
  9399. Parameters: ~
  9400. • {timer} (`integer`)
  9401. Return: ~
  9402. (`any`)
  9403. timer_stopall() *timer_stopall()*
  9404. Stop all timers. The timer callbacks will no longer be
  9405. invoked. Useful if some timers is misbehaving. If there are
  9406. no timers there is no error.
  9407. Return: ~
  9408. (`any`)
  9409. tolower({expr}) *tolower()*
  9410. The result is a copy of the String given, with all uppercase
  9411. characters turned into lowercase (just like applying |gu| to
  9412. the string). Returns an empty string on error.
  9413. Parameters: ~
  9414. • {expr} (`string`)
  9415. Return: ~
  9416. (`string`)
  9417. toupper({expr}) *toupper()*
  9418. The result is a copy of the String given, with all lowercase
  9419. characters turned into uppercase (just like applying |gU| to
  9420. the string). Returns an empty string on error.
  9421. Parameters: ~
  9422. • {expr} (`string`)
  9423. Return: ~
  9424. (`string`)
  9425. tr({src}, {fromstr}, {tostr}) *tr()*
  9426. The result is a copy of the {src} string with all characters
  9427. which appear in {fromstr} replaced by the character in that
  9428. position in the {tostr} string. Thus the first character in
  9429. {fromstr} is translated into the first character in {tostr}
  9430. and so on. Exactly like the unix "tr" command.
  9431. This code also deals with multibyte characters properly.
  9432. Returns an empty string on error.
  9433. Examples: >vim
  9434. echo tr("hello there", "ht", "HT")
  9435. < returns "Hello THere" >vim
  9436. echo tr("<blob>", "<>", "{}")
  9437. < returns "{blob}"
  9438. Parameters: ~
  9439. • {src} (`string`)
  9440. • {fromstr} (`string`)
  9441. • {tostr} (`string`)
  9442. Return: ~
  9443. (`string`)
  9444. trim({text} [, {mask} [, {dir}]]) *trim()*
  9445. Return {text} as a String where any character in {mask} is
  9446. removed from the beginning and/or end of {text}.
  9447. If {mask} is not given, or is an empty string, {mask} is all
  9448. characters up to 0x20, which includes Tab, space, NL and CR,
  9449. plus the non-breaking space character 0xa0.
  9450. The optional {dir} argument specifies where to remove the
  9451. characters:
  9452. 0 remove from the beginning and end of {text}
  9453. 1 remove only at the beginning of {text}
  9454. 2 remove only at the end of {text}
  9455. When omitted both ends are trimmed.
  9456. This function deals with multibyte characters properly.
  9457. Returns an empty string on error.
  9458. Examples: >vim
  9459. echo trim(" some text ")
  9460. < returns "some text" >vim
  9461. echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  9462. < returns "RESERVE_TAIL" >vim
  9463. echo trim("rm<Xrm<>X>rrm", "rm<>")
  9464. < returns "Xrm<>X" (characters in the middle are not removed) >vim
  9465. echo trim(" vim ", " ", 2)
  9466. < returns " vim"
  9467. Parameters: ~
  9468. • {text} (`string`)
  9469. • {mask} (`string?`)
  9470. • {dir} (`0|1|2?`)
  9471. Return: ~
  9472. (`string`)
  9473. trunc({expr}) *trunc()*
  9474. Return the largest integral value with magnitude less than or
  9475. equal to {expr} as a |Float| (truncate towards zero).
  9476. {expr} must evaluate to a |Float| or a |Number|.
  9477. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9478. Examples: >vim
  9479. echo trunc(1.456)
  9480. < 1.0 >vim
  9481. echo trunc(-5.456)
  9482. < -5.0 >vim
  9483. echo trunc(4.0)
  9484. < 4.0
  9485. Parameters: ~
  9486. • {expr} (`number`)
  9487. Return: ~
  9488. (`integer`)
  9489. type({expr}) *type()*
  9490. The result is a Number representing the type of {expr}.
  9491. Instead of using the number directly, it is better to use the
  9492. v:t_ variable that has the value:
  9493. Number: 0 |v:t_number|
  9494. String: 1 |v:t_string|
  9495. Funcref: 2 |v:t_func|
  9496. List: 3 |v:t_list|
  9497. Dictionary: 4 |v:t_dict|
  9498. Float: 5 |v:t_float|
  9499. Boolean: 6 |v:t_bool| (|v:false| and |v:true|)
  9500. Null: 7 (|v:null|)
  9501. Blob: 10 |v:t_blob|
  9502. For backward compatibility, this method can be used: >vim
  9503. if type(myvar) == type(0) | endif
  9504. if type(myvar) == type("") | endif
  9505. if type(myvar) == type(function("tr")) | endif
  9506. if type(myvar) == type([]) | endif
  9507. if type(myvar) == type({}) | endif
  9508. if type(myvar) == type(0.0) | endif
  9509. if type(myvar) == type(v:true) | endif
  9510. < In place of checking for |v:null| type it is better to check
  9511. for |v:null| directly as it is the only value of this type: >vim
  9512. if myvar is v:null | endif
  9513. < To check if the v:t_ variables exist use this: >vim
  9514. if exists('v:t_number') | endif
  9515. <
  9516. Parameters: ~
  9517. • {expr} (`any`)
  9518. Return: ~
  9519. (`integer`)
  9520. undofile({name}) *undofile()*
  9521. Return the name of the undo file that would be used for a file
  9522. with name {name} when writing. This uses the 'undodir'
  9523. option, finding directories that exist. It does not check if
  9524. the undo file exists.
  9525. {name} is always expanded to the full path, since that is what
  9526. is used internally.
  9527. If {name} is empty undofile() returns an empty string, since a
  9528. buffer without a file name will not write an undo file.
  9529. Useful in combination with |:wundo| and |:rundo|.
  9530. Parameters: ~
  9531. • {name} (`string`)
  9532. Return: ~
  9533. (`string`)
  9534. undotree([{buf}]) *undotree()*
  9535. Return the current state of the undo tree for the current
  9536. buffer, or for a specific buffer if {buf} is given. The
  9537. result is a dictionary with the following items:
  9538. "seq_last" The highest undo sequence number used.
  9539. "seq_cur" The sequence number of the current position in
  9540. the undo tree. This differs from "seq_last"
  9541. when some changes were undone.
  9542. "time_cur" Time last used for |:earlier| and related
  9543. commands. Use |strftime()| to convert to
  9544. something readable.
  9545. "save_last" Number of the last file write. Zero when no
  9546. write yet.
  9547. "save_cur" Number of the current position in the undo
  9548. tree.
  9549. "synced" Non-zero when the last undo block was synced.
  9550. This happens when waiting from input from the
  9551. user. See |undo-blocks|.
  9552. "entries" A list of dictionaries with information about
  9553. undo blocks.
  9554. The first item in the "entries" list is the oldest undo item.
  9555. Each List item is a |Dictionary| with these items:
  9556. "seq" Undo sequence number. Same as what appears in
  9557. |:undolist|.
  9558. "time" Timestamp when the change happened. Use
  9559. |strftime()| to convert to something readable.
  9560. "newhead" Only appears in the item that is the last one
  9561. that was added. This marks the last change
  9562. and where further changes will be added.
  9563. "curhead" Only appears in the item that is the last one
  9564. that was undone. This marks the current
  9565. position in the undo tree, the block that will
  9566. be used by a redo command. When nothing was
  9567. undone after the last change this item will
  9568. not appear anywhere.
  9569. "save" Only appears on the last block before a file
  9570. write. The number is the write count. The
  9571. first write has number 1, the last one the
  9572. "save_last" mentioned above.
  9573. "alt" Alternate entry. This is again a List of undo
  9574. blocks. Each item may again have an "alt"
  9575. item.
  9576. Parameters: ~
  9577. • {buf} (`integer|string?`)
  9578. Return: ~
  9579. (`vim.fn.undotree.ret`)
  9580. uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
  9581. Remove second and succeeding copies of repeated adjacent
  9582. {list} items in-place. Returns {list}. If you want a list
  9583. to remain unmodified make a copy first: >vim
  9584. let newlist = uniq(copy(mylist))
  9585. < The default compare function uses the string representation of
  9586. each item. For the use of {func} and {dict} see |sort()|.
  9587. Returns zero if {list} is not a |List|.
  9588. Parameters: ~
  9589. • {list} (`any`)
  9590. • {func} (`any?`)
  9591. • {dict} (`any?`)
  9592. Return: ~
  9593. (`any[]|0`)
  9594. utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()*
  9595. Same as |charidx()| but returns the UTF-16 code unit index of
  9596. the byte at {idx} in {string} (after converting it to UTF-16).
  9597. When {charidx} is present and TRUE, {idx} is used as the
  9598. character index in the String {string} instead of as the byte
  9599. index.
  9600. An {idx} in the middle of a UTF-8 sequence is rounded
  9601. downwards to the beginning of that sequence.
  9602. Returns -1 if the arguments are invalid or if there are less
  9603. than {idx} bytes in {string}. If there are exactly {idx} bytes
  9604. the length of the string in UTF-16 code units is returned.
  9605. See |byteidx()| and |byteidxcomp()| for getting the byte index
  9606. from the UTF-16 index and |charidx()| for getting the
  9607. character index from the UTF-16 index.
  9608. Refer to |string-offset-encoding| for more information.
  9609. Examples: >vim
  9610. echo utf16idx('a😊😊', 3) " returns 2
  9611. echo utf16idx('a😊😊', 7) " returns 4
  9612. echo utf16idx('a😊😊', 1, 0, 1) " returns 2
  9613. echo utf16idx('a😊😊', 2, 0, 1) " returns 4
  9614. echo utf16idx('aą́c', 6) " returns 2
  9615. echo utf16idx('aą́c', 6, 1) " returns 4
  9616. echo utf16idx('a😊😊', 9) " returns -1
  9617. <
  9618. Parameters: ~
  9619. • {string} (`string`)
  9620. • {idx} (`integer`)
  9621. • {countcc} (`boolean?`)
  9622. • {charidx} (`boolean?`)
  9623. Return: ~
  9624. (`integer`)
  9625. values({dict}) *values()*
  9626. Return a |List| with all the values of {dict}. The |List| is
  9627. in arbitrary order. Also see |items()| and |keys()|.
  9628. Returns zero if {dict} is not a |Dict|.
  9629. Parameters: ~
  9630. • {dict} (`any`)
  9631. Return: ~
  9632. (`any`)
  9633. virtcol({expr} [, {list} [, {winid}]]) *virtcol()*
  9634. The result is a Number, which is the screen column of the file
  9635. position given with {expr}. That is, the last screen position
  9636. occupied by the character at that position, when the screen
  9637. would be of unlimited width. When there is a <Tab> at the
  9638. position, the returned Number will be the column at the end of
  9639. the <Tab>. For example, for a <Tab> in column 1, with 'ts'
  9640. set to 8, it returns 8. |conceal| is ignored.
  9641. For the byte position use |col()|.
  9642. For the use of {expr} see |getpos()| and |col()|.
  9643. When {expr} is "$", it means the end of the cursor line, so
  9644. the result is the number of cells in the cursor line plus one.
  9645. When 'virtualedit' is used {expr} can be [lnum, col, off],
  9646. where "off" is the offset in screen columns from the start of
  9647. the character. E.g., a position within a <Tab> or after the
  9648. last character. When "off" is omitted zero is used. When
  9649. Virtual editing is active in the current mode, a position
  9650. beyond the end of the line can be returned. Also see
  9651. |'virtualedit'|
  9652. If {list} is present and non-zero then virtcol() returns a
  9653. List with the first and last screen position occupied by the
  9654. character.
  9655. With the optional {winid} argument the values are obtained for
  9656. that window instead of the current window.
  9657. Note that only marks in the current file can be used.
  9658. Examples: >vim
  9659. " With text "foo^Lbar" and cursor on the "^L":
  9660. echo virtcol(".") " returns 5
  9661. echo virtcol(".", 1) " returns [4, 5]
  9662. echo virtcol("$") " returns 9
  9663. " With text " there", with 't at 'h':
  9664. echo virtcol("'t") " returns 6
  9665. <
  9666. The first column is 1. 0 or [0, 0] is returned for an error.
  9667. A more advanced example that echoes the maximum length of
  9668. all lines: >vim
  9669. echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  9670. <
  9671. Parameters: ~
  9672. • {expr} (`string|any[]`)
  9673. • {list} (`boolean?`)
  9674. • {winid} (`integer?`)
  9675. Return: ~
  9676. (`any`)
  9677. virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
  9678. The result is a Number, which is the byte index of the
  9679. character in window {winid} at buffer line {lnum} and virtual
  9680. column {col}.
  9681. If buffer line {lnum} is an empty line, 0 is returned.
  9682. If {col} is greater than the last virtual column in line
  9683. {lnum}, then the byte index of the character at the last
  9684. virtual column is returned.
  9685. For a multi-byte character, the column number of the first
  9686. byte in the character is returned.
  9687. The {winid} argument can be the window number or the
  9688. |window-ID|. If this is zero, then the current window is used.
  9689. Returns -1 if the window {winid} doesn't exist or the buffer
  9690. line {lnum} or virtual column {col} is invalid.
  9691. See also |screenpos()|, |virtcol()| and |col()|.
  9692. Parameters: ~
  9693. • {winid} (`integer`)
  9694. • {lnum} (`integer`)
  9695. • {col} (`integer`)
  9696. Return: ~
  9697. (`any`)
  9698. visualmode([{expr}]) *visualmode()*
  9699. The result is a String, which describes the last Visual mode
  9700. used in the current buffer. Initially it returns an empty
  9701. string, but once Visual mode has been used, it returns "v",
  9702. "V", or "<CTRL-V>" (a single CTRL-V character) for
  9703. character-wise, line-wise, or block-wise Visual mode
  9704. respectively.
  9705. Example: >vim
  9706. exe "normal " .. visualmode()
  9707. < This enters the same Visual mode as before. It is also useful
  9708. in scripts if you wish to act differently depending on the
  9709. Visual mode that was used.
  9710. If Visual mode is active, use |mode()| to get the Visual mode
  9711. (e.g., in a |:vmap|).
  9712. If {expr} is supplied and it evaluates to a non-zero Number or
  9713. a non-empty String, then the Visual mode will be cleared and
  9714. the old value is returned. See |non-zero-arg|.
  9715. Parameters: ~
  9716. • {expr} (`boolean?`)
  9717. Return: ~
  9718. (`any`)
  9719. wait({timeout}, {condition} [, {interval}]) *wait()*
  9720. Waits until {condition} evaluates to |TRUE|, where {condition}
  9721. is a |Funcref| or |string| containing an expression.
  9722. {timeout} is the maximum waiting time in milliseconds, -1
  9723. means forever.
  9724. Condition is evaluated on user events, internal events, and
  9725. every {interval} milliseconds (default: 200).
  9726. Returns a status integer:
  9727. 0 if the condition was satisfied before timeout
  9728. -1 if the timeout was exceeded
  9729. -2 if the function was interrupted (by |CTRL-C|)
  9730. -3 if an error occurred
  9731. Parameters: ~
  9732. • {timeout} (`integer`)
  9733. • {condition} (`any`)
  9734. • {interval} (`number?`)
  9735. Return: ~
  9736. (`any`)
  9737. wildmenumode() *wildmenumode()*
  9738. Returns |TRUE| when the wildmenu is active and |FALSE|
  9739. otherwise. See 'wildmenu' and 'wildmode'.
  9740. This can be used in mappings to handle the 'wildcharm' option
  9741. gracefully. (Makes only sense with |mapmode-c| mappings).
  9742. For example to make <c-j> work like <down> in wildmode, use: >vim
  9743. cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  9744. <
  9745. (Note: this needs the 'wildcharm' option set appropriately).
  9746. Return: ~
  9747. (`any`)
  9748. win_execute({id}, {command} [, {silent}]) *win_execute()*
  9749. Like `execute()` but in the context of window {id}.
  9750. The window will temporarily be made the current window,
  9751. without triggering autocommands or changing directory. When
  9752. executing {command} autocommands will be triggered, this may
  9753. have unexpected side effects. Use `:noautocmd` if needed.
  9754. Example: >vim
  9755. call win_execute(winid, 'syntax enable')
  9756. < Doing the same with `setwinvar()` would not trigger
  9757. autocommands and not actually show syntax highlighting.
  9758. When window {id} does not exist then no error is given and
  9759. an empty string is returned.
  9760. Parameters: ~
  9761. • {id} (`integer`)
  9762. • {command} (`string`)
  9763. • {silent} (`boolean?`)
  9764. Return: ~
  9765. (`any`)
  9766. win_findbuf({bufnr}) *win_findbuf()*
  9767. Returns a |List| with |window-ID|s for windows that contain
  9768. buffer {bufnr}. When there is none the list is empty.
  9769. Parameters: ~
  9770. • {bufnr} (`integer`)
  9771. Return: ~
  9772. (`integer[]`)
  9773. win_getid([{win} [, {tab}]]) *win_getid()*
  9774. Get the |window-ID| for the specified window.
  9775. When {win} is missing use the current window.
  9776. With {win} this is the window number. The top window has
  9777. number 1.
  9778. Without {tab} use the current tab, otherwise the tab with
  9779. number {tab}. The first tab has number one.
  9780. Return zero if the window cannot be found.
  9781. Parameters: ~
  9782. • {win} (`integer?`)
  9783. • {tab} (`integer?`)
  9784. Return: ~
  9785. (`integer`)
  9786. win_gettype([{nr}]) *win_gettype()*
  9787. Return the type of the window:
  9788. "autocmd" autocommand window. Temporary window
  9789. used to execute autocommands.
  9790. "command" command-line window |cmdwin|
  9791. (empty) normal window
  9792. "loclist" |location-list-window|
  9793. "popup" floating window |api-floatwin|
  9794. "preview" preview window |preview-window|
  9795. "quickfix" |quickfix-window|
  9796. "unknown" window {nr} not found
  9797. When {nr} is omitted return the type of the current window.
  9798. When {nr} is given return the type of this window by number or
  9799. |window-ID|.
  9800. Also see the 'buftype' option.
  9801. Parameters: ~
  9802. • {nr} (`integer?`)
  9803. Return: ~
  9804. (`'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'`)
  9805. win_gotoid({expr}) *win_gotoid()*
  9806. Go to window with ID {expr}. This may also change the current
  9807. tabpage.
  9808. Return TRUE if successful, FALSE if the window cannot be found.
  9809. Parameters: ~
  9810. • {expr} (`integer`)
  9811. Return: ~
  9812. (`0|1`)
  9813. win_id2tabwin({expr}) *win_id2tabwin()*
  9814. Return a list with the tab number and window number of window
  9815. with ID {expr}: [tabnr, winnr].
  9816. Return [0, 0] if the window cannot be found.
  9817. Parameters: ~
  9818. • {expr} (`integer`)
  9819. Return: ~
  9820. (`any`)
  9821. win_id2win({expr}) *win_id2win()*
  9822. Return the window number of window with ID {expr}.
  9823. Return 0 if the window cannot be found in the current tabpage.
  9824. Parameters: ~
  9825. • {expr} (`integer`)
  9826. Return: ~
  9827. (`any`)
  9828. win_move_separator({nr}, {offset}) *win_move_separator()*
  9829. Move window {nr}'s vertical separator (i.e., the right border)
  9830. by {offset} columns, as if being dragged by the mouse. {nr}
  9831. can be a window number or |window-ID|. A positive {offset}
  9832. moves right and a negative {offset} moves left. Moving a
  9833. window's vertical separator will change the width of the
  9834. window and the width of other windows adjacent to the vertical
  9835. separator. The magnitude of movement may be smaller than
  9836. specified (e.g., as a consequence of maintaining
  9837. 'winminwidth'). Returns TRUE if the window can be found and
  9838. FALSE otherwise.
  9839. This will fail for the rightmost window and a full-width
  9840. window, since it has no separator on the right.
  9841. Only works for the current tab page. *E1308*
  9842. Parameters: ~
  9843. • {nr} (`integer`)
  9844. • {offset} (`integer`)
  9845. Return: ~
  9846. (`any`)
  9847. win_move_statusline({nr}, {offset}) *win_move_statusline()*
  9848. Move window {nr}'s status line (i.e., the bottom border) by
  9849. {offset} rows, as if being dragged by the mouse. {nr} can be a
  9850. window number or |window-ID|. A positive {offset} moves down
  9851. and a negative {offset} moves up. Moving a window's status
  9852. line will change the height of the window and the height of
  9853. other windows adjacent to the status line. The magnitude of
  9854. movement may be smaller than specified (e.g., as a consequence
  9855. of maintaining 'winminheight'). Returns TRUE if the window can
  9856. be found and FALSE otherwise.
  9857. Only works for the current tab page.
  9858. Parameters: ~
  9859. • {nr} (`integer`)
  9860. • {offset} (`integer`)
  9861. Return: ~
  9862. (`any`)
  9863. win_screenpos({nr}) *win_screenpos()*
  9864. Return the screen position of window {nr} as a list with two
  9865. numbers: [row, col]. The first window always has position
  9866. [1, 1], unless there is a tabline, then it is [2, 1].
  9867. {nr} can be the window number or the |window-ID|. Use zero
  9868. for the current window.
  9869. Returns [0, 0] if the window cannot be found.
  9870. Parameters: ~
  9871. • {nr} (`integer`)
  9872. Return: ~
  9873. (`any`)
  9874. win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
  9875. Temporarily switch to window {target}, then move window {nr}
  9876. to a new split adjacent to {target}.
  9877. Unlike commands such as |:split|, no new windows are created
  9878. (the |window-ID| of window {nr} is unchanged after the move).
  9879. Both {nr} and {target} can be window numbers or |window-ID|s.
  9880. Both must be in the current tab page.
  9881. Returns zero for success, non-zero for failure.
  9882. {options} is a |Dictionary| with the following optional entries:
  9883. "vertical" When TRUE, the split is created vertically,
  9884. like with |:vsplit|.
  9885. "rightbelow" When TRUE, the split is made below or to the
  9886. right (if vertical). When FALSE, it is done
  9887. above or to the left (if vertical). When not
  9888. present, the values of 'splitbelow' and
  9889. 'splitright' are used.
  9890. Parameters: ~
  9891. • {nr} (`integer`)
  9892. • {target} (`integer`)
  9893. • {options} (`table?`)
  9894. Return: ~
  9895. (`any`)
  9896. winbufnr({nr}) *winbufnr()*
  9897. The result is a Number, which is the number of the buffer
  9898. associated with window {nr}. {nr} can be the window number or
  9899. the |window-ID|.
  9900. When {nr} is zero, the number of the buffer in the current
  9901. window is returned.
  9902. When window {nr} doesn't exist, -1 is returned.
  9903. Example: >vim
  9904. echo "The file in the current window is " .. bufname(winbufnr(0))
  9905. <
  9906. Parameters: ~
  9907. • {nr} (`integer`)
  9908. Return: ~
  9909. (`integer`)
  9910. wincol() *wincol()*
  9911. The result is a Number, which is the virtual column of the
  9912. cursor in the window. This is counting screen cells from the
  9913. left side of the window. The leftmost column is one.
  9914. Return: ~
  9915. (`integer`)
  9916. windowsversion() *windowsversion()*
  9917. The result is a String. For MS-Windows it indicates the OS
  9918. version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  9919. Windows XP is "5.1". For non-MS-Windows systems the result is
  9920. an empty string.
  9921. Return: ~
  9922. (`string`)
  9923. winheight({nr}) *winheight()*
  9924. The result is a Number, which is the height of window {nr}.
  9925. {nr} can be the window number or the |window-ID|.
  9926. When {nr} is zero, the height of the current window is
  9927. returned. When window {nr} doesn't exist, -1 is returned.
  9928. An existing window always has a height of zero or more.
  9929. This excludes any window toolbar line.
  9930. Examples: >vim
  9931. echo "The current window has " .. winheight(0) .. " lines."
  9932. <
  9933. Parameters: ~
  9934. • {nr} (`integer`)
  9935. Return: ~
  9936. (`integer`)
  9937. winlayout([{tabnr}]) *winlayout()*
  9938. The result is a nested List containing the layout of windows
  9939. in a tabpage.
  9940. Without {tabnr} use the current tabpage, otherwise the tabpage
  9941. with number {tabnr}. If the tabpage {tabnr} is not found,
  9942. returns an empty list.
  9943. For a leaf window, it returns: >
  9944. ["leaf", {winid}]
  9945. <
  9946. For horizontally split windows, which form a column, it
  9947. returns: >
  9948. ["col", [{nested list of windows}]]
  9949. < For vertically split windows, which form a row, it returns: >
  9950. ["row", [{nested list of windows}]]
  9951. <
  9952. Example: >vim
  9953. " Only one window in the tab page
  9954. echo winlayout()
  9955. < >
  9956. ['leaf', 1000]
  9957. < >vim
  9958. " Two horizontally split windows
  9959. echo winlayout()
  9960. < >
  9961. ['col', [['leaf', 1000], ['leaf', 1001]]]
  9962. < >vim
  9963. " The second tab page, with three horizontally split
  9964. " windows, with two vertically split windows in the
  9965. " middle window
  9966. echo winlayout(2)
  9967. < >
  9968. ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  9969. ['leaf', 1001]]], ['leaf', 1000]]]
  9970. <
  9971. Parameters: ~
  9972. • {tabnr} (`integer?`)
  9973. Return: ~
  9974. (`any`)
  9975. winline() *winline()*
  9976. The result is a Number, which is the screen line of the cursor
  9977. in the window. This is counting screen lines from the top of
  9978. the window. The first line is one.
  9979. If the cursor was moved the view on the file will be updated
  9980. first, this may cause a scroll.
  9981. Return: ~
  9982. (`integer`)
  9983. winnr([{arg}]) *winnr()*
  9984. The result is a Number, which is the number of the current
  9985. window. The top window has number 1.
  9986. Returns zero for a popup window.
  9987. The optional argument {arg} supports the following values:
  9988. $ the number of the last window (the window
  9989. count).
  9990. # the number of the last accessed window (where
  9991. |CTRL-W_p| goes to). If there is no previous
  9992. window or it is in another tab page 0 is
  9993. returned. May refer to the current window in
  9994. some cases (e.g. when evaluating 'statusline'
  9995. expressions).
  9996. {N}j the number of the Nth window below the
  9997. current window (where |CTRL-W_j| goes to).
  9998. {N}k the number of the Nth window above the current
  9999. window (where |CTRL-W_k| goes to).
  10000. {N}h the number of the Nth window left of the
  10001. current window (where |CTRL-W_h| goes to).
  10002. {N}l the number of the Nth window right of the
  10003. current window (where |CTRL-W_l| goes to).
  10004. The number can be used with |CTRL-W_w| and ":wincmd w"
  10005. |:wincmd|.
  10006. When {arg} is invalid an error is given and zero is returned.
  10007. Also see |tabpagewinnr()| and |win_getid()|.
  10008. Examples: >vim
  10009. let window_count = winnr('$')
  10010. let prev_window = winnr('#')
  10011. let wnum = winnr('3k')
  10012. <
  10013. Parameters: ~
  10014. • {arg} (`string|integer?`)
  10015. Return: ~
  10016. (`any`)
  10017. winrestcmd() *winrestcmd()*
  10018. Returns a sequence of |:resize| commands that should restore
  10019. the current window sizes. Only works properly when no windows
  10020. are opened or closed and the current window and tab page is
  10021. unchanged.
  10022. Example: >vim
  10023. let cmd = winrestcmd()
  10024. call MessWithWindowSizes()
  10025. exe cmd
  10026. <
  10027. Return: ~
  10028. (`any`)
  10029. winrestview({dict}) *winrestview()*
  10030. Uses the |Dictionary| returned by |winsaveview()| to restore
  10031. the view of the current window.
  10032. Note: The {dict} does not have to contain all values, that are
  10033. returned by |winsaveview()|. If values are missing, those
  10034. settings won't be restored. So you can use: >vim
  10035. call winrestview({'curswant': 4})
  10036. <
  10037. This will only set the curswant value (the column the cursor
  10038. wants to move on vertical movements) of the cursor to column 5
  10039. (yes, that is 5), while all other settings will remain the
  10040. same. This is useful, if you set the cursor position manually.
  10041. If you have changed the values the result is unpredictable.
  10042. If the window size changed the result won't be the same.
  10043. Parameters: ~
  10044. • {dict} (`vim.fn.winrestview.dict`)
  10045. Return: ~
  10046. (`any`)
  10047. winsaveview() *winsaveview()*
  10048. Returns a |Dictionary| that contains information to restore
  10049. the view of the current window. Use |winrestview()| to
  10050. restore the view.
  10051. This is useful if you have a mapping that jumps around in the
  10052. buffer and you want to go back to the original view.
  10053. This does not save fold information. Use the 'foldenable'
  10054. option to temporarily switch off folding, so that folds are
  10055. not opened when moving around. This may have side effects.
  10056. The return value includes:
  10057. lnum cursor line number
  10058. col cursor column (Note: the first column
  10059. zero, as opposed to what |getcurpos()|
  10060. returns)
  10061. coladd cursor column offset for 'virtualedit'
  10062. curswant column for vertical movement (Note:
  10063. the first column is zero, as opposed
  10064. to what |getcurpos()| returns). After
  10065. |$| command it will be a very large
  10066. number equal to |v:maxcol|.
  10067. topline first line in the window
  10068. topfill filler lines, only in diff mode
  10069. leftcol first column displayed; only used when
  10070. 'wrap' is off
  10071. skipcol columns skipped
  10072. Note that no option values are saved.
  10073. Return: ~
  10074. (`vim.fn.winsaveview.ret`)
  10075. winwidth({nr}) *winwidth()*
  10076. The result is a Number, which is the width of window {nr}.
  10077. {nr} can be the window number or the |window-ID|.
  10078. When {nr} is zero, the width of the current window is
  10079. returned. When window {nr} doesn't exist, -1 is returned.
  10080. An existing window always has a width of zero or more.
  10081. Examples: >vim
  10082. echo "The current window has " .. winwidth(0) .. " columns."
  10083. if winwidth(0) <= 50
  10084. 50 wincmd |
  10085. endif
  10086. < For getting the terminal or screen size, see the 'columns'
  10087. option.
  10088. Parameters: ~
  10089. • {nr} (`integer`)
  10090. Return: ~
  10091. (`any`)
  10092. wordcount() *wordcount()*
  10093. The result is a dictionary of byte/chars/word statistics for
  10094. the current buffer. This is the same info as provided by
  10095. |g_CTRL-G|
  10096. The return value includes:
  10097. bytes Number of bytes in the buffer
  10098. chars Number of chars in the buffer
  10099. words Number of words in the buffer
  10100. cursor_bytes Number of bytes before cursor position
  10101. (not in Visual mode)
  10102. cursor_chars Number of chars before cursor position
  10103. (not in Visual mode)
  10104. cursor_words Number of words before cursor position
  10105. (not in Visual mode)
  10106. visual_bytes Number of bytes visually selected
  10107. (only in Visual mode)
  10108. visual_chars Number of chars visually selected
  10109. (only in Visual mode)
  10110. visual_words Number of words visually selected
  10111. (only in Visual mode)
  10112. Return: ~
  10113. (`any`)
  10114. writefile({object}, {fname} [, {flags}]) *writefile()*
  10115. When {object} is a |List| write it to file {fname}. Each list
  10116. item is separated with a NL. Each list item must be a String
  10117. or Number.
  10118. All NL characters are replaced with a NUL character.
  10119. Inserting CR characters needs to be done before passing {list}
  10120. to writefile().
  10121. When {object} is a |Blob| write the bytes to file {fname}
  10122. unmodified, also when binary mode is not specified.
  10123. {flags} must be a String. These characters are recognized:
  10124. 'b' Binary mode is used: There will not be a NL after the
  10125. last list item. An empty item at the end does cause the
  10126. last line in the file to end in a NL.
  10127. 'a' Append mode is used, lines are appended to the file: >vim
  10128. call writefile(["foo"], "event.log", "a")
  10129. call writefile(["bar"], "event.log", "a")
  10130. <
  10131. 'D' Delete the file when the current function ends. This
  10132. works like: >vim
  10133. defer delete({fname})
  10134. < Fails when not in a function. Also see |:defer|.
  10135. 's' fsync() is called after writing the file. This flushes
  10136. the file to disk, if possible. This takes more time but
  10137. avoids losing the file if the system crashes.
  10138. 'S' fsync() is not called, even when 'fsync' is set.
  10139. When {flags} does not contain "S" or "s" then fsync() is
  10140. called if the 'fsync' option is set.
  10141. An existing file is overwritten, if possible.
  10142. When the write fails -1 is returned, otherwise 0. There is an
  10143. error message if the file can't be created or when writing
  10144. fails.
  10145. Also see |readfile()|.
  10146. To copy a file byte for byte: >vim
  10147. let fl = readfile("foo", "b")
  10148. call writefile(fl, "foocopy", "b")
  10149. <
  10150. Parameters: ~
  10151. • {object} (`any`)
  10152. • {fname} (`string`)
  10153. • {flags} (`string?`)
  10154. Return: ~
  10155. (`any`)
  10156. xor({expr}, {expr}) *xor()*
  10157. Bitwise XOR on the two arguments. The arguments are converted
  10158. to a number. A List, Dict or Float argument causes an error.
  10159. Also see `and()` and `or()`.
  10160. Example: >vim
  10161. let bits = xor(bits, 0x80)
  10162. <
  10163. Parameters: ~
  10164. • {expr} (`number`)
  10165. • {expr1} (`number`)
  10166. Return: ~
  10167. (`any`)
  10168. ==============================================================================
  10169. 2. Matching a pattern in a String *string-match*
  10170. This is common between several functions. A regexp pattern as explained at
  10171. |pattern| is normally used to find a match in the buffer lines. When a
  10172. pattern is used to find a match in a String, almost everything works in the
  10173. same way. The difference is that a String is handled like it is one line.
  10174. When it contains a "\n" character, this is not seen as a line break for the
  10175. pattern. It can be matched with a "\n" in the pattern, or with ".". Example:
  10176. >vim
  10177. let a = "aaaa\nxxxx"
  10178. echo matchstr(a, "..\n..")
  10179. " aa
  10180. " xx
  10181. echo matchstr(a, "a.x")
  10182. " a
  10183. " x
  10184. Don't forget that "^" will only match at the first character of the String and
  10185. "$" at the last character of the string. They don't match after or before a
  10186. "\n".
  10187. vim:tw=78:ts=8:noet:ft=help:norl: