builtin.txt 441 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248
  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. leftcol first column displayed; only used when
  3594. 'wrap' is off
  3595. loclist 1 if showing a location list
  3596. quickfix 1 if quickfix or location list window
  3597. terminal 1 if a terminal window
  3598. tabnr tab page number
  3599. topline first displayed buffer line
  3600. variables a reference to the dictionary with
  3601. window-local variables
  3602. width window width
  3603. winbar 1 if the window has a toolbar, 0
  3604. otherwise
  3605. wincol leftmost screen column of the window;
  3606. "col" from |win_screenpos()|
  3607. textoff number of columns occupied by any
  3608. 'foldcolumn', 'signcolumn' and line
  3609. number in front of the text
  3610. winid |window-ID|
  3611. winnr window number
  3612. winrow topmost screen line of the window;
  3613. "row" from |win_screenpos()|
  3614. Parameters: ~
  3615. • {winid} (`integer?`)
  3616. Return: ~
  3617. (`vim.fn.getwininfo.ret.item[]`)
  3618. getwinpos([{timeout}]) *getwinpos()*
  3619. The result is a |List| with two numbers, the result of
  3620. |getwinposx()| and |getwinposy()| combined:
  3621. [x-pos, y-pos]
  3622. {timeout} can be used to specify how long to wait in msec for
  3623. a response from the terminal. When omitted 100 msec is used.
  3624. Use a longer time for a remote terminal.
  3625. When using a value less than 10 and no response is received
  3626. within that time, a previously reported position is returned,
  3627. if available. This can be used to poll for the position and
  3628. do some work in the meantime: >vim
  3629. while 1
  3630. let res = getwinpos(1)
  3631. if res[0] >= 0
  3632. break
  3633. endif
  3634. " Do some work here
  3635. endwhile
  3636. <
  3637. Parameters: ~
  3638. • {timeout} (`integer?`)
  3639. Return: ~
  3640. (`any`)
  3641. getwinposx() *getwinposx()*
  3642. The result is a Number, which is the X coordinate in pixels of
  3643. the left hand side of the GUI Vim window. The result will be
  3644. -1 if the information is not available.
  3645. The value can be used with `:winpos`.
  3646. Return: ~
  3647. (`integer`)
  3648. getwinposy() *getwinposy()*
  3649. The result is a Number, which is the Y coordinate in pixels of
  3650. the top of the GUI Vim window. The result will be -1 if the
  3651. information is not available.
  3652. The value can be used with `:winpos`.
  3653. Return: ~
  3654. (`integer`)
  3655. getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
  3656. Like |gettabwinvar()| for the current tabpage.
  3657. Examples: >vim
  3658. let list_is_on = getwinvar(2, '&list')
  3659. echo "myvar = " .. getwinvar(1, 'myvar')
  3660. Parameters: ~
  3661. • {winnr} (`integer`)
  3662. • {varname} (`string`)
  3663. • {def} (`any?`)
  3664. Return: ~
  3665. (`any`)
  3666. glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
  3667. Expand the file wildcards in {expr}. See |wildcards| for the
  3668. use of special characters.
  3669. Unless the optional {nosuf} argument is given and is |TRUE|,
  3670. the 'suffixes' and 'wildignore' options apply: Names matching
  3671. one of the patterns in 'wildignore' will be skipped and
  3672. 'suffixes' affect the ordering of matches.
  3673. 'wildignorecase' always applies.
  3674. When {list} is present and it is |TRUE| the result is a |List|
  3675. with all matching files. The advantage of using a List is,
  3676. you also get filenames containing newlines correctly.
  3677. Otherwise the result is a String and when there are several
  3678. matches, they are separated by <NL> characters.
  3679. If the expansion fails, the result is an empty String or List.
  3680. You can also use |readdir()| if you need to do complicated
  3681. things, such as limiting the number of matches.
  3682. A name for a non-existing file is not included. A symbolic
  3683. link is only included if it points to an existing file.
  3684. However, when the {alllinks} argument is present and it is
  3685. |TRUE| then all symbolic links are included.
  3686. For most systems backticks can be used to get files names from
  3687. any external command. Example: >vim
  3688. let tagfiles = glob("`find . -name tags -print`")
  3689. let &tags = substitute(tagfiles, "\n", ",", "g")
  3690. < The result of the program inside the backticks should be one
  3691. item per line. Spaces inside an item are allowed.
  3692. See |expand()| for expanding special Vim variables. See
  3693. |system()| for getting the raw output of an external command.
  3694. Parameters: ~
  3695. • {expr} (`string`)
  3696. • {nosuf} (`boolean?`)
  3697. • {list} (`boolean?`)
  3698. • {alllinks} (`boolean?`)
  3699. Return: ~
  3700. (`any`)
  3701. glob2regpat({string}) *glob2regpat()*
  3702. Convert a file pattern, as used by glob(), into a search
  3703. pattern. The result can be used to match with a string that
  3704. is a file name. E.g. >vim
  3705. if filename =~ glob2regpat('Make*.mak')
  3706. " ...
  3707. endif
  3708. < This is equivalent to: >vim
  3709. if filename =~ '^Make.*\.mak$'
  3710. " ...
  3711. endif
  3712. < When {string} is an empty string the result is "^$", match an
  3713. empty string.
  3714. Note that the result depends on the system. On MS-Windows
  3715. a backslash usually means a path separator.
  3716. Parameters: ~
  3717. • {string} (`string`)
  3718. Return: ~
  3719. (`any`)
  3720. globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()*
  3721. Perform glob() for String {expr} on all directories in {path}
  3722. and concatenate the results. Example: >vim
  3723. echo globpath(&rtp, "syntax/c.vim")
  3724. <
  3725. {path} is a comma-separated list of directory names. Each
  3726. directory name is prepended to {expr} and expanded like with
  3727. |glob()|. A path separator is inserted when needed.
  3728. To add a comma inside a directory name escape it with a
  3729. backslash. Note that on MS-Windows a directory may have a
  3730. trailing backslash, remove it if you put a comma after it.
  3731. If the expansion fails for one of the directories, there is no
  3732. error message.
  3733. Unless the optional {nosuf} argument is given and is |TRUE|,
  3734. the 'suffixes' and 'wildignore' options apply: Names matching
  3735. one of the patterns in 'wildignore' will be skipped and
  3736. 'suffixes' affect the ordering of matches.
  3737. When {list} is present and it is |TRUE| the result is a |List|
  3738. with all matching files. The advantage of using a List is, you
  3739. also get filenames containing newlines correctly. Otherwise
  3740. the result is a String and when there are several matches,
  3741. they are separated by <NL> characters. Example: >vim
  3742. echo globpath(&rtp, "syntax/c.vim", 0, 1)
  3743. <
  3744. {allinks} is used as with |glob()|.
  3745. The "**" item can be used to search in a directory tree.
  3746. For example, to find all "README.txt" files in the directories
  3747. in 'runtimepath' and below: >vim
  3748. echo globpath(&rtp, "**/README.txt")
  3749. < Upwards search and limiting the depth of "**" is not
  3750. supported, thus using 'path' will not always work properly.
  3751. Parameters: ~
  3752. • {path} (`string`)
  3753. • {expr} (`string`)
  3754. • {nosuf} (`boolean?`)
  3755. • {list} (`boolean?`)
  3756. • {allinks} (`boolean?`)
  3757. Return: ~
  3758. (`any`)
  3759. has({feature}) *has()*
  3760. Returns 1 if {feature} is supported, 0 otherwise. The
  3761. {feature} argument is a feature name like "nvim-0.2.1" or
  3762. "win32", see below. See also |exists()|.
  3763. To get the system name use |vim.uv|.os_uname() in Lua: >lua
  3764. print(vim.uv.os_uname().sysname)
  3765. < If the code has a syntax error then Vimscript may skip the
  3766. rest of the line. Put |:if| and |:endif| on separate lines to
  3767. avoid the syntax error: >vim
  3768. if has('feature')
  3769. let x = this_breaks_without_the_feature()
  3770. endif
  3771. <
  3772. Vim's compile-time feature-names (prefixed with "+") are not
  3773. recognized because Nvim is always compiled with all possible
  3774. features. |feature-compile|
  3775. Feature names can be:
  3776. 1. Nvim version. For example the "nvim-0.2.1" feature means
  3777. that Nvim is version 0.2.1 or later: >vim
  3778. if has("nvim-0.2.1")
  3779. " ...
  3780. endif
  3781. < 2. Runtime condition or other pseudo-feature. For example the
  3782. "win32" feature checks if the current system is Windows: >vim
  3783. if has("win32")
  3784. " ...
  3785. endif
  3786. < *feature-list*
  3787. List of supported pseudo-feature names:
  3788. acl |ACL| support.
  3789. bsd BSD system (not macOS, use "mac" for that).
  3790. clipboard |clipboard| provider is available.
  3791. fname_case Case in file names matters (for Darwin and MS-Windows
  3792. this is not present).
  3793. gui_running Nvim has a GUI.
  3794. iconv Can use |iconv()| for conversion.
  3795. linux Linux system.
  3796. mac MacOS system.
  3797. nvim This is Nvim.
  3798. python3 Legacy Vim |python3| interface. |has-python|
  3799. pythonx Legacy Vim |python_x| interface. |has-pythonx|
  3800. sun SunOS system.
  3801. ttyin input is a terminal (tty).
  3802. ttyout output is a terminal (tty).
  3803. unix Unix system.
  3804. *vim_starting* True during |startup|.
  3805. win32 Windows system (32 or 64 bit).
  3806. win64 Windows system (64 bit).
  3807. wsl WSL (Windows Subsystem for Linux) system.
  3808. *has-patch*
  3809. 3. Vim patch. For example the "patch123" feature means that
  3810. Vim patch 123 at the current |v:version| was included: >vim
  3811. if v:version > 602 || v:version == 602 && has("patch148")
  3812. " ...
  3813. endif
  3814. < 4. Vim version. For example the "patch-7.4.237" feature means
  3815. that Nvim is Vim-compatible to version 7.4.237 or later. >vim
  3816. if has("patch-7.4.237")
  3817. " ...
  3818. endif
  3819. <
  3820. Parameters: ~
  3821. • {feature} (`string`)
  3822. Return: ~
  3823. (`0|1`)
  3824. has_key({dict}, {key}) *has_key()*
  3825. The result is a Number, which is TRUE if |Dictionary| {dict}
  3826. has an entry with key {key}. FALSE otherwise. The {key}
  3827. argument is a string.
  3828. Parameters: ~
  3829. • {dict} (`table`)
  3830. • {key} (`string`)
  3831. Return: ~
  3832. (`0|1`)
  3833. haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()*
  3834. The result is a Number, which is 1 when the window has set a
  3835. local path via |:lcd| or when {winnr} is -1 and the tabpage
  3836. has set a local path via |:tcd|, otherwise 0.
  3837. Tabs and windows are identified by their respective numbers,
  3838. 0 means current tab or window. Missing argument implies 0.
  3839. Thus the following are equivalent: >vim
  3840. echo haslocaldir()
  3841. echo haslocaldir(0)
  3842. echo haslocaldir(0, 0)
  3843. < With {winnr} use that window in the current tabpage.
  3844. With {winnr} and {tabnr} use the window in that tabpage.
  3845. {winnr} can be the window number or the |window-ID|.
  3846. If {winnr} is -1 it is ignored, only the tab is resolved.
  3847. Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
  3848. Parameters: ~
  3849. • {winnr} (`integer?`)
  3850. • {tabnr} (`integer?`)
  3851. Return: ~
  3852. (`0|1`)
  3853. hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
  3854. The result is a Number, which is TRUE if there is a mapping
  3855. that contains {what} in somewhere in the rhs (what it is
  3856. mapped to) and this mapping exists in one of the modes
  3857. indicated by {mode}.
  3858. The arguments {what} and {mode} are strings.
  3859. When {abbr} is there and it is |TRUE| use abbreviations
  3860. instead of mappings. Don't forget to specify Insert and/or
  3861. Command-line mode.
  3862. Both the global mappings and the mappings local to the current
  3863. buffer are checked for a match.
  3864. If no matching mapping is found FALSE is returned.
  3865. The following characters are recognized in {mode}:
  3866. n Normal mode
  3867. v Visual and Select mode
  3868. x Visual mode
  3869. s Select mode
  3870. o Operator-pending mode
  3871. i Insert mode
  3872. l Language-Argument ("r", "f", "t", etc.)
  3873. c Command-line mode
  3874. When {mode} is omitted, "nvo" is used.
  3875. This function is useful to check if a mapping already exists
  3876. to a function in a Vim script. Example: >vim
  3877. if !hasmapto('\ABCdoit')
  3878. map <Leader>d \ABCdoit
  3879. endif
  3880. < This installs the mapping to "\ABCdoit" only if there isn't
  3881. already a mapping to "\ABCdoit".
  3882. Parameters: ~
  3883. • {what} (`any`)
  3884. • {mode} (`string?`)
  3885. • {abbr} (`boolean?`)
  3886. Return: ~
  3887. (`0|1`)
  3888. histadd({history}, {item}) *histadd()*
  3889. Add the String {item} to the history {history} which can be
  3890. one of: *hist-names*
  3891. "cmd" or ":" command line history
  3892. "search" or "/" search pattern history
  3893. "expr" or "=" typed expression history
  3894. "input" or "@" input line history
  3895. "debug" or ">" debug command history
  3896. empty the current or last used history
  3897. The {history} string does not need to be the whole name, one
  3898. character is sufficient.
  3899. If {item} does already exist in the history, it will be
  3900. shifted to become the newest entry.
  3901. The result is a Number: TRUE if the operation was successful,
  3902. otherwise FALSE is returned.
  3903. Example: >vim
  3904. call histadd("input", strftime("%Y %b %d"))
  3905. let date=input("Enter date: ")
  3906. < This function is not available in the |sandbox|.
  3907. Parameters: ~
  3908. • {history} (`string`)
  3909. • {item} (`any`)
  3910. Return: ~
  3911. (`0|1`)
  3912. histdel({history} [, {item}]) *histdel()*
  3913. Clear {history}, i.e. delete all its entries. See |hist-names|
  3914. for the possible values of {history}.
  3915. If the parameter {item} evaluates to a String, it is used as a
  3916. regular expression. All entries matching that expression will
  3917. be removed from the history (if there are any).
  3918. Upper/lowercase must match, unless "\c" is used |/\c|.
  3919. If {item} evaluates to a Number, it will be interpreted as
  3920. an index, see |:history-indexing|. The respective entry will
  3921. be removed if it exists.
  3922. The result is TRUE for a successful operation, otherwise FALSE
  3923. is returned.
  3924. Examples:
  3925. Clear expression register history: >vim
  3926. call histdel("expr")
  3927. <
  3928. Remove all entries starting with "*" from the search history: >vim
  3929. call histdel("/", '^\*')
  3930. <
  3931. The following three are equivalent: >vim
  3932. call histdel("search", histnr("search"))
  3933. call histdel("search", -1)
  3934. call histdel("search", '^' .. histget("search", -1) .. '$')
  3935. <
  3936. To delete the last search pattern and use the last-but-one for
  3937. the "n" command and 'hlsearch': >vim
  3938. call histdel("search", -1)
  3939. let @/ = histget("search", -1)
  3940. <
  3941. Parameters: ~
  3942. • {history} (`string`)
  3943. • {item} (`any?`)
  3944. Return: ~
  3945. (`0|1`)
  3946. histget({history} [, {index}]) *histget()*
  3947. The result is a String, the entry with Number {index} from
  3948. {history}. See |hist-names| for the possible values of
  3949. {history}, and |:history-indexing| for {index}. If there is
  3950. no such entry, an empty String is returned. When {index} is
  3951. omitted, the most recent item from the history is used.
  3952. Examples:
  3953. Redo the second last search from history. >vim
  3954. execute '/' .. histget("search", -2)
  3955. < Define an Ex command ":H {num}" that supports re-execution of
  3956. the {num}th entry from the output of |:history|. >vim
  3957. command -nargs=1 H execute histget("cmd", 0+<args>)
  3958. <
  3959. Parameters: ~
  3960. • {history} (`string`)
  3961. • {index} (`integer|string?`)
  3962. Return: ~
  3963. (`string`)
  3964. histnr({history}) *histnr()*
  3965. The result is the Number of the current entry in {history}.
  3966. See |hist-names| for the possible values of {history}.
  3967. If an error occurred, -1 is returned.
  3968. Example: >vim
  3969. let inp_index = histnr("expr")
  3970. <
  3971. Parameters: ~
  3972. • {history} (`string`)
  3973. Return: ~
  3974. (`integer`)
  3975. hlID({name}) *hlID()*
  3976. The result is a Number, which is the ID of the highlight group
  3977. with name {name}. When the highlight group doesn't exist,
  3978. zero is returned.
  3979. This can be used to retrieve information about the highlight
  3980. group. For example, to get the background color of the
  3981. "Comment" group: >vim
  3982. echo synIDattr(synIDtrans(hlID("Comment")), "bg")
  3983. <
  3984. Parameters: ~
  3985. • {name} (`string`)
  3986. Return: ~
  3987. (`integer`)
  3988. hlexists({name}) *hlexists()*
  3989. The result is a Number, which is TRUE if a highlight group
  3990. called {name} exists. This is when the group has been
  3991. defined in some way. Not necessarily when highlighting has
  3992. been defined for it, it may also have been used for a syntax
  3993. item.
  3994. Parameters: ~
  3995. • {name} (`string`)
  3996. Return: ~
  3997. (`0|1`)
  3998. hostname() *hostname()*
  3999. The result is a String, which is the name of the machine on
  4000. which Vim is currently running. Machine names greater than
  4001. 256 characters long are truncated.
  4002. Return: ~
  4003. (`string`)
  4004. iconv({string}, {from}, {to}) *iconv()*
  4005. The result is a String, which is the text {string} converted
  4006. from encoding {from} to encoding {to}.
  4007. When the conversion completely fails an empty string is
  4008. returned. When some characters could not be converted they
  4009. are replaced with "?".
  4010. The encoding names are whatever the iconv() library function
  4011. can accept, see ":!man 3 iconv".
  4012. Note that Vim uses UTF-8 for all Unicode encodings, conversion
  4013. from/to UCS-2 is automatically changed to use UTF-8. You
  4014. cannot use UCS-2 in a string anyway, because of the NUL bytes.
  4015. Parameters: ~
  4016. • {string} (`string`)
  4017. • {from} (`string`)
  4018. • {to} (`string`)
  4019. Return: ~
  4020. (`any`)
  4021. id({expr}) *id()*
  4022. Returns a |String| which is a unique identifier of the
  4023. container type (|List|, |Dict|, |Blob| and |Partial|). It is
  4024. guaranteed that for the mentioned types `id(v1) ==# id(v2)`
  4025. returns true iff `type(v1) == type(v2) && v1 is v2`.
  4026. Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
  4027. `v:_null_blob` have the same `id()` with different types
  4028. because they are internally represented as NULL pointers.
  4029. `id()` returns a hexadecimal representation of the pointers to
  4030. the containers (i.e. like `0x994a40`), same as `printf("%p",
  4031. {expr})`, but it is advised against counting on the exact
  4032. format of the return value.
  4033. It is not guaranteed that `id(no_longer_existing_container)`
  4034. will not be equal to some other `id()`: new containers may
  4035. reuse identifiers of the garbage-collected ones.
  4036. Parameters: ~
  4037. • {expr} (`any`)
  4038. Return: ~
  4039. (`any`)
  4040. indent({lnum}) *indent()*
  4041. The result is a Number, which is indent of line {lnum} in the
  4042. current buffer. The indent is counted in spaces, the value
  4043. of 'tabstop' is relevant. {lnum} is used just like in
  4044. |getline()|.
  4045. When {lnum} is invalid -1 is returned.
  4046. Parameters: ~
  4047. • {lnum} (`integer|string`)
  4048. Return: ~
  4049. (`integer`)
  4050. index({object}, {expr} [, {start} [, {ic}]]) *index()*
  4051. Find {expr} in {object} and return its index. See
  4052. |indexof()| for using a lambda to select the item.
  4053. If {object} is a |List| return the lowest index where the item
  4054. has a value equal to {expr}. There is no automatic
  4055. conversion, so the String "4" is different from the Number 4.
  4056. And the Number 4 is different from the Float 4.0. The value
  4057. of 'ignorecase' is not used here, case matters as indicated by
  4058. the {ic} argument.
  4059. If {object} is a |Blob| return the lowest index where the byte
  4060. value is equal to {expr}.
  4061. If {start} is given then start looking at the item with index
  4062. {start} (may be negative for an item relative to the end).
  4063. When {ic} is given and it is |TRUE|, ignore case. Otherwise
  4064. case must match.
  4065. -1 is returned when {expr} is not found in {object}.
  4066. Example: >vim
  4067. let idx = index(words, "the")
  4068. if index(numbers, 123) >= 0
  4069. " ...
  4070. endif
  4071. <
  4072. Parameters: ~
  4073. • {object} (`any`)
  4074. • {expr} (`any`)
  4075. • {start} (`integer?`)
  4076. • {ic} (`boolean?`)
  4077. Return: ~
  4078. (`any`)
  4079. indexof({object}, {expr} [, {opts}]) *indexof()*
  4080. Returns the index of an item in {object} where {expr} is
  4081. v:true. {object} must be a |List| or a |Blob|.
  4082. If {object} is a |List|, evaluate {expr} for each item in the
  4083. List until the expression is v:true and return the index of
  4084. this item.
  4085. If {object} is a |Blob| evaluate {expr} for each byte in the
  4086. Blob until the expression is v:true and return the index of
  4087. this byte.
  4088. {expr} must be a |string| or |Funcref|.
  4089. If {expr} is a |string|: If {object} is a |List|, inside
  4090. {expr} |v:key| has the index of the current List item and
  4091. |v:val| has the value of the item. If {object} is a |Blob|,
  4092. inside {expr} |v:key| has the index of the current byte and
  4093. |v:val| has the byte value.
  4094. If {expr} is a |Funcref| it must take two arguments:
  4095. 1. the key or the index of the current item.
  4096. 2. the value of the current item.
  4097. The function must return |TRUE| if the item is found and the
  4098. search should stop.
  4099. The optional argument {opts} is a Dict and supports the
  4100. following items:
  4101. startidx start evaluating {expr} at the item with this
  4102. index; may be negative for an item relative to
  4103. the end
  4104. Returns -1 when {expr} evaluates to v:false for all the items.
  4105. Example: >vim
  4106. let l = [#{n: 10}, #{n: 20}, #{n: 30}]
  4107. echo indexof(l, "v:val.n == 20")
  4108. echo indexof(l, {i, v -> v.n == 30})
  4109. echo indexof(l, "v:val.n == 20", #{startidx: 1})
  4110. <
  4111. Parameters: ~
  4112. • {object} (`any`)
  4113. • {expr} (`any`)
  4114. • {opts} (`table?`)
  4115. Return: ~
  4116. (`any`)
  4117. input({prompt} [, {text} [, {completion}]]) *input()*
  4118. Parameters: ~
  4119. • {prompt} (`string`)
  4120. • {text} (`string?`)
  4121. • {completion} (`string?`)
  4122. Return: ~
  4123. (`any`)
  4124. input({opts})
  4125. The result is a String, which is whatever the user typed on
  4126. the command-line. The {prompt} argument is either a prompt
  4127. string, or a blank string (for no prompt). A '\n' can be used
  4128. in the prompt to start a new line.
  4129. In the second form it accepts a single dictionary with the
  4130. following keys, any of which may be omitted:
  4131. Key Default Description ~
  4132. prompt "" Same as {prompt} in the first form.
  4133. default "" Same as {text} in the first form.
  4134. completion nothing Same as {completion} in the first form.
  4135. cancelreturn "" The value returned when the dialog is
  4136. cancelled.
  4137. highlight nothing Highlight handler: |Funcref|.
  4138. The highlighting set with |:echohl| is used for the prompt.
  4139. The input is entered just like a command-line, with the same
  4140. editing commands and mappings. There is a separate history
  4141. for lines typed for input().
  4142. Example: >vim
  4143. if input("Coffee or beer? ") == "beer"
  4144. echo "Cheers!"
  4145. endif
  4146. <
  4147. If the optional {text} argument is present and not empty, this
  4148. is used for the default reply, as if the user typed this.
  4149. Example: >vim
  4150. let color = input("Color? ", "white")
  4151. < The optional {completion} argument specifies the type of
  4152. completion supported for the input. Without it completion is
  4153. not performed. The supported completion types are the same as
  4154. that can be supplied to a user-defined command using the
  4155. "-complete=" argument. Refer to |:command-completion| for
  4156. more information. Example: >vim
  4157. let fname = input("File: ", "", "file")
  4158. < *input()-highlight* *E5400* *E5402*
  4159. The optional `highlight` key allows specifying function which
  4160. will be used for highlighting user input. This function
  4161. receives user input as its only argument and must return
  4162. a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
  4163. where
  4164. hl_start_col is the first highlighted column,
  4165. hl_end_col is the last highlighted column (+ 1!),
  4166. hl_group is |:hi| group used for highlighting.
  4167. *E5403* *E5404* *E5405* *E5406*
  4168. Both hl_start_col and hl_end_col + 1 must point to the start
  4169. of the multibyte character (highlighting must not break
  4170. multibyte characters), hl_end_col + 1 may be equal to the
  4171. input length. Start column must be in range [0, len(input)),
  4172. end column must be in range (hl_start_col, len(input)],
  4173. sections must be ordered so that next hl_start_col is greater
  4174. then or equal to previous hl_end_col.
  4175. Example (try some input with parentheses): >vim
  4176. highlight RBP1 guibg=Red ctermbg=red
  4177. highlight RBP2 guibg=Yellow ctermbg=yellow
  4178. highlight RBP3 guibg=Green ctermbg=green
  4179. highlight RBP4 guibg=Blue ctermbg=blue
  4180. let g:rainbow_levels = 4
  4181. function! RainbowParens(cmdline)
  4182. let ret = []
  4183. let i = 0
  4184. let lvl = 0
  4185. while i < len(a:cmdline)
  4186. if a:cmdline[i] is# '('
  4187. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4188. let lvl += 1
  4189. elseif a:cmdline[i] is# ')'
  4190. let lvl -= 1
  4191. call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
  4192. endif
  4193. let i += 1
  4194. endwhile
  4195. return ret
  4196. endfunction
  4197. call input({'prompt':'>','highlight':'RainbowParens'})
  4198. <
  4199. Highlight function is called at least once for each new
  4200. displayed input string, before command-line is redrawn. It is
  4201. expected that function is pure for the duration of one input()
  4202. call, i.e. it produces the same output for the same input, so
  4203. output may be memoized. Function is run like under |:silent|
  4204. modifier. If the function causes any errors, it will be
  4205. skipped for the duration of the current input() call.
  4206. Highlighting is disabled if command-line contains arabic
  4207. characters.
  4208. NOTE: This function must not be used in a startup file, for
  4209. the versions that only run in GUI mode (e.g., the Win32 GUI).
  4210. Note: When input() is called from within a mapping it will
  4211. consume remaining characters from that mapping, because a
  4212. mapping is handled like the characters were typed.
  4213. Use |inputsave()| before input() and |inputrestore()|
  4214. after input() to avoid that. Another solution is to avoid
  4215. that further characters follow in the mapping, e.g., by using
  4216. |:execute| or |:normal|.
  4217. Example with a mapping: >vim
  4218. nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
  4219. function GetFoo()
  4220. call inputsave()
  4221. let g:Foo = input("enter search pattern: ")
  4222. call inputrestore()
  4223. endfunction
  4224. <
  4225. Parameters: ~
  4226. • {opts} (`table`)
  4227. Return: ~
  4228. (`any`)
  4229. inputlist({textlist}) *inputlist()*
  4230. {textlist} must be a |List| of strings. This |List| is
  4231. displayed, one string per line. The user will be prompted to
  4232. enter a number, which is returned.
  4233. The user can also select an item by clicking on it with the
  4234. mouse, if the mouse is enabled in the command line ('mouse' is
  4235. "a" or includes "c"). For the first string 0 is returned.
  4236. When clicking above the first item a negative number is
  4237. returned. When clicking on the prompt one more than the
  4238. length of {textlist} is returned.
  4239. Make sure {textlist} has less than 'lines' entries, otherwise
  4240. it won't work. It's a good idea to put the entry number at
  4241. the start of the string. And put a prompt in the first item.
  4242. Example: >vim
  4243. let color = inputlist(['Select color:', '1. red',
  4244. \ '2. green', '3. blue'])
  4245. Parameters: ~
  4246. • {textlist} (`string[]`)
  4247. Return: ~
  4248. (`any`)
  4249. inputrestore() *inputrestore()*
  4250. Restore typeahead that was saved with a previous |inputsave()|.
  4251. Should be called the same number of times inputsave() is
  4252. called. Calling it more often is harmless though.
  4253. Returns TRUE when there is nothing to restore, FALSE otherwise.
  4254. Return: ~
  4255. (`any`)
  4256. inputsave() *inputsave()*
  4257. Preserve typeahead (also from mappings) and clear it, so that
  4258. a following prompt gets input from the user. Should be
  4259. followed by a matching inputrestore() after the prompt. Can
  4260. be used several times, in which case there must be just as
  4261. many inputrestore() calls.
  4262. Returns TRUE when out of memory, FALSE otherwise.
  4263. Return: ~
  4264. (`any`)
  4265. inputsecret({prompt} [, {text}]) *inputsecret()*
  4266. This function acts much like the |input()| function with but
  4267. two exceptions:
  4268. a) the user's response will be displayed as a sequence of
  4269. asterisks ("*") thereby keeping the entry secret, and
  4270. b) the user's response will not be recorded on the input
  4271. |history| stack.
  4272. The result is a String, which is whatever the user actually
  4273. typed on the command-line in response to the issued prompt.
  4274. NOTE: Command-line completion is not supported.
  4275. Parameters: ~
  4276. • {prompt} (`string`)
  4277. • {text} (`string?`)
  4278. Return: ~
  4279. (`any`)
  4280. insert({object}, {item} [, {idx}]) *insert()*
  4281. When {object} is a |List| or a |Blob| insert {item} at the start
  4282. of it.
  4283. If {idx} is specified insert {item} before the item with index
  4284. {idx}. If {idx} is zero it goes before the first item, just
  4285. like omitting {idx}. A negative {idx} is also possible, see
  4286. |list-index|. -1 inserts just before the last item.
  4287. Returns the resulting |List| or |Blob|. Examples: >vim
  4288. let mylist = insert([2, 3, 5], 1)
  4289. call insert(mylist, 4, -1)
  4290. call insert(mylist, 6, len(mylist))
  4291. < The last example can be done simpler with |add()|.
  4292. Note that when {item} is a |List| it is inserted as a single
  4293. item. Use |extend()| to concatenate |Lists|.
  4294. Parameters: ~
  4295. • {object} (`any`)
  4296. • {item} (`any`)
  4297. • {idx} (`integer?`)
  4298. Return: ~
  4299. (`any`)
  4300. interrupt() *interrupt()*
  4301. Interrupt script execution. It works more or less like the
  4302. user typing CTRL-C, most commands won't execute and control
  4303. returns to the user. This is useful to abort execution
  4304. from lower down, e.g. in an autocommand. Example: >vim
  4305. function s:check_typoname(file)
  4306. if fnamemodify(a:file, ':t') == '['
  4307. echomsg 'Maybe typo'
  4308. call interrupt()
  4309. endif
  4310. endfunction
  4311. au BufWritePre * call s:check_typoname(expand('<amatch>'))
  4312. <
  4313. Return: ~
  4314. (`any`)
  4315. invert({expr}) *invert()*
  4316. Bitwise invert. The argument is converted to a number. A
  4317. List, Dict or Float argument causes an error. Example: >vim
  4318. let bits = invert(bits)
  4319. <
  4320. Parameters: ~
  4321. • {expr} (`number`)
  4322. Return: ~
  4323. (`any`)
  4324. isabsolutepath({path}) *isabsolutepath()*
  4325. The result is a Number, which is |TRUE| when {path} is an
  4326. absolute path.
  4327. On Unix, a path is considered absolute when it starts with '/'.
  4328. On MS-Windows, it is considered absolute when it starts with an
  4329. optional drive prefix and is followed by a '\' or '/'. UNC paths
  4330. are always absolute.
  4331. Example: >vim
  4332. echo isabsolutepath('/usr/share/') " 1
  4333. echo isabsolutepath('./foobar') " 0
  4334. echo isabsolutepath('C:\Windows') " 1
  4335. echo isabsolutepath('foobar') " 0
  4336. echo isabsolutepath('\\remote\file') " 1
  4337. <
  4338. Parameters: ~
  4339. • {path} (`string`)
  4340. Return: ~
  4341. (`0|1`)
  4342. isdirectory({directory}) *isdirectory()*
  4343. The result is a Number, which is |TRUE| when a directory
  4344. with the name {directory} exists. If {directory} doesn't
  4345. exist, or isn't a directory, the result is |FALSE|. {directory}
  4346. is any expression, which is used as a String.
  4347. Parameters: ~
  4348. • {directory} (`string`)
  4349. Return: ~
  4350. (`0|1`)
  4351. isinf({expr}) *isinf()*
  4352. Return 1 if {expr} is a positive infinity, or -1 a negative
  4353. infinity, otherwise 0. >vim
  4354. echo isinf(1.0 / 0.0)
  4355. < 1 >vim
  4356. echo isinf(-1.0 / 0.0)
  4357. < -1
  4358. Parameters: ~
  4359. • {expr} (`number`)
  4360. Return: ~
  4361. (`1|0|-1`)
  4362. islocked({expr}) *islocked()* *E786*
  4363. The result is a Number, which is |TRUE| when {expr} is the
  4364. name of a locked variable.
  4365. The string argument {expr} must be the name of a variable,
  4366. |List| item or |Dictionary| entry, not the variable itself!
  4367. Example: >vim
  4368. let alist = [0, ['a', 'b'], 2, 3]
  4369. lockvar 1 alist
  4370. echo islocked('alist') " 1
  4371. echo islocked('alist[1]') " 0
  4372. < When {expr} is a variable that does not exist you get an error
  4373. message. Use |exists()| to check for existence.
  4374. Parameters: ~
  4375. • {expr} (`any`)
  4376. Return: ~
  4377. (`0|1`)
  4378. isnan({expr}) *isnan()*
  4379. Return |TRUE| if {expr} is a float with value NaN. >vim
  4380. echo isnan(0.0 / 0.0)
  4381. < 1
  4382. Parameters: ~
  4383. • {expr} (`number`)
  4384. Return: ~
  4385. (`0|1`)
  4386. items({dict}) *items()*
  4387. Return a |List| with all the key-value pairs of {dict}. Each
  4388. |List| item is a list with two items: the key of a {dict}
  4389. entry and the value of this entry. The |List| is in arbitrary
  4390. order. Also see |keys()| and |values()|.
  4391. Example: >vim
  4392. for [key, value] in items(mydict)
  4393. echo key .. ': ' .. value
  4394. endfor
  4395. <
  4396. A List or a String argument is also supported. In these
  4397. cases, items() returns a List with the index and the value at
  4398. the index.
  4399. Parameters: ~
  4400. • {dict} (`any`)
  4401. Return: ~
  4402. (`any`)
  4403. jobpid({job}) *jobpid()*
  4404. Return the PID (process id) of |job-id| {job}.
  4405. Parameters: ~
  4406. • {job} (`integer`)
  4407. Return: ~
  4408. (`integer`)
  4409. jobresize({job}, {width}, {height}) *jobresize()*
  4410. Resize the pseudo terminal window of |job-id| {job} to {width}
  4411. columns and {height} rows.
  4412. Fails if the job was not started with `"pty":v:true`.
  4413. Parameters: ~
  4414. • {job} (`integer`)
  4415. • {width} (`integer`)
  4416. • {height} (`integer`)
  4417. Return: ~
  4418. (`any`)
  4419. jobstart({cmd} [, {opts}]) *jobstart()*
  4420. Note: Prefer |vim.system()| in Lua (unless using the `pty` option).
  4421. Spawns {cmd} as a job.
  4422. If {cmd} is a List it runs directly (no 'shell').
  4423. If {cmd} is a String it runs in the 'shell', like this: >vim
  4424. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  4425. < (See |shell-unquoting| for details.)
  4426. Example: >vim
  4427. call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}})
  4428. <
  4429. Returns |job-id| on success, 0 on invalid arguments (or job
  4430. table is full), -1 if {cmd}[0] or 'shell' is not executable.
  4431. The returned job-id is a valid |channel-id| representing the
  4432. job's stdio streams. Use |chansend()| (or |rpcnotify()| and
  4433. |rpcrequest()| if "rpc" was enabled) to send data to stdin and
  4434. |chanclose()| to close the streams without stopping the job.
  4435. See |job-control| and |RPC|.
  4436. NOTE: on Windows if {cmd} is a List:
  4437. - cmd[0] must be an executable (not a "built-in"). If it is
  4438. in $PATH it can be called by name, without an extension: >vim
  4439. call jobstart(['ping', 'neovim.io'])
  4440. < If it is a full or partial path, extension is required: >vim
  4441. call jobstart(['System32\ping.exe', 'neovim.io'])
  4442. < - {cmd} is collapsed to a string of quoted args as expected
  4443. by CommandLineToArgvW https://msdn.microsoft.com/bb776391
  4444. unless cmd[0] is some form of "cmd.exe".
  4445. *jobstart-env*
  4446. The job environment is initialized as follows:
  4447. $NVIM is set to |v:servername| of the parent Nvim
  4448. $NVIM_LISTEN_ADDRESS is unset
  4449. $NVIM_LOG_FILE is unset
  4450. $VIM is unset
  4451. $VIMRUNTIME is unset
  4452. You can set these with the `env` option.
  4453. *jobstart-options*
  4454. {opts} is a dictionary with these keys:
  4455. clear_env: (boolean) `env` defines the job environment
  4456. exactly, instead of merging current environment.
  4457. cwd: (string, default=|current-directory|) Working
  4458. directory of the job.
  4459. detach: (boolean) Detach the job process: it will not be
  4460. killed when Nvim exits. If the process exits
  4461. before Nvim, `on_exit` will be invoked.
  4462. env: (dict) Map of environment variable name:value
  4463. pairs extending (or replace with "clear_env")
  4464. the current environment. |jobstart-env|
  4465. height: (number) Height of the `pty` terminal.
  4466. |on_exit|: (function) Callback invoked when the job exits.
  4467. |on_stdout|: (function) Callback invoked when the job emits
  4468. stdout data.
  4469. |on_stderr|: (function) Callback invoked when the job emits
  4470. stderr data.
  4471. overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
  4472. stdio passed to the child process. Only on
  4473. MS-Windows; ignored on other platforms.
  4474. pty: (boolean) Connect the job to a new pseudo
  4475. terminal, and its streams to the master file
  4476. descriptor. `on_stdout` receives all output,
  4477. `on_stderr` is ignored. |terminal-start|
  4478. rpc: (boolean) Use |msgpack-rpc| to communicate with
  4479. the job over stdio. Then `on_stdout` is ignored,
  4480. but `on_stderr` can still be used.
  4481. stderr_buffered: (boolean) Collect data until EOF (stream closed)
  4482. before invoking `on_stderr`. |channel-buffered|
  4483. stdout_buffered: (boolean) Collect data until EOF (stream
  4484. closed) before invoking `on_stdout`. |channel-buffered|
  4485. stdin: (string) Either "pipe" (default) to connect the
  4486. job's stdin to a channel or "null" to disconnect
  4487. stdin.
  4488. width: (number) Width of the `pty` terminal.
  4489. {opts} is passed as |self| dictionary to the callback; the
  4490. caller may set other keys to pass application-specific data.
  4491. Returns:
  4492. - |channel-id| on success
  4493. - 0 on invalid arguments
  4494. - -1 if {cmd}[0] is not executable.
  4495. See also |job-control|, |channel|, |msgpack-rpc|.
  4496. Parameters: ~
  4497. • {cmd} (`string|string[]`)
  4498. • {opts} (`table?`)
  4499. Return: ~
  4500. (`any`)
  4501. jobstop({id}) *jobstop()*
  4502. Stop |job-id| {id} by sending SIGTERM to the job process. If
  4503. the process does not terminate after a timeout then SIGKILL
  4504. will be sent. When the job terminates its |on_exit| handler
  4505. (if any) will be invoked.
  4506. See |job-control|.
  4507. Returns 1 for valid job id, 0 for invalid id, including jobs have
  4508. exited or stopped.
  4509. Parameters: ~
  4510. • {id} (`integer`)
  4511. Return: ~
  4512. (`any`)
  4513. jobwait({jobs} [, {timeout}]) *jobwait()*
  4514. Waits for jobs and their |on_exit| handlers to complete.
  4515. {jobs} is a List of |job-id|s to wait for.
  4516. {timeout} is the maximum waiting time in milliseconds. If
  4517. omitted or -1, wait forever.
  4518. Timeout of 0 can be used to check the status of a job: >vim
  4519. let running = jobwait([{job-id}], 0)[0] == -1
  4520. <
  4521. During jobwait() callbacks for jobs not in the {jobs} list may
  4522. be invoked. The screen will not redraw unless |:redraw| is
  4523. invoked by a callback.
  4524. Returns a list of len({jobs}) integers, where each integer is
  4525. the status of the corresponding job:
  4526. Exit-code, if the job exited
  4527. -1 if the timeout was exceeded
  4528. -2 if the job was interrupted (by |CTRL-C|)
  4529. -3 if the job-id is invalid
  4530. Parameters: ~
  4531. • {jobs} (`integer[]`)
  4532. • {timeout} (`integer?`)
  4533. Return: ~
  4534. (`integer[]`)
  4535. join({list} [, {sep}]) *join()*
  4536. Join the items in {list} together into one String.
  4537. When {sep} is specified it is put in between the items. If
  4538. {sep} is omitted a single space is used.
  4539. Note that {sep} is not added at the end. You might want to
  4540. add it there too: >vim
  4541. let lines = join(mylist, "\n") .. "\n"
  4542. < String items are used as-is. |Lists| and |Dictionaries| are
  4543. converted into a string like with |string()|.
  4544. The opposite function is |split()|.
  4545. Parameters: ~
  4546. • {list} (`any[]`)
  4547. • {sep} (`string?`)
  4548. Return: ~
  4549. (`any`)
  4550. json_decode({expr}) *json_decode()*
  4551. Convert {expr} from JSON object. Accepts |readfile()|-style
  4552. list as the input, as well as regular string. May output any
  4553. Vim value. In the following cases it will output
  4554. |msgpack-special-dict|:
  4555. 1. Dictionary contains duplicate key.
  4556. 2. String contains NUL byte. Two special dictionaries: for
  4557. dictionary and for string will be emitted in case string
  4558. with NUL byte was a dictionary key.
  4559. Note: function treats its input as UTF-8 always. The JSON
  4560. standard allows only a few encodings, of which UTF-8 is
  4561. recommended and the only one required to be supported.
  4562. Non-UTF-8 characters are an error.
  4563. Parameters: ~
  4564. • {expr} (`any`)
  4565. Return: ~
  4566. (`any`)
  4567. json_encode({expr}) *json_encode()*
  4568. Convert {expr} into a JSON string. Accepts
  4569. |msgpack-special-dict| as the input. Will not convert
  4570. |Funcref|s, mappings with non-string keys (can be created as
  4571. |msgpack-special-dict|), values with self-referencing
  4572. containers, strings which contain non-UTF-8 characters,
  4573. pseudo-UTF-8 strings which contain codepoints reserved for
  4574. surrogate pairs (such strings are not valid UTF-8 strings).
  4575. Non-printable characters are converted into "\u1234" escapes
  4576. or special escapes like "\t", other are dumped as-is.
  4577. |Blob|s are converted to arrays of the individual bytes.
  4578. Parameters: ~
  4579. • {expr} (`any`)
  4580. Return: ~
  4581. (`any`)
  4582. keys({dict}) *keys()*
  4583. Return a |List| with all the keys of {dict}. The |List| is in
  4584. arbitrary order. Also see |items()| and |values()|.
  4585. Parameters: ~
  4586. • {dict} (`table`)
  4587. Return: ~
  4588. (`any`)
  4589. keytrans({string}) *keytrans()*
  4590. Turn the internal byte representation of keys into a form that
  4591. can be used for |:map|. E.g. >vim
  4592. let xx = "\<C-Home>"
  4593. echo keytrans(xx)
  4594. < <C-Home>
  4595. Parameters: ~
  4596. • {string} (`string`)
  4597. Return: ~
  4598. (`any`)
  4599. len({expr}) *len()* *E701*
  4600. The result is a Number, which is the length of the argument.
  4601. When {expr} is a String or a Number the length in bytes is
  4602. used, as with |strlen()|.
  4603. When {expr} is a |List| the number of items in the |List| is
  4604. returned.
  4605. When {expr} is a |Blob| the number of bytes is returned.
  4606. When {expr} is a |Dictionary| the number of entries in the
  4607. |Dictionary| is returned.
  4608. Otherwise an error is given and returns zero.
  4609. Parameters: ~
  4610. • {expr} (`any`)
  4611. Return: ~
  4612. (`any`)
  4613. libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E368*
  4614. Call function {funcname} in the run-time library {libname}
  4615. with single argument {argument}.
  4616. This is useful to call functions in a library that you
  4617. especially made to be used with Vim. Since only one argument
  4618. is possible, calling standard library functions is rather
  4619. limited.
  4620. The result is the String returned by the function. If the
  4621. function returns NULL, this will appear as an empty string ""
  4622. to Vim.
  4623. If the function returns a number, use libcallnr()!
  4624. If {argument} is a number, it is passed to the function as an
  4625. int; if {argument} is a string, it is passed as a
  4626. null-terminated string.
  4627. libcall() allows you to write your own 'plug-in' extensions to
  4628. Vim without having to recompile the program. It is NOT a
  4629. means to call system functions! If you try to do so Vim will
  4630. very probably crash.
  4631. For Win32, the functions you write must be placed in a DLL
  4632. and use the normal C calling convention (NOT Pascal which is
  4633. used in Windows System DLLs). The function must take exactly
  4634. one parameter, either a character pointer or a long integer,
  4635. and must return a character pointer or NULL. The character
  4636. pointer returned must point to memory that will remain valid
  4637. after the function has returned (e.g. in static data in the
  4638. DLL). If it points to allocated memory, that memory will
  4639. leak away. Using a static buffer in the function should work,
  4640. it's then freed when the DLL is unloaded.
  4641. WARNING: If the function returns a non-valid pointer, Vim may
  4642. crash! This also happens if the function returns a number,
  4643. because Vim thinks it's a pointer.
  4644. For Win32 systems, {libname} should be the filename of the DLL
  4645. without the ".DLL" suffix. A full path is only required if
  4646. the DLL is not in the usual places.
  4647. For Unix: When compiling your own plugins, remember that the
  4648. object code must be compiled as position-independent ('PIC').
  4649. Examples: >vim
  4650. echo libcall("libc.so", "getenv", "HOME")
  4651. Parameters: ~
  4652. • {libname} (`string`)
  4653. • {funcname} (`string`)
  4654. • {argument} (`any`)
  4655. Return: ~
  4656. (`any`)
  4657. libcallnr({libname}, {funcname}, {argument}) *libcallnr()*
  4658. Just like |libcall()|, but used for a function that returns an
  4659. int instead of a string.
  4660. Examples: >vim
  4661. echo libcallnr("/usr/lib/libc.so", "getpid", "")
  4662. call libcallnr("libc.so", "printf", "Hello World!\n")
  4663. call libcallnr("libc.so", "sleep", 10)
  4664. <
  4665. Parameters: ~
  4666. • {libname} (`string`)
  4667. • {funcname} (`string`)
  4668. • {argument} (`any`)
  4669. Return: ~
  4670. (`any`)
  4671. line({expr} [, {winid}]) *line()*
  4672. See |getpos()| for accepted positions.
  4673. To get the column number use |col()|. To get both use
  4674. |getpos()|.
  4675. With the optional {winid} argument the values are obtained for
  4676. that window instead of the current window.
  4677. Returns 0 for invalid values of {expr} and {winid}.
  4678. Examples: >vim
  4679. echo line(".") " line number of the cursor
  4680. echo line(".", winid) " idem, in window "winid"
  4681. echo line("'t") " line number of mark t
  4682. echo line("'" .. marker) " line number of mark marker
  4683. <
  4684. To jump to the last known position when opening a file see
  4685. |last-position-jump|.
  4686. Parameters: ~
  4687. • {expr} (`string|integer[]`)
  4688. • {winid} (`integer?`)
  4689. Return: ~
  4690. (`integer`)
  4691. line2byte({lnum}) *line2byte()*
  4692. Return the byte count from the start of the buffer for line
  4693. {lnum}. This includes the end-of-line character, depending on
  4694. the 'fileformat' option for the current buffer. The first
  4695. line returns 1. UTF-8 encoding is used, 'fileencoding' is
  4696. ignored. This can also be used to get the byte count for the
  4697. line just below the last line: >vim
  4698. echo line2byte(line("$") + 1)
  4699. < This is the buffer size plus one. If 'fileencoding' is empty
  4700. it is the file size plus one. {lnum} is used like with
  4701. |getline()|. When {lnum} is invalid -1 is returned.
  4702. Also see |byte2line()|, |go| and |:goto|.
  4703. Parameters: ~
  4704. • {lnum} (`integer`)
  4705. Return: ~
  4706. (`integer`)
  4707. lispindent({lnum}) *lispindent()*
  4708. Get the amount of indent for line {lnum} according the lisp
  4709. indenting rules, as with 'lisp'.
  4710. The indent is counted in spaces, the value of 'tabstop' is
  4711. relevant. {lnum} is used just like in |getline()|.
  4712. When {lnum} is invalid, -1 is returned.
  4713. Parameters: ~
  4714. • {lnum} (`integer`)
  4715. Return: ~
  4716. (`any`)
  4717. list2blob({list}) *list2blob()*
  4718. Return a Blob concatenating all the number values in {list}.
  4719. Examples: >vim
  4720. echo list2blob([1, 2, 3, 4]) " returns 0z01020304
  4721. echo list2blob([]) " returns 0z
  4722. < Returns an empty Blob on error. If one of the numbers is
  4723. negative or more than 255 error *E1239* is given.
  4724. |blob2list()| does the opposite.
  4725. Parameters: ~
  4726. • {list} (`any[]`)
  4727. Return: ~
  4728. (`any`)
  4729. list2str({list} [, {utf8}]) *list2str()*
  4730. Convert each number in {list} to a character string can
  4731. concatenate them all. Examples: >vim
  4732. echo list2str([32]) " returns " "
  4733. echo list2str([65, 66, 67]) " returns "ABC"
  4734. < The same can be done (slowly) with: >vim
  4735. echo join(map(list, {nr, val -> nr2char(val)}), '')
  4736. < |str2list()| does the opposite.
  4737. UTF-8 encoding is always used, {utf8} option has no effect,
  4738. and exists only for backwards-compatibility.
  4739. With UTF-8 composing characters work as expected: >vim
  4740. echo list2str([97, 769]) " returns "á"
  4741. <
  4742. Returns an empty string on error.
  4743. Parameters: ~
  4744. • {list} (`any[]`)
  4745. • {utf8} (`boolean?`)
  4746. Return: ~
  4747. (`any`)
  4748. localtime() *localtime()*
  4749. Return the current time, measured as seconds since 1st Jan
  4750. 1970. See also |strftime()|, |strptime()| and |getftime()|.
  4751. Return: ~
  4752. (`any`)
  4753. log({expr}) *log()*
  4754. Return the natural logarithm (base e) of {expr} as a |Float|.
  4755. {expr} must evaluate to a |Float| or a |Number| in the range
  4756. (0, inf].
  4757. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4758. Examples: >vim
  4759. echo log(10)
  4760. < 2.302585 >vim
  4761. echo log(exp(5))
  4762. < 5.0
  4763. Parameters: ~
  4764. • {expr} (`number`)
  4765. Return: ~
  4766. (`any`)
  4767. log10({expr}) *log10()*
  4768. Return the logarithm of Float {expr} to base 10 as a |Float|.
  4769. {expr} must evaluate to a |Float| or a |Number|.
  4770. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  4771. Examples: >vim
  4772. echo log10(1000)
  4773. < 3.0 >vim
  4774. echo log10(0.01)
  4775. < -2.0
  4776. Parameters: ~
  4777. • {expr} (`number`)
  4778. Return: ~
  4779. (`any`)
  4780. luaeval({expr} [, {expr}]) *luaeval()*
  4781. Evaluate Lua expression {expr} and return its result converted
  4782. to Vim data structures. See |lua-eval| for more details.
  4783. Parameters: ~
  4784. • {expr} (`string`)
  4785. • {expr1} (`any[]?`)
  4786. Return: ~
  4787. (`any`)
  4788. map({expr1}, {expr2}) *map()*
  4789. {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
  4790. When {expr1} is a |List| or |Dictionary|, replace each
  4791. item in {expr1} with the result of evaluating {expr2}.
  4792. For a |Blob| each byte is replaced.
  4793. For a |String|, each character, including composing
  4794. characters, is replaced.
  4795. If the item type changes you may want to use |mapnew()| to
  4796. create a new List or Dictionary.
  4797. {expr2} must be a |String| or |Funcref|.
  4798. If {expr2} is a |String|, inside {expr2} |v:val| has the value
  4799. of the current item. For a |Dictionary| |v:key| has the key
  4800. of the current item and for a |List| |v:key| has the index of
  4801. the current item. For a |Blob| |v:key| has the index of the
  4802. current byte. For a |String| |v:key| has the index of the
  4803. current character.
  4804. Example: >vim
  4805. call map(mylist, '"> " .. v:val .. " <"')
  4806. < This puts "> " before and " <" after each item in "mylist".
  4807. Note that {expr2} is the result of an expression and is then
  4808. used as an expression again. Often it is good to use a
  4809. |literal-string| to avoid having to double backslashes. You
  4810. still have to double ' quotes
  4811. If {expr2} is a |Funcref| it is called with two arguments:
  4812. 1. The key or the index of the current item.
  4813. 2. the value of the current item.
  4814. The function must return the new value of the item. Example
  4815. that changes each value by "key-value": >vim
  4816. func KeyValue(key, val)
  4817. return a:key .. '-' .. a:val
  4818. endfunc
  4819. call map(myDict, function('KeyValue'))
  4820. < It is shorter when using a |lambda|: >vim
  4821. call map(myDict, {key, val -> key .. '-' .. val})
  4822. < If you do not use "val" you can leave it out: >vim
  4823. call map(myDict, {key -> 'item: ' .. key})
  4824. < If you do not use "key" you can use a short name: >vim
  4825. call map(myDict, {_, val -> 'item: ' .. val})
  4826. <
  4827. The operation is done in-place for a |List| and |Dictionary|.
  4828. If you want it to remain unmodified make a copy first: >vim
  4829. let tlist = map(copy(mylist), ' v:val .. "\t"')
  4830. < Returns {expr1}, the |List| or |Dictionary| that was filtered,
  4831. or a new |Blob| or |String|.
  4832. When an error is encountered while evaluating {expr2} no
  4833. further items in {expr1} are processed.
  4834. When {expr2} is a Funcref errors inside a function are ignored,
  4835. unless it was defined with the "abort" flag.
  4836. Parameters: ~
  4837. • {expr1} (`string|table|any[]`)
  4838. • {expr2} (`string|function`)
  4839. Return: ~
  4840. (`any`)
  4841. maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
  4842. When {dict} is omitted or zero: Return the rhs of mapping
  4843. {name} in mode {mode}. The returned String has special
  4844. characters translated like in the output of the ":map" command
  4845. listing. When {dict} is TRUE a dictionary is returned, see
  4846. below. To get a list of all mappings see |maplist()|.
  4847. When there is no mapping for {name}, an empty String is
  4848. returned if {dict} is FALSE, otherwise returns an empty Dict.
  4849. When the mapping for {name} is empty, then "<Nop>" is
  4850. returned.
  4851. The {name} can have special key names, like in the ":map"
  4852. command.
  4853. {mode} can be one of these strings:
  4854. "n" Normal
  4855. "v" Visual (including Select)
  4856. "o" Operator-pending
  4857. "i" Insert
  4858. "c" Cmd-line
  4859. "s" Select
  4860. "x" Visual
  4861. "l" langmap |language-mapping|
  4862. "t" Terminal
  4863. "" Normal, Visual and Operator-pending
  4864. When {mode} is omitted, the modes for "" are used.
  4865. When {abbr} is there and it is |TRUE| use abbreviations
  4866. instead of mappings.
  4867. When {dict} is there and it is |TRUE| return a dictionary
  4868. containing all the information of the mapping with the
  4869. following items: *mapping-dict*
  4870. "lhs" The {lhs} of the mapping as it would be typed
  4871. "lhsraw" The {lhs} of the mapping as raw bytes
  4872. "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
  4873. form, only present when it differs from "lhsraw"
  4874. "rhs" The {rhs} of the mapping as typed.
  4875. "callback" Lua function, if RHS was defined as such.
  4876. "silent" 1 for a |:map-silent| mapping, else 0.
  4877. "noremap" 1 if the {rhs} of the mapping is not remappable.
  4878. "script" 1 if mapping was defined with <script>.
  4879. "expr" 1 for an expression mapping (|:map-<expr>|).
  4880. "buffer" 1 for a buffer local mapping (|:map-local|).
  4881. "mode" Modes for which the mapping is defined. In
  4882. addition to the modes mentioned above, these
  4883. characters will be used:
  4884. " " Normal, Visual and Operator-pending
  4885. "!" Insert and Commandline mode
  4886. (|mapmode-ic|)
  4887. "sid" The script local ID, used for <sid> mappings
  4888. (|<SID>|). Negative for special contexts.
  4889. "scriptversion" The version of the script, always 1.
  4890. "lnum" The line number in "sid", zero if unknown.
  4891. "nowait" Do not wait for other, longer mappings.
  4892. (|:map-<nowait>|).
  4893. "abbr" True if this is an |abbreviation|.
  4894. "mode_bits" Nvim's internal binary representation of "mode".
  4895. |mapset()| ignores this; only "mode" is used.
  4896. See |maplist()| for usage examples. The values
  4897. are from src/nvim/state_defs.h and may change in
  4898. the future.
  4899. The dictionary can be used to restore a mapping with
  4900. |mapset()|.
  4901. The mappings local to the current buffer are checked first,
  4902. then the global mappings.
  4903. This function can be used to map a key even when it's already
  4904. mapped, and have it do the original mapping too. Sketch: >vim
  4905. exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
  4906. <
  4907. Parameters: ~
  4908. • {name} (`string`)
  4909. • {mode} (`string?`)
  4910. • {abbr} (`boolean?`)
  4911. • {dict} (`false?`)
  4912. Return: ~
  4913. (`string`)
  4914. mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
  4915. Check if there is a mapping that matches with {name} in mode
  4916. {mode}. See |maparg()| for {mode} and special names in
  4917. {name}.
  4918. When {abbr} is there and it is non-zero use abbreviations
  4919. instead of mappings.
  4920. A match happens with a mapping that starts with {name} and
  4921. with a mapping which is equal to the start of {name}.
  4922. matches mapping "a" "ab" "abc" ~
  4923. mapcheck("a") yes yes yes
  4924. mapcheck("abc") yes yes yes
  4925. mapcheck("ax") yes no no
  4926. mapcheck("b") no no no
  4927. The difference with maparg() is that mapcheck() finds a
  4928. mapping that matches with {name}, while maparg() only finds a
  4929. mapping for {name} exactly.
  4930. When there is no mapping that starts with {name}, an empty
  4931. String is returned. If there is one, the RHS of that mapping
  4932. is returned. If there are several mappings that start with
  4933. {name}, the RHS of one of them is returned. This will be
  4934. "<Nop>" if the RHS is empty.
  4935. The mappings local to the current buffer are checked first,
  4936. then the global mappings.
  4937. This function can be used to check if a mapping can be added
  4938. without being ambiguous. Example: >vim
  4939. if mapcheck("_vv") == ""
  4940. map _vv :set guifont=7x13<CR>
  4941. endif
  4942. < This avoids adding the "_vv" mapping when there already is a
  4943. mapping for "_v" or for "_vvv".
  4944. Parameters: ~
  4945. • {name} (`string`)
  4946. • {mode} (`string?`)
  4947. • {abbr} (`boolean?`)
  4948. Return: ~
  4949. (`any`)
  4950. maplist([{abbr}]) *maplist()*
  4951. Returns a |List| of all mappings. Each List item is a |Dict|,
  4952. the same as what is returned by |maparg()|, see
  4953. |mapping-dict|. When {abbr} is there and it is |TRUE| use
  4954. abbreviations instead of mappings.
  4955. Example to show all mappings with "MultiMatch" in rhs: >vim
  4956. echo maplist()->filter({_, m ->
  4957. \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
  4958. \ })
  4959. < It can be tricky to find mappings for particular |:map-modes|.
  4960. |mapping-dict|'s "mode_bits" can simplify this. For example,
  4961. the mode_bits for Normal, Insert or Command-line modes are
  4962. 0x19. To find all the mappings available in those modes you
  4963. can do: >vim
  4964. let saved_maps = []
  4965. for m in maplist()
  4966. if and(m.mode_bits, 0x19) != 0
  4967. eval saved_maps->add(m)
  4968. endif
  4969. endfor
  4970. echo saved_maps->mapnew({_, m -> m.lhs})
  4971. < The values of the mode_bits are defined in Nvim's
  4972. src/nvim/state_defs.h file and they can be discovered at
  4973. runtime using |:map-commands| and "maplist()". Example: >vim
  4974. omap xyzzy <Nop>
  4975. let op_bit = maplist()->filter(
  4976. \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
  4977. ounmap xyzzy
  4978. echo printf("Operator-pending mode bit: 0x%x", op_bit)
  4979. <
  4980. Parameters: ~
  4981. • {abbr} (`0|1?`)
  4982. Return: ~
  4983. (`table[]`)
  4984. mapnew({expr1}, {expr2}) *mapnew()*
  4985. Like |map()| but instead of replacing items in {expr1} a new
  4986. List or Dictionary is created and returned. {expr1} remains
  4987. unchanged. Items can still be changed by {expr2}, if you
  4988. don't want that use |deepcopy()| first.
  4989. Parameters: ~
  4990. • {expr1} (`any`)
  4991. • {expr2} (`any`)
  4992. Return: ~
  4993. (`any`)
  4994. mapset({mode}, {abbr}, {dict}) *mapset()*
  4995. mapset({dict})
  4996. Restore a mapping from a dictionary, possibly returned by
  4997. |maparg()| or |maplist()|. A buffer mapping, when dict.buffer
  4998. is true, is set on the current buffer; it is up to the caller
  4999. to ensure that the intended buffer is the current buffer. This
  5000. feature allows copying mappings from one buffer to another.
  5001. The dict.mode value may restore a single mapping that covers
  5002. more than one mode, like with mode values of '!', ' ', "nox",
  5003. or 'v'. *E1276*
  5004. In the first form, {mode} and {abbr} should be the same as
  5005. for the call to |maparg()|. *E460*
  5006. {mode} is used to define the mode in which the mapping is set,
  5007. not the "mode" entry in {dict}.
  5008. Example for saving and restoring a mapping: >vim
  5009. let save_map = maparg('K', 'n', 0, 1)
  5010. nnoremap K somethingelse
  5011. " ...
  5012. call mapset('n', 0, save_map)
  5013. < Note that if you are going to replace a map in several modes,
  5014. e.g. with `:map!`, you need to save/restore the mapping for
  5015. all of them, when they might differ.
  5016. In the second form, with {dict} as the only argument, mode
  5017. and abbr are taken from the dict.
  5018. Example: >vim
  5019. let save_maps = maplist()->filter(
  5020. \ {_, m -> m.lhs == 'K'})
  5021. nnoremap K somethingelse
  5022. cnoremap K somethingelse2
  5023. " ...
  5024. unmap K
  5025. for d in save_maps
  5026. call mapset(d)
  5027. endfor
  5028. <
  5029. Parameters: ~
  5030. • {dict} (`boolean`)
  5031. Return: ~
  5032. (`any`)
  5033. match({expr}, {pat} [, {start} [, {count}]]) *match()*
  5034. When {expr} is a |List| then this returns the index of the
  5035. first item where {pat} matches. Each item is used as a
  5036. String, |Lists| and |Dictionaries| are used as echoed.
  5037. Otherwise, {expr} is used as a String. The result is a
  5038. Number, which gives the index (byte offset) in {expr} where
  5039. {pat} matches.
  5040. A match at the first character or |List| item returns zero.
  5041. If there is no match -1 is returned.
  5042. For getting submatches see |matchlist()|.
  5043. Example: >vim
  5044. echo match("testing", "ing") " results in 4
  5045. echo match([1, 'x'], '\a') " results in 1
  5046. < See |string-match| for how {pat} is used.
  5047. *strpbrk()*
  5048. Vim doesn't have a strpbrk() function. But you can do: >vim
  5049. let sepidx = match(line, '[.,;: \t]')
  5050. < *strcasestr()*
  5051. Vim doesn't have a strcasestr() function. But you can add
  5052. "\c" to the pattern to ignore case: >vim
  5053. let idx = match(haystack, '\cneedle')
  5054. <
  5055. If {start} is given, the search starts from byte index
  5056. {start} in a String or item {start} in a |List|.
  5057. The result, however, is still the index counted from the
  5058. first character/item. Example: >vim
  5059. echo match("testing", "ing", 2)
  5060. < result is again "4". >vim
  5061. echo match("testing", "ing", 4)
  5062. < result is again "4". >vim
  5063. echo match("testing", "t", 2)
  5064. < result is "3".
  5065. For a String, if {start} > 0 then it is like the string starts
  5066. {start} bytes later, thus "^" will match at {start}. Except
  5067. when {count} is given, then it's like matches before the
  5068. {start} byte are ignored (this is a bit complicated to keep it
  5069. backwards compatible).
  5070. For a String, if {start} < 0, it will be set to 0. For a list
  5071. the index is counted from the end.
  5072. If {start} is out of range ({start} > strlen({expr}) for a
  5073. String or {start} > len({expr}) for a |List|) -1 is returned.
  5074. When {count} is given use the {count}th match. When a match
  5075. is found in a String the search for the next one starts one
  5076. character further. Thus this example results in 1: >vim
  5077. echo match("testing", "..", 0, 2)
  5078. < In a |List| the search continues in the next item.
  5079. Note that when {count} is added the way {start} works changes,
  5080. see above.
  5081. *match-pattern*
  5082. See |pattern| for the patterns that are accepted.
  5083. The 'ignorecase' option is used to set the ignore-caseness of
  5084. the pattern. 'smartcase' is NOT used. The matching is always
  5085. done like 'magic' is set and 'cpoptions' is empty.
  5086. Note that a match at the start is preferred, thus when the
  5087. pattern is using "*" (any number of matches) it tends to find
  5088. zero matches at the start instead of a number of matches
  5089. further down in the text.
  5090. Parameters: ~
  5091. • {expr} (`string|any[]`)
  5092. • {pat} (`string`)
  5093. • {start} (`integer?`)
  5094. • {count} (`integer?`)
  5095. Return: ~
  5096. (`any`)
  5097. *matchadd()* *E798* *E799* *E801* *E957*
  5098. matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
  5099. Defines a pattern to be highlighted in the current window (a
  5100. "match"). It will be highlighted with {group}. Returns an
  5101. identification number (ID), which can be used to delete the
  5102. match using |matchdelete()|. The ID is bound to the window.
  5103. Matching is case sensitive and magic, unless case sensitivity
  5104. or magicness are explicitly overridden in {pattern}. The
  5105. 'magic', 'smartcase' and 'ignorecase' options are not used.
  5106. The "Conceal" value is special, it causes the match to be
  5107. concealed.
  5108. The optional {priority} argument assigns a priority to the
  5109. match. A match with a high priority will have its
  5110. highlighting overrule that of a match with a lower priority.
  5111. A priority is specified as an integer (negative numbers are no
  5112. exception). If the {priority} argument is not specified, the
  5113. default priority is 10. The priority of 'hlsearch' is zero,
  5114. hence all matches with a priority greater than zero will
  5115. overrule it. Syntax highlighting (see 'syntax') is a separate
  5116. mechanism, and regardless of the chosen priority a match will
  5117. always overrule syntax highlighting.
  5118. The optional {id} argument allows the request for a specific
  5119. match ID. If a specified ID is already taken, an error
  5120. message will appear and the match will not be added. An ID
  5121. is specified as a positive integer (zero excluded). IDs 1, 2
  5122. and 3 are reserved for |:match|, |:2match| and |:3match|,
  5123. respectively. 3 is reserved for use by the |matchparen|
  5124. plugin.
  5125. If the {id} argument is not specified or -1, |matchadd()|
  5126. automatically chooses a free ID, which is at least 1000.
  5127. The optional {dict} argument allows for further custom
  5128. values. Currently this is used to specify a match specific
  5129. conceal character that will be shown for |hl-Conceal|
  5130. highlighted matches. The dict can have the following members:
  5131. conceal Special character to show instead of the
  5132. match (only for |hl-Conceal| highlighted
  5133. matches, see |:syn-cchar|)
  5134. window Instead of the current window use the
  5135. window with this number or window ID.
  5136. The number of matches is not limited, as it is the case with
  5137. the |:match| commands.
  5138. Returns -1 on error.
  5139. Example: >vim
  5140. highlight MyGroup ctermbg=green guibg=green
  5141. let m = matchadd("MyGroup", "TODO")
  5142. < Deletion of the pattern: >vim
  5143. call matchdelete(m)
  5144. < A list of matches defined by |matchadd()| and |:match| are
  5145. available from |getmatches()|. All matches can be deleted in
  5146. one operation by |clearmatches()|.
  5147. Parameters: ~
  5148. • {group} (`integer|string`)
  5149. • {pattern} (`string`)
  5150. • {priority} (`integer?`)
  5151. • {id} (`integer?`)
  5152. • {dict} (`string?`)
  5153. Return: ~
  5154. (`any`)
  5155. matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()*
  5156. Same as |matchadd()|, but requires a list of positions {pos}
  5157. instead of a pattern. This command is faster than |matchadd()|
  5158. because it does not handle regular expressions and it sets
  5159. buffer line boundaries to redraw screen. It is supposed to be
  5160. used when fast match additions and deletions are required, for
  5161. example to highlight matching parentheses.
  5162. *E5030* *E5031*
  5163. {pos} is a list of positions. Each position can be one of
  5164. these:
  5165. - A number. This whole line will be highlighted. The first
  5166. line has number 1.
  5167. - A list with one number, e.g., [23]. The whole line with this
  5168. number will be highlighted.
  5169. - A list with two numbers, e.g., [23, 11]. The first number is
  5170. the line number, the second one is the column number (first
  5171. column is 1, the value must correspond to the byte index as
  5172. |col()| would return). The character at this position will
  5173. be highlighted.
  5174. - A list with three numbers, e.g., [23, 11, 3]. As above, but
  5175. the third number gives the length of the highlight in bytes.
  5176. Entries with zero and negative line numbers are silently
  5177. ignored, as well as entries with negative column numbers and
  5178. lengths.
  5179. Returns -1 on error.
  5180. Example: >vim
  5181. highlight MyGroup ctermbg=green guibg=green
  5182. let m = matchaddpos("MyGroup", [[23, 24], 34])
  5183. < Deletion of the pattern: >vim
  5184. call matchdelete(m)
  5185. < Matches added by |matchaddpos()| are returned by
  5186. |getmatches()|.
  5187. Parameters: ~
  5188. • {group} (`integer|string`)
  5189. • {pos} (`any[]`)
  5190. • {priority} (`integer?`)
  5191. • {id} (`integer?`)
  5192. • {dict} (`string?`)
  5193. Return: ~
  5194. (`any`)
  5195. matcharg({nr}) *matcharg()*
  5196. Selects the {nr} match item, as set with a |:match|,
  5197. |:2match| or |:3match| command.
  5198. Return a |List| with two elements:
  5199. The name of the highlight group used
  5200. The pattern used.
  5201. When {nr} is not 1, 2 or 3 returns an empty |List|.
  5202. When there is no match item set returns ['', ''].
  5203. This is useful to save and restore a |:match|.
  5204. Highlighting matches using the |:match| commands are limited
  5205. to three matches. |matchadd()| does not have this limitation.
  5206. Parameters: ~
  5207. • {nr} (`integer`)
  5208. Return: ~
  5209. (`any`)
  5210. matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
  5211. Returns the |List| of matches in lines from {lnum} to {end} in
  5212. buffer {buf} where {pat} matches.
  5213. {lnum} and {end} can either be a line number or the string "$"
  5214. to refer to the last line in {buf}.
  5215. The {dict} argument supports following items:
  5216. submatches include submatch information (|/\(|)
  5217. For each match, a |Dict| with the following items is returned:
  5218. byteidx starting byte index of the match
  5219. lnum line number where there is a match
  5220. text matched string
  5221. Note that there can be multiple matches in a single line.
  5222. This function works only for loaded buffers. First call
  5223. |bufload()| if needed.
  5224. See |match-pattern| for information about the effect of some
  5225. option settings on the pattern.
  5226. When {buf} is not a valid buffer, the buffer is not loaded or
  5227. {lnum} or {end} is not valid then an error is given and an
  5228. empty |List| is returned.
  5229. Examples: >vim
  5230. " Assuming line 3 in buffer 5 contains "a"
  5231. echo matchbufline(5, '\<\k\+\>', 3, 3)
  5232. < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
  5233. " Assuming line 4 in buffer 10 contains "tik tok"
  5234. echo matchbufline(10, '\<\k\+\>', 1, 4)
  5235. < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
  5236. If {submatch} is present and is v:true, then submatches like
  5237. "\1", "\2", etc. are also returned. Example: >vim
  5238. " Assuming line 2 in buffer 2 contains "acd"
  5239. echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
  5240. \ {'submatches': v:true})
  5241. < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5242. The "submatches" List always contains 9 items. If a submatch
  5243. is not found, then an empty string is returned for that
  5244. submatch.
  5245. Parameters: ~
  5246. • {buf} (`string|integer`)
  5247. • {pat} (`string`)
  5248. • {lnum} (`string|integer`)
  5249. • {end} (`string|integer`)
  5250. • {dict} (`table?`)
  5251. Return: ~
  5252. (`any`)
  5253. matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
  5254. Deletes a match with ID {id} previously defined by |matchadd()|
  5255. or one of the |:match| commands. Returns 0 if successful,
  5256. otherwise -1. See example for |matchadd()|. All matches can
  5257. be deleted in one operation by |clearmatches()|.
  5258. If {win} is specified, use the window with this number or
  5259. window ID instead of the current window.
  5260. Parameters: ~
  5261. • {id} (`integer`)
  5262. • {win} (`integer?`)
  5263. Return: ~
  5264. (`any`)
  5265. matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
  5266. Same as |match()|, but return the index of first character
  5267. after the match. Example: >vim
  5268. echo matchend("testing", "ing")
  5269. < results in "7".
  5270. *strspn()* *strcspn()*
  5271. Vim doesn't have a strspn() or strcspn() function, but you can
  5272. do it with matchend(): >vim
  5273. let span = matchend(line, '[a-zA-Z]')
  5274. let span = matchend(line, '[^a-zA-Z]')
  5275. < Except that -1 is returned when there are no matches.
  5276. The {start}, if given, has the same meaning as for |match()|. >vim
  5277. echo matchend("testing", "ing", 2)
  5278. < results in "7". >vim
  5279. echo matchend("testing", "ing", 5)
  5280. < result is "-1".
  5281. When {expr} is a |List| the result is equal to |match()|.
  5282. Parameters: ~
  5283. • {expr} (`any`)
  5284. • {pat} (`string`)
  5285. • {start} (`integer?`)
  5286. • {count} (`integer?`)
  5287. Return: ~
  5288. (`any`)
  5289. matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
  5290. If {list} is a list of strings, then returns a |List| with all
  5291. the strings in {list} that fuzzy match {str}. The strings in
  5292. the returned list are sorted based on the matching score.
  5293. The optional {dict} argument always supports the following
  5294. items:
  5295. matchseq When this item is present return only matches
  5296. that contain the characters in {str} in the
  5297. given sequence.
  5298. limit Maximum number of matches in {list} to be
  5299. returned. Zero means no limit.
  5300. If {list} is a list of dictionaries, then the optional {dict}
  5301. argument supports the following additional items:
  5302. key Key of the item which is fuzzy matched against
  5303. {str}. The value of this item should be a
  5304. string.
  5305. text_cb |Funcref| that will be called for every item
  5306. in {list} to get the text for fuzzy matching.
  5307. This should accept a dictionary item as the
  5308. argument and return the text for that item to
  5309. use for fuzzy matching.
  5310. {str} is treated as a literal string and regular expression
  5311. matching is NOT supported. The maximum supported {str} length
  5312. is 256.
  5313. When {str} has multiple words each separated by white space,
  5314. then the list of strings that have all the words is returned.
  5315. If there are no matching strings or there is an error, then an
  5316. empty list is returned. If length of {str} is greater than
  5317. 256, then returns an empty list.
  5318. When {limit} is given, matchfuzzy() will find up to this
  5319. number of matches in {list} and return them in sorted order.
  5320. Refer to |fuzzy-matching| for more information about fuzzy
  5321. matching strings.
  5322. Example: >vim
  5323. echo matchfuzzy(["clay", "crow"], "cay")
  5324. < results in ["clay"]. >vim
  5325. echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
  5326. < results in a list of buffer names fuzzy matching "ndl". >vim
  5327. echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
  5328. < results in a list of buffer information dicts with buffer
  5329. names fuzzy matching "ndl". >vim
  5330. echo getbufinfo()->matchfuzzy("spl",
  5331. \ {'text_cb' : {v -> v.name}})
  5332. < results in a list of buffer information dicts with buffer
  5333. names fuzzy matching "spl". >vim
  5334. echo v:oldfiles->matchfuzzy("test")
  5335. < results in a list of file names fuzzy matching "test". >vim
  5336. let l = readfile("buffer.c")->matchfuzzy("str")
  5337. < results in a list of lines in "buffer.c" fuzzy matching "str". >vim
  5338. echo ['one two', 'two one']->matchfuzzy('two one')
  5339. < results in `['two one', 'one two']` . >vim
  5340. echo ['one two', 'two one']->matchfuzzy('two one',
  5341. \ {'matchseq': 1})
  5342. < results in `['two one']`.
  5343. Parameters: ~
  5344. • {list} (`any[]`)
  5345. • {str} (`string`)
  5346. • {dict} (`string?`)
  5347. Return: ~
  5348. (`any`)
  5349. matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
  5350. Same as |matchfuzzy()|, but returns the list of matched
  5351. strings, the list of character positions where characters
  5352. in {str} matches and a list of matching scores. You can
  5353. use |byteidx()| to convert a character position to a byte
  5354. position.
  5355. If {str} matches multiple times in a string, then only the
  5356. positions for the best match is returned.
  5357. If there are no matching strings or there is an error, then a
  5358. list with three empty list items is returned.
  5359. Example: >vim
  5360. echo matchfuzzypos(['testing'], 'tsg')
  5361. < results in [["testing"], [[0, 2, 6]], [99]] >vim
  5362. echo matchfuzzypos(['clay', 'lacy'], 'la')
  5363. < results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
  5364. echo [{'text': 'hello', 'id' : 10}]
  5365. \ ->matchfuzzypos('ll', {'key' : 'text'})
  5366. < results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
  5367. Parameters: ~
  5368. • {list} (`any[]`)
  5369. • {str} (`string`)
  5370. • {dict} (`string?`)
  5371. Return: ~
  5372. (`any`)
  5373. matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
  5374. Same as |match()|, but return a |List|. The first item in the
  5375. list is the matched string, same as what matchstr() would
  5376. return. Following items are submatches, like "\1", "\2", etc.
  5377. in |:substitute|. When an optional submatch didn't match an
  5378. empty string is used. Example: >vim
  5379. echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
  5380. < Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
  5381. When there is no match an empty list is returned.
  5382. You can pass in a List, but that is not very useful.
  5383. Parameters: ~
  5384. • {expr} (`any`)
  5385. • {pat} (`string`)
  5386. • {start} (`integer?`)
  5387. • {count} (`integer?`)
  5388. Return: ~
  5389. (`any`)
  5390. matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
  5391. Same as |match()|, but return the matched string. Example: >vim
  5392. echo matchstr("testing", "ing")
  5393. < results in "ing".
  5394. When there is no match "" is returned.
  5395. The {start}, if given, has the same meaning as for |match()|. >vim
  5396. echo matchstr("testing", "ing", 2)
  5397. < results in "ing". >vim
  5398. echo matchstr("testing", "ing", 5)
  5399. < result is "".
  5400. When {expr} is a |List| then the matching item is returned.
  5401. The type isn't changed, it's not necessarily a String.
  5402. Parameters: ~
  5403. • {expr} (`any`)
  5404. • {pat} (`string`)
  5405. • {start} (`integer?`)
  5406. • {count} (`integer?`)
  5407. Return: ~
  5408. (`any`)
  5409. matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
  5410. Returns the |List| of matches in {list} where {pat} matches.
  5411. {list} is a |List| of strings. {pat} is matched against each
  5412. string in {list}.
  5413. The {dict} argument supports following items:
  5414. submatches include submatch information (|/\(|)
  5415. For each match, a |Dict| with the following items is returned:
  5416. byteidx starting byte index of the match.
  5417. idx index in {list} of the match.
  5418. text matched string
  5419. submatches a List of submatches. Present only if
  5420. "submatches" is set to v:true in {dict}.
  5421. See |match-pattern| for information about the effect of some
  5422. option settings on the pattern.
  5423. Example: >vim
  5424. echo matchstrlist(['tik tok'], '\<\k\+\>')
  5425. < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
  5426. echo matchstrlist(['a', 'b'], '\<\k\+\>')
  5427. < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
  5428. If "submatches" is present and is v:true, then submatches like
  5429. "\1", "\2", etc. are also returned. Example: >vim
  5430. echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
  5431. \ #{submatches: v:true})
  5432. < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
  5433. The "submatches" List always contains 9 items. If a submatch
  5434. is not found, then an empty string is returned for that
  5435. submatch.
  5436. Parameters: ~
  5437. • {list} (`string[]`)
  5438. • {pat} (`string`)
  5439. • {dict} (`table?`)
  5440. Return: ~
  5441. (`any`)
  5442. matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
  5443. Same as |matchstr()|, but return the matched string, the start
  5444. position and the end position of the match. Example: >vim
  5445. echo matchstrpos("testing", "ing")
  5446. < results in ["ing", 4, 7].
  5447. When there is no match ["", -1, -1] is returned.
  5448. The {start}, if given, has the same meaning as for |match()|. >vim
  5449. echo matchstrpos("testing", "ing", 2)
  5450. < results in ["ing", 4, 7]. >vim
  5451. echo matchstrpos("testing", "ing", 5)
  5452. < result is ["", -1, -1].
  5453. When {expr} is a |List| then the matching item, the index
  5454. of first item where {pat} matches, the start position and the
  5455. end position of the match are returned. >vim
  5456. echo matchstrpos([1, '__x'], '\a')
  5457. < result is ["x", 1, 2, 3].
  5458. The type isn't changed, it's not necessarily a String.
  5459. Parameters: ~
  5460. • {expr} (`any`)
  5461. • {pat} (`string`)
  5462. • {start} (`integer?`)
  5463. • {count} (`integer?`)
  5464. Return: ~
  5465. (`any`)
  5466. max({expr}) *max()*
  5467. Return the maximum value of all items in {expr}. Example: >vim
  5468. echo max([apples, pears, oranges])
  5469. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5470. it returns the maximum of all values in the Dictionary.
  5471. If {expr} is neither a List nor a Dictionary, or one of the
  5472. items in {expr} cannot be used as a Number this results in
  5473. an error. An empty |List| or |Dictionary| results in zero.
  5474. Parameters: ~
  5475. • {expr} (`any`)
  5476. Return: ~
  5477. (`any`)
  5478. menu_get({path} [, {modes}]) *menu_get()*
  5479. Returns a |List| of |Dictionaries| describing |menus| (defined
  5480. by |:menu|, |:amenu|, …), including |hidden-menus|.
  5481. {path} matches a menu by name, or all menus if {path} is an
  5482. empty string. Example: >vim
  5483. echo menu_get('File','')
  5484. echo menu_get('')
  5485. <
  5486. {modes} is a string of zero or more modes (see |maparg()| or
  5487. |creating-menus| for the list of modes). "a" means "all".
  5488. Example: >vim
  5489. nnoremenu &Test.Test inormal
  5490. inoremenu Test.Test insert
  5491. vnoremenu Test.Test x
  5492. echo menu_get("")
  5493. < returns something like this: >
  5494. [ {
  5495. "hidden": 0,
  5496. "name": "Test",
  5497. "priority": 500,
  5498. "shortcut": 84,
  5499. "submenus": [ {
  5500. "hidden": 0,
  5501. "mappings": {
  5502. i": {
  5503. "enabled": 1,
  5504. "noremap": 1,
  5505. "rhs": "insert",
  5506. "sid": 1,
  5507. "silent": 0
  5508. },
  5509. n": { ... },
  5510. s": { ... },
  5511. v": { ... }
  5512. },
  5513. "name": "Test",
  5514. "priority": 500,
  5515. "shortcut": 0
  5516. } ]
  5517. } ]
  5518. <
  5519. Parameters: ~
  5520. • {path} (`string`)
  5521. • {modes} (`string?`)
  5522. Return: ~
  5523. (`any`)
  5524. menu_info({name} [, {mode}]) *menu_info()*
  5525. Return information about the specified menu {name} in
  5526. mode {mode}. The menu name should be specified without the
  5527. shortcut character ('&'). If {name} is "", then the top-level
  5528. menu names are returned.
  5529. {mode} can be one of these strings:
  5530. "n" Normal
  5531. "v" Visual (including Select)
  5532. "o" Operator-pending
  5533. "i" Insert
  5534. "c" Cmd-line
  5535. "s" Select
  5536. "x" Visual
  5537. "t" Terminal-Job
  5538. "" Normal, Visual and Operator-pending
  5539. "!" Insert and Cmd-line
  5540. When {mode} is omitted, the modes for "" are used.
  5541. Returns a |Dictionary| containing the following items:
  5542. accel menu item accelerator text |menu-text|
  5543. display display name (name without '&')
  5544. enabled v:true if this menu item is enabled
  5545. Refer to |:menu-enable|
  5546. icon name of the icon file (for toolbar)
  5547. |toolbar-icon|
  5548. iconidx index of a built-in icon
  5549. modes modes for which the menu is defined. In
  5550. addition to the modes mentioned above, these
  5551. characters will be used:
  5552. " " Normal, Visual and Operator-pending
  5553. name menu item name.
  5554. noremenu v:true if the {rhs} of the menu item is not
  5555. remappable else v:false.
  5556. priority menu order priority |menu-priority|
  5557. rhs right-hand-side of the menu item. The returned
  5558. string has special characters translated like
  5559. in the output of the ":menu" command listing.
  5560. When the {rhs} of a menu item is empty, then
  5561. "<Nop>" is returned.
  5562. script v:true if script-local remapping of {rhs} is
  5563. allowed else v:false. See |:menu-script|.
  5564. shortcut shortcut key (character after '&' in
  5565. the menu name) |menu-shortcut|
  5566. silent v:true if the menu item is created
  5567. with <silent> argument |:menu-silent|
  5568. submenus |List| containing the names of
  5569. all the submenus. Present only if the menu
  5570. item has submenus.
  5571. Returns an empty dictionary if the menu item is not found.
  5572. Examples: >vim
  5573. echo menu_info('Edit.Cut')
  5574. echo menu_info('File.Save', 'n')
  5575. " Display the entire menu hierarchy in a buffer
  5576. func ShowMenu(name, pfx)
  5577. let m = menu_info(a:name)
  5578. call append(line('$'), a:pfx .. m.display)
  5579. for child in m->get('submenus', [])
  5580. call ShowMenu(a:name .. '.' .. escape(child, '.'),
  5581. \ a:pfx .. ' ')
  5582. endfor
  5583. endfunc
  5584. new
  5585. for topmenu in menu_info('').submenus
  5586. call ShowMenu(topmenu, '')
  5587. endfor
  5588. <
  5589. Parameters: ~
  5590. • {name} (`string`)
  5591. • {mode} (`string?`)
  5592. Return: ~
  5593. (`any`)
  5594. min({expr}) *min()*
  5595. Return the minimum value of all items in {expr}. Example: >vim
  5596. echo min([apples, pears, oranges])
  5597. < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
  5598. it returns the minimum of all values in the Dictionary.
  5599. If {expr} is neither a List nor a Dictionary, or one of the
  5600. items in {expr} cannot be used as a Number this results in
  5601. an error. An empty |List| or |Dictionary| results in zero.
  5602. Parameters: ~
  5603. • {expr} (`any`)
  5604. Return: ~
  5605. (`any`)
  5606. mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739*
  5607. Create directory {name}.
  5608. When {flags} is present it must be a string. An empty string
  5609. has no effect.
  5610. {flags} can contain these character flags:
  5611. "p" intermediate directories will be created as necessary
  5612. "D" {name} will be deleted at the end of the current
  5613. function, but not recursively |:defer|
  5614. "R" {name} will be deleted recursively at the end of the
  5615. current function |:defer|
  5616. Note that when {name} has more than one part and "p" is used
  5617. some directories may already exist. Only the first one that
  5618. is created and what it contains is scheduled to be deleted.
  5619. E.g. when using: >vim
  5620. call mkdir('subdir/tmp/autoload', 'pR')
  5621. < and "subdir" already exists then "subdir/tmp" will be
  5622. scheduled for deletion, like with: >vim
  5623. defer delete('subdir/tmp', 'rf')
  5624. <
  5625. If {prot} is given it is used to set the protection bits of
  5626. the new directory. The default is 0o755 (rwxr-xr-x: r/w for
  5627. the user, readable for others). Use 0o700 to make it
  5628. unreadable for others.
  5629. {prot} is applied for all parts of {name}. Thus if you create
  5630. /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: >vim
  5631. call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
  5632. < This function is not available in the |sandbox|.
  5633. If you try to create an existing directory with {flags} set to
  5634. "p" mkdir() will silently exit.
  5635. The function result is a Number, which is TRUE if the call was
  5636. successful or FALSE if the directory creation failed or partly
  5637. failed.
  5638. Parameters: ~
  5639. • {name} (`string`)
  5640. • {flags} (`string?`)
  5641. • {prot} (`string?`)
  5642. Return: ~
  5643. (`any`)
  5644. mode([{expr}]) *mode()*
  5645. Return a string that indicates the current mode.
  5646. If {expr} is supplied and it evaluates to a non-zero Number or
  5647. a non-empty String (|non-zero-arg|), then the full mode is
  5648. returned, otherwise only the first letter is returned.
  5649. Also see |state()|.
  5650. n Normal
  5651. no Operator-pending
  5652. nov Operator-pending (forced charwise |o_v|)
  5653. noV Operator-pending (forced linewise |o_V|)
  5654. noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
  5655. CTRL-V is one character
  5656. niI Normal using |i_CTRL-O| in |Insert-mode|
  5657. niR Normal using |i_CTRL-O| in |Replace-mode|
  5658. niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
  5659. nt Normal in |terminal-emulator| (insert goes to
  5660. Terminal mode)
  5661. ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
  5662. v Visual by character
  5663. vs Visual by character using |v_CTRL-O| in Select mode
  5664. V Visual by line
  5665. Vs Visual by line using |v_CTRL-O| in Select mode
  5666. CTRL-V Visual blockwise
  5667. CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode
  5668. s Select by character
  5669. S Select by line
  5670. CTRL-S Select blockwise
  5671. i Insert
  5672. ic Insert mode completion |compl-generic|
  5673. ix Insert mode |i_CTRL-X| completion
  5674. R Replace |R|
  5675. Rc Replace mode completion |compl-generic|
  5676. Rx Replace mode |i_CTRL-X| completion
  5677. Rv Virtual Replace |gR|
  5678. Rvc Virtual Replace mode completion |compl-generic|
  5679. Rvx Virtual Replace mode |i_CTRL-X| completion
  5680. c Command-line editing
  5681. cr Command-line editing overstrike mode |c_<Insert>|
  5682. cv Vim Ex mode |gQ|
  5683. cvr Vim Ex mode while in overstrike mode |c_<Insert>|
  5684. r Hit-enter prompt
  5685. rm The -- more -- prompt
  5686. r? A |:confirm| query of some sort
  5687. ! Shell or external command is executing
  5688. t Terminal mode: keys go to the job
  5689. This is useful in the 'statusline' option or RPC calls. In
  5690. most other places it always returns "c" or "n".
  5691. Note that in the future more modes and more specific modes may
  5692. be added. It's better not to compare the whole string but only
  5693. the leading character(s).
  5694. Also see |visualmode()|.
  5695. Parameters: ~
  5696. • {expr} (`any?`)
  5697. Return: ~
  5698. (`any`)
  5699. msgpackdump({list} [, {type}]) *msgpackdump()*
  5700. Convert a list of Vimscript objects to msgpack. Returned value is a
  5701. |readfile()|-style list. When {type} contains "B", a |Blob| is
  5702. returned instead. Example: >vim
  5703. call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
  5704. < or, using a |Blob|: >vim
  5705. call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
  5706. <
  5707. This will write the single 0x80 byte to a `fname.mpack` file
  5708. (dictionary with zero items is represented by 0x80 byte in
  5709. messagepack).
  5710. Limitations: *E5004* *E5005*
  5711. 1. |Funcref|s cannot be dumped.
  5712. 2. Containers that reference themselves cannot be dumped.
  5713. 3. Dictionary keys are always dumped as STR strings.
  5714. 4. Other strings and |Blob|s are always dumped as BIN strings.
  5715. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
  5716. Parameters: ~
  5717. • {list} (`any`)
  5718. • {type} (`any?`)
  5719. Return: ~
  5720. (`any`)
  5721. msgpackparse({data}) *msgpackparse()*
  5722. Convert a |readfile()|-style list or a |Blob| to a list of
  5723. Vimscript objects.
  5724. Example: >vim
  5725. let fname = expand('~/.config/nvim/shada/main.shada')
  5726. let mpack = readfile(fname, 'b')
  5727. let shada_objects = msgpackparse(mpack)
  5728. < This will read ~/.config/nvim/shada/main.shada file to
  5729. `shada_objects` list.
  5730. Limitations:
  5731. 1. Mapping ordering is not preserved unless messagepack
  5732. mapping is dumped using generic mapping
  5733. (|msgpack-special-map|).
  5734. 2. Since the parser aims to preserve all data untouched
  5735. (except for 1.) some strings are parsed to
  5736. |msgpack-special-dict| format which is not convenient to
  5737. use.
  5738. *msgpack-special-dict*
  5739. Some messagepack strings may be parsed to special
  5740. dictionaries. Special dictionaries are dictionaries which
  5741. 1. Contain exactly two keys: `_TYPE` and `_VAL`.
  5742. 2. `_TYPE` key is one of the types found in |v:msgpack_types|
  5743. variable.
  5744. 3. Value for `_VAL` has the following format (Key column
  5745. contains name of the key from |v:msgpack_types|):
  5746. Key Value ~
  5747. nil Zero, ignored when dumping. Not returned by
  5748. |msgpackparse()| since |v:null| was introduced.
  5749. boolean One or zero. When dumping it is only checked that
  5750. value is a |Number|. Not returned by |msgpackparse()|
  5751. since |v:true| and |v:false| were introduced.
  5752. integer |List| with four numbers: sign (-1 or 1), highest two
  5753. bits, number with bits from 62nd to 31st, lowest 31
  5754. bits. I.e. to get actual number one will need to use
  5755. code like >
  5756. _VAL[0] * ((_VAL[1] << 62)
  5757. & (_VAL[2] << 31)
  5758. & _VAL[3])
  5759. < Special dictionary with this type will appear in
  5760. |msgpackparse()| output under one of the following
  5761. circumstances:
  5762. 1. |Number| is 32-bit and value is either above
  5763. INT32_MAX or below INT32_MIN.
  5764. 2. |Number| is 64-bit and value is above INT64_MAX. It
  5765. cannot possibly be below INT64_MIN because msgpack
  5766. C parser does not support such values.
  5767. float |Float|. This value cannot possibly appear in
  5768. |msgpackparse()| output.
  5769. string |String|, or |Blob| if binary string contains zero
  5770. byte. This value cannot appear in |msgpackparse()|
  5771. output since blobs were introduced.
  5772. array |List|. This value cannot appear in |msgpackparse()|
  5773. output.
  5774. *msgpack-special-map*
  5775. map |List| of |List|s with two items (key and value) each.
  5776. This value will appear in |msgpackparse()| output if
  5777. parsed mapping contains one of the following keys:
  5778. 1. Any key that is not a string (including keys which
  5779. are binary strings).
  5780. 2. String with NUL byte inside.
  5781. 3. Duplicate key.
  5782. ext |List| with two values: first is a signed integer
  5783. representing extension type. Second is
  5784. |readfile()|-style list of strings.
  5785. Parameters: ~
  5786. • {data} (`any`)
  5787. Return: ~
  5788. (`any`)
  5789. nextnonblank({lnum}) *nextnonblank()*
  5790. Return the line number of the first line at or below {lnum}
  5791. that is not blank. Example: >vim
  5792. if getline(nextnonblank(1)) =~ "Java" | endif
  5793. < When {lnum} is invalid or there is no non-blank line at or
  5794. below it, zero is returned.
  5795. {lnum} is used like with |getline()|.
  5796. See also |prevnonblank()|.
  5797. Parameters: ~
  5798. • {lnum} (`integer`)
  5799. Return: ~
  5800. (`any`)
  5801. nr2char({expr} [, {utf8}]) *nr2char()*
  5802. Return a string with a single character, which has the number
  5803. value {expr}. Examples: >vim
  5804. echo nr2char(64) " returns '@'
  5805. echo nr2char(32) " returns ' '
  5806. < Example for "utf-8": >vim
  5807. echo nr2char(300) " returns I with bow character
  5808. <
  5809. UTF-8 encoding is always used, {utf8} option has no effect,
  5810. and exists only for backwards-compatibility.
  5811. Note that a NUL character in the file is specified with
  5812. nr2char(10), because NULs are represented with newline
  5813. characters. nr2char(0) is a real NUL and terminates the
  5814. string, thus results in an empty string.
  5815. Parameters: ~
  5816. • {expr} (`integer`)
  5817. • {utf8} (`boolean?`)
  5818. Return: ~
  5819. (`any`)
  5820. nvim_...({...}) *nvim_...()* *E5555* *eval-api*
  5821. Call nvim |api| functions. The type checking of arguments will
  5822. be stricter than for most other builtins. For instance,
  5823. if Integer is expected, a |Number| must be passed in, a
  5824. |String| will not be autoconverted.
  5825. Buffer numbers, as returned by |bufnr()| could be used as
  5826. first argument to nvim_buf_... functions. All functions
  5827. expecting an object (buffer, window or tabpage) can
  5828. also take the numerical value 0 to indicate the current
  5829. (focused) object.
  5830. Parameters: ~
  5831. • {...} (`any`)
  5832. Return: ~
  5833. (`any`)
  5834. or({expr}, {expr}) *or()*
  5835. Bitwise OR on the two arguments. The arguments are converted
  5836. to a number. A List, Dict or Float argument causes an error.
  5837. Also see `and()` and `xor()`.
  5838. Example: >vim
  5839. let bits = or(bits, 0x80)
  5840. < Rationale: The reason this is a function and not using the "|"
  5841. character like many languages, is that Vi has always used "|"
  5842. to separate commands. In many places it would not be clear if
  5843. "|" is an operator or a command separator.
  5844. Parameters: ~
  5845. • {expr} (`number`)
  5846. • {expr1} (`number`)
  5847. Return: ~
  5848. (`any`)
  5849. pathshorten({path} [, {len}]) *pathshorten()*
  5850. Shorten directory names in the path {path} and return the
  5851. result. The tail, the file name, is kept as-is. The other
  5852. components in the path are reduced to {len} letters in length.
  5853. If {len} is omitted or smaller than 1 then 1 is used (single
  5854. letters). Leading '~' and '.' characters are kept. Examples: >vim
  5855. echo pathshorten('~/.config/nvim/autoload/file1.vim')
  5856. < ~/.c/n/a/file1.vim ~
  5857. >vim
  5858. echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
  5859. < ~/.co/nv/au/file2.vim ~
  5860. It doesn't matter if the path exists or not.
  5861. Returns an empty string on error.
  5862. Parameters: ~
  5863. • {path} (`string`)
  5864. • {len} (`integer?`)
  5865. Return: ~
  5866. (`any`)
  5867. perleval({expr}) *perleval()*
  5868. Evaluate |perl| expression {expr} and return its result
  5869. converted to Vim data structures.
  5870. Numbers and strings are returned as they are (strings are
  5871. copied though).
  5872. Lists are represented as Vim |List| type.
  5873. Dictionaries are represented as Vim |Dictionary| type,
  5874. non-string keys result in error.
  5875. Note: If you want an array or hash, {expr} must return a
  5876. reference to it.
  5877. Example: >vim
  5878. echo perleval('[1 .. 4]')
  5879. < [1, 2, 3, 4]
  5880. Parameters: ~
  5881. • {expr} (`any`)
  5882. Return: ~
  5883. (`any`)
  5884. pow({x}, {y}) *pow()*
  5885. Return the power of {x} to the exponent {y} as a |Float|.
  5886. {x} and {y} must evaluate to a |Float| or a |Number|.
  5887. Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
  5888. Examples: >vim
  5889. echo pow(3, 3)
  5890. < 27.0 >vim
  5891. echo pow(2, 16)
  5892. < 65536.0 >vim
  5893. echo pow(32, 0.20)
  5894. < 2.0
  5895. Parameters: ~
  5896. • {x} (`number`)
  5897. • {y} (`number`)
  5898. Return: ~
  5899. (`any`)
  5900. prevnonblank({lnum}) *prevnonblank()*
  5901. Return the line number of the first line at or above {lnum}
  5902. that is not blank. Example: >vim
  5903. let ind = indent(prevnonblank(v:lnum - 1))
  5904. < When {lnum} is invalid or there is no non-blank line at or
  5905. above it, zero is returned.
  5906. {lnum} is used like with |getline()|.
  5907. Also see |nextnonblank()|.
  5908. Parameters: ~
  5909. • {lnum} (`integer`)
  5910. Return: ~
  5911. (`any`)
  5912. printf({fmt}, {expr1} ...) *printf()*
  5913. Return a String with {fmt}, where "%" items are replaced by
  5914. the formatted form of their respective arguments. Example: >vim
  5915. echo printf("%4d: E%d %.30s", lnum, errno, msg)
  5916. < May result in:
  5917. " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
  5918. When used as a |method| the base is passed as the second
  5919. argument: >vim
  5920. Compute()->printf("result: %d")
  5921. <
  5922. You can use `call()` to pass the items as a list.
  5923. Often used items are:
  5924. %s string
  5925. %6S string right-aligned in 6 display cells
  5926. %6s string right-aligned in 6 bytes
  5927. %.9s string truncated to 9 bytes
  5928. %c single byte
  5929. %d decimal number
  5930. %5d decimal number padded with spaces to 5 characters
  5931. %b binary number
  5932. %08b binary number padded with zeros to at least 8 characters
  5933. %B binary number using upper case letters
  5934. %x hex number
  5935. %04x hex number padded with zeros to at least 4 characters
  5936. %X hex number using upper case letters
  5937. %o octal number
  5938. %f floating point number as 12.23, inf, -inf or nan
  5939. %F floating point number as 12.23, INF, -INF or NAN
  5940. %e floating point number as 1.23e3, inf, -inf or nan
  5941. %E floating point number as 1.23E3, INF, -INF or NAN
  5942. %g floating point number, as %f or %e depending on value
  5943. %G floating point number, as %F or %E depending on value
  5944. %% the % character itself
  5945. %p representation of the pointer to the container
  5946. Conversion specifications start with '%' and end with the
  5947. conversion type. All other characters are copied unchanged to
  5948. the result.
  5949. The "%" starts a conversion specification. The following
  5950. arguments appear in sequence:
  5951. % [pos-argument] [flags] [field-width] [.precision] type
  5952. pos-argument
  5953. At most one positional argument specifier. These
  5954. take the form {n$}, where n is >= 1.
  5955. flags
  5956. Zero or more of the following flags:
  5957. # The value should be converted to an "alternate
  5958. form". For c, d, and s conversions, this option
  5959. has no effect. For o conversions, the precision
  5960. of the number is increased to force the first
  5961. character of the output string to a zero (except
  5962. if a zero value is printed with an explicit
  5963. precision of zero).
  5964. For x and X conversions, a non-zero result has
  5965. the string "0x" (or "0X" for X conversions)
  5966. prepended to it.
  5967. 0 (zero) Zero padding. For all conversions the converted
  5968. value is padded on the left with zeros rather
  5969. than blanks. If a precision is given with a
  5970. numeric conversion (d, o, x, and X), the 0 flag
  5971. is ignored.
  5972. - A negative field width flag; the converted value
  5973. is to be left adjusted on the field boundary.
  5974. The converted value is padded on the right with
  5975. blanks, rather than on the left with blanks or
  5976. zeros. A - overrides a 0 if both are given.
  5977. ' ' (space) A blank should be left before a positive
  5978. number produced by a signed conversion (d).
  5979. + A sign must always be placed before a number
  5980. produced by a signed conversion. A + overrides
  5981. a space if both are used.
  5982. field-width
  5983. An optional decimal digit string specifying a minimum
  5984. field width. If the converted value has fewer bytes
  5985. than the field width, it will be padded with spaces on
  5986. the left (or right, if the left-adjustment flag has
  5987. been given) to fill out the field width. For the S
  5988. conversion the count is in cells.
  5989. .precision
  5990. An optional precision, in the form of a period '.'
  5991. followed by an optional digit string. If the digit
  5992. string is omitted, the precision is taken as zero.
  5993. This gives the minimum number of digits to appear for
  5994. d, o, x, and X conversions, the maximum number of
  5995. bytes to be printed from a string for s conversions,
  5996. or the maximum number of cells to be printed from a
  5997. string for S conversions.
  5998. For floating point it is the number of digits after
  5999. the decimal point.
  6000. type
  6001. A character that specifies the type of conversion to
  6002. be applied, see below.
  6003. A field width or precision, or both, may be indicated by an
  6004. asterisk "*" instead of a digit string. In this case, a
  6005. Number argument supplies the field width or precision. A
  6006. negative field width is treated as a left adjustment flag
  6007. followed by a positive field width; a negative precision is
  6008. treated as though it were missing. Example: >vim
  6009. echo printf("%d: %.*s", nr, width, line)
  6010. < This limits the length of the text used from "line" to
  6011. "width" bytes.
  6012. If the argument to be formatted is specified using a
  6013. positional argument specifier, and a '*' is used to indicate
  6014. that a number argument is to be used to specify the width or
  6015. precision, the argument(s) to be used must also be specified
  6016. using a {n$} positional argument specifier. See |printf-$|.
  6017. The conversion specifiers and their meanings are:
  6018. *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
  6019. dbBoxX The Number argument is converted to signed decimal (d),
  6020. unsigned binary (b and B), unsigned octal (o), or
  6021. unsigned hexadecimal (x and X) notation. The letters
  6022. "abcdef" are used for x conversions; the letters
  6023. "ABCDEF" are used for X conversions. The precision, if
  6024. any, gives the minimum number of digits that must
  6025. appear; if the converted value requires fewer digits, it
  6026. is padded on the left with zeros. In no case does a
  6027. non-existent or small field width cause truncation of a
  6028. numeric field; if the result of a conversion is wider
  6029. than the field width, the field is expanded to contain
  6030. the conversion result.
  6031. The 'h' modifier indicates the argument is 16 bits.
  6032. The 'l' modifier indicates the argument is a long
  6033. integer. The size will be 32 bits or 64 bits
  6034. depending on your platform.
  6035. The "ll" modifier indicates the argument is 64 bits.
  6036. The b and B conversion specifiers never take a width
  6037. modifier and always assume their argument is a 64 bit
  6038. integer.
  6039. Generally, these modifiers are not useful. They are
  6040. ignored when type is known from the argument.
  6041. i alias for d
  6042. D alias for ld
  6043. U alias for lu
  6044. O alias for lo
  6045. *printf-c*
  6046. c The Number argument is converted to a byte, and the
  6047. resulting character is written.
  6048. *printf-s*
  6049. s The text of the String argument is used. If a
  6050. precision is specified, no more bytes than the number
  6051. specified are used.
  6052. If the argument is not a String type, it is
  6053. automatically converted to text with the same format
  6054. as ":echo".
  6055. *printf-S*
  6056. S The text of the String argument is used. If a
  6057. precision is specified, no more display cells than the
  6058. number specified are used.
  6059. *printf-f* *E807*
  6060. f F The Float argument is converted into a string of the
  6061. form 123.456. The precision specifies the number of
  6062. digits after the decimal point. When the precision is
  6063. zero the decimal point is omitted. When the precision
  6064. is not specified 6 is used. A really big number
  6065. (out of range or dividing by zero) results in "inf"
  6066. or "-inf" with %f (INF or -INF with %F).
  6067. "0.0 / 0.0" results in "nan" with %f (NAN with %F).
  6068. Example: >vim
  6069. echo printf("%.2f", 12.115)
  6070. < 12.12
  6071. Note that roundoff depends on the system libraries.
  6072. Use |round()| when in doubt.
  6073. *printf-e* *printf-E*
  6074. e E The Float argument is converted into a string of the
  6075. form 1.234e+03 or 1.234E+03 when using 'E'. The
  6076. precision specifies the number of digits after the
  6077. decimal point, like with 'f'.
  6078. *printf-g* *printf-G*
  6079. g G The Float argument is converted like with 'f' if the
  6080. value is between 0.001 (inclusive) and 10000000.0
  6081. (exclusive). Otherwise 'e' is used for 'g' and 'E'
  6082. for 'G'. When no precision is specified superfluous
  6083. zeroes and '+' signs are removed, except for the zero
  6084. immediately after the decimal point. Thus 10000000.0
  6085. results in 1.0e7.
  6086. *printf-%*
  6087. % A '%' is written. No argument is converted. The
  6088. complete conversion specification is "%%".
  6089. When a Number argument is expected a String argument is also
  6090. accepted and automatically converted.
  6091. When a Float or String argument is expected a Number argument
  6092. is also accepted and automatically converted.
  6093. Any other argument type results in an error message.
  6094. *E766* *E767*
  6095. The number of {exprN} arguments must exactly match the number
  6096. of "%" items. If there are not sufficient or too many
  6097. arguments an error is given. Up to 18 arguments can be used.
  6098. *printf-$*
  6099. In certain languages, error and informative messages are
  6100. more readable when the order of words is different from the
  6101. corresponding message in English. To accommodate translations
  6102. having a different word order, positional arguments may be
  6103. used to indicate this. For instance: >vim
  6104. #, c-format
  6105. msgid "%s returning %s"
  6106. msgstr "waarde %2$s komt terug van %1$s"
  6107. <
  6108. In this example, the sentence has its 2 string arguments
  6109. reversed in the output. >vim
  6110. echo printf(
  6111. "In The Netherlands, vim's creator's name is: %1$s %2$s",
  6112. "Bram", "Moolenaar")
  6113. < In The Netherlands, vim's creator's name is: Bram Moolenaar >vim
  6114. echo printf(
  6115. "In Belgium, vim's creator's name is: %2$s %1$s",
  6116. "Bram", "Moolenaar")
  6117. < In Belgium, vim's creator's name is: Moolenaar Bram
  6118. Width (and precision) can be specified using the '*' specifier.
  6119. In this case, you must specify the field width position in the
  6120. argument list. >vim
  6121. echo printf("%1$*2$.*3$d", 1, 2, 3)
  6122. < 001 >vim
  6123. echo printf("%2$*3$.*1$d", 1, 2, 3)
  6124. < 2 >vim
  6125. echo printf("%3$*1$.*2$d", 1, 2, 3)
  6126. < 03 >vim
  6127. echo printf("%1$*2$.*3$g", 1.4142, 2, 3)
  6128. < 1.414
  6129. You can mix specifying the width and/or precision directly
  6130. and via positional arguments: >vim
  6131. echo printf("%1$4.*2$f", 1.4142135, 6)
  6132. < 1.414214 >vim
  6133. echo printf("%1$*2$.4f", 1.4142135, 6)
  6134. < 1.4142 >vim
  6135. echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
  6136. < 1.41
  6137. You will get an overflow error |E1510|, when the field-width
  6138. or precision will result in a string longer than 6400 chars.
  6139. *E1500*
  6140. You cannot mix positional and non-positional arguments: >vim
  6141. echo printf("%s%1$s", "One", "Two")
  6142. < E1500: Cannot mix positional and non-positional arguments:
  6143. %s%1$s
  6144. *E1501*
  6145. You cannot skip a positional argument in a format string: >vim
  6146. echo printf("%3$s%1$s", "One", "Two", "Three")
  6147. < E1501: format argument 2 unused in $-style format:
  6148. %3$s%1$s
  6149. *E1502*
  6150. You can re-use a [field-width] (or [precision]) argument: >vim
  6151. echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
  6152. < 1 at width 2 is: 01
  6153. However, you can't use it as a different type: >vim
  6154. echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
  6155. < E1502: Positional argument 2 used as field width reused as
  6156. different type: long int/int
  6157. *E1503*
  6158. When a positional argument is used, but not the correct number
  6159. or arguments is given, an error is raised: >vim
  6160. echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
  6161. < E1503: Positional argument 3 out of bounds: %1$d at width
  6162. %2$d is: %01$*2$.*3$d
  6163. Only the first error is reported: >vim
  6164. echo printf("%01$*2$.*3$d %4$d", 1, 2)
  6165. < E1503: Positional argument 3 out of bounds: %01$*2$.*3$d
  6166. %4$d
  6167. *E1504*
  6168. A positional argument can be used more than once: >vim
  6169. echo printf("%1$s %2$s %1$s", "One", "Two")
  6170. < One Two One
  6171. However, you can't use a different type the second time: >vim
  6172. echo printf("%1$s %2$s %1$d", "One", "Two")
  6173. < E1504: Positional argument 1 type used inconsistently:
  6174. int/string
  6175. *E1505*
  6176. Various other errors that lead to a format string being
  6177. wrongly formatted lead to: >vim
  6178. echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
  6179. < E1505: Invalid format specifier: %1$d at width %2$d is:
  6180. %01$*2$.3$d
  6181. *E1507*
  6182. This internal error indicates that the logic to parse a
  6183. positional format argument ran into a problem that couldn't be
  6184. otherwise reported. Please file a bug against Vim if you run
  6185. into this, copying the exact format string and parameters that
  6186. were used.
  6187. Parameters: ~
  6188. • {fmt} (`string`)
  6189. • {expr1} (`any?`)
  6190. Return: ~
  6191. (`string`)
  6192. prompt_getprompt({buf}) *prompt_getprompt()*
  6193. Returns the effective prompt text for buffer {buf}. {buf} can
  6194. be a buffer name or number. See |prompt-buffer|.
  6195. If the buffer doesn't exist or isn't a prompt buffer, an empty
  6196. string is returned.
  6197. Parameters: ~
  6198. • {buf} (`integer|string`)
  6199. Return: ~
  6200. (`any`)
  6201. prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
  6202. Set prompt callback for buffer {buf} to {expr}. When {expr}
  6203. is an empty string the callback is removed. This has only
  6204. effect if {buf} has 'buftype' set to "prompt".
  6205. The callback is invoked when pressing Enter. The current
  6206. buffer will always be the prompt buffer. A new line for a
  6207. prompt is added before invoking the callback, thus the prompt
  6208. for which the callback was invoked will be in the last but one
  6209. line.
  6210. If the callback wants to add text to the buffer, it must
  6211. insert it above the last line, since that is where the current
  6212. prompt is. This can also be done asynchronously.
  6213. The callback is invoked with one argument, which is the text
  6214. that was entered at the prompt. This can be an empty string
  6215. if the user only typed Enter.
  6216. Example: >vim
  6217. func s:TextEntered(text)
  6218. if a:text == 'exit' || a:text == 'quit'
  6219. stopinsert
  6220. " Reset 'modified' to allow the buffer to be closed.
  6221. " We assume there is nothing useful to be saved.
  6222. set nomodified
  6223. close
  6224. else
  6225. " Do something useful with "a:text". In this example
  6226. " we just repeat it.
  6227. call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
  6228. endif
  6229. endfunc
  6230. call prompt_setcallback(bufnr(), function('s:TextEntered'))
  6231. Parameters: ~
  6232. • {buf} (`integer|string`)
  6233. • {expr} (`string|function`)
  6234. Return: ~
  6235. (`any`)
  6236. prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
  6237. Set a callback for buffer {buf} to {expr}. When {expr} is an
  6238. empty string the callback is removed. This has only effect if
  6239. {buf} has 'buftype' set to "prompt".
  6240. This callback will be invoked when pressing CTRL-C in Insert
  6241. mode. Without setting a callback Vim will exit Insert mode,
  6242. as in any buffer.
  6243. Parameters: ~
  6244. • {buf} (`integer|string`)
  6245. • {expr} (`string|function`)
  6246. Return: ~
  6247. (`any`)
  6248. prompt_setprompt({buf}, {text}) *prompt_setprompt()*
  6249. Set prompt for buffer {buf} to {text}. You most likely want
  6250. {text} to end in a space.
  6251. The result is only visible if {buf} has 'buftype' set to
  6252. "prompt". Example: >vim
  6253. call prompt_setprompt(bufnr(''), 'command: ')
  6254. <
  6255. Parameters: ~
  6256. • {buf} (`integer|string`)
  6257. • {text} (`string`)
  6258. Return: ~
  6259. (`any`)
  6260. pum_getpos() *pum_getpos()*
  6261. If the popup menu (see |ins-completion-menu|) is not visible,
  6262. returns an empty |Dictionary|, otherwise, returns a
  6263. |Dictionary| with the following keys:
  6264. height nr of items visible
  6265. width screen cells
  6266. row top screen row (0 first row)
  6267. col leftmost screen column (0 first col)
  6268. size total nr of items
  6269. scrollbar |TRUE| if scrollbar is visible
  6270. The values are the same as in |v:event| during |CompleteChanged|.
  6271. Return: ~
  6272. (`any`)
  6273. pumvisible() *pumvisible()*
  6274. Returns non-zero when the popup menu is visible, zero
  6275. otherwise. See |ins-completion-menu|.
  6276. This can be used to avoid some things that would remove the
  6277. popup menu.
  6278. Return: ~
  6279. (`any`)
  6280. py3eval({expr}) *py3eval()*
  6281. Evaluate Python expression {expr} and return its result
  6282. converted to Vim data structures.
  6283. Numbers and strings are returned as they are (strings are
  6284. copied though, Unicode strings are additionally converted to
  6285. UTF-8).
  6286. Lists are represented as Vim |List| type.
  6287. Dictionaries are represented as Vim |Dictionary| type with
  6288. keys converted to strings.
  6289. Parameters: ~
  6290. • {expr} (`any`)
  6291. Return: ~
  6292. (`any`)
  6293. pyeval({expr}) *pyeval()* *E858* *E859*
  6294. Evaluate Python expression {expr} and return its result
  6295. converted to Vim data structures.
  6296. Numbers and strings are returned as they are (strings are
  6297. copied though).
  6298. Lists are represented as Vim |List| type.
  6299. Dictionaries are represented as Vim |Dictionary| type,
  6300. non-string keys result in error.
  6301. Parameters: ~
  6302. • {expr} (`any`)
  6303. Return: ~
  6304. (`any`)
  6305. pyxeval({expr}) *pyxeval()*
  6306. Evaluate Python expression {expr} and return its result
  6307. converted to Vim data structures.
  6308. Uses Python 2 or 3, see |python_x| and 'pyxversion'.
  6309. See also: |pyeval()|, |py3eval()|
  6310. Parameters: ~
  6311. • {expr} (`any`)
  6312. Return: ~
  6313. (`any`)
  6314. rand([{expr}]) *rand()*
  6315. Return a pseudo-random Number generated with an xoshiro128**
  6316. algorithm using seed {expr}. The returned number is 32 bits,
  6317. also on 64 bits systems, for consistency.
  6318. {expr} can be initialized by |srand()| and will be updated by
  6319. rand(). If {expr} is omitted, an internal seed value is used
  6320. and updated.
  6321. Returns -1 if {expr} is invalid.
  6322. Examples: >vim
  6323. echo rand()
  6324. let seed = srand()
  6325. echo rand(seed)
  6326. echo rand(seed) % 16 " random number 0 - 15
  6327. <
  6328. Parameters: ~
  6329. • {expr} (`number?`)
  6330. Return: ~
  6331. (`any`)
  6332. range({expr} [, {max} [, {stride}]]) *range()* *E726* *E727*
  6333. Returns a |List| with Numbers:
  6334. - If only {expr} is specified: [0, 1, ..., {expr} - 1]
  6335. - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
  6336. - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
  6337. {max}] (increasing {expr} with {stride} each time, not
  6338. producing a value past {max}).
  6339. When the maximum is one before the start the result is an
  6340. empty list. When the maximum is more than one before the
  6341. start this is an error.
  6342. Examples: >vim
  6343. echo range(4) " [0, 1, 2, 3]
  6344. echo range(2, 4) " [2, 3, 4]
  6345. echo range(2, 9, 3) " [2, 5, 8]
  6346. echo range(2, -2, -1) " [2, 1, 0, -1, -2]
  6347. echo range(0) " []
  6348. echo range(2, 0) " error!
  6349. <
  6350. Parameters: ~
  6351. • {expr} (`any`)
  6352. • {max} (`integer?`)
  6353. • {stride} (`integer?`)
  6354. Return: ~
  6355. (`any`)
  6356. readblob({fname} [, {offset} [, {size}]]) *readblob()*
  6357. Read file {fname} in binary mode and return a |Blob|.
  6358. If {offset} is specified, read the file from the specified
  6359. offset. If it is a negative value, it is used as an offset
  6360. from the end of the file. E.g., to read the last 12 bytes: >vim
  6361. echo readblob('file.bin', -12)
  6362. < If {size} is specified, only the specified size will be read.
  6363. E.g. to read the first 100 bytes of a file: >vim
  6364. echo readblob('file.bin', 0, 100)
  6365. < If {size} is -1 or omitted, the whole data starting from
  6366. {offset} will be read.
  6367. This can be also used to read the data from a character device
  6368. on Unix when {size} is explicitly set. Only if the device
  6369. supports seeking {offset} can be used. Otherwise it should be
  6370. zero. E.g. to read 10 bytes from a serial console: >vim
  6371. echo readblob('/dev/ttyS0', 0, 10)
  6372. < When the file can't be opened an error message is given and
  6373. the result is an empty |Blob|.
  6374. When the offset is beyond the end of the file the result is an
  6375. empty blob.
  6376. When trying to read more bytes than are available the result
  6377. is truncated.
  6378. Also see |readfile()| and |writefile()|.
  6379. Parameters: ~
  6380. • {fname} (`string`)
  6381. • {offset} (`integer?`)
  6382. • {size} (`integer?`)
  6383. Return: ~
  6384. (`any`)
  6385. readdir({directory} [, {expr}]) *readdir()*
  6386. Return a list with file and directory names in {directory}.
  6387. You can also use |glob()| if you don't need to do complicated
  6388. things, such as limiting the number of matches.
  6389. When {expr} is omitted all entries are included.
  6390. When {expr} is given, it is evaluated to check what to do:
  6391. If {expr} results in -1 then no further entries will
  6392. be handled.
  6393. If {expr} results in 0 then this entry will not be
  6394. added to the list.
  6395. If {expr} results in 1 then this entry will be added
  6396. to the list.
  6397. Each time {expr} is evaluated |v:val| is set to the entry name.
  6398. When {expr} is a function the name is passed as the argument.
  6399. For example, to get a list of files ending in ".txt": >vim
  6400. echo readdir(dirname, {n -> n =~ '.txt$'})
  6401. < To skip hidden and backup files: >vim
  6402. echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
  6403. < If you want to get a directory tree: >vim
  6404. function! s:tree(dir)
  6405. return {a:dir : map(readdir(a:dir),
  6406. \ {_, x -> isdirectory(x) ?
  6407. \ {x : s:tree(a:dir .. '/' .. x)} : x})}
  6408. endfunction
  6409. echo s:tree(".")
  6410. <
  6411. Returns an empty List on error.
  6412. Parameters: ~
  6413. • {directory} (`string`)
  6414. • {expr} (`integer?`)
  6415. Return: ~
  6416. (`any`)
  6417. readfile({fname} [, {type} [, {max}]]) *readfile()*
  6418. Read file {fname} and return a |List|, each line of the file
  6419. as an item. Lines are broken at NL characters. Macintosh
  6420. files separated with CR will result in a single long line
  6421. (unless a NL appears somewhere).
  6422. All NUL characters are replaced with a NL character.
  6423. When {type} contains "b" binary mode is used:
  6424. - When the last line ends in a NL an extra empty list item is
  6425. added.
  6426. - No CR characters are removed.
  6427. Otherwise:
  6428. - CR characters that appear before a NL are removed.
  6429. - Whether the last line ends in a NL or not does not matter.
  6430. - Any UTF-8 byte order mark is removed from the text.
  6431. When {max} is given this specifies the maximum number of lines
  6432. to be read. Useful if you only want to check the first ten
  6433. lines of a file: >vim
  6434. for line in readfile(fname, '', 10)
  6435. if line =~ 'Date' | echo line | endif
  6436. endfor
  6437. < When {max} is negative -{max} lines from the end of the file
  6438. are returned, or as many as there are.
  6439. When {max} is zero the result is an empty list.
  6440. Note that without {max} the whole file is read into memory.
  6441. Also note that there is no recognition of encoding. Read a
  6442. file into a buffer if you need to.
  6443. Deprecated (use |readblob()| instead): When {type} contains
  6444. "B" a |Blob| is returned with the binary data of the file
  6445. unmodified.
  6446. When the file can't be opened an error message is given and
  6447. the result is an empty list.
  6448. Also see |writefile()|.
  6449. Parameters: ~
  6450. • {fname} (`string`)
  6451. • {type} (`string?`)
  6452. • {max} (`integer?`)
  6453. Return: ~
  6454. (`any`)
  6455. reduce({object}, {func} [, {initial}]) *reduce()* *E998*
  6456. {func} is called for every item in {object}, which can be a
  6457. |String|, |List| or a |Blob|. {func} is called with two
  6458. arguments: the result so far and current item. After
  6459. processing all items the result is returned.
  6460. {initial} is the initial result. When omitted, the first item
  6461. in {object} is used and {func} is first called for the second
  6462. item. If {initial} is not given and {object} is empty no
  6463. result can be computed, an E998 error is given.
  6464. Examples: >vim
  6465. echo reduce([1, 3, 5], { acc, val -> acc + val })
  6466. echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
  6467. echo reduce(0z1122, { acc, val -> 2 * acc + val })
  6468. echo reduce('xyz', { acc, val -> acc .. ',' .. val })
  6469. <
  6470. Parameters: ~
  6471. • {object} (`any`)
  6472. • {func} (`function`)
  6473. • {initial} (`any?`)
  6474. Return: ~
  6475. (`any`)
  6476. reg_executing() *reg_executing()*
  6477. Returns the single letter name of the register being executed.
  6478. Returns an empty string when no register is being executed.
  6479. See |@|.
  6480. Return: ~
  6481. (`any`)
  6482. reg_recorded() *reg_recorded()*
  6483. Returns the single letter name of the last recorded register.
  6484. Returns an empty string when nothing was recorded yet.
  6485. See |q| and |Q|.
  6486. Return: ~
  6487. (`any`)
  6488. reg_recording() *reg_recording()*
  6489. Returns the single letter name of the register being recorded.
  6490. Returns an empty string when not recording. See |q|.
  6491. Return: ~
  6492. (`any`)
  6493. reltime() *reltime()*
  6494. reltime({start})
  6495. reltime({start}, {end})
  6496. Return an item that represents a time value. The item is a
  6497. list with items that depend on the system.
  6498. The item can be passed to |reltimestr()| to convert it to a
  6499. string or |reltimefloat()| to convert to a Float.
  6500. Without an argument it returns the current "relative time", an
  6501. implementation-defined value meaningful only when used as an
  6502. argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
  6503. With one argument it returns the time passed since the time
  6504. specified in the argument.
  6505. With two arguments it returns the time passed between {start}
  6506. and {end}.
  6507. The {start} and {end} arguments must be values returned by
  6508. reltime(). Returns zero on error.
  6509. Note: |localtime()| returns the current (non-relative) time.
  6510. Parameters: ~
  6511. • {start} (`any?`)
  6512. • {end} (`any?`)
  6513. Return: ~
  6514. (`any`)
  6515. reltimefloat({time}) *reltimefloat()*
  6516. Return a Float that represents the time value of {time}.
  6517. Unit of time is seconds.
  6518. Example:
  6519. let start = reltime()
  6520. call MyFunction()
  6521. let seconds = reltimefloat(reltime(start))
  6522. See the note of reltimestr() about overhead.
  6523. Also see |profiling|.
  6524. If there is an error an empty string is returned
  6525. Parameters: ~
  6526. • {time} (`any`)
  6527. Return: ~
  6528. (`any`)
  6529. reltimestr({time}) *reltimestr()*
  6530. Return a String that represents the time value of {time}.
  6531. This is the number of seconds, a dot and the number of
  6532. microseconds. Example: >vim
  6533. let start = reltime()
  6534. call MyFunction()
  6535. echo reltimestr(reltime(start))
  6536. < Note that overhead for the commands will be added to the time.
  6537. Leading spaces are used to make the string align nicely. You
  6538. can use split() to remove it. >vim
  6539. echo split(reltimestr(reltime(start)))[0]
  6540. < Also see |profiling|.
  6541. If there is an error an empty string is returned
  6542. Parameters: ~
  6543. • {time} (`any`)
  6544. Return: ~
  6545. (`any`)
  6546. remove({list}, {idx}) *remove()*
  6547. remove({list}, {idx}, {end})
  6548. Without {end}: Remove the item at {idx} from |List| {list} and
  6549. return the item.
  6550. With {end}: Remove items from {idx} to {end} (inclusive) and
  6551. return a |List| with these items. When {idx} points to the same
  6552. item as {end} a list with one item is returned. When {end}
  6553. points to an item before {idx} this is an error.
  6554. See |list-index| for possible values of {idx} and {end}.
  6555. Returns zero on error.
  6556. Example: >vim
  6557. echo "last item: " .. remove(mylist, -1)
  6558. call remove(mylist, 0, 9)
  6559. <
  6560. Use |delete()| to remove a file.
  6561. Parameters: ~
  6562. • {list} (`any[]`)
  6563. • {idx} (`integer`)
  6564. • {end} (`integer?`)
  6565. Return: ~
  6566. (`any`)
  6567. remove({blob}, {idx})
  6568. remove({blob}, {idx}, {end})
  6569. Without {end}: Remove the byte at {idx} from |Blob| {blob} and
  6570. return the byte.
  6571. With {end}: Remove bytes from {idx} to {end} (inclusive) and
  6572. return a |Blob| with these bytes. When {idx} points to the same
  6573. byte as {end} a |Blob| with one byte is returned. When {end}
  6574. points to a byte before {idx} this is an error.
  6575. Returns zero on error.
  6576. Example: >vim
  6577. echo "last byte: " .. remove(myblob, -1)
  6578. call remove(mylist, 0, 9)
  6579. <
  6580. Parameters: ~
  6581. • {blob} (`any`)
  6582. • {idx} (`integer`)
  6583. • {end} (`integer?`)
  6584. Return: ~
  6585. (`any`)
  6586. remove({dict}, {key})
  6587. Remove the entry from {dict} with key {key} and return it.
  6588. Example: >vim
  6589. echo "removed " .. remove(dict, "one")
  6590. < If there is no {key} in {dict} this is an error.
  6591. Returns zero on error.
  6592. Parameters: ~
  6593. • {dict} (`any`)
  6594. • {key} (`string`)
  6595. Return: ~
  6596. (`any`)
  6597. rename({from}, {to}) *rename()*
  6598. Rename the file by the name {from} to the name {to}. This
  6599. should also work to move files across file systems. The
  6600. result is a Number, which is 0 if the file was renamed
  6601. successfully, and non-zero when the renaming failed.
  6602. NOTE: If {to} exists it is overwritten without warning.
  6603. This function is not available in the |sandbox|.
  6604. Parameters: ~
  6605. • {from} (`string`)
  6606. • {to} (`string`)
  6607. Return: ~
  6608. (`any`)
  6609. repeat({expr}, {count}) *repeat()*
  6610. Repeat {expr} {count} times and return the concatenated
  6611. result. Example: >vim
  6612. let separator = repeat('-', 80)
  6613. < When {count} is zero or negative the result is empty.
  6614. When {expr} is a |List| or a |Blob| the result is {expr}
  6615. concatenated {count} times. Example: >vim
  6616. let longlist = repeat(['a', 'b'], 3)
  6617. < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
  6618. Parameters: ~
  6619. • {expr} (`any`)
  6620. • {count} (`integer`)
  6621. Return: ~
  6622. (`any`)
  6623. resolve({filename}) *resolve()* *E655*
  6624. On MS-Windows, when {filename} is a shortcut (a .lnk file),
  6625. returns the path the shortcut points to in a simplified form.
  6626. On Unix, repeat resolving symbolic links in all path
  6627. components of {filename} and return the simplified result.
  6628. To cope with link cycles, resolving of symbolic links is
  6629. stopped after 100 iterations.
  6630. On other systems, return the simplified {filename}.
  6631. The simplification step is done as by |simplify()|.
  6632. resolve() keeps a leading path component specifying the
  6633. current directory (provided the result is still a relative
  6634. path name) and also keeps a trailing path separator.
  6635. Parameters: ~
  6636. • {filename} (`string`)
  6637. Return: ~
  6638. (`any`)
  6639. reverse({object}) *reverse()*
  6640. Reverse the order of items in {object}. {object} can be a
  6641. |List|, a |Blob| or a |String|. For a List and a Blob the
  6642. items are reversed in-place and {object} is returned.
  6643. For a String a new String is returned.
  6644. Returns zero if {object} is not a List, Blob or a String.
  6645. If you want a List or Blob to remain unmodified make a copy
  6646. first: >vim
  6647. let revlist = reverse(copy(mylist))
  6648. <
  6649. Parameters: ~
  6650. • {object} (`any`)
  6651. Return: ~
  6652. (`any`)
  6653. round({expr}) *round()*
  6654. Round off {expr} to the nearest integral value and return it
  6655. as a |Float|. If {expr} lies halfway between two integral
  6656. values, then use the larger one (away from zero).
  6657. {expr} must evaluate to a |Float| or a |Number|.
  6658. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  6659. Examples: >vim
  6660. echo round(0.456)
  6661. < 0.0 >vim
  6662. echo round(4.5)
  6663. < 5.0 >vim
  6664. echo round(-4.5)
  6665. < -5.0
  6666. Parameters: ~
  6667. • {expr} (`number`)
  6668. Return: ~
  6669. (`any`)
  6670. rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()*
  6671. Sends {event} to {channel} via |RPC| and returns immediately.
  6672. If {channel} is 0, the event is broadcast to all channels.
  6673. Example: >vim
  6674. au VimLeave call rpcnotify(0, "leaving")
  6675. <
  6676. Parameters: ~
  6677. • {channel} (`integer`)
  6678. • {event} (`string`)
  6679. • {...} (`any`)
  6680. Return: ~
  6681. (`any`)
  6682. rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()*
  6683. Sends a request to {channel} to invoke {method} via
  6684. |RPC| and blocks until a response is received.
  6685. Example: >vim
  6686. let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
  6687. <
  6688. Parameters: ~
  6689. • {channel} (`integer`)
  6690. • {method} (`string`)
  6691. • {...} (`any`)
  6692. Return: ~
  6693. (`any`)
  6694. rubyeval({expr}) *rubyeval()*
  6695. Evaluate Ruby expression {expr} and return its result
  6696. converted to Vim data structures.
  6697. Numbers, floats and strings are returned as they are (strings
  6698. are copied though).
  6699. Arrays are represented as Vim |List| type.
  6700. Hashes are represented as Vim |Dictionary| type.
  6701. Other objects are represented as strings resulted from their
  6702. "Object#to_s" method.
  6703. Parameters: ~
  6704. • {expr} (`any`)
  6705. Return: ~
  6706. (`any`)
  6707. screenattr({row}, {col}) *screenattr()*
  6708. Like |screenchar()|, but return the attribute. This is a rather
  6709. arbitrary number that can only be used to compare to the
  6710. attribute at other positions.
  6711. Returns -1 when row or col is out of range.
  6712. Parameters: ~
  6713. • {row} (`integer`)
  6714. • {col} (`integer`)
  6715. Return: ~
  6716. (`any`)
  6717. screenchar({row}, {col}) *screenchar()*
  6718. The result is a Number, which is the character at position
  6719. [row, col] on the screen. This works for every possible
  6720. screen position, also status lines, window separators and the
  6721. command line. The top left position is row one, column one
  6722. The character excludes composing characters. For double-byte
  6723. encodings it may only be the first byte.
  6724. This is mainly to be used for testing.
  6725. Returns -1 when row or col is out of range.
  6726. Parameters: ~
  6727. • {row} (`integer`)
  6728. • {col} (`integer`)
  6729. Return: ~
  6730. (`any`)
  6731. screenchars({row}, {col}) *screenchars()*
  6732. The result is a |List| of Numbers. The first number is the same
  6733. as what |screenchar()| returns. Further numbers are
  6734. composing characters on top of the base character.
  6735. This is mainly to be used for testing.
  6736. Returns an empty List when row or col is out of range.
  6737. Parameters: ~
  6738. • {row} (`integer`)
  6739. • {col} (`integer`)
  6740. Return: ~
  6741. (`any`)
  6742. screencol() *screencol()*
  6743. The result is a Number, which is the current screen column of
  6744. the cursor. The leftmost column has number 1.
  6745. This function is mainly used for testing.
  6746. Note: Always returns the current screen column, thus if used
  6747. in a command (e.g. ":echo screencol()") it will return the
  6748. column inside the command line, which is 1 when the command is
  6749. executed. To get the cursor position in the file use one of
  6750. the following mappings: >vim
  6751. nnoremap <expr> GG ":echom " .. screencol() .. "\n"
  6752. nnoremap <silent> GG :echom screencol()<CR>
  6753. noremap GG <Cmd>echom screencol()<CR>
  6754. <
  6755. Return: ~
  6756. (`any`)
  6757. screenpos({winid}, {lnum}, {col}) *screenpos()*
  6758. The result is a Dict with the screen position of the text
  6759. character in window {winid} at buffer line {lnum} and column
  6760. {col}. {col} is a one-based byte index.
  6761. The Dict has these members:
  6762. row screen row
  6763. col first screen column
  6764. endcol last screen column
  6765. curscol cursor screen column
  6766. If the specified position is not visible, all values are zero.
  6767. The "endcol" value differs from "col" when the character
  6768. occupies more than one screen cell. E.g. for a Tab "col" can
  6769. be 1 and "endcol" can be 8.
  6770. The "curscol" value is where the cursor would be placed. For
  6771. a Tab it would be the same as "endcol", while for a double
  6772. width character it would be the same as "col".
  6773. The |conceal| feature is ignored here, the column numbers are
  6774. as if 'conceallevel' is zero. You can set the cursor to the
  6775. right position and use |screencol()| to get the value with
  6776. |conceal| taken into account.
  6777. If the position is in a closed fold the screen position of the
  6778. first character is returned, {col} is not used.
  6779. Returns an empty Dict if {winid} is invalid.
  6780. Parameters: ~
  6781. • {winid} (`integer`)
  6782. • {lnum} (`integer`)
  6783. • {col} (`integer`)
  6784. Return: ~
  6785. (`any`)
  6786. screenrow() *screenrow()*
  6787. The result is a Number, which is the current screen row of the
  6788. cursor. The top line has number one.
  6789. This function is mainly used for testing.
  6790. Alternatively you can use |winline()|.
  6791. Note: Same restrictions as with |screencol()|.
  6792. Return: ~
  6793. (`any`)
  6794. screenstring({row}, {col}) *screenstring()*
  6795. The result is a String that contains the base character and
  6796. any composing characters at position [row, col] on the screen.
  6797. This is like |screenchars()| but returning a String with the
  6798. characters.
  6799. This is mainly to be used for testing.
  6800. Returns an empty String when row or col is out of range.
  6801. Parameters: ~
  6802. • {row} (`integer`)
  6803. • {col} (`integer`)
  6804. Return: ~
  6805. (`any`)
  6806. search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()*
  6807. Search for regexp pattern {pattern}. The search starts at the
  6808. cursor position (you can use |cursor()| to set it).
  6809. When a match has been found its line number is returned.
  6810. If there is no match a 0 is returned and the cursor doesn't
  6811. move. No error message is given.
  6812. To get the matched string, use |matchbufline()|.
  6813. {flags} is a String, which can contain these character flags:
  6814. 'b' search Backward instead of forward
  6815. 'c' accept a match at the Cursor position
  6816. 'e' move to the End of the match
  6817. 'n' do Not move the cursor
  6818. 'p' return number of matching sub-Pattern (see below)
  6819. 's' Set the ' mark at the previous location of the cursor
  6820. 'w' Wrap around the end of the file
  6821. 'W' don't Wrap around the end of the file
  6822. 'z' start searching at the cursor column instead of Zero
  6823. If neither 'w' or 'W' is given, the 'wrapscan' option applies.
  6824. If the 's' flag is supplied, the ' mark is set, only if the
  6825. cursor is moved. The 's' flag cannot be combined with the 'n'
  6826. flag.
  6827. 'ignorecase', 'smartcase' and 'magic' are used.
  6828. When the 'z' flag is not given, forward searching always
  6829. starts in column zero and then matches before the cursor are
  6830. skipped. When the 'c' flag is present in 'cpo' the next
  6831. search starts after the match. Without the 'c' flag the next
  6832. search starts one column after the start of the match. This
  6833. matters for overlapping matches. See |cpo-c|. You can also
  6834. insert "\ze" to change where the match ends, see |/\ze|.
  6835. When searching backwards and the 'z' flag is given then the
  6836. search starts in column zero, thus no match in the current
  6837. line will be found (unless wrapping around the end of the
  6838. file).
  6839. When the {stopline} argument is given then the search stops
  6840. after searching this line. This is useful to restrict the
  6841. search to a range of lines. Examples: >vim
  6842. let match = search('(', 'b', line("w0"))
  6843. let end = search('END', '', line("w$"))
  6844. < When {stopline} is used and it is not zero this also implies
  6845. that the search does not wrap around the end of the file.
  6846. A zero value is equal to not giving the argument.
  6847. When the {timeout} argument is given the search stops when
  6848. more than this many milliseconds have passed. Thus when
  6849. {timeout} is 500 the search stops after half a second.
  6850. The value must not be negative. A zero value is like not
  6851. giving the argument.
  6852. Note: the timeout is only considered when searching, not
  6853. while evaluating the {skip} expression.
  6854. If the {skip} expression is given it is evaluated with the
  6855. cursor positioned on the start of a match. If it evaluates to
  6856. non-zero this match is skipped. This can be used, for
  6857. example, to skip a match in a comment or a string.
  6858. {skip} can be a string, which is evaluated as an expression, a
  6859. function reference or a lambda.
  6860. When {skip} is omitted or empty, every match is accepted.
  6861. When evaluating {skip} causes an error the search is aborted
  6862. and -1 returned.
  6863. *search()-sub-match*
  6864. With the 'p' flag the returned value is one more than the
  6865. first sub-match in \(\). One if none of them matched but the
  6866. whole pattern did match.
  6867. To get the column number too use |searchpos()|.
  6868. The cursor will be positioned at the match, unless the 'n'
  6869. flag is used.
  6870. Example (goes over all files in the argument list): >vim
  6871. let n = 1
  6872. while n <= argc() " loop over all files in arglist
  6873. exe "argument " .. n
  6874. " start at the last char in the file and wrap for the
  6875. " first search to find match at start of file
  6876. normal G$
  6877. let flags = "w"
  6878. while search("foo", flags) > 0
  6879. s/foo/bar/g
  6880. let flags = "W"
  6881. endwhile
  6882. update " write the file if modified
  6883. let n = n + 1
  6884. endwhile
  6885. <
  6886. Example for using some flags: >vim
  6887. echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
  6888. < This will search for the keywords "if", "else", and "endif"
  6889. under or after the cursor. Because of the 'p' flag, it
  6890. returns 1, 2, or 3 depending on which keyword is found, or 0
  6891. if the search fails. With the cursor on the first word of the
  6892. line:
  6893. if (foo == 0) | let foo = foo + 1 | endif ~
  6894. the function returns 1. Without the 'c' flag, the function
  6895. finds the "endif" and returns 3. The same thing happens
  6896. without the 'e' flag if the cursor is on the "f" of "if".
  6897. The 'n' flag tells the function not to move the cursor.
  6898. Parameters: ~
  6899. • {pattern} (`string`)
  6900. • {flags} (`string?`)
  6901. • {stopline} (`integer?`)
  6902. • {timeout} (`integer?`)
  6903. • {skip} (`string|function?`)
  6904. Return: ~
  6905. (`any`)
  6906. searchcount([{options}]) *searchcount()*
  6907. Get or update the last search count, like what is displayed
  6908. without the "S" flag in 'shortmess'. This works even if
  6909. 'shortmess' does contain the "S" flag.
  6910. This returns a |Dictionary|. The dictionary is empty if the
  6911. previous pattern was not set and "pattern" was not specified.
  6912. key type meaning ~
  6913. current |Number| current position of match;
  6914. 0 if the cursor position is
  6915. before the first match
  6916. exact_match |Boolean| 1 if "current" is matched on
  6917. "pos", otherwise 0
  6918. total |Number| total count of matches found
  6919. incomplete |Number| 0: search was fully completed
  6920. 1: recomputing was timed out
  6921. 2: max count exceeded
  6922. For {options} see further down.
  6923. To get the last search count when |n| or |N| was pressed, call
  6924. this function with `recompute: 0` . This sometimes returns
  6925. wrong information because |n| and |N|'s maximum count is 99.
  6926. If it exceeded 99 the result must be max count + 1 (100). If
  6927. you want to get correct information, specify `recompute: 1`: >vim
  6928. " result == maxcount + 1 (100) when many matches
  6929. let result = searchcount(#{recompute: 0})
  6930. " Below returns correct result (recompute defaults
  6931. " to 1)
  6932. let result = searchcount()
  6933. <
  6934. The function is useful to add the count to 'statusline': >vim
  6935. function! LastSearchCount() abort
  6936. let result = searchcount(#{recompute: 0})
  6937. if empty(result)
  6938. return ''
  6939. endif
  6940. if result.incomplete ==# 1 " timed out
  6941. return printf(' /%s [?/??]', @/)
  6942. elseif result.incomplete ==# 2 " max count exceeded
  6943. if result.total > result.maxcount &&
  6944. \ result.current > result.maxcount
  6945. return printf(' /%s [>%d/>%d]', @/,
  6946. \ result.current, result.total)
  6947. elseif result.total > result.maxcount
  6948. return printf(' /%s [%d/>%d]', @/,
  6949. \ result.current, result.total)
  6950. endif
  6951. endif
  6952. return printf(' /%s [%d/%d]', @/,
  6953. \ result.current, result.total)
  6954. endfunction
  6955. let &statusline ..= '%{LastSearchCount()}'
  6956. " Or if you want to show the count only when
  6957. " 'hlsearch' was on
  6958. " let &statusline ..=
  6959. " \ '%{v:hlsearch ? LastSearchCount() : ""}'
  6960. <
  6961. You can also update the search count, which can be useful in a
  6962. |CursorMoved| or |CursorMovedI| autocommand: >vim
  6963. autocmd CursorMoved,CursorMovedI *
  6964. \ let s:searchcount_timer = timer_start(
  6965. \ 200, function('s:update_searchcount'))
  6966. function! s:update_searchcount(timer) abort
  6967. if a:timer ==# s:searchcount_timer
  6968. call searchcount(#{
  6969. \ recompute: 1, maxcount: 0, timeout: 100})
  6970. redrawstatus
  6971. endif
  6972. endfunction
  6973. <
  6974. This can also be used to count matched texts with specified
  6975. pattern in the current buffer using "pattern": >vim
  6976. " Count '\<foo\>' in this buffer
  6977. " (Note that it also updates search count)
  6978. let result = searchcount(#{pattern: '\<foo\>'})
  6979. " To restore old search count by old pattern,
  6980. " search again
  6981. call searchcount()
  6982. <
  6983. {options} must be a |Dictionary|. It can contain:
  6984. key type meaning ~
  6985. recompute |Boolean| if |TRUE|, recompute the count
  6986. like |n| or |N| was executed.
  6987. otherwise returns the last
  6988. computed result (when |n| or
  6989. |N| was used when "S" is not
  6990. in 'shortmess', or this
  6991. function was called).
  6992. (default: |TRUE|)
  6993. pattern |String| recompute if this was given
  6994. and different with |@/|.
  6995. this works as same as the
  6996. below command is executed
  6997. before calling this function >vim
  6998. let @/ = pattern
  6999. < (default: |@/|)
  7000. timeout |Number| 0 or negative number is no
  7001. timeout. timeout milliseconds
  7002. for recomputing the result
  7003. (default: 0)
  7004. maxcount |Number| 0 or negative number is no
  7005. limit. max count of matched
  7006. text while recomputing the
  7007. result. if search exceeded
  7008. total count, "total" value
  7009. becomes `maxcount + 1`
  7010. (default: 0)
  7011. pos |List| `[lnum, col, off]` value
  7012. when recomputing the result.
  7013. this changes "current" result
  7014. value. see |cursor()|, |getpos()|
  7015. (default: cursor's position)
  7016. Parameters: ~
  7017. • {options} (`table?`)
  7018. Return: ~
  7019. (`any`)
  7020. searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()*
  7021. Search for the declaration of {name}.
  7022. With a non-zero {global} argument it works like |gD|, find
  7023. first match in the file. Otherwise it works like |gd|, find
  7024. first match in the function.
  7025. With a non-zero {thisblock} argument matches in a {} block
  7026. that ends before the cursor position are ignored. Avoids
  7027. finding variable declarations only valid in another scope.
  7028. Moves the cursor to the found match.
  7029. Returns zero for success, non-zero for failure.
  7030. Example: >vim
  7031. if searchdecl('myvar') == 0
  7032. echo getline('.')
  7033. endif
  7034. <
  7035. Parameters: ~
  7036. • {name} (`string`)
  7037. • {global} (`boolean?`)
  7038. • {thisblock} (`boolean?`)
  7039. Return: ~
  7040. (`any`)
  7041. *searchpair()*
  7042. searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7043. Search for the match of a nested start-end pair. This can be
  7044. used to find the "endif" that matches an "if", while other
  7045. if/endif pairs in between are ignored.
  7046. The search starts at the cursor. The default is to search
  7047. forward, include 'b' in {flags} to search backward.
  7048. If a match is found, the cursor is positioned at it and the
  7049. line number is returned. If no match is found 0 or -1 is
  7050. returned and the cursor doesn't move. No error message is
  7051. given.
  7052. {start}, {middle} and {end} are patterns, see |pattern|. They
  7053. must not contain \( \) pairs. Use of \%( \) is allowed. When
  7054. {middle} is not empty, it is found when searching from either
  7055. direction, but only when not in a nested start-end pair. A
  7056. typical use is: >vim
  7057. echo searchpair('\<if\>', '\<else\>', '\<endif\>')
  7058. < By leaving {middle} empty the "else" is skipped.
  7059. {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
  7060. |search()|. Additionally:
  7061. 'r' Repeat until no more matches found; will find the
  7062. outer pair. Implies the 'W' flag.
  7063. 'm' Return number of matches instead of line number with
  7064. the match; will be > 1 when 'r' is used.
  7065. Note: it's nearly always a good idea to use the 'W' flag, to
  7066. avoid wrapping around the end of the file.
  7067. When a match for {start}, {middle} or {end} is found, the
  7068. {skip} expression is evaluated with the cursor positioned on
  7069. the start of the match. It should return non-zero if this
  7070. match is to be skipped. E.g., because it is inside a comment
  7071. or a string.
  7072. When {skip} is omitted or empty, every match is accepted.
  7073. When evaluating {skip} causes an error the search is aborted
  7074. and -1 returned.
  7075. {skip} can be a string, a lambda, a funcref or a partial.
  7076. Anything else makes the function fail.
  7077. For {stopline} and {timeout} see |search()|.
  7078. The value of 'ignorecase' is used. 'magic' is ignored, the
  7079. patterns are used like it's on.
  7080. The search starts exactly at the cursor. A match with
  7081. {start}, {middle} or {end} at the next character, in the
  7082. direction of searching, is the first one found. Example: >vim
  7083. if 1
  7084. if 2
  7085. endif 2
  7086. endif 1
  7087. < When starting at the "if 2", with the cursor on the "i", and
  7088. searching forwards, the "endif 2" is found. When starting on
  7089. the character just before the "if 2", the "endif 1" will be
  7090. found. That's because the "if 2" will be found first, and
  7091. then this is considered to be a nested if/endif from "if 2" to
  7092. "endif 2".
  7093. When searching backwards and {end} is more than one character,
  7094. it may be useful to put "\zs" at the end of the pattern, so
  7095. that when the cursor is inside a match with the end it finds
  7096. the matching start.
  7097. Example, to find the "endif" command in a Vim script: >vim
  7098. echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
  7099. \ 'getline(".") =~ "^\\s*\""')
  7100. < The cursor must be at or after the "if" for which a match is
  7101. to be found. Note that single-quote strings are used to avoid
  7102. having to double the backslashes. The skip expression only
  7103. catches comments at the start of a line, not after a command.
  7104. Also, a word "en" or "if" halfway through a line is considered
  7105. a match.
  7106. Another example, to search for the matching "{" of a "}": >vim
  7107. echo searchpair('{', '', '}', 'bW')
  7108. < This works when the cursor is at or before the "}" for which a
  7109. match is to be found. To reject matches that syntax
  7110. highlighting recognized as strings: >vim
  7111. echo searchpair('{', '', '}', 'bW',
  7112. \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
  7113. <
  7114. Parameters: ~
  7115. • {start} (`string`)
  7116. • {middle} (`string`)
  7117. • {end} (`string`)
  7118. • {flags} (`string?`)
  7119. • {skip} (`string|function?`)
  7120. • {stopline} (`integer?`)
  7121. • {timeout} (`integer?`)
  7122. Return: ~
  7123. (`integer`)
  7124. *searchpairpos()*
  7125. searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])
  7126. Same as |searchpair()|, but returns a |List| with the line and
  7127. column position of the match. The first element of the |List|
  7128. is the line number and the second element is the byte index of
  7129. the column position of the match. If no match is found,
  7130. returns [0, 0]. >vim
  7131. let [lnum,col] = searchpairpos('{', '', '}', 'n')
  7132. <
  7133. See |match-parens| for a bigger and more useful example.
  7134. Parameters: ~
  7135. • {start} (`string`)
  7136. • {middle} (`string`)
  7137. • {end} (`string`)
  7138. • {flags} (`string?`)
  7139. • {skip} (`string|function?`)
  7140. • {stopline} (`integer?`)
  7141. • {timeout} (`integer?`)
  7142. Return: ~
  7143. (`[integer, integer]`)
  7144. *searchpos()*
  7145. searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
  7146. Same as |search()|, but returns a |List| with the line and
  7147. column position of the match. The first element of the |List|
  7148. is the line number and the second element is the byte index of
  7149. the column position of the match. If no match is found,
  7150. returns [0, 0].
  7151. Example: >vim
  7152. let [lnum, col] = searchpos('mypattern', 'n')
  7153. < When the 'p' flag is given then there is an extra item with
  7154. the sub-pattern match number |search()-sub-match|. Example: >vim
  7155. let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
  7156. < In this example "submatch" is 2 when a lowercase letter is
  7157. found |/\l|, 3 when an uppercase letter is found |/\u|.
  7158. Parameters: ~
  7159. • {pattern} (`string`)
  7160. • {flags} (`string?`)
  7161. • {stopline} (`integer?`)
  7162. • {timeout} (`integer?`)
  7163. • {skip} (`string|function?`)
  7164. Return: ~
  7165. (`any`)
  7166. serverlist() *serverlist()*
  7167. Returns a list of server addresses, or empty if all servers
  7168. were stopped. |serverstart()| |serverstop()|
  7169. Example: >vim
  7170. echo serverlist()
  7171. <
  7172. Return: ~
  7173. (`any`)
  7174. serverstart([{address}]) *serverstart()*
  7175. Opens a socket or named pipe at {address} and listens for
  7176. |RPC| messages. Clients can send |API| commands to the
  7177. returned address to control Nvim.
  7178. Returns the address string (which may differ from the
  7179. {address} argument, see below).
  7180. - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
  7181. where the last ":" separates host and port (empty or zero
  7182. assigns a random port).
  7183. - Else {address} is the path to a named pipe (except on Windows).
  7184. - If {address} has no slashes ("/") it is treated as the
  7185. "name" part of a generated path in this format: >vim
  7186. stdpath("run").."/{name}.{pid}.{counter}"
  7187. < - If {address} is omitted the name is "nvim". >vim
  7188. echo serverstart()
  7189. < >
  7190. => /tmp/nvim.bram/oknANW/nvim.15430.5
  7191. <
  7192. Example bash command to list all Nvim servers: >bash
  7193. ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
  7194. < Example named pipe: >vim
  7195. if has('win32')
  7196. echo serverstart('\\.\pipe\nvim-pipe-1234')
  7197. else
  7198. echo serverstart('nvim.sock')
  7199. endif
  7200. <
  7201. Example TCP/IP address: >vim
  7202. echo serverstart('::1:12345')
  7203. <
  7204. Parameters: ~
  7205. • {address} (`string?`)
  7206. Return: ~
  7207. (`any`)
  7208. serverstop({address}) *serverstop()*
  7209. Closes the pipe or socket at {address}.
  7210. Returns TRUE if {address} is valid, else FALSE.
  7211. If |v:servername| is stopped it is set to the next available
  7212. address in |serverlist()|.
  7213. Parameters: ~
  7214. • {address} (`string`)
  7215. Return: ~
  7216. (`any`)
  7217. setbufline({buf}, {lnum}, {text}) *setbufline()*
  7218. Set line {lnum} to {text} in buffer {buf}. This works like
  7219. |setline()| for the specified buffer.
  7220. This function works only for loaded buffers. First call
  7221. |bufload()| if needed.
  7222. To insert lines use |appendbufline()|.
  7223. {text} can be a string to set one line, or a List of strings
  7224. to set multiple lines. If the List extends below the last
  7225. line then those lines are added. If the List is empty then
  7226. nothing is changed and zero is returned.
  7227. For the use of {buf}, see |bufname()| above.
  7228. {lnum} is used like with |setline()|.
  7229. Use "$" to refer to the last line in buffer {buf}.
  7230. When {lnum} is just below the last line the {text} will be
  7231. added below the last line.
  7232. On success 0 is returned, on failure 1 is returned.
  7233. If {buf} is not a valid buffer or {lnum} is not valid, an
  7234. error message is given.
  7235. Parameters: ~
  7236. • {buf} (`integer|string`)
  7237. • {lnum} (`integer`)
  7238. • {text} (`string|string[]`)
  7239. Return: ~
  7240. (`any`)
  7241. setbufvar({buf}, {varname}, {val}) *setbufvar()*
  7242. Set option or local variable {varname} in buffer {buf} to
  7243. {val}.
  7244. This also works for a global or local window option, but it
  7245. doesn't work for a global or local window variable.
  7246. For a local window option the global value is unchanged.
  7247. For the use of {buf}, see |bufname()| above.
  7248. The {varname} argument is a string.
  7249. Note that the variable name without "b:" must be used.
  7250. Examples: >vim
  7251. call setbufvar(1, "&mod", 1)
  7252. call setbufvar("todo", "myvar", "foobar")
  7253. < This function is not available in the |sandbox|.
  7254. Parameters: ~
  7255. • {buf} (`integer|string`)
  7256. • {varname} (`string`)
  7257. • {val} (`any`)
  7258. Return: ~
  7259. (`any`)
  7260. setcellwidths({list}) *setcellwidths()*
  7261. Specify overrides for cell widths of character ranges. This
  7262. tells Vim how wide characters are when displayed in the
  7263. terminal, counted in screen cells. The values override
  7264. 'ambiwidth'. Example: >vim
  7265. call setcellwidths([
  7266. \ [0x111, 0x111, 1],
  7267. \ [0x2194, 0x2199, 2],
  7268. \ ])
  7269. < The {list} argument is a List of Lists with each three
  7270. numbers: [{low}, {high}, {width}]. *E1109* *E1110*
  7271. {low} and {high} can be the same, in which case this refers to
  7272. one character. Otherwise it is the range of characters from
  7273. {low} to {high} (inclusive). *E1111* *E1114*
  7274. Only characters with value 0x80 and higher can be used.
  7275. {width} must be either 1 or 2, indicating the character width
  7276. in screen cells. *E1112*
  7277. An error is given if the argument is invalid, also when a
  7278. range overlaps with another. *E1113*
  7279. If the new value causes 'fillchars' or 'listchars' to become
  7280. invalid it is rejected and an error is given.
  7281. To clear the overrides pass an empty {list}: >vim
  7282. call setcellwidths([])
  7283. < You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
  7284. the effect for known emoji characters. Move the cursor
  7285. through the text to check if the cell widths of your terminal
  7286. match with what Vim knows about each emoji. If it doesn't
  7287. look right you need to adjust the {list} argument.
  7288. Parameters: ~
  7289. • {list} (`any[]`)
  7290. Return: ~
  7291. (`any`)
  7292. setcharpos({expr}, {list}) *setcharpos()*
  7293. Same as |setpos()| but uses the specified column number as the
  7294. character index instead of the byte index in the line.
  7295. Example:
  7296. With the text "여보세요" in line 8: >vim
  7297. call setcharpos('.', [0, 8, 4, 0])
  7298. < positions the cursor on the fourth character '요'. >vim
  7299. call setpos('.', [0, 8, 4, 0])
  7300. < positions the cursor on the second character '보'.
  7301. Parameters: ~
  7302. • {expr} (`string`)
  7303. • {list} (`integer[]`)
  7304. Return: ~
  7305. (`any`)
  7306. setcharsearch({dict}) *setcharsearch()*
  7307. Set the current character search information to {dict},
  7308. which contains one or more of the following entries:
  7309. char character which will be used for a subsequent
  7310. |,| or |;| command; an empty string clears the
  7311. character search
  7312. forward direction of character search; 1 for forward,
  7313. 0 for backward
  7314. until type of character search; 1 for a |t| or |T|
  7315. character search, 0 for an |f| or |F|
  7316. character search
  7317. This can be useful to save/restore a user's character search
  7318. from a script: >vim
  7319. let prevsearch = getcharsearch()
  7320. " Perform a command which clobbers user's search
  7321. call setcharsearch(prevsearch)
  7322. < Also see |getcharsearch()|.
  7323. Parameters: ~
  7324. • {dict} (`string`)
  7325. Return: ~
  7326. (`any`)
  7327. setcmdline({str} [, {pos}]) *setcmdline()*
  7328. Set the command line to {str} and set the cursor position to
  7329. {pos}.
  7330. If {pos} is omitted, the cursor is positioned after the text.
  7331. Returns 0 when successful, 1 when not editing the command
  7332. line.
  7333. Parameters: ~
  7334. • {str} (`string`)
  7335. • {pos} (`integer?`)
  7336. Return: ~
  7337. (`any`)
  7338. setcmdpos({pos}) *setcmdpos()*
  7339. Set the cursor position in the command line to byte position
  7340. {pos}. The first position is 1.
  7341. Use |getcmdpos()| to obtain the current position.
  7342. Only works while editing the command line, thus you must use
  7343. |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
  7344. |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
  7345. set after the command line is set to the expression. For
  7346. |c_CTRL-R_=| it is set after evaluating the expression but
  7347. before inserting the resulting text.
  7348. When the number is too big the cursor is put at the end of the
  7349. line. A number smaller than one has undefined results.
  7350. Returns 0 when successful, 1 when not editing the command
  7351. line.
  7352. Parameters: ~
  7353. • {pos} (`integer`)
  7354. Return: ~
  7355. (`any`)
  7356. setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()*
  7357. setcursorcharpos({list})
  7358. Same as |cursor()| but uses the specified column number as the
  7359. character index instead of the byte index in the line.
  7360. Example:
  7361. With the text "여보세요" in line 4: >vim
  7362. call setcursorcharpos(4, 3)
  7363. < positions the cursor on the third character '세'. >vim
  7364. call cursor(4, 3)
  7365. < positions the cursor on the first character '여'.
  7366. Parameters: ~
  7367. • {list} (`integer[]`)
  7368. Return: ~
  7369. (`any`)
  7370. setenv({name}, {val}) *setenv()*
  7371. Set environment variable {name} to {val}. Example: >vim
  7372. call setenv('HOME', '/home/myhome')
  7373. < When {val} is |v:null| the environment variable is deleted.
  7374. See also |expr-env|.
  7375. Parameters: ~
  7376. • {name} (`string`)
  7377. • {val} (`string`)
  7378. Return: ~
  7379. (`any`)
  7380. setfperm({fname}, {mode}) *setfperm()* *chmod*
  7381. Set the file permissions for {fname} to {mode}.
  7382. {mode} must be a string with 9 characters. It is of the form
  7383. "rwxrwxrwx", where each group of "rwx" flags represent, in
  7384. turn, the permissions of the owner of the file, the group the
  7385. file belongs to, and other users. A '-' character means the
  7386. permission is off, any other character means on. Multi-byte
  7387. characters are not supported.
  7388. For example "rw-r-----" means read-write for the user,
  7389. readable by the group, not accessible by others. "xx-x-----"
  7390. would do the same thing.
  7391. Returns non-zero for success, zero for failure.
  7392. To read permissions see |getfperm()|.
  7393. Parameters: ~
  7394. • {fname} (`string`)
  7395. • {mode} (`string`)
  7396. Return: ~
  7397. (`any`)
  7398. setline({lnum}, {text}) *setline()*
  7399. Set line {lnum} of the current buffer to {text}. To insert
  7400. lines use |append()|. To set lines in another buffer use
  7401. |setbufline()|.
  7402. {lnum} is used like with |getline()|.
  7403. When {lnum} is just below the last line the {text} will be
  7404. added below the last line.
  7405. {text} can be any type or a List of any type, each item is
  7406. converted to a String. When {text} is an empty List then
  7407. nothing is changed and FALSE is returned.
  7408. If this succeeds, FALSE is returned. If this fails (most likely
  7409. because {lnum} is invalid) TRUE is returned.
  7410. Example: >vim
  7411. call setline(5, strftime("%c"))
  7412. < When {text} is a |List| then line {lnum} and following lines
  7413. will be set to the items in the list. Example: >vim
  7414. call setline(5, ['aaa', 'bbb', 'ccc'])
  7415. < This is equivalent to: >vim
  7416. for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
  7417. call setline(n, l)
  7418. endfor
  7419. < Note: The '[ and '] marks are not set.
  7420. Parameters: ~
  7421. • {lnum} (`integer`)
  7422. • {text} (`any`)
  7423. Return: ~
  7424. (`any`)
  7425. setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
  7426. Create or replace or add to the location list for window {nr}.
  7427. {nr} can be the window number or the |window-ID|.
  7428. When {nr} is zero the current window is used.
  7429. For a location list window, the displayed location list is
  7430. modified. For an invalid window number {nr}, -1 is returned.
  7431. Otherwise, same as |setqflist()|.
  7432. Also see |location-list|.
  7433. For {action} see |setqflist-action|.
  7434. If the optional {what} dictionary argument is supplied, then
  7435. only the items listed in {what} are set. Refer to |setqflist()|
  7436. for the list of supported keys in {what}.
  7437. Parameters: ~
  7438. • {nr} (`integer`)
  7439. • {list} (`any`)
  7440. • {action} (`string?`)
  7441. • {what} (`table?`)
  7442. Return: ~
  7443. (`any`)
  7444. setmatches({list} [, {win}]) *setmatches()*
  7445. Restores a list of matches saved by |getmatches()| for the
  7446. current window. Returns 0 if successful, otherwise -1. All
  7447. current matches are cleared before the list is restored. See
  7448. example for |getmatches()|.
  7449. If {win} is specified, use the window with this number or
  7450. window ID instead of the current window.
  7451. Parameters: ~
  7452. • {list} (`any`)
  7453. • {win} (`integer?`)
  7454. Return: ~
  7455. (`any`)
  7456. setpos({expr}, {list}) *setpos()*
  7457. Set the position for String {expr}. Possible values:
  7458. . the cursor
  7459. 'x mark x
  7460. {list} must be a |List| with four or five numbers:
  7461. [bufnum, lnum, col, off]
  7462. [bufnum, lnum, col, off, curswant]
  7463. "bufnum" is the buffer number. Zero can be used for the
  7464. current buffer. When setting an uppercase mark "bufnum" is
  7465. used for the mark position. For other marks it specifies the
  7466. buffer to set the mark in. You can use the |bufnr()| function
  7467. to turn a file name into a buffer number.
  7468. For setting the cursor and the ' mark "bufnum" is ignored,
  7469. since these are associated with a window, not a buffer.
  7470. Does not change the jumplist.
  7471. "lnum" and "col" are the position in the buffer. The first
  7472. column is 1. Use a zero "lnum" to delete a mark. If "col" is
  7473. smaller than 1 then 1 is used. To use the character count
  7474. instead of the byte count, use |setcharpos()|.
  7475. The "off" number is only used when 'virtualedit' is set. Then
  7476. it is the offset in screen columns from the start of the
  7477. character. E.g., a position within a <Tab> or after the last
  7478. character.
  7479. The "curswant" number is only used when setting the cursor
  7480. position. It sets the preferred column for when moving the
  7481. cursor vertically. When the "curswant" number is missing the
  7482. preferred column is not set. When it is present and setting a
  7483. mark position it is not used.
  7484. Note that for '< and '> changing the line number may result in
  7485. the marks to be effectively be swapped, so that '< is always
  7486. before '>.
  7487. Returns 0 when the position could be set, -1 otherwise.
  7488. An error message is given if {expr} is invalid.
  7489. Also see |setcharpos()|, |getpos()| and |getcurpos()|.
  7490. This does not restore the preferred column for moving
  7491. vertically; if you set the cursor position with this, |j| and
  7492. |k| motions will jump to previous columns! Use |cursor()| to
  7493. also set the preferred column. Also see the "curswant" key in
  7494. |winrestview()|.
  7495. Parameters: ~
  7496. • {expr} (`string`)
  7497. • {list} (`integer[]`)
  7498. Return: ~
  7499. (`any`)
  7500. setqflist({list} [, {action} [, {what}]]) *setqflist()*
  7501. Create or replace or add to the quickfix list.
  7502. If the optional {what} dictionary argument is supplied, then
  7503. only the items listed in {what} are set. The first {list}
  7504. argument is ignored. See below for the supported items in
  7505. {what}.
  7506. *setqflist-what*
  7507. When {what} is not present, the items in {list} are used. Each
  7508. item must be a dictionary. Non-dictionary items in {list} are
  7509. ignored. Each dictionary item can contain the following
  7510. entries:
  7511. bufnr buffer number; must be the number of a valid
  7512. buffer
  7513. filename name of a file; only used when "bufnr" is not
  7514. present or it is invalid.
  7515. module name of a module; if given it will be used in
  7516. quickfix error window instead of the filename.
  7517. lnum line number in the file
  7518. end_lnum end of lines, if the item spans multiple lines
  7519. pattern search pattern used to locate the error
  7520. col column number
  7521. vcol when non-zero: "col" is visual column
  7522. when zero: "col" is byte index
  7523. end_col end column, if the item spans multiple columns
  7524. nr error number
  7525. text description of the error
  7526. type single-character error type, 'E', 'W', etc.
  7527. valid recognized error message
  7528. user_data
  7529. custom data associated with the item, can be
  7530. any type.
  7531. The "col", "vcol", "nr", "type" and "text" entries are
  7532. optional. Either "lnum" or "pattern" entry can be used to
  7533. locate a matching error line.
  7534. If the "filename" and "bufnr" entries are not present or
  7535. neither the "lnum" or "pattern" entries are present, then the
  7536. item will not be handled as an error line.
  7537. If both "pattern" and "lnum" are present then "pattern" will
  7538. be used.
  7539. If the "valid" entry is not supplied, then the valid flag is
  7540. set when "bufnr" is a valid buffer or "filename" exists.
  7541. If you supply an empty {list}, the quickfix list will be
  7542. cleared.
  7543. Note that the list is not exactly the same as what
  7544. |getqflist()| returns.
  7545. {action} values: *setqflist-action* *E927*
  7546. 'a' The items from {list} are added to the existing
  7547. quickfix list. If there is no existing list, then a
  7548. new list is created.
  7549. 'r' The items from the current quickfix list are replaced
  7550. with the items from {list}. This can also be used to
  7551. clear the list: >vim
  7552. call setqflist([], 'r')
  7553. <
  7554. 'u' Like 'r', but tries to preserve the current selection
  7555. in the quickfix list.
  7556. 'f' All the quickfix lists in the quickfix stack are
  7557. freed.
  7558. If {action} is not present or is set to ' ', then a new list
  7559. is created. The new quickfix list is added after the current
  7560. quickfix list in the stack and all the following lists are
  7561. freed. To add a new quickfix list at the end of the stack,
  7562. set "nr" in {what} to "$".
  7563. The following items can be specified in dictionary {what}:
  7564. context quickfix list context. See |quickfix-context|
  7565. efm errorformat to use when parsing text from
  7566. "lines". If this is not present, then the
  7567. 'errorformat' option value is used.
  7568. See |quickfix-parse|
  7569. id quickfix list identifier |quickfix-ID|
  7570. idx index of the current entry in the quickfix
  7571. list specified by "id" or "nr". If set to '$',
  7572. then the last entry in the list is set as the
  7573. current entry. See |quickfix-index|
  7574. items list of quickfix entries. Same as the {list}
  7575. argument.
  7576. lines use 'errorformat' to parse a list of lines and
  7577. add the resulting entries to the quickfix list
  7578. {nr} or {id}. Only a |List| value is supported.
  7579. See |quickfix-parse|
  7580. nr list number in the quickfix stack; zero
  7581. means the current quickfix list and "$" means
  7582. the last quickfix list.
  7583. quickfixtextfunc
  7584. function to get the text to display in the
  7585. quickfix window. The value can be the name of
  7586. a function or a funcref or a lambda. Refer to
  7587. |quickfix-window-function| for an explanation
  7588. of how to write the function and an example.
  7589. title quickfix list title text. See |quickfix-title|
  7590. Unsupported keys in {what} are ignored.
  7591. If the "nr" item is not present, then the current quickfix list
  7592. is modified. When creating a new quickfix list, "nr" can be
  7593. set to a value one greater than the quickfix stack size.
  7594. When modifying a quickfix list, to guarantee that the correct
  7595. list is modified, "id" should be used instead of "nr" to
  7596. specify the list.
  7597. Examples (See also |setqflist-examples|): >vim
  7598. call setqflist([], 'r', {'title': 'My search'})
  7599. call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
  7600. call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
  7601. <
  7602. Returns zero for success, -1 for failure.
  7603. This function can be used to create a quickfix list
  7604. independent of the 'errorformat' setting. Use a command like
  7605. `:cc 1` to jump to the first position.
  7606. Parameters: ~
  7607. • {list} (`vim.quickfix.entry[]`)
  7608. • {action} (`string?`)
  7609. • {what} (`vim.fn.setqflist.what?`)
  7610. Return: ~
  7611. (`any`)
  7612. setreg({regname}, {value} [, {options}]) *setreg()*
  7613. Set the register {regname} to {value}.
  7614. If {regname} is "" or "@", the unnamed register '"' is used.
  7615. The {regname} argument is a string.
  7616. {value} may be any value returned by |getreg()| or
  7617. |getreginfo()|, including a |List| or |Dict|.
  7618. If {options} contains "a" or {regname} is upper case,
  7619. then the value is appended.
  7620. {options} can also contain a register type specification:
  7621. "c" or "v" |charwise| mode
  7622. "l" or "V" |linewise| mode
  7623. "b" or "<CTRL-V>" |blockwise-visual| mode
  7624. If a number immediately follows "b" or "<CTRL-V>" then this is
  7625. used as the width of the selection - if it is not specified
  7626. then the width of the block is set to the number of characters
  7627. in the longest line (counting a <Tab> as 1 character).
  7628. If {options} contains "u" or '"', then the unnamed register is
  7629. set to point to register {regname}.
  7630. If {options} contains no register settings, then the default
  7631. is to use character mode unless {value} ends in a <NL> for
  7632. string {value} and linewise mode for list {value}. Blockwise
  7633. mode is never selected automatically.
  7634. Returns zero for success, non-zero for failure.
  7635. *E883*
  7636. Note: you may not use |List| containing more than one item to
  7637. set search and expression registers. Lists containing no
  7638. items act like empty strings.
  7639. Examples: >vim
  7640. call setreg(v:register, @*)
  7641. call setreg('*', @%, 'ac')
  7642. call setreg('a', "1\n2\n3", 'b5')
  7643. call setreg('"', { 'points_to': 'a'})
  7644. < This example shows using the functions to save and restore a
  7645. register: >vim
  7646. let var_a = getreginfo()
  7647. call setreg('a', var_a)
  7648. < or: >vim
  7649. let var_a = getreg('a', 1, 1)
  7650. let var_amode = getregtype('a')
  7651. " ....
  7652. call setreg('a', var_a, var_amode)
  7653. < Note: you may not reliably restore register value
  7654. without using the third argument to |getreg()| as without it
  7655. newlines are represented as newlines AND Nul bytes are
  7656. represented as newlines as well, see |NL-used-for-Nul|.
  7657. You can also change the type of a register by appending
  7658. nothing: >vim
  7659. call setreg('a', '', 'al')
  7660. Parameters: ~
  7661. • {regname} (`string`)
  7662. • {value} (`any`)
  7663. • {options} (`string?`)
  7664. Return: ~
  7665. (`any`)
  7666. settabvar({tabnr}, {varname}, {val}) *settabvar()*
  7667. Set tab-local variable {varname} to {val} in tab page {tabnr}.
  7668. |t:var|
  7669. The {varname} argument is a string.
  7670. Note that the variable name without "t:" must be used.
  7671. Tabs are numbered starting with one.
  7672. This function is not available in the |sandbox|.
  7673. Parameters: ~
  7674. • {tabnr} (`integer`)
  7675. • {varname} (`string`)
  7676. • {val} (`any`)
  7677. Return: ~
  7678. (`any`)
  7679. settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
  7680. Set option or local variable {varname} in window {winnr} to
  7681. {val}.
  7682. Tabs are numbered starting with one. For the current tabpage
  7683. use |setwinvar()|.
  7684. {winnr} can be the window number or the |window-ID|.
  7685. When {winnr} is zero the current window is used.
  7686. This also works for a global or local buffer option, but it
  7687. doesn't work for a global or local buffer variable.
  7688. For a local buffer option the global value is unchanged.
  7689. Note that the variable name without "w:" must be used.
  7690. Examples: >vim
  7691. call settabwinvar(1, 1, "&list", 0)
  7692. call settabwinvar(3, 2, "myvar", "foobar")
  7693. < This function is not available in the |sandbox|.
  7694. Parameters: ~
  7695. • {tabnr} (`integer`)
  7696. • {winnr} (`integer`)
  7697. • {varname} (`string`)
  7698. • {val} (`any`)
  7699. Return: ~
  7700. (`any`)
  7701. settagstack({nr}, {dict} [, {action}]) *settagstack()*
  7702. Modify the tag stack of the window {nr} using {dict}.
  7703. {nr} can be the window number or the |window-ID|.
  7704. For a list of supported items in {dict}, refer to
  7705. |gettagstack()|. "curidx" takes effect before changing the tag
  7706. stack.
  7707. *E962*
  7708. How the tag stack is modified depends on the {action}
  7709. argument:
  7710. - If {action} is not present or is set to 'r', then the tag
  7711. stack is replaced.
  7712. - If {action} is set to 'a', then new entries from {dict} are
  7713. pushed (added) onto the tag stack.
  7714. - If {action} is set to 't', then all the entries from the
  7715. current entry in the tag stack or "curidx" in {dict} are
  7716. removed and then new entries are pushed to the stack.
  7717. The current index is set to one after the length of the tag
  7718. stack after the modification.
  7719. Returns zero for success, -1 for failure.
  7720. Examples (for more examples see |tagstack-examples|):
  7721. Empty the tag stack of window 3: >vim
  7722. call settagstack(3, {'items' : []})
  7723. < Save and restore the tag stack: >vim
  7724. let stack = gettagstack(1003)
  7725. " do something else
  7726. call settagstack(1003, stack)
  7727. unlet stack
  7728. <
  7729. Parameters: ~
  7730. • {nr} (`integer`)
  7731. • {dict} (`any`)
  7732. • {action} (`string?`)
  7733. Return: ~
  7734. (`any`)
  7735. setwinvar({nr}, {varname}, {val}) *setwinvar()*
  7736. Like |settabwinvar()| for the current tab page.
  7737. Examples: >vim
  7738. call setwinvar(1, "&list", 0)
  7739. call setwinvar(2, "myvar", "foobar")
  7740. Parameters: ~
  7741. • {nr} (`integer`)
  7742. • {varname} (`string`)
  7743. • {val} (`any`)
  7744. Return: ~
  7745. (`any`)
  7746. sha256({string}) *sha256()*
  7747. Returns a String with 64 hex characters, which is the SHA256
  7748. checksum of {string}.
  7749. Parameters: ~
  7750. • {string} (`string`)
  7751. Return: ~
  7752. (`any`)
  7753. shellescape({string} [, {special}]) *shellescape()*
  7754. Escape {string} for use as a shell command argument.
  7755. On Windows when 'shellslash' is not set, encloses {string} in
  7756. double-quotes and doubles all double-quotes within {string}.
  7757. Otherwise encloses {string} in single-quotes and replaces all
  7758. "'" with "'\''".
  7759. The {special} argument adds additional escaping of keywords
  7760. used in Vim commands. If it is a |non-zero-arg|:
  7761. - Special items such as "!", "%", "#" and "<cword>" (as listed
  7762. in |expand()|) will be preceded by a backslash.
  7763. The backslash will be removed again by the |:!| command.
  7764. - The <NL> character is escaped.
  7765. If 'shell' contains "csh" in the tail:
  7766. - The "!" character will be escaped. This is because csh and
  7767. tcsh use "!" for history replacement even in single-quotes.
  7768. - The <NL> character is escaped (twice if {special} is
  7769. a |non-zero-arg|).
  7770. If 'shell' contains "fish" in the tail, the "\" character will
  7771. be escaped because in fish it is used as an escape character
  7772. inside single quotes.
  7773. Example of use with a |:!| command: >vim
  7774. exe '!dir ' .. shellescape(expand('<cfile>'), 1)
  7775. < This results in a directory listing for the file under the
  7776. cursor. Example of use with |system()|: >vim
  7777. call system("chmod +w -- " .. shellescape(expand("%")))
  7778. < See also |::S|.
  7779. Parameters: ~
  7780. • {string} (`string`)
  7781. • {special} (`boolean?`)
  7782. Return: ~
  7783. (`any`)
  7784. shiftwidth([{col}]) *shiftwidth()*
  7785. Returns the effective value of 'shiftwidth'. This is the
  7786. 'shiftwidth' value unless it is zero, in which case it is the
  7787. 'tabstop' value. To be backwards compatible in indent
  7788. plugins, use this: >vim
  7789. if exists('*shiftwidth')
  7790. func s:sw()
  7791. return shiftwidth()
  7792. endfunc
  7793. else
  7794. func s:sw()
  7795. return &sw
  7796. endfunc
  7797. endif
  7798. < And then use s:sw() instead of &sw.
  7799. When there is one argument {col} this is used as column number
  7800. for which to return the 'shiftwidth' value. This matters for the
  7801. 'vartabstop' feature. If no {col} argument is given, column 1
  7802. will be assumed.
  7803. Parameters: ~
  7804. • {col} (`integer?`)
  7805. Return: ~
  7806. (`integer`)
  7807. sign_define({name} [, {dict}]) *sign_define()*
  7808. sign_define({list})
  7809. Define a new sign named {name} or modify the attributes of an
  7810. existing sign. This is similar to the |:sign-define| command.
  7811. Prefix {name} with a unique text to avoid name collisions.
  7812. There is no {group} like with placing signs.
  7813. The {name} can be a String or a Number. The optional {dict}
  7814. argument specifies the sign attributes. The following values
  7815. are supported:
  7816. icon full path to the bitmap file for the sign.
  7817. linehl highlight group used for the whole line the
  7818. sign is placed in.
  7819. priority default priority value of the sign
  7820. numhl highlight group used for the line number where
  7821. the sign is placed.
  7822. text text that is displayed when there is no icon
  7823. or the GUI is not being used.
  7824. texthl highlight group used for the text item
  7825. culhl highlight group used for the text item when
  7826. the cursor is on the same line as the sign and
  7827. 'cursorline' is enabled.
  7828. If the sign named {name} already exists, then the attributes
  7829. of the sign are updated.
  7830. The one argument {list} can be used to define a list of signs.
  7831. Each list item is a dictionary with the above items in {dict}
  7832. and a "name" item for the sign name.
  7833. Returns 0 on success and -1 on failure. When the one argument
  7834. {list} is used, then returns a List of values one for each
  7835. defined sign.
  7836. Examples: >vim
  7837. call sign_define("mySign", {
  7838. \ "text" : "=>",
  7839. \ "texthl" : "Error",
  7840. \ "linehl" : "Search"})
  7841. call sign_define([
  7842. \ {'name' : 'sign1',
  7843. \ 'text' : '=>'},
  7844. \ {'name' : 'sign2',
  7845. \ 'text' : '!!'}
  7846. \ ])
  7847. <
  7848. Parameters: ~
  7849. • {list} (`vim.fn.sign_define.dict[]`)
  7850. Return: ~
  7851. (`(0|-1)[]`)
  7852. sign_getdefined([{name}]) *sign_getdefined()*
  7853. Get a list of defined signs and their attributes.
  7854. This is similar to the |:sign-list| command.
  7855. If the {name} is not supplied, then a list of all the defined
  7856. signs is returned. Otherwise the attribute of the specified
  7857. sign is returned.
  7858. Each list item in the returned value is a dictionary with the
  7859. following entries:
  7860. icon full path to the bitmap file of the sign
  7861. linehl highlight group used for the whole line the
  7862. sign is placed in; not present if not set.
  7863. name name of the sign
  7864. priority default priority value of the sign
  7865. numhl highlight group used for the line number where
  7866. the sign is placed; not present if not set.
  7867. text text that is displayed when there is no icon
  7868. or the GUI is not being used.
  7869. texthl highlight group used for the text item; not
  7870. present if not set.
  7871. culhl highlight group used for the text item when
  7872. the cursor is on the same line as the sign and
  7873. 'cursorline' is enabled; not present if not
  7874. set.
  7875. Returns an empty List if there are no signs and when {name} is
  7876. not found.
  7877. Examples: >vim
  7878. " Get a list of all the defined signs
  7879. echo sign_getdefined()
  7880. " Get the attribute of the sign named mySign
  7881. echo sign_getdefined("mySign")
  7882. <
  7883. Parameters: ~
  7884. • {name} (`string?`)
  7885. Return: ~
  7886. (`vim.fn.sign_getdefined.ret.item[]`)
  7887. sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
  7888. Return a list of signs placed in a buffer or all the buffers.
  7889. This is similar to the |:sign-place-list| command.
  7890. If the optional buffer name {buf} is specified, then only the
  7891. list of signs placed in that buffer is returned. For the use
  7892. of {buf}, see |bufname()|. The optional {dict} can contain
  7893. the following entries:
  7894. group select only signs in this group
  7895. id select sign with this identifier
  7896. lnum select signs placed in this line. For the use
  7897. of {lnum}, see |line()|.
  7898. If {group} is "*", then signs in all the groups including the
  7899. global group are returned. If {group} is not supplied or is an
  7900. empty string, then only signs in the global group are
  7901. returned. If no arguments are supplied, then signs in the
  7902. global group placed in all the buffers are returned.
  7903. See |sign-group|.
  7904. Each list item in the returned value is a dictionary with the
  7905. following entries:
  7906. bufnr number of the buffer with the sign
  7907. signs list of signs placed in {bufnr}. Each list
  7908. item is a dictionary with the below listed
  7909. entries
  7910. The dictionary for each sign contains the following entries:
  7911. group sign group. Set to '' for the global group.
  7912. id identifier of the sign
  7913. lnum line number where the sign is placed
  7914. name name of the defined sign
  7915. priority sign priority
  7916. The returned signs in a buffer are ordered by their line
  7917. number and priority.
  7918. Returns an empty list on failure or if there are no placed
  7919. signs.
  7920. Examples: >vim
  7921. " Get a List of signs placed in eval.c in the
  7922. " global group
  7923. echo sign_getplaced("eval.c")
  7924. " Get a List of signs in group 'g1' placed in eval.c
  7925. echo sign_getplaced("eval.c", {'group' : 'g1'})
  7926. " Get a List of signs placed at line 10 in eval.c
  7927. echo sign_getplaced("eval.c", {'lnum' : 10})
  7928. " Get sign with identifier 10 placed in a.py
  7929. echo sign_getplaced("a.py", {'id' : 10})
  7930. " Get sign with id 20 in group 'g1' placed in a.py
  7931. echo sign_getplaced("a.py", {'group' : 'g1',
  7932. \ 'id' : 20})
  7933. " Get a List of all the placed signs
  7934. echo sign_getplaced()
  7935. <
  7936. Parameters: ~
  7937. • {buf} (`integer|string?`)
  7938. • {dict} (`vim.fn.sign_getplaced.dict?`)
  7939. Return: ~
  7940. (`vim.fn.sign_getplaced.ret.item[]`)
  7941. sign_jump({id}, {group}, {buf}) *sign_jump()*
  7942. Open the buffer {buf} or jump to the window that contains
  7943. {buf} and position the cursor at sign {id} in group {group}.
  7944. This is similar to the |:sign-jump| command.
  7945. If {group} is an empty string, then the global group is used.
  7946. For the use of {buf}, see |bufname()|.
  7947. Returns the line number of the sign. Returns -1 if the
  7948. arguments are invalid.
  7949. Example: >vim
  7950. " Jump to sign 10 in the current buffer
  7951. call sign_jump(10, '', '')
  7952. <
  7953. Parameters: ~
  7954. • {id} (`integer`)
  7955. • {group} (`string`)
  7956. • {buf} (`integer|string`)
  7957. Return: ~
  7958. (`integer`)
  7959. sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()*
  7960. Place the sign defined as {name} at line {lnum} in file or
  7961. buffer {buf} and assign {id} and {group} to sign. This is
  7962. similar to the |:sign-place| command.
  7963. If the sign identifier {id} is zero, then a new identifier is
  7964. allocated. Otherwise the specified number is used. {group} is
  7965. the sign group name. To use the global sign group, use an
  7966. empty string. {group} functions as a namespace for {id}, thus
  7967. two groups can use the same IDs. Refer to |sign-identifier|
  7968. and |sign-group| for more information.
  7969. {name} refers to a defined sign.
  7970. {buf} refers to a buffer name or number. For the accepted
  7971. values, see |bufname()|.
  7972. The optional {dict} argument supports the following entries:
  7973. lnum line number in the file or buffer
  7974. {buf} where the sign is to be placed.
  7975. For the accepted values, see |line()|.
  7976. priority priority of the sign. See
  7977. |sign-priority| for more information.
  7978. If the optional {dict} is not specified, then it modifies the
  7979. placed sign {id} in group {group} to use the defined sign
  7980. {name}.
  7981. Returns the sign identifier on success and -1 on failure.
  7982. Examples: >vim
  7983. " Place a sign named sign1 with id 5 at line 20 in
  7984. " buffer json.c
  7985. call sign_place(5, '', 'sign1', 'json.c',
  7986. \ {'lnum' : 20})
  7987. " Updates sign 5 in buffer json.c to use sign2
  7988. call sign_place(5, '', 'sign2', 'json.c')
  7989. " Place a sign named sign3 at line 30 in
  7990. " buffer json.c with a new identifier
  7991. let id = sign_place(0, '', 'sign3', 'json.c',
  7992. \ {'lnum' : 30})
  7993. " Place a sign named sign4 with id 10 in group 'g3'
  7994. " at line 40 in buffer json.c with priority 90
  7995. call sign_place(10, 'g3', 'sign4', 'json.c',
  7996. \ {'lnum' : 40, 'priority' : 90})
  7997. <
  7998. Parameters: ~
  7999. • {id} (`integer`)
  8000. • {group} (`string`)
  8001. • {name} (`string`)
  8002. • {buf} (`integer|string`)
  8003. • {dict} (`vim.fn.sign_place.dict?`)
  8004. Return: ~
  8005. (`integer`)
  8006. sign_placelist({list}) *sign_placelist()*
  8007. Place one or more signs. This is similar to the
  8008. |sign_place()| function. The {list} argument specifies the
  8009. List of signs to place. Each list item is a dict with the
  8010. following sign attributes:
  8011. buffer Buffer name or number. For the accepted
  8012. values, see |bufname()|.
  8013. group Sign group. {group} functions as a namespace
  8014. for {id}, thus two groups can use the same
  8015. IDs. If not specified or set to an empty
  8016. string, then the global group is used. See
  8017. |sign-group| for more information.
  8018. id Sign identifier. If not specified or zero,
  8019. then a new unique identifier is allocated.
  8020. Otherwise the specified number is used. See
  8021. |sign-identifier| for more information.
  8022. lnum Line number in the buffer where the sign is to
  8023. be placed. For the accepted values, see
  8024. |line()|.
  8025. name Name of the sign to place. See |sign_define()|
  8026. for more information.
  8027. priority Priority of the sign. When multiple signs are
  8028. placed on a line, the sign with the highest
  8029. priority is used. If not specified, the
  8030. default value of 10 is used, unless specified
  8031. otherwise by the sign definition. See
  8032. |sign-priority| for more information.
  8033. If {id} refers to an existing sign, then the existing sign is
  8034. modified to use the specified {name} and/or {priority}.
  8035. Returns a List of sign identifiers. If failed to place a
  8036. sign, the corresponding list item is set to -1.
  8037. Examples: >vim
  8038. " Place sign s1 with id 5 at line 20 and id 10 at line
  8039. " 30 in buffer a.c
  8040. let [n1, n2] = sign_placelist([
  8041. \ {'id' : 5,
  8042. \ 'name' : 's1',
  8043. \ 'buffer' : 'a.c',
  8044. \ 'lnum' : 20},
  8045. \ {'id' : 10,
  8046. \ 'name' : 's1',
  8047. \ 'buffer' : 'a.c',
  8048. \ 'lnum' : 30}
  8049. \ ])
  8050. " Place sign s1 in buffer a.c at line 40 and 50
  8051. " with auto-generated identifiers
  8052. let [n1, n2] = sign_placelist([
  8053. \ {'name' : 's1',
  8054. \ 'buffer' : 'a.c',
  8055. \ 'lnum' : 40},
  8056. \ {'name' : 's1',
  8057. \ 'buffer' : 'a.c',
  8058. \ 'lnum' : 50}
  8059. \ ])
  8060. <
  8061. Parameters: ~
  8062. • {list} (`vim.fn.sign_placelist.list.item[]`)
  8063. Return: ~
  8064. (`integer[]`)
  8065. sign_undefine([{name}]) *sign_undefine()*
  8066. sign_undefine({list})
  8067. Deletes a previously defined sign {name}. This is similar to
  8068. the |:sign-undefine| command. If {name} is not supplied, then
  8069. deletes all the defined signs.
  8070. The one argument {list} can be used to undefine a list of
  8071. signs. Each list item is the name of a sign.
  8072. Returns 0 on success and -1 on failure. For the one argument
  8073. {list} call, returns a list of values one for each undefined
  8074. sign.
  8075. Examples: >vim
  8076. " Delete a sign named mySign
  8077. call sign_undefine("mySign")
  8078. " Delete signs 'sign1' and 'sign2'
  8079. call sign_undefine(["sign1", "sign2"])
  8080. " Delete all the signs
  8081. call sign_undefine()
  8082. <
  8083. Parameters: ~
  8084. • {list} (`string[]?`)
  8085. Return: ~
  8086. (`integer[]`)
  8087. sign_unplace({group} [, {dict}]) *sign_unplace()*
  8088. Remove a previously placed sign in one or more buffers. This
  8089. is similar to the |:sign-unplace| command.
  8090. {group} is the sign group name. To use the global sign group,
  8091. use an empty string. If {group} is set to "*", then all the
  8092. groups including the global group are used.
  8093. The signs in {group} are selected based on the entries in
  8094. {dict}. The following optional entries in {dict} are
  8095. supported:
  8096. buffer buffer name or number. See |bufname()|.
  8097. id sign identifier
  8098. If {dict} is not supplied, then all the signs in {group} are
  8099. removed.
  8100. Returns 0 on success and -1 on failure.
  8101. Examples: >vim
  8102. " Remove sign 10 from buffer a.vim
  8103. call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
  8104. " Remove sign 20 in group 'g1' from buffer 3
  8105. call sign_unplace('g1', {'buffer' : 3, 'id' : 20})
  8106. " Remove all the signs in group 'g2' from buffer 10
  8107. call sign_unplace('g2', {'buffer' : 10})
  8108. " Remove sign 30 in group 'g3' from all the buffers
  8109. call sign_unplace('g3', {'id' : 30})
  8110. " Remove all the signs placed in buffer 5
  8111. call sign_unplace('*', {'buffer' : 5})
  8112. " Remove the signs in group 'g4' from all the buffers
  8113. call sign_unplace('g4')
  8114. " Remove sign 40 from all the buffers
  8115. call sign_unplace('*', {'id' : 40})
  8116. " Remove all the placed signs from all the buffers
  8117. call sign_unplace('*')
  8118. Parameters: ~
  8119. • {group} (`string`)
  8120. • {dict} (`vim.fn.sign_unplace.dict?`)
  8121. Return: ~
  8122. (`0|-1`)
  8123. sign_unplacelist({list}) *sign_unplacelist()*
  8124. Remove previously placed signs from one or more buffers. This
  8125. is similar to the |sign_unplace()| function.
  8126. The {list} argument specifies the List of signs to remove.
  8127. Each list item is a dict with the following sign attributes:
  8128. buffer buffer name or number. For the accepted
  8129. values, see |bufname()|. If not specified,
  8130. then the specified sign is removed from all
  8131. the buffers.
  8132. group sign group name. If not specified or set to an
  8133. empty string, then the global sign group is
  8134. used. If set to "*", then all the groups
  8135. including the global group are used.
  8136. id sign identifier. If not specified, then all
  8137. the signs in the specified group are removed.
  8138. Returns a List where an entry is set to 0 if the corresponding
  8139. sign was successfully removed or -1 on failure.
  8140. Example: >vim
  8141. " Remove sign with id 10 from buffer a.vim and sign
  8142. " with id 20 from buffer b.vim
  8143. call sign_unplacelist([
  8144. \ {'id' : 10, 'buffer' : "a.vim"},
  8145. \ {'id' : 20, 'buffer' : 'b.vim'},
  8146. \ ])
  8147. <
  8148. Parameters: ~
  8149. • {list} (`vim.fn.sign_unplacelist.list.item`)
  8150. Return: ~
  8151. (`(0|-1)[]`)
  8152. simplify({filename}) *simplify()*
  8153. Simplify the file name as much as possible without changing
  8154. the meaning. Shortcuts (on MS-Windows) or symbolic links (on
  8155. Unix) are not resolved. If the first path component in
  8156. {filename} designates the current directory, this will be
  8157. valid for the result as well. A trailing path separator is
  8158. not removed either. On Unix "//path" is unchanged, but
  8159. "///path" is simplified to "/path" (this follows the Posix
  8160. standard).
  8161. Example: >vim
  8162. simplify("./dir/.././/file/") == "./file/"
  8163. < Note: The combination "dir/.." is only removed if "dir" is
  8164. a searchable directory or does not exist. On Unix, it is also
  8165. removed when "dir" is a symbolic link within the same
  8166. directory. In order to resolve all the involved symbolic
  8167. links before simplifying the path name, use |resolve()|.
  8168. Parameters: ~
  8169. • {filename} (`string`)
  8170. Return: ~
  8171. (`any`)
  8172. sin({expr}) *sin()*
  8173. Return the sine of {expr}, measured in radians, as a |Float|.
  8174. {expr} must evaluate to a |Float| or a |Number|.
  8175. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8176. Examples: >vim
  8177. echo sin(100)
  8178. < -0.506366 >vim
  8179. echo sin(-4.01)
  8180. < 0.763301
  8181. Parameters: ~
  8182. • {expr} (`number`)
  8183. Return: ~
  8184. (`any`)
  8185. sinh({expr}) *sinh()*
  8186. Return the hyperbolic sine of {expr} as a |Float| in the range
  8187. [-inf, inf].
  8188. {expr} must evaluate to a |Float| or a |Number|.
  8189. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  8190. Examples: >vim
  8191. echo sinh(0.5)
  8192. < 0.521095 >vim
  8193. echo sinh(-0.9)
  8194. < -1.026517
  8195. Parameters: ~
  8196. • {expr} (`number`)
  8197. Return: ~
  8198. (`any`)
  8199. slice({expr}, {start} [, {end}]) *slice()*
  8200. Similar to using a |slice| "expr[start : end]", but "end" is
  8201. used exclusive. And for a string the indexes are used as
  8202. character indexes instead of byte indexes.
  8203. Also, composing characters are treated as a part of the
  8204. preceding base character.
  8205. When {end} is omitted the slice continues to the last item.
  8206. When {end} is -1 the last item is omitted.
  8207. Returns an empty value if {start} or {end} are invalid.
  8208. Parameters: ~
  8209. • {expr} (`any`)
  8210. • {start} (`integer`)
  8211. • {end} (`integer?`)
  8212. Return: ~
  8213. (`any`)
  8214. sockconnect({mode}, {address} [, {opts}]) *sockconnect()*
  8215. Connect a socket to an address. If {mode} is "pipe" then
  8216. {address} should be the path of a local domain socket (on
  8217. unix) or named pipe (on Windows). If {mode} is "tcp" then
  8218. {address} should be of the form "host:port" where the host
  8219. should be an ip address or host name, and port the port
  8220. number.
  8221. For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see
  8222. |luv-tcp-handle|.
  8223. Returns a |channel| ID. Close the socket with |chanclose()|.
  8224. Use |chansend()| to send data over a bytes socket, and
  8225. |rpcrequest()| and |rpcnotify()| to communicate with a RPC
  8226. socket.
  8227. {opts} is an optional dictionary with these keys:
  8228. |on_data| : callback invoked when data was read from socket
  8229. data_buffered : read socket data in |channel-buffered| mode.
  8230. rpc : If set, |msgpack-rpc| will be used to communicate
  8231. over the socket.
  8232. Returns:
  8233. - The channel ID on success (greater than zero)
  8234. - 0 on invalid arguments or connection failure.
  8235. Parameters: ~
  8236. • {mode} (`string`)
  8237. • {address} (`string`)
  8238. • {opts} (`table?`)
  8239. Return: ~
  8240. (`any`)
  8241. sort({list} [, {how} [, {dict}]]) *sort()* *E702*
  8242. Sort the items in {list} in-place. Returns {list}.
  8243. If you want a list to remain unmodified make a copy first: >vim
  8244. let sortedlist = sort(copy(mylist))
  8245. < When {how} is omitted or is a string, then sort() uses the
  8246. string representation of each item to sort on. Numbers sort
  8247. after Strings, |Lists| after Numbers. For sorting text in the
  8248. current buffer use |:sort|.
  8249. When {how} is given and it is 'i' then case is ignored.
  8250. For backwards compatibility, the value one can be used to
  8251. ignore case. Zero means to not ignore case.
  8252. When {how} is given and it is 'l' then the current collation
  8253. locale is used for ordering. Implementation details: strcoll()
  8254. is used to compare strings. See |:language| check or set the
  8255. collation locale. |v:collate| can also be used to check the
  8256. current locale. Sorting using the locale typically ignores
  8257. case. Example: >vim
  8258. " ö is sorted similarly to o with English locale.
  8259. language collate en_US.UTF8
  8260. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8261. < ['n', 'o', 'O', 'ö', 'p', 'z'] ~
  8262. >vim
  8263. " ö is sorted after z with Swedish locale.
  8264. language collate sv_SE.UTF8
  8265. echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
  8266. < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
  8267. This does not work properly on Mac.
  8268. When {how} is given and it is 'n' then all items will be
  8269. sorted numerical (Implementation detail: this uses the
  8270. strtod() function to parse numbers, Strings, Lists, Dicts and
  8271. Funcrefs will be considered as being 0).
  8272. When {how} is given and it is 'N' then all items will be
  8273. sorted numerical. This is like 'n' but a string containing
  8274. digits will be used as the number they represent.
  8275. When {how} is given and it is 'f' then all items will be
  8276. sorted numerical. All values must be a Number or a Float.
  8277. When {how} is a |Funcref| or a function name, this function
  8278. is called to compare items. The function is invoked with two
  8279. items as argument and must return zero if they are equal, 1 or
  8280. bigger if the first one sorts after the second one, -1 or
  8281. smaller if the first one sorts before the second one.
  8282. {dict} is for functions with the "dict" attribute. It will be
  8283. used to set the local variable "self". |Dictionary-function|
  8284. The sort is stable, items which compare equal (as number or as
  8285. string) will keep their relative position. E.g., when sorting
  8286. on numbers, text strings will sort next to each other, in the
  8287. same order as they were originally.
  8288. Example: >vim
  8289. func MyCompare(i1, i2)
  8290. return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
  8291. endfunc
  8292. eval mylist->sort("MyCompare")
  8293. < A shorter compare version for this specific simple case, which
  8294. ignores overflow: >vim
  8295. func MyCompare(i1, i2)
  8296. return a:i1 - a:i2
  8297. endfunc
  8298. < For a simple expression you can use a lambda: >vim
  8299. eval mylist->sort({i1, i2 -> i1 - i2})
  8300. <
  8301. Parameters: ~
  8302. • {list} (`any`)
  8303. • {how} (`string|function?`)
  8304. • {dict} (`any?`)
  8305. Return: ~
  8306. (`any`)
  8307. soundfold({word}) *soundfold()*
  8308. Return the sound-folded equivalent of {word}. Uses the first
  8309. language in 'spelllang' for the current window that supports
  8310. soundfolding. 'spell' must be set. When no sound folding is
  8311. possible the {word} is returned unmodified.
  8312. This can be used for making spelling suggestions. Note that
  8313. the method can be quite slow.
  8314. Parameters: ~
  8315. • {word} (`string`)
  8316. Return: ~
  8317. (`any`)
  8318. spellbadword([{sentence}]) *spellbadword()*
  8319. Without argument: The result is the badly spelled word under
  8320. or after the cursor. The cursor is moved to the start of the
  8321. bad word. When no bad word is found in the cursor line the
  8322. result is an empty string and the cursor doesn't move.
  8323. With argument: The result is the first word in {sentence} that
  8324. is badly spelled. If there are no spelling mistakes the
  8325. result is an empty string.
  8326. The return value is a list with two items:
  8327. - The badly spelled word or an empty string.
  8328. - The type of the spelling error:
  8329. "bad" spelling mistake
  8330. "rare" rare word
  8331. "local" word only valid in another region
  8332. "caps" word should start with Capital
  8333. Example: >vim
  8334. echo spellbadword("the quik brown fox")
  8335. < ['quik', 'bad'] ~
  8336. The spelling information for the current window and the value
  8337. of 'spelllang' are used.
  8338. Parameters: ~
  8339. • {sentence} (`string?`)
  8340. Return: ~
  8341. (`any`)
  8342. spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()*
  8343. Return a |List| with spelling suggestions to replace {word}.
  8344. When {max} is given up to this number of suggestions are
  8345. returned. Otherwise up to 25 suggestions are returned.
  8346. When the {capital} argument is given and it's non-zero only
  8347. suggestions with a leading capital will be given. Use this
  8348. after a match with 'spellcapcheck'.
  8349. {word} can be a badly spelled word followed by other text.
  8350. This allows for joining two words that were split. The
  8351. suggestions also include the following text, thus you can
  8352. replace a line.
  8353. {word} may also be a good word. Similar words will then be
  8354. returned. {word} itself is not included in the suggestions,
  8355. although it may appear capitalized.
  8356. The spelling information for the current window is used. The
  8357. values of 'spelllang' and 'spellsuggest' are used.
  8358. Parameters: ~
  8359. • {word} (`string`)
  8360. • {max} (`integer?`)
  8361. • {capital} (`boolean?`)
  8362. Return: ~
  8363. (`any`)
  8364. split({string} [, {pattern} [, {keepempty}]]) *split()*
  8365. Make a |List| out of {string}. When {pattern} is omitted or
  8366. empty each white space separated sequence of characters
  8367. becomes an item.
  8368. Otherwise the string is split where {pattern} matches,
  8369. removing the matched characters. 'ignorecase' is not used
  8370. here, add \c to ignore case. |/\c|
  8371. When the first or last item is empty it is omitted, unless the
  8372. {keepempty} argument is given and it's non-zero.
  8373. Other empty items are kept when {pattern} matches at least one
  8374. character or when {keepempty} is non-zero.
  8375. Example: >vim
  8376. let words = split(getline('.'), '\W\+')
  8377. < To split a string in individual characters: >vim
  8378. for c in split(mystring, '\zs') | endfor
  8379. < If you want to keep the separator you can also use '\zs' at
  8380. the end of the pattern: >vim
  8381. echo split('abc:def:ghi', ':\zs')
  8382. < >
  8383. ['abc:', 'def:', 'ghi']
  8384. <
  8385. Splitting a table where the first element can be empty: >vim
  8386. let items = split(line, ':', 1)
  8387. < The opposite function is |join()|.
  8388. Parameters: ~
  8389. • {string} (`string`)
  8390. • {pattern} (`string?`)
  8391. • {keepempty} (`boolean?`)
  8392. Return: ~
  8393. (`any`)
  8394. sqrt({expr}) *sqrt()*
  8395. Return the non-negative square root of Float {expr} as a
  8396. |Float|.
  8397. {expr} must evaluate to a |Float| or a |Number|. When {expr}
  8398. is negative the result is NaN (Not a Number). Returns 0.0 if
  8399. {expr} is not a |Float| or a |Number|.
  8400. Examples: >vim
  8401. echo sqrt(100)
  8402. < 10.0 >vim
  8403. echo sqrt(-4.01)
  8404. < str2float("nan")
  8405. NaN may be different, it depends on system libraries.
  8406. Parameters: ~
  8407. • {expr} (`number`)
  8408. Return: ~
  8409. (`any`)
  8410. srand([{expr}]) *srand()*
  8411. Initialize seed used by |rand()|:
  8412. - If {expr} is not given, seed values are initialized by
  8413. reading from /dev/urandom, if possible, or using time(NULL)
  8414. a.k.a. epoch time otherwise; this only has second accuracy.
  8415. - If {expr} is given it must be a Number. It is used to
  8416. initialize the seed values. This is useful for testing or
  8417. when a predictable sequence is intended.
  8418. Examples: >vim
  8419. let seed = srand()
  8420. let seed = srand(userinput)
  8421. echo rand(seed)
  8422. <
  8423. Parameters: ~
  8424. • {expr} (`number?`)
  8425. Return: ~
  8426. (`any`)
  8427. state([{what}]) *state()*
  8428. Return a string which contains characters indicating the
  8429. current state. Mostly useful in callbacks that want to do
  8430. work that may not always be safe. Roughly this works like:
  8431. - callback uses state() to check if work is safe to do.
  8432. Yes: then do it right away.
  8433. No: add to work queue and add a |SafeState| autocommand.
  8434. - When SafeState is triggered and executes your autocommand,
  8435. check with `state()` if the work can be done now, and if yes
  8436. remove it from the queue and execute.
  8437. Remove the autocommand if the queue is now empty.
  8438. Also see |mode()|.
  8439. When {what} is given only characters in this string will be
  8440. added. E.g, this checks if the screen has scrolled: >vim
  8441. if state('s') == ''
  8442. " screen has not scrolled
  8443. <
  8444. These characters indicate the state, generally indicating that
  8445. something is busy:
  8446. m halfway a mapping, :normal command, feedkeys() or
  8447. stuffed command
  8448. o operator pending, e.g. after |d|
  8449. a Insert mode autocomplete active
  8450. x executing an autocommand
  8451. S not triggering SafeState, e.g. after |f| or a count
  8452. c callback invoked, including timer (repeats for
  8453. recursiveness up to "ccc")
  8454. s screen has scrolled for messages
  8455. Parameters: ~
  8456. • {what} (`string?`)
  8457. Return: ~
  8458. (`any`)
  8459. stdioopen({opts}) *stdioopen()*
  8460. With |--headless| this opens stdin and stdout as a |channel|.
  8461. May be called only once. See |channel-stdio|. stderr is not
  8462. handled by this function, see |v:stderr|.
  8463. Close the stdio handles with |chanclose()|. Use |chansend()|
  8464. to send data to stdout, and |rpcrequest()| and |rpcnotify()|
  8465. to communicate over RPC.
  8466. {opts} is a dictionary with these keys:
  8467. |on_stdin| : callback invoked when stdin is written to.
  8468. on_print : callback invoked when Nvim needs to print a
  8469. message, with the message (whose type is string)
  8470. as sole argument.
  8471. stdin_buffered : read stdin in |channel-buffered| mode.
  8472. rpc : If set, |msgpack-rpc| will be used to communicate
  8473. over stdio
  8474. Returns:
  8475. - |channel-id| on success (value is always 1)
  8476. - 0 on invalid arguments
  8477. Parameters: ~
  8478. • {opts} (`table`)
  8479. Return: ~
  8480. (`any`)
  8481. stdpath({what}) *stdpath()* *E6100*
  8482. Returns |standard-path| locations of various default files and
  8483. directories.
  8484. {what} Type Description ~
  8485. cache String Cache directory: arbitrary temporary
  8486. storage for plugins, etc.
  8487. config String User configuration directory. |init.vim|
  8488. is stored here.
  8489. config_dirs List Other configuration directories.
  8490. data String User data directory.
  8491. data_dirs List Other data directories.
  8492. log String Logs directory (for use by plugins too).
  8493. run String Run directory: temporary, local storage
  8494. for sockets, named pipes, etc.
  8495. state String Session state directory: storage for file
  8496. drafts, swap, undo, |shada|.
  8497. Example: >vim
  8498. echo stdpath("config")
  8499. <
  8500. Parameters: ~
  8501. • {what}
  8502. (`'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'`)
  8503. Return: ~
  8504. (`string|string[]`)
  8505. str2float({string} [, {quoted}]) *str2float()*
  8506. Convert String {string} to a Float. This mostly works the
  8507. same as when using a floating point number in an expression,
  8508. see |floating-point-format|. But it's a bit more permissive.
  8509. E.g., "1e40" is accepted, while in an expression you need to
  8510. write "1.0e40". The hexadecimal form "0x123" is also
  8511. accepted, but not others, like binary or octal.
  8512. When {quoted} is present and non-zero then embedded single
  8513. quotes before the dot are ignored, thus "1'000.0" is a
  8514. thousand.
  8515. Text after the number is silently ignored.
  8516. The decimal point is always '.', no matter what the locale is
  8517. set to. A comma ends the number: "12,345.67" is converted to
  8518. 12.0. You can strip out thousands separators with
  8519. |substitute()|: >vim
  8520. let f = str2float(substitute(text, ',', '', 'g'))
  8521. <
  8522. Returns 0.0 if the conversion fails.
  8523. Parameters: ~
  8524. • {string} (`string`)
  8525. • {quoted} (`boolean?`)
  8526. Return: ~
  8527. (`any`)
  8528. str2list({string} [, {utf8}]) *str2list()*
  8529. Return a list containing the number values which represent
  8530. each character in String {string}. Examples: >vim
  8531. echo str2list(" ") " returns [32]
  8532. echo str2list("ABC") " returns [65, 66, 67]
  8533. < |list2str()| does the opposite.
  8534. UTF-8 encoding is always used, {utf8} option has no effect,
  8535. and exists only for backwards-compatibility.
  8536. With UTF-8 composing characters are handled properly: >vim
  8537. echo str2list("á") " returns [97, 769]
  8538. <
  8539. Parameters: ~
  8540. • {string} (`string`)
  8541. • {utf8} (`boolean?`)
  8542. Return: ~
  8543. (`any`)
  8544. str2nr({string} [, {base}]) *str2nr()*
  8545. Convert string {string} to a number.
  8546. {base} is the conversion base, it can be 2, 8, 10 or 16.
  8547. When {quoted} is present and non-zero then embedded single
  8548. quotes are ignored, thus "1'000'000" is a million.
  8549. When {base} is omitted base 10 is used. This also means that
  8550. a leading zero doesn't cause octal conversion to be used, as
  8551. with the default String to Number conversion. Example: >vim
  8552. let nr = str2nr('0123')
  8553. <
  8554. When {base} is 16 a leading "0x" or "0X" is ignored. With a
  8555. different base the result will be zero. Similarly, when
  8556. {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
  8557. {base} is 2 a leading "0b" or "0B" is ignored.
  8558. Text after the number is silently ignored.
  8559. Returns 0 if {string} is empty or on error.
  8560. Parameters: ~
  8561. • {string} (`string`)
  8562. • {base} (`integer?`)
  8563. Return: ~
  8564. (`any`)
  8565. strcharlen({string}) *strcharlen()*
  8566. The result is a Number, which is the number of characters
  8567. in String {string}. Composing characters are ignored.
  8568. |strchars()| can count the number of characters, counting
  8569. composing characters separately.
  8570. Returns 0 if {string} is empty or on error.
  8571. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8572. Parameters: ~
  8573. • {string} (`string`)
  8574. Return: ~
  8575. (`any`)
  8576. strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
  8577. Like |strpart()| but using character index and length instead
  8578. of byte index and length.
  8579. When {skipcc} is omitted or zero, composing characters are
  8580. counted separately.
  8581. When {skipcc} set to 1, composing characters are treated as a
  8582. part of the preceding base character, similar to |slice()|.
  8583. When a character index is used where a character does not
  8584. exist it is omitted and counted as one character. For
  8585. example: >vim
  8586. echo strcharpart('abc', -1, 2)
  8587. < results in 'a'.
  8588. Returns an empty string on error.
  8589. Parameters: ~
  8590. • {src} (`string`)
  8591. • {start} (`integer`)
  8592. • {len} (`integer?`)
  8593. • {skipcc} (`boolean?`)
  8594. Return: ~
  8595. (`any`)
  8596. strchars({string} [, {skipcc}]) *strchars()*
  8597. The result is a Number, which is the number of characters
  8598. in String {string}.
  8599. When {skipcc} is omitted or zero, composing characters are
  8600. counted separately.
  8601. When {skipcc} set to 1, composing characters are ignored.
  8602. |strcharlen()| always does this.
  8603. Returns zero on error.
  8604. Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
  8605. {skipcc} is only available after 7.4.755. For backward
  8606. compatibility, you can define a wrapper function: >vim
  8607. if has("patch-7.4.755")
  8608. function s:strchars(str, skipcc)
  8609. return strchars(a:str, a:skipcc)
  8610. endfunction
  8611. else
  8612. function s:strchars(str, skipcc)
  8613. if a:skipcc
  8614. return strlen(substitute(a:str, ".", "x", "g"))
  8615. else
  8616. return strchars(a:str)
  8617. endif
  8618. endfunction
  8619. endif
  8620. <
  8621. Parameters: ~
  8622. • {string} (`string`)
  8623. • {skipcc} (`boolean?`)
  8624. Return: ~
  8625. (`integer`)
  8626. strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
  8627. The result is a Number, which is the number of display cells
  8628. String {string} occupies on the screen when it starts at {col}
  8629. (first column is zero). When {col} is omitted zero is used.
  8630. Otherwise it is the screen column where to start. This
  8631. matters for Tab characters.
  8632. The option settings of the current window are used. This
  8633. matters for anything that's displayed differently, such as
  8634. 'tabstop' and 'display'.
  8635. When {string} contains characters with East Asian Width Class
  8636. Ambiguous, this function's return value depends on 'ambiwidth'.
  8637. Returns zero on error.
  8638. Also see |strlen()|, |strwidth()| and |strchars()|.
  8639. Parameters: ~
  8640. • {string} (`string`)
  8641. • {col} (`integer?`)
  8642. Return: ~
  8643. (`integer`)
  8644. strftime({format} [, {time}]) *strftime()*
  8645. The result is a String, which is a formatted date and time, as
  8646. specified by the {format} string. The given {time} is used,
  8647. or the current time if no time is given. The accepted
  8648. {format} depends on your system, thus this is not portable!
  8649. See the manual page of the C function strftime() for the
  8650. format. The maximum length of the result is 80 characters.
  8651. See also |localtime()|, |getftime()| and |strptime()|.
  8652. The language can be changed with the |:language| command.
  8653. Examples: >vim
  8654. echo strftime("%c") " Sun Apr 27 11:49:23 1997
  8655. echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25
  8656. echo strftime("%y%m%d %T") " 970427 11:53:55
  8657. echo strftime("%H:%M") " 11:55
  8658. echo strftime("%c", getftime("file.c"))
  8659. " Show mod time of file.c.
  8660. Parameters: ~
  8661. • {format} (`string`)
  8662. • {time} (`number?`)
  8663. Return: ~
  8664. (`string`)
  8665. strgetchar({str}, {index}) *strgetchar()*
  8666. Get a Number corresponding to the character at {index} in
  8667. {str}. This uses a zero-based character index, not a byte
  8668. index. Composing characters are considered separate
  8669. characters here. Use |nr2char()| to convert the Number to a
  8670. String.
  8671. Returns -1 if {index} is invalid.
  8672. Also see |strcharpart()| and |strchars()|.
  8673. Parameters: ~
  8674. • {str} (`string`)
  8675. • {index} (`integer`)
  8676. Return: ~
  8677. (`integer`)
  8678. stridx({haystack}, {needle} [, {start}]) *stridx()*
  8679. The result is a Number, which gives the byte index in
  8680. {haystack} of the first occurrence of the String {needle}.
  8681. If {start} is specified, the search starts at index {start}.
  8682. This can be used to find a second match: >vim
  8683. let colon1 = stridx(line, ":")
  8684. let colon2 = stridx(line, ":", colon1 + 1)
  8685. < The search is done case-sensitive.
  8686. For pattern searches use |match()|.
  8687. -1 is returned if the {needle} does not occur in {haystack}.
  8688. See also |strridx()|.
  8689. Examples: >vim
  8690. echo stridx("An Example", "Example") " 3
  8691. echo stridx("Starting point", "Start") " 0
  8692. echo stridx("Starting point", "start") " -1
  8693. < *strstr()* *strchr()*
  8694. stridx() works similar to the C function strstr(). When used
  8695. with a single character it works similar to strchr().
  8696. Parameters: ~
  8697. • {haystack} (`string`)
  8698. • {needle} (`string`)
  8699. • {start} (`integer?`)
  8700. Return: ~
  8701. (`integer`)
  8702. string({expr}) *string()*
  8703. Return {expr} converted to a String. If {expr} is a Number,
  8704. Float, String, Blob or a composition of them, then the result
  8705. can be parsed back with |eval()|.
  8706. {expr} type result ~
  8707. String 'string'
  8708. Number 123
  8709. Float 123.123456 or 1.123456e8 or
  8710. `str2float('inf')`
  8711. Funcref `function('name')`
  8712. Blob 0z00112233.44556677.8899
  8713. List [item, item]
  8714. Dictionary `{key: value, key: value}`
  8715. Note that in String values the ' character is doubled.
  8716. Also see |strtrans()|.
  8717. Note 2: Output format is mostly compatible with YAML, except
  8718. for infinite and NaN floating-point values representations
  8719. which use |str2float()|. Strings are also dumped literally,
  8720. only single quote is escaped, which does not allow using YAML
  8721. for parsing back binary strings. |eval()| should always work
  8722. for strings and floats though, and this is the only official
  8723. method. Use |msgpackdump()| or |json_encode()| if you need to
  8724. share data with other applications.
  8725. Parameters: ~
  8726. • {expr} (`any`)
  8727. Return: ~
  8728. (`string`)
  8729. strlen({string}) *strlen()*
  8730. The result is a Number, which is the length of the String
  8731. {string} in bytes.
  8732. If the argument is a Number it is first converted to a String.
  8733. For other types an error is given and zero is returned.
  8734. If you want to count the number of multibyte characters use
  8735. |strchars()|.
  8736. Also see |len()|, |strdisplaywidth()| and |strwidth()|.
  8737. Parameters: ~
  8738. • {string} (`string`)
  8739. Return: ~
  8740. (`integer`)
  8741. strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
  8742. The result is a String, which is part of {src}, starting from
  8743. byte {start}, with the byte length {len}.
  8744. When {chars} is present and TRUE then {len} is the number of
  8745. characters positions (composing characters are not counted
  8746. separately, thus "1" means one base character and any
  8747. following composing characters).
  8748. To count {start} as characters instead of bytes use
  8749. |strcharpart()|.
  8750. When bytes are selected which do not exist, this doesn't
  8751. result in an error, the bytes are simply omitted.
  8752. If {len} is missing, the copy continues from {start} till the
  8753. end of the {src}. >vim
  8754. echo strpart("abcdefg", 3, 2) " returns 'de'
  8755. echo strpart("abcdefg", -2, 4) " returns 'ab'
  8756. echo strpart("abcdefg", 5, 4) " returns 'fg'
  8757. echo strpart("abcdefg", 3) " returns 'defg'
  8758. < Note: To get the first character, {start} must be 0. For
  8759. example, to get the character under the cursor: >vim
  8760. strpart(getline("."), col(".") - 1, 1, v:true)
  8761. <
  8762. Returns an empty string on error.
  8763. Parameters: ~
  8764. • {src} (`string`)
  8765. • {start} (`integer`)
  8766. • {len} (`integer?`)
  8767. • {chars} (`0|1?`)
  8768. Return: ~
  8769. (`string`)
  8770. strptime({format}, {timestring}) *strptime()*
  8771. The result is a Number, which is a unix timestamp representing
  8772. the date and time in {timestring}, which is expected to match
  8773. the format specified in {format}.
  8774. The accepted {format} depends on your system, thus this is not
  8775. portable! See the manual page of the C function strptime()
  8776. for the format. Especially avoid "%c". The value of $TZ also
  8777. matters.
  8778. If the {timestring} cannot be parsed with {format} zero is
  8779. returned. If you do not know the format of {timestring} you
  8780. can try different {format} values until you get a non-zero
  8781. result.
  8782. See also |strftime()|.
  8783. Examples: >vim
  8784. echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
  8785. < 862156163 >vim
  8786. echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
  8787. < Sun Apr 27 11:53:55 1997 >vim
  8788. echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
  8789. < Sun Apr 27 12:53:55 1997
  8790. Parameters: ~
  8791. • {format} (`string`)
  8792. • {timestring} (`string`)
  8793. Return: ~
  8794. (`integer`)
  8795. strridx({haystack}, {needle} [, {start}]) *strridx()*
  8796. The result is a Number, which gives the byte index in
  8797. {haystack} of the last occurrence of the String {needle}.
  8798. When {start} is specified, matches beyond this index are
  8799. ignored. This can be used to find a match before a previous
  8800. match: >vim
  8801. let lastcomma = strridx(line, ",")
  8802. let comma2 = strridx(line, ",", lastcomma - 1)
  8803. < The search is done case-sensitive.
  8804. For pattern searches use |match()|.
  8805. -1 is returned if the {needle} does not occur in {haystack}.
  8806. If the {needle} is empty the length of {haystack} is returned.
  8807. See also |stridx()|. Examples: >vim
  8808. echo strridx("an angry armadillo", "an") 3
  8809. < *strrchr()*
  8810. When used with a single character it works similar to the C
  8811. function strrchr().
  8812. Parameters: ~
  8813. • {haystack} (`string`)
  8814. • {needle} (`string`)
  8815. • {start} (`integer?`)
  8816. Return: ~
  8817. (`integer`)
  8818. strtrans({string}) *strtrans()*
  8819. The result is a String, which is {string} with all unprintable
  8820. characters translated into printable characters |'isprint'|.
  8821. Like they are shown in a window. Example: >vim
  8822. echo strtrans(@a)
  8823. < This displays a newline in register a as "^@" instead of
  8824. starting a new line.
  8825. Returns an empty string on error.
  8826. Parameters: ~
  8827. • {string} (`string`)
  8828. Return: ~
  8829. (`string`)
  8830. strutf16len({string} [, {countcc}]) *strutf16len()*
  8831. The result is a Number, which is the number of UTF-16 code
  8832. units in String {string} (after converting it to UTF-16).
  8833. When {countcc} is TRUE, composing characters are counted
  8834. separately.
  8835. When {countcc} is omitted or FALSE, composing characters are
  8836. ignored.
  8837. Returns zero on error.
  8838. Also see |strlen()| and |strcharlen()|.
  8839. Examples: >vim
  8840. echo strutf16len('a') " returns 1
  8841. echo strutf16len('©') " returns 1
  8842. echo strutf16len('😊') " returns 2
  8843. echo strutf16len('ą́') " returns 1
  8844. echo strutf16len('ą́', v:true) " returns 3
  8845. <
  8846. Parameters: ~
  8847. • {string} (`string`)
  8848. • {countcc} (`0|1?`)
  8849. Return: ~
  8850. (`integer`)
  8851. strwidth({string}) *strwidth()*
  8852. The result is a Number, which is the number of display cells
  8853. String {string} occupies. A Tab character is counted as one
  8854. cell, alternatively use |strdisplaywidth()|.
  8855. When {string} contains characters with East Asian Width Class
  8856. Ambiguous, this function's return value depends on 'ambiwidth'.
  8857. Returns zero on error.
  8858. Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
  8859. Parameters: ~
  8860. • {string} (`string`)
  8861. Return: ~
  8862. (`integer`)
  8863. submatch({nr} [, {list}]) *submatch()* *E935*
  8864. Only for an expression in a |:substitute| command or
  8865. substitute() function.
  8866. Returns the {nr}th submatch of the matched text. When {nr}
  8867. is 0 the whole matched text is returned.
  8868. Note that a NL in the string can stand for a line break of a
  8869. multi-line match or a NUL character in the text.
  8870. Also see |sub-replace-expression|.
  8871. If {list} is present and non-zero then submatch() returns
  8872. a list of strings, similar to |getline()| with two arguments.
  8873. NL characters in the text represent NUL characters in the
  8874. text.
  8875. Only returns more than one item for |:substitute|, inside
  8876. |substitute()| this list will always contain one or zero
  8877. items, since there are no real line breaks.
  8878. When substitute() is used recursively only the submatches in
  8879. the current (deepest) call can be obtained.
  8880. Returns an empty string or list on error.
  8881. Examples: >vim
  8882. s/\d\+/\=submatch(0) + 1/
  8883. echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
  8884. < This finds the first number in the line and adds one to it.
  8885. A line break is included as a newline character.
  8886. Parameters: ~
  8887. • {nr} (`integer`)
  8888. • {list} (`nil?`)
  8889. Return: ~
  8890. (`string`)
  8891. substitute({string}, {pat}, {sub}, {flags}) *substitute()*
  8892. The result is a String, which is a copy of {string}, in which
  8893. the first match of {pat} is replaced with {sub}.
  8894. When {flags} is "g", all matches of {pat} in {string} are
  8895. replaced. Otherwise {flags} should be "".
  8896. This works like the ":substitute" command (without any flags).
  8897. But the matching with {pat} is always done like the 'magic'
  8898. option is set and 'cpoptions' is empty (to make scripts
  8899. portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
  8900. if you want to ignore or match case and ignore 'ignorecase'.
  8901. 'smartcase' is not used. See |string-match| for how {pat} is
  8902. used.
  8903. A "~" in {sub} is not replaced with the previous {sub}.
  8904. Note that some codes in {sub} have a special meaning
  8905. |sub-replace-special|. For example, to replace something with
  8906. "\n" (two characters), use "\\\\n" or '\\n'.
  8907. When {pat} does not match in {string}, {string} is returned
  8908. unmodified.
  8909. Example: >vim
  8910. let &path = substitute(&path, ",\\=[^,]*$", "", "")
  8911. < This removes the last component of the 'path' option. >vim
  8912. echo substitute("testing", ".*", "\\U\\0", "")
  8913. < results in "TESTING".
  8914. When {sub} starts with "\=", the remainder is interpreted as
  8915. an expression. See |sub-replace-expression|. Example: >vim
  8916. echo substitute(s, '%\(\x\x\)',
  8917. \ '\=nr2char("0x" .. submatch(1))', 'g')
  8918. < When {sub} is a Funcref that function is called, with one
  8919. optional argument. Example: >vim
  8920. echo substitute(s, '%\(\x\x\)', SubNr, 'g')
  8921. < The optional argument is a list which contains the whole
  8922. matched string and up to nine submatches, like what
  8923. |submatch()| returns. Example: >vim
  8924. echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
  8925. < Returns an empty string on error.
  8926. Parameters: ~
  8927. • {string} (`string`)
  8928. • {pat} (`string`)
  8929. • {sub} (`string`)
  8930. • {flags} (`string`)
  8931. Return: ~
  8932. (`string`)
  8933. swapfilelist() *swapfilelist()*
  8934. Returns a list of swap file names, like what "vim -r" shows.
  8935. See the |-r| command argument. The 'directory' option is used
  8936. for the directories to inspect. If you only want to get a
  8937. list of swap files in the current directory then temporarily
  8938. set 'directory' to a dot: >vim
  8939. let save_dir = &directory
  8940. let &directory = '.'
  8941. let swapfiles = swapfilelist()
  8942. let &directory = save_dir
  8943. Return: ~
  8944. (`string[]`)
  8945. swapinfo({fname}) *swapinfo()*
  8946. The result is a dictionary, which holds information about the
  8947. swapfile {fname}. The available fields are:
  8948. version Vim version
  8949. user user name
  8950. host host name
  8951. fname original file name
  8952. pid PID of the Nvim process that created the swap
  8953. file, or zero if not running.
  8954. mtime last modification time in seconds
  8955. inode Optional: INODE number of the file
  8956. dirty 1 if file was modified, 0 if not
  8957. In case of failure an "error" item is added with the reason:
  8958. Cannot open file: file not found or in accessible
  8959. Cannot read file: cannot read first block
  8960. Not a swap file: does not contain correct block ID
  8961. Magic number mismatch: Info in first block is invalid
  8962. Parameters: ~
  8963. • {fname} (`string`)
  8964. Return: ~
  8965. (`any`)
  8966. swapname({buf}) *swapname()*
  8967. The result is the swap file path of the buffer {buf}.
  8968. For the use of {buf}, see |bufname()| above.
  8969. If buffer {buf} is the current buffer, the result is equal to
  8970. |:swapname| (unless there is no swap file).
  8971. If buffer {buf} has no swap file, returns an empty string.
  8972. Parameters: ~
  8973. • {buf} (`integer|string`)
  8974. Return: ~
  8975. (`string`)
  8976. synID({lnum}, {col}, {trans}) *synID()*
  8977. The result is a Number, which is the syntax ID at the position
  8978. {lnum} and {col} in the current window.
  8979. The syntax ID can be used with |synIDattr()| and
  8980. |synIDtrans()| to obtain syntax information about text.
  8981. {col} is 1 for the leftmost column, {lnum} is 1 for the first
  8982. line. 'synmaxcol' applies, in a longer line zero is returned.
  8983. Note that when the position is after the last character,
  8984. that's where the cursor can be in Insert mode, synID() returns
  8985. zero. {lnum} is used like with |getline()|.
  8986. When {trans} is |TRUE|, transparent items are reduced to the
  8987. item that they reveal. This is useful when wanting to know
  8988. the effective color. When {trans} is |FALSE|, the transparent
  8989. item is returned. This is useful when wanting to know which
  8990. syntax item is effective (e.g. inside parens).
  8991. Warning: This function can be very slow. Best speed is
  8992. obtained by going through the file in forward direction.
  8993. Returns zero on error.
  8994. Example (echoes the name of the syntax item under the cursor): >vim
  8995. echo synIDattr(synID(line("."), col("."), 1), "name")
  8996. <
  8997. Parameters: ~
  8998. • {lnum} (`integer`)
  8999. • {col} (`integer`)
  9000. • {trans} (`0|1`)
  9001. Return: ~
  9002. (`integer`)
  9003. synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
  9004. The result is a String, which is the {what} attribute of
  9005. syntax ID {synID}. This can be used to obtain information
  9006. about a syntax item.
  9007. {mode} can be "gui" or "cterm", to get the attributes
  9008. for that mode. When {mode} is omitted, or an invalid value is
  9009. used, the attributes for the currently active highlighting are
  9010. used (GUI or cterm).
  9011. Use synIDtrans() to follow linked highlight groups.
  9012. {what} result
  9013. "name" the name of the syntax item
  9014. "fg" foreground color (GUI: color name used to set
  9015. the color, cterm: color number as a string,
  9016. term: empty string)
  9017. "bg" background color (as with "fg")
  9018. "font" font name (only available in the GUI)
  9019. |highlight-font|
  9020. "sp" special color (as with "fg") |guisp|
  9021. "fg#" like "fg", but for the GUI and the GUI is
  9022. running the name in "#RRGGBB" form
  9023. "bg#" like "fg#" for "bg"
  9024. "sp#" like "fg#" for "sp"
  9025. "bold" "1" if bold
  9026. "italic" "1" if italic
  9027. "reverse" "1" if reverse
  9028. "inverse" "1" if inverse (= reverse)
  9029. "standout" "1" if standout
  9030. "underline" "1" if underlined
  9031. "undercurl" "1" if undercurled
  9032. "underdouble" "1" if double underlined
  9033. "underdotted" "1" if dotted underlined
  9034. "underdashed" "1" if dashed underlined
  9035. "strikethrough" "1" if struckthrough
  9036. "altfont" "1" if alternative font
  9037. "nocombine" "1" if nocombine
  9038. Returns an empty string on error.
  9039. Example (echoes the color of the syntax item under the
  9040. cursor): >vim
  9041. echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  9042. <
  9043. Can also be used as a |method|: >vim
  9044. echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  9045. <
  9046. Parameters: ~
  9047. • {synID} (`integer`)
  9048. • {what} (`string`)
  9049. • {mode} (`string?`)
  9050. Return: ~
  9051. (`string`)
  9052. synIDtrans({synID}) *synIDtrans()*
  9053. The result is a Number, which is the translated syntax ID of
  9054. {synID}. This is the syntax group ID of what is being used to
  9055. highlight the character. Highlight links given with
  9056. ":highlight link" are followed.
  9057. Returns zero on error.
  9058. Parameters: ~
  9059. • {synID} (`integer`)
  9060. Return: ~
  9061. (`integer`)
  9062. synconcealed({lnum}, {col}) *synconcealed()*
  9063. The result is a |List| with currently three items:
  9064. 1. The first item in the list is 0 if the character at the
  9065. position {lnum} and {col} is not part of a concealable
  9066. region, 1 if it is. {lnum} is used like with |getline()|.
  9067. 2. The second item in the list is a string. If the first item
  9068. is 1, the second item contains the text which will be
  9069. displayed in place of the concealed text, depending on the
  9070. current setting of 'conceallevel' and 'listchars'.
  9071. 3. The third and final item in the list is a number
  9072. representing the specific syntax region matched in the
  9073. line. When the character is not concealed the value is
  9074. zero. This allows detection of the beginning of a new
  9075. concealable region if there are two consecutive regions
  9076. with the same replacement character. For an example, if
  9077. the text is "123456" and both "23" and "45" are concealed
  9078. and replaced by the character "X", then:
  9079. call returns ~
  9080. synconcealed(lnum, 1) [0, '', 0]
  9081. synconcealed(lnum, 2) [1, 'X', 1]
  9082. synconcealed(lnum, 3) [1, 'X', 1]
  9083. synconcealed(lnum, 4) [1, 'X', 2]
  9084. synconcealed(lnum, 5) [1, 'X', 2]
  9085. synconcealed(lnum, 6) [0, '', 0]
  9086. Note: Doesn't consider |matchadd()| highlighting items,
  9087. since syntax and matching highlighting are two different
  9088. mechanisms |syntax-vs-match|.
  9089. Parameters: ~
  9090. • {lnum} (`integer`)
  9091. • {col} (`integer`)
  9092. Return: ~
  9093. (`[integer, string, integer]`)
  9094. synstack({lnum}, {col}) *synstack()*
  9095. Return a |List|, which is the stack of syntax items at the
  9096. position {lnum} and {col} in the current window. {lnum} is
  9097. used like with |getline()|. Each item in the List is an ID
  9098. like what |synID()| returns.
  9099. The first item in the List is the outer region, following are
  9100. items contained in that one. The last one is what |synID()|
  9101. returns, unless not the whole item is highlighted or it is a
  9102. transparent item.
  9103. This function is useful for debugging a syntax file.
  9104. Example that shows the syntax stack under the cursor: >vim
  9105. for id in synstack(line("."), col("."))
  9106. echo synIDattr(id, "name")
  9107. endfor
  9108. < When the position specified with {lnum} and {col} is invalid
  9109. an empty list is returned. The position just after the last
  9110. character in a line and the first column in an empty line are
  9111. valid positions.
  9112. Parameters: ~
  9113. • {lnum} (`integer`)
  9114. • {col} (`integer`)
  9115. Return: ~
  9116. (`integer[]`)
  9117. system({cmd} [, {input}]) *system()* *E677*
  9118. Note: Prefer |vim.system()| in Lua.
  9119. Gets the output of {cmd} as a |string| (|systemlist()| returns
  9120. a |List|) and sets |v:shell_error| to the error code.
  9121. {cmd} is treated as in |jobstart()|:
  9122. If {cmd} is a List it runs directly (no 'shell').
  9123. If {cmd} is a String it runs in the 'shell', like this: >vim
  9124. call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  9125. < Not to be used for interactive commands.
  9126. Result is a String, filtered to avoid platform-specific quirks:
  9127. - <CR><NL> is replaced with <NL>
  9128. - NUL characters are replaced with SOH (0x01)
  9129. Example: >vim
  9130. echo system(['ls', expand('%:h')])
  9131. < If {input} is a string it is written to a pipe and passed as
  9132. stdin to the command. The string is written as-is, line
  9133. separators are not changed.
  9134. If {input} is a |List| it is written to the pipe as
  9135. |writefile()| does with {binary} set to "b" (i.e. with
  9136. a newline between each list item, and newlines inside list
  9137. items converted to NULs).
  9138. When {input} is given and is a valid buffer id, the content of
  9139. the buffer is written to the file line by line, each line
  9140. terminated by NL (and NUL where the text has NL).
  9141. *E5677*
  9142. Note: system() cannot write to or read from backgrounded ("&")
  9143. shell commands, e.g.: >vim
  9144. echo system("cat - &", "foo")
  9145. < which is equivalent to: >
  9146. $ echo foo | bash -c 'cat - &'
  9147. < The pipes are disconnected (unless overridden by shell
  9148. redirection syntax) before input can reach it. Use
  9149. |jobstart()| instead.
  9150. Note: Use |shellescape()| or |::S| with |expand()| or
  9151. |fnamemodify()| to escape special characters in a command
  9152. argument. 'shellquote' and 'shellxquote' must be properly
  9153. configured. Example: >vim
  9154. echo system('ls '..shellescape(expand('%:h')))
  9155. echo system('ls '..expand('%:h:S'))
  9156. < Unlike ":!cmd" there is no automatic check for changed files.
  9157. Use |:checktime| to force a check.
  9158. Parameters: ~
  9159. • {cmd} (`string|string[]`)
  9160. • {input} (`string|string[]|integer?`)
  9161. Return: ~
  9162. (`string`)
  9163. systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
  9164. Same as |system()|, but returns a |List| with lines (parts of
  9165. output separated by NL) with NULs transformed into NLs. Output
  9166. is the same as |readfile()| will output with {binary} argument
  9167. set to "b", except that a final newline is not preserved,
  9168. unless {keepempty} is non-zero.
  9169. Note that on MS-Windows you may get trailing CR characters.
  9170. To see the difference between "echo hello" and "echo -n hello"
  9171. use |system()| and |split()|: >vim
  9172. echo split(system('echo hello'), '\n', 1)
  9173. <
  9174. Returns an empty string on error.
  9175. Parameters: ~
  9176. • {cmd} (`string|string[]`)
  9177. • {input} (`string|string[]|integer?`)
  9178. • {keepempty} (`integer?`)
  9179. Return: ~
  9180. (`string[]`)
  9181. tabpagebuflist([{arg}]) *tabpagebuflist()*
  9182. The result is a |List|, where each item is the number of the
  9183. buffer associated with each window in the current tab page.
  9184. {arg} specifies the number of the tab page to be used. When
  9185. omitted the current tab page is used.
  9186. When {arg} is invalid the number zero is returned.
  9187. To get a list of all buffers in all tabs use this: >vim
  9188. let buflist = []
  9189. for i in range(tabpagenr('$'))
  9190. call extend(buflist, tabpagebuflist(i + 1))
  9191. endfor
  9192. < Note that a buffer may appear in more than one window.
  9193. Parameters: ~
  9194. • {arg} (`integer?`)
  9195. Return: ~
  9196. (`any`)
  9197. tabpagenr([{arg}]) *tabpagenr()*
  9198. The result is a Number, which is the number of the current
  9199. tab page. The first tab page has number 1.
  9200. The optional argument {arg} supports the following values:
  9201. $ the number of the last tab page (the tab page
  9202. count).
  9203. # the number of the last accessed tab page
  9204. (where |g<Tab>| goes to). If there is no
  9205. previous tab page, 0 is returned.
  9206. The number can be used with the |:tab| command.
  9207. Returns zero on error.
  9208. Parameters: ~
  9209. • {arg} (`'$'|'#'?`)
  9210. Return: ~
  9211. (`integer`)
  9212. tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()*
  9213. Like |winnr()| but for tab page {tabarg}.
  9214. {tabarg} specifies the number of tab page to be used.
  9215. {arg} is used like with |winnr()|:
  9216. - When omitted the current window number is returned. This is
  9217. the window which will be used when going to this tab page.
  9218. - When "$" the number of windows is returned.
  9219. - When "#" the previous window nr is returned.
  9220. Useful examples: >vim
  9221. tabpagewinnr(1) " current window of tab page 1
  9222. tabpagewinnr(4, '$') " number of windows in tab page 4
  9223. < When {tabarg} is invalid zero is returned.
  9224. Parameters: ~
  9225. • {tabarg} (`integer`)
  9226. • {arg} (`'$'|'#'?`)
  9227. Return: ~
  9228. (`integer`)
  9229. tagfiles() *tagfiles()*
  9230. Returns a |List| with the file names used to search for tags
  9231. for the current buffer. This is the 'tags' option expanded.
  9232. Return: ~
  9233. (`string[]`)
  9234. taglist({expr} [, {filename}]) *taglist()*
  9235. Returns a |List| of tags matching the regular expression {expr}.
  9236. If {filename} is passed it is used to prioritize the results
  9237. in the same way that |:tselect| does. See |tag-priority|.
  9238. {filename} should be the full path of the file.
  9239. Each list item is a dictionary with at least the following
  9240. entries:
  9241. name Name of the tag.
  9242. filename Name of the file where the tag is
  9243. defined. It is either relative to the
  9244. current directory or a full path.
  9245. cmd Ex command used to locate the tag in
  9246. the file.
  9247. kind Type of the tag. The value for this
  9248. entry depends on the language specific
  9249. kind values. Only available when
  9250. using a tags file generated by
  9251. Universal/Exuberant ctags or hdrtag.
  9252. static A file specific tag. Refer to
  9253. |static-tag| for more information.
  9254. More entries may be present, depending on the content of the
  9255. tags file: access, implementation, inherits and signature.
  9256. Refer to the ctags documentation for information about these
  9257. fields. For C code the fields "struct", "class" and "enum"
  9258. may appear, they give the name of the entity the tag is
  9259. contained in.
  9260. The ex-command "cmd" can be either an ex search pattern, a
  9261. line number or a line number followed by a byte number.
  9262. If there are no matching tags, then an empty list is returned.
  9263. To get an exact tag match, the anchors '^' and '$' should be
  9264. used in {expr}. This also make the function work faster.
  9265. Refer to |tag-regexp| for more information about the tag
  9266. search regular expression pattern.
  9267. Refer to |'tags'| for information about how the tags file is
  9268. located by Vim. Refer to |tags-file-format| for the format of
  9269. the tags file generated by the different ctags tools.
  9270. Parameters: ~
  9271. • {expr} (`any`)
  9272. • {filename} (`string?`)
  9273. Return: ~
  9274. (`any`)
  9275. tan({expr}) *tan()*
  9276. Return the tangent of {expr}, measured in radians, as a |Float|
  9277. in the range [-inf, inf].
  9278. {expr} must evaluate to a |Float| or a |Number|.
  9279. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9280. Examples: >vim
  9281. echo tan(10)
  9282. < 0.648361 >vim
  9283. echo tan(-4.01)
  9284. < -1.181502
  9285. Parameters: ~
  9286. • {expr} (`number`)
  9287. Return: ~
  9288. (`number`)
  9289. tanh({expr}) *tanh()*
  9290. Return the hyperbolic tangent of {expr} as a |Float| in the
  9291. range [-1, 1].
  9292. {expr} must evaluate to a |Float| or a |Number|.
  9293. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9294. Examples: >vim
  9295. echo tanh(0.5)
  9296. < 0.462117 >vim
  9297. echo tanh(-1)
  9298. < -0.761594
  9299. Parameters: ~
  9300. • {expr} (`number`)
  9301. Return: ~
  9302. (`number`)
  9303. tempname() *tempname()*
  9304. Generates a (non-existent) filename located in the Nvim root
  9305. |tempdir|. Scripts can use the filename as a temporary file.
  9306. Example: >vim
  9307. let tmpfile = tempname()
  9308. exe "redir > " .. tmpfile
  9309. <
  9310. Return: ~
  9311. (`string`)
  9312. termopen({cmd} [, {opts}]) *termopen()*
  9313. Spawns {cmd} in a new pseudo-terminal session connected
  9314. to the current (unmodified) buffer. Parameters and behavior
  9315. are the same as |jobstart()| except "pty", "width", "height",
  9316. and "TERM" are ignored: "height" and "width" are taken from
  9317. the current window. Note that termopen() implies a "pty" arg
  9318. to jobstart(), and thus has the implications documented at
  9319. |jobstart()|.
  9320. Returns the same values as jobstart().
  9321. Terminal environment is initialized as in |jobstart-env|,
  9322. except $TERM is set to "xterm-256color". Full behavior is
  9323. described in |terminal|.
  9324. Parameters: ~
  9325. • {cmd} (`string|string[]`)
  9326. • {opts} (`table?`)
  9327. Return: ~
  9328. (`any`)
  9329. test_garbagecollect_now() *test_garbagecollect_now()*
  9330. Like |garbagecollect()|, but executed right away. This must
  9331. only be called directly to avoid any structure to exist
  9332. internally, and |v:testing| must have been set before calling
  9333. any function. *E1142*
  9334. Return: ~
  9335. (`any`)
  9336. timer_info([{id}]) *timer_info()*
  9337. Return a list with information about timers.
  9338. When {id} is given only information about this timer is
  9339. returned. When timer {id} does not exist an empty list is
  9340. returned.
  9341. When {id} is omitted information about all timers is returned.
  9342. For each timer the information is stored in a |Dictionary| with
  9343. these items:
  9344. "id" the timer ID
  9345. "time" time the timer was started with
  9346. "repeat" number of times the timer will still fire;
  9347. -1 means forever
  9348. "callback" the callback
  9349. Parameters: ~
  9350. • {id} (`integer?`)
  9351. Return: ~
  9352. (`any`)
  9353. timer_pause({timer}, {paused}) *timer_pause()*
  9354. Pause or unpause a timer. A paused timer does not invoke its
  9355. callback when its time expires. Unpausing a timer may cause
  9356. the callback to be invoked almost immediately if enough time
  9357. has passed.
  9358. Pausing a timer is useful to avoid the callback to be called
  9359. for a short time.
  9360. If {paused} evaluates to a non-zero Number or a non-empty
  9361. String, then the timer is paused, otherwise it is unpaused.
  9362. See |non-zero-arg|.
  9363. Parameters: ~
  9364. • {timer} (`integer`)
  9365. • {paused} (`boolean`)
  9366. Return: ~
  9367. (`any`)
  9368. timer_start({time}, {callback} [, {options}]) *timer_start()* *timer*
  9369. Create a timer and return the timer ID.
  9370. {time} is the waiting time in milliseconds. This is the
  9371. minimum time before invoking the callback. When the system is
  9372. busy or Vim is not waiting for input the time will be longer.
  9373. Zero can be used to execute the callback when Vim is back in
  9374. the main loop.
  9375. {callback} is the function to call. It can be the name of a
  9376. function or a |Funcref|. It is called with one argument, which
  9377. is the timer ID. The callback is only invoked when Vim is
  9378. waiting for input.
  9379. {options} is a dictionary. Supported entries:
  9380. "repeat" Number of times to repeat the callback.
  9381. -1 means forever. Default is 1.
  9382. If the timer causes an error three times in a
  9383. row the repeat is cancelled.
  9384. Returns -1 on error.
  9385. Example: >vim
  9386. func MyHandler(timer)
  9387. echo 'Handler called'
  9388. endfunc
  9389. let timer = timer_start(500, 'MyHandler',
  9390. \ {'repeat': 3})
  9391. < This invokes MyHandler() three times at 500 msec intervals.
  9392. Parameters: ~
  9393. • {time} (`number`)
  9394. • {callback} (`string|function`)
  9395. • {options} (`table?`)
  9396. Return: ~
  9397. (`any`)
  9398. timer_stop({timer}) *timer_stop()*
  9399. Stop a timer. The timer callback will no longer be invoked.
  9400. {timer} is an ID returned by timer_start(), thus it must be a
  9401. Number. If {timer} does not exist there is no error.
  9402. Parameters: ~
  9403. • {timer} (`integer`)
  9404. Return: ~
  9405. (`any`)
  9406. timer_stopall() *timer_stopall()*
  9407. Stop all timers. The timer callbacks will no longer be
  9408. invoked. Useful if some timers is misbehaving. If there are
  9409. no timers there is no error.
  9410. Return: ~
  9411. (`any`)
  9412. tolower({expr}) *tolower()*
  9413. The result is a copy of the String given, with all uppercase
  9414. characters turned into lowercase (just like applying |gu| to
  9415. the string). Returns an empty string on error.
  9416. Parameters: ~
  9417. • {expr} (`string`)
  9418. Return: ~
  9419. (`string`)
  9420. toupper({expr}) *toupper()*
  9421. The result is a copy of the String given, with all lowercase
  9422. characters turned into uppercase (just like applying |gU| to
  9423. the string). Returns an empty string on error.
  9424. Parameters: ~
  9425. • {expr} (`string`)
  9426. Return: ~
  9427. (`string`)
  9428. tr({src}, {fromstr}, {tostr}) *tr()*
  9429. The result is a copy of the {src} string with all characters
  9430. which appear in {fromstr} replaced by the character in that
  9431. position in the {tostr} string. Thus the first character in
  9432. {fromstr} is translated into the first character in {tostr}
  9433. and so on. Exactly like the unix "tr" command.
  9434. This code also deals with multibyte characters properly.
  9435. Returns an empty string on error.
  9436. Examples: >vim
  9437. echo tr("hello there", "ht", "HT")
  9438. < returns "Hello THere" >vim
  9439. echo tr("<blob>", "<>", "{}")
  9440. < returns "{blob}"
  9441. Parameters: ~
  9442. • {src} (`string`)
  9443. • {fromstr} (`string`)
  9444. • {tostr} (`string`)
  9445. Return: ~
  9446. (`string`)
  9447. trim({text} [, {mask} [, {dir}]]) *trim()*
  9448. Return {text} as a String where any character in {mask} is
  9449. removed from the beginning and/or end of {text}.
  9450. If {mask} is not given, or is an empty string, {mask} is all
  9451. characters up to 0x20, which includes Tab, space, NL and CR,
  9452. plus the non-breaking space character 0xa0.
  9453. The optional {dir} argument specifies where to remove the
  9454. characters:
  9455. 0 remove from the beginning and end of {text}
  9456. 1 remove only at the beginning of {text}
  9457. 2 remove only at the end of {text}
  9458. When omitted both ends are trimmed.
  9459. This function deals with multibyte characters properly.
  9460. Returns an empty string on error.
  9461. Examples: >vim
  9462. echo trim(" some text ")
  9463. < returns "some text" >vim
  9464. echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  9465. < returns "RESERVE_TAIL" >vim
  9466. echo trim("rm<Xrm<>X>rrm", "rm<>")
  9467. < returns "Xrm<>X" (characters in the middle are not removed) >vim
  9468. echo trim(" vim ", " ", 2)
  9469. < returns " vim"
  9470. Parameters: ~
  9471. • {text} (`string`)
  9472. • {mask} (`string?`)
  9473. • {dir} (`0|1|2?`)
  9474. Return: ~
  9475. (`string`)
  9476. trunc({expr}) *trunc()*
  9477. Return the largest integral value with magnitude less than or
  9478. equal to {expr} as a |Float| (truncate towards zero).
  9479. {expr} must evaluate to a |Float| or a |Number|.
  9480. Returns 0.0 if {expr} is not a |Float| or a |Number|.
  9481. Examples: >vim
  9482. echo trunc(1.456)
  9483. < 1.0 >vim
  9484. echo trunc(-5.456)
  9485. < -5.0 >vim
  9486. echo trunc(4.0)
  9487. < 4.0
  9488. Parameters: ~
  9489. • {expr} (`number`)
  9490. Return: ~
  9491. (`integer`)
  9492. type({expr}) *type()*
  9493. The result is a Number representing the type of {expr}.
  9494. Instead of using the number directly, it is better to use the
  9495. v:t_ variable that has the value:
  9496. Number: 0 |v:t_number|
  9497. String: 1 |v:t_string|
  9498. Funcref: 2 |v:t_func|
  9499. List: 3 |v:t_list|
  9500. Dictionary: 4 |v:t_dict|
  9501. Float: 5 |v:t_float|
  9502. Boolean: 6 |v:t_bool| (|v:false| and |v:true|)
  9503. Null: 7 (|v:null|)
  9504. Blob: 10 |v:t_blob|
  9505. For backward compatibility, this method can be used: >vim
  9506. if type(myvar) == type(0) | endif
  9507. if type(myvar) == type("") | endif
  9508. if type(myvar) == type(function("tr")) | endif
  9509. if type(myvar) == type([]) | endif
  9510. if type(myvar) == type({}) | endif
  9511. if type(myvar) == type(0.0) | endif
  9512. if type(myvar) == type(v:true) | endif
  9513. < In place of checking for |v:null| type it is better to check
  9514. for |v:null| directly as it is the only value of this type: >vim
  9515. if myvar is v:null | endif
  9516. < To check if the v:t_ variables exist use this: >vim
  9517. if exists('v:t_number') | endif
  9518. <
  9519. Parameters: ~
  9520. • {expr} (`any`)
  9521. Return: ~
  9522. (`integer`)
  9523. undofile({name}) *undofile()*
  9524. Return the name of the undo file that would be used for a file
  9525. with name {name} when writing. This uses the 'undodir'
  9526. option, finding directories that exist. It does not check if
  9527. the undo file exists.
  9528. {name} is always expanded to the full path, since that is what
  9529. is used internally.
  9530. If {name} is empty undofile() returns an empty string, since a
  9531. buffer without a file name will not write an undo file.
  9532. Useful in combination with |:wundo| and |:rundo|.
  9533. Parameters: ~
  9534. • {name} (`string`)
  9535. Return: ~
  9536. (`string`)
  9537. undotree([{buf}]) *undotree()*
  9538. Return the current state of the undo tree for the current
  9539. buffer, or for a specific buffer if {buf} is given. The
  9540. result is a dictionary with the following items:
  9541. "seq_last" The highest undo sequence number used.
  9542. "seq_cur" The sequence number of the current position in
  9543. the undo tree. This differs from "seq_last"
  9544. when some changes were undone.
  9545. "time_cur" Time last used for |:earlier| and related
  9546. commands. Use |strftime()| to convert to
  9547. something readable.
  9548. "save_last" Number of the last file write. Zero when no
  9549. write yet.
  9550. "save_cur" Number of the current position in the undo
  9551. tree.
  9552. "synced" Non-zero when the last undo block was synced.
  9553. This happens when waiting from input from the
  9554. user. See |undo-blocks|.
  9555. "entries" A list of dictionaries with information about
  9556. undo blocks.
  9557. The first item in the "entries" list is the oldest undo item.
  9558. Each List item is a |Dictionary| with these items:
  9559. "seq" Undo sequence number. Same as what appears in
  9560. |:undolist|.
  9561. "time" Timestamp when the change happened. Use
  9562. |strftime()| to convert to something readable.
  9563. "newhead" Only appears in the item that is the last one
  9564. that was added. This marks the last change
  9565. and where further changes will be added.
  9566. "curhead" Only appears in the item that is the last one
  9567. that was undone. This marks the current
  9568. position in the undo tree, the block that will
  9569. be used by a redo command. When nothing was
  9570. undone after the last change this item will
  9571. not appear anywhere.
  9572. "save" Only appears on the last block before a file
  9573. write. The number is the write count. The
  9574. first write has number 1, the last one the
  9575. "save_last" mentioned above.
  9576. "alt" Alternate entry. This is again a List of undo
  9577. blocks. Each item may again have an "alt"
  9578. item.
  9579. Parameters: ~
  9580. • {buf} (`integer|string?`)
  9581. Return: ~
  9582. (`vim.fn.undotree.ret`)
  9583. uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
  9584. Remove second and succeeding copies of repeated adjacent
  9585. {list} items in-place. Returns {list}. If you want a list
  9586. to remain unmodified make a copy first: >vim
  9587. let newlist = uniq(copy(mylist))
  9588. < The default compare function uses the string representation of
  9589. each item. For the use of {func} and {dict} see |sort()|.
  9590. Returns zero if {list} is not a |List|.
  9591. Parameters: ~
  9592. • {list} (`any`)
  9593. • {func} (`any?`)
  9594. • {dict} (`any?`)
  9595. Return: ~
  9596. (`any[]|0`)
  9597. utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()*
  9598. Same as |charidx()| but returns the UTF-16 code unit index of
  9599. the byte at {idx} in {string} (after converting it to UTF-16).
  9600. When {charidx} is present and TRUE, {idx} is used as the
  9601. character index in the String {string} instead of as the byte
  9602. index.
  9603. An {idx} in the middle of a UTF-8 sequence is rounded
  9604. downwards to the beginning of that sequence.
  9605. Returns -1 if the arguments are invalid or if there are less
  9606. than {idx} bytes in {string}. If there are exactly {idx} bytes
  9607. the length of the string in UTF-16 code units is returned.
  9608. See |byteidx()| and |byteidxcomp()| for getting the byte index
  9609. from the UTF-16 index and |charidx()| for getting the
  9610. character index from the UTF-16 index.
  9611. Refer to |string-offset-encoding| for more information.
  9612. Examples: >vim
  9613. echo utf16idx('a😊😊', 3) " returns 2
  9614. echo utf16idx('a😊😊', 7) " returns 4
  9615. echo utf16idx('a😊😊', 1, 0, 1) " returns 2
  9616. echo utf16idx('a😊😊', 2, 0, 1) " returns 4
  9617. echo utf16idx('aą́c', 6) " returns 2
  9618. echo utf16idx('aą́c', 6, 1) " returns 4
  9619. echo utf16idx('a😊😊', 9) " returns -1
  9620. <
  9621. Parameters: ~
  9622. • {string} (`string`)
  9623. • {idx} (`integer`)
  9624. • {countcc} (`boolean?`)
  9625. • {charidx} (`boolean?`)
  9626. Return: ~
  9627. (`integer`)
  9628. values({dict}) *values()*
  9629. Return a |List| with all the values of {dict}. The |List| is
  9630. in arbitrary order. Also see |items()| and |keys()|.
  9631. Returns zero if {dict} is not a |Dict|.
  9632. Parameters: ~
  9633. • {dict} (`any`)
  9634. Return: ~
  9635. (`any`)
  9636. virtcol({expr} [, {list} [, {winid}]]) *virtcol()*
  9637. The result is a Number, which is the screen column of the file
  9638. position given with {expr}. That is, the last screen position
  9639. occupied by the character at that position, when the screen
  9640. would be of unlimited width. When there is a <Tab> at the
  9641. position, the returned Number will be the column at the end of
  9642. the <Tab>. For example, for a <Tab> in column 1, with 'ts'
  9643. set to 8, it returns 8. |conceal| is ignored.
  9644. For the byte position use |col()|.
  9645. For the use of {expr} see |getpos()| and |col()|.
  9646. When {expr} is "$", it means the end of the cursor line, so
  9647. the result is the number of cells in the cursor line plus one.
  9648. When 'virtualedit' is used {expr} can be [lnum, col, off],
  9649. where "off" is the offset in screen columns from the start of
  9650. the character. E.g., a position within a <Tab> or after the
  9651. last character. When "off" is omitted zero is used. When
  9652. Virtual editing is active in the current mode, a position
  9653. beyond the end of the line can be returned. Also see
  9654. |'virtualedit'|
  9655. If {list} is present and non-zero then virtcol() returns a
  9656. List with the first and last screen position occupied by the
  9657. character.
  9658. With the optional {winid} argument the values are obtained for
  9659. that window instead of the current window.
  9660. Note that only marks in the current file can be used.
  9661. Examples: >vim
  9662. " With text "foo^Lbar" and cursor on the "^L":
  9663. echo virtcol(".") " returns 5
  9664. echo virtcol(".", 1) " returns [4, 5]
  9665. echo virtcol("$") " returns 9
  9666. " With text " there", with 't at 'h':
  9667. echo virtcol("'t") " returns 6
  9668. <
  9669. The first column is 1. 0 or [0, 0] is returned for an error.
  9670. A more advanced example that echoes the maximum length of
  9671. all lines: >vim
  9672. echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  9673. <
  9674. Parameters: ~
  9675. • {expr} (`string|any[]`)
  9676. • {list} (`boolean?`)
  9677. • {winid} (`integer?`)
  9678. Return: ~
  9679. (`any`)
  9680. virtcol2col({winid}, {lnum}, {col}) *virtcol2col()*
  9681. The result is a Number, which is the byte index of the
  9682. character in window {winid} at buffer line {lnum} and virtual
  9683. column {col}.
  9684. If buffer line {lnum} is an empty line, 0 is returned.
  9685. If {col} is greater than the last virtual column in line
  9686. {lnum}, then the byte index of the character at the last
  9687. virtual column is returned.
  9688. For a multi-byte character, the column number of the first
  9689. byte in the character is returned.
  9690. The {winid} argument can be the window number or the
  9691. |window-ID|. If this is zero, then the current window is used.
  9692. Returns -1 if the window {winid} doesn't exist or the buffer
  9693. line {lnum} or virtual column {col} is invalid.
  9694. See also |screenpos()|, |virtcol()| and |col()|.
  9695. Parameters: ~
  9696. • {winid} (`integer`)
  9697. • {lnum} (`integer`)
  9698. • {col} (`integer`)
  9699. Return: ~
  9700. (`any`)
  9701. visualmode([{expr}]) *visualmode()*
  9702. The result is a String, which describes the last Visual mode
  9703. used in the current buffer. Initially it returns an empty
  9704. string, but once Visual mode has been used, it returns "v",
  9705. "V", or "<CTRL-V>" (a single CTRL-V character) for
  9706. character-wise, line-wise, or block-wise Visual mode
  9707. respectively.
  9708. Example: >vim
  9709. exe "normal " .. visualmode()
  9710. < This enters the same Visual mode as before. It is also useful
  9711. in scripts if you wish to act differently depending on the
  9712. Visual mode that was used.
  9713. If Visual mode is active, use |mode()| to get the Visual mode
  9714. (e.g., in a |:vmap|).
  9715. If {expr} is supplied and it evaluates to a non-zero Number or
  9716. a non-empty String, then the Visual mode will be cleared and
  9717. the old value is returned. See |non-zero-arg|.
  9718. Parameters: ~
  9719. • {expr} (`boolean?`)
  9720. Return: ~
  9721. (`any`)
  9722. wait({timeout}, {condition} [, {interval}]) *wait()*
  9723. Waits until {condition} evaluates to |TRUE|, where {condition}
  9724. is a |Funcref| or |string| containing an expression.
  9725. {timeout} is the maximum waiting time in milliseconds, -1
  9726. means forever.
  9727. Condition is evaluated on user events, internal events, and
  9728. every {interval} milliseconds (default: 200).
  9729. Returns a status integer:
  9730. 0 if the condition was satisfied before timeout
  9731. -1 if the timeout was exceeded
  9732. -2 if the function was interrupted (by |CTRL-C|)
  9733. -3 if an error occurred
  9734. Parameters: ~
  9735. • {timeout} (`integer`)
  9736. • {condition} (`any`)
  9737. • {interval} (`number?`)
  9738. Return: ~
  9739. (`any`)
  9740. wildmenumode() *wildmenumode()*
  9741. Returns |TRUE| when the wildmenu is active and |FALSE|
  9742. otherwise. See 'wildmenu' and 'wildmode'.
  9743. This can be used in mappings to handle the 'wildcharm' option
  9744. gracefully. (Makes only sense with |mapmode-c| mappings).
  9745. For example to make <c-j> work like <down> in wildmode, use: >vim
  9746. cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  9747. <
  9748. (Note: this needs the 'wildcharm' option set appropriately).
  9749. Return: ~
  9750. (`any`)
  9751. win_execute({id}, {command} [, {silent}]) *win_execute()*
  9752. Like `execute()` but in the context of window {id}.
  9753. The window will temporarily be made the current window,
  9754. without triggering autocommands or changing directory. When
  9755. executing {command} autocommands will be triggered, this may
  9756. have unexpected side effects. Use `:noautocmd` if needed.
  9757. Example: >vim
  9758. call win_execute(winid, 'syntax enable')
  9759. < Doing the same with `setwinvar()` would not trigger
  9760. autocommands and not actually show syntax highlighting.
  9761. When window {id} does not exist then no error is given and
  9762. an empty string is returned.
  9763. Parameters: ~
  9764. • {id} (`integer`)
  9765. • {command} (`string`)
  9766. • {silent} (`boolean?`)
  9767. Return: ~
  9768. (`any`)
  9769. win_findbuf({bufnr}) *win_findbuf()*
  9770. Returns a |List| with |window-ID|s for windows that contain
  9771. buffer {bufnr}. When there is none the list is empty.
  9772. Parameters: ~
  9773. • {bufnr} (`integer`)
  9774. Return: ~
  9775. (`integer[]`)
  9776. win_getid([{win} [, {tab}]]) *win_getid()*
  9777. Get the |window-ID| for the specified window.
  9778. When {win} is missing use the current window.
  9779. With {win} this is the window number. The top window has
  9780. number 1.
  9781. Without {tab} use the current tab, otherwise the tab with
  9782. number {tab}. The first tab has number one.
  9783. Return zero if the window cannot be found.
  9784. Parameters: ~
  9785. • {win} (`integer?`)
  9786. • {tab} (`integer?`)
  9787. Return: ~
  9788. (`integer`)
  9789. win_gettype([{nr}]) *win_gettype()*
  9790. Return the type of the window:
  9791. "autocmd" autocommand window. Temporary window
  9792. used to execute autocommands.
  9793. "command" command-line window |cmdwin|
  9794. (empty) normal window
  9795. "loclist" |location-list-window|
  9796. "popup" floating window |api-floatwin|
  9797. "preview" preview window |preview-window|
  9798. "quickfix" |quickfix-window|
  9799. "unknown" window {nr} not found
  9800. When {nr} is omitted return the type of the current window.
  9801. When {nr} is given return the type of this window by number or
  9802. |window-ID|.
  9803. Also see the 'buftype' option.
  9804. Parameters: ~
  9805. • {nr} (`integer?`)
  9806. Return: ~
  9807. (`'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'`)
  9808. win_gotoid({expr}) *win_gotoid()*
  9809. Go to window with ID {expr}. This may also change the current
  9810. tabpage.
  9811. Return TRUE if successful, FALSE if the window cannot be found.
  9812. Parameters: ~
  9813. • {expr} (`integer`)
  9814. Return: ~
  9815. (`0|1`)
  9816. win_id2tabwin({expr}) *win_id2tabwin()*
  9817. Return a list with the tab number and window number of window
  9818. with ID {expr}: [tabnr, winnr].
  9819. Return [0, 0] if the window cannot be found.
  9820. Parameters: ~
  9821. • {expr} (`integer`)
  9822. Return: ~
  9823. (`any`)
  9824. win_id2win({expr}) *win_id2win()*
  9825. Return the window number of window with ID {expr}.
  9826. Return 0 if the window cannot be found in the current tabpage.
  9827. Parameters: ~
  9828. • {expr} (`integer`)
  9829. Return: ~
  9830. (`any`)
  9831. win_move_separator({nr}, {offset}) *win_move_separator()*
  9832. Move window {nr}'s vertical separator (i.e., the right border)
  9833. by {offset} columns, as if being dragged by the mouse. {nr}
  9834. can be a window number or |window-ID|. A positive {offset}
  9835. moves right and a negative {offset} moves left. Moving a
  9836. window's vertical separator will change the width of the
  9837. window and the width of other windows adjacent to the vertical
  9838. separator. The magnitude of movement may be smaller than
  9839. specified (e.g., as a consequence of maintaining
  9840. 'winminwidth'). Returns TRUE if the window can be found and
  9841. FALSE otherwise.
  9842. This will fail for the rightmost window and a full-width
  9843. window, since it has no separator on the right.
  9844. Only works for the current tab page. *E1308*
  9845. Parameters: ~
  9846. • {nr} (`integer`)
  9847. • {offset} (`integer`)
  9848. Return: ~
  9849. (`any`)
  9850. win_move_statusline({nr}, {offset}) *win_move_statusline()*
  9851. Move window {nr}'s status line (i.e., the bottom border) by
  9852. {offset} rows, as if being dragged by the mouse. {nr} can be a
  9853. window number or |window-ID|. A positive {offset} moves down
  9854. and a negative {offset} moves up. Moving a window's status
  9855. line will change the height of the window and the height of
  9856. other windows adjacent to the status line. The magnitude of
  9857. movement may be smaller than specified (e.g., as a consequence
  9858. of maintaining 'winminheight'). Returns TRUE if the window can
  9859. be found and FALSE otherwise.
  9860. Only works for the current tab page.
  9861. Parameters: ~
  9862. • {nr} (`integer`)
  9863. • {offset} (`integer`)
  9864. Return: ~
  9865. (`any`)
  9866. win_screenpos({nr}) *win_screenpos()*
  9867. Return the screen position of window {nr} as a list with two
  9868. numbers: [row, col]. The first window always has position
  9869. [1, 1], unless there is a tabline, then it is [2, 1].
  9870. {nr} can be the window number or the |window-ID|. Use zero
  9871. for the current window.
  9872. Returns [0, 0] if the window cannot be found.
  9873. Parameters: ~
  9874. • {nr} (`integer`)
  9875. Return: ~
  9876. (`any`)
  9877. win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
  9878. Temporarily switch to window {target}, then move window {nr}
  9879. to a new split adjacent to {target}.
  9880. Unlike commands such as |:split|, no new windows are created
  9881. (the |window-ID| of window {nr} is unchanged after the move).
  9882. Both {nr} and {target} can be window numbers or |window-ID|s.
  9883. Both must be in the current tab page.
  9884. Returns zero for success, non-zero for failure.
  9885. {options} is a |Dictionary| with the following optional entries:
  9886. "vertical" When TRUE, the split is created vertically,
  9887. like with |:vsplit|.
  9888. "rightbelow" When TRUE, the split is made below or to the
  9889. right (if vertical). When FALSE, it is done
  9890. above or to the left (if vertical). When not
  9891. present, the values of 'splitbelow' and
  9892. 'splitright' are used.
  9893. Parameters: ~
  9894. • {nr} (`integer`)
  9895. • {target} (`integer`)
  9896. • {options} (`table?`)
  9897. Return: ~
  9898. (`any`)
  9899. winbufnr({nr}) *winbufnr()*
  9900. The result is a Number, which is the number of the buffer
  9901. associated with window {nr}. {nr} can be the window number or
  9902. the |window-ID|.
  9903. When {nr} is zero, the number of the buffer in the current
  9904. window is returned.
  9905. When window {nr} doesn't exist, -1 is returned.
  9906. Example: >vim
  9907. echo "The file in the current window is " .. bufname(winbufnr(0))
  9908. <
  9909. Parameters: ~
  9910. • {nr} (`integer`)
  9911. Return: ~
  9912. (`integer`)
  9913. wincol() *wincol()*
  9914. The result is a Number, which is the virtual column of the
  9915. cursor in the window. This is counting screen cells from the
  9916. left side of the window. The leftmost column is one.
  9917. Return: ~
  9918. (`integer`)
  9919. windowsversion() *windowsversion()*
  9920. The result is a String. For MS-Windows it indicates the OS
  9921. version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  9922. Windows XP is "5.1". For non-MS-Windows systems the result is
  9923. an empty string.
  9924. Return: ~
  9925. (`string`)
  9926. winheight({nr}) *winheight()*
  9927. The result is a Number, which is the height of window {nr}.
  9928. {nr} can be the window number or the |window-ID|.
  9929. When {nr} is zero, the height of the current window is
  9930. returned. When window {nr} doesn't exist, -1 is returned.
  9931. An existing window always has a height of zero or more.
  9932. This excludes any window toolbar line.
  9933. Examples: >vim
  9934. echo "The current window has " .. winheight(0) .. " lines."
  9935. <
  9936. Parameters: ~
  9937. • {nr} (`integer`)
  9938. Return: ~
  9939. (`integer`)
  9940. winlayout([{tabnr}]) *winlayout()*
  9941. The result is a nested List containing the layout of windows
  9942. in a tabpage.
  9943. Without {tabnr} use the current tabpage, otherwise the tabpage
  9944. with number {tabnr}. If the tabpage {tabnr} is not found,
  9945. returns an empty list.
  9946. For a leaf window, it returns: >
  9947. ["leaf", {winid}]
  9948. <
  9949. For horizontally split windows, which form a column, it
  9950. returns: >
  9951. ["col", [{nested list of windows}]]
  9952. < For vertically split windows, which form a row, it returns: >
  9953. ["row", [{nested list of windows}]]
  9954. <
  9955. Example: >vim
  9956. " Only one window in the tab page
  9957. echo winlayout()
  9958. < >
  9959. ['leaf', 1000]
  9960. < >vim
  9961. " Two horizontally split windows
  9962. echo winlayout()
  9963. < >
  9964. ['col', [['leaf', 1000], ['leaf', 1001]]]
  9965. < >vim
  9966. " The second tab page, with three horizontally split
  9967. " windows, with two vertically split windows in the
  9968. " middle window
  9969. echo winlayout(2)
  9970. < >
  9971. ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  9972. ['leaf', 1001]]], ['leaf', 1000]]]
  9973. <
  9974. Parameters: ~
  9975. • {tabnr} (`integer?`)
  9976. Return: ~
  9977. (`any[]`)
  9978. winline() *winline()*
  9979. The result is a Number, which is the screen line of the cursor
  9980. in the window. This is counting screen lines from the top of
  9981. the window. The first line is one.
  9982. If the cursor was moved the view on the file will be updated
  9983. first, this may cause a scroll.
  9984. Return: ~
  9985. (`integer`)
  9986. winnr([{arg}]) *winnr()*
  9987. The result is a Number, which is the number of the current
  9988. window. The top window has number 1.
  9989. Returns zero for a popup window.
  9990. The optional argument {arg} supports the following values:
  9991. $ the number of the last window (the window
  9992. count).
  9993. # the number of the last accessed window (where
  9994. |CTRL-W_p| goes to). If there is no previous
  9995. window or it is in another tab page 0 is
  9996. returned. May refer to the current window in
  9997. some cases (e.g. when evaluating 'statusline'
  9998. expressions).
  9999. {N}j the number of the Nth window below the
  10000. current window (where |CTRL-W_j| goes to).
  10001. {N}k the number of the Nth window above the current
  10002. window (where |CTRL-W_k| goes to).
  10003. {N}h the number of the Nth window left of the
  10004. current window (where |CTRL-W_h| goes to).
  10005. {N}l the number of the Nth window right of the
  10006. current window (where |CTRL-W_l| goes to).
  10007. The number can be used with |CTRL-W_w| and ":wincmd w"
  10008. |:wincmd|.
  10009. When {arg} is invalid an error is given and zero is returned.
  10010. Also see |tabpagewinnr()| and |win_getid()|.
  10011. Examples: >vim
  10012. let window_count = winnr('$')
  10013. let prev_window = winnr('#')
  10014. let wnum = winnr('3k')
  10015. <
  10016. Parameters: ~
  10017. • {arg} (`string|integer?`)
  10018. Return: ~
  10019. (`any`)
  10020. winrestcmd() *winrestcmd()*
  10021. Returns a sequence of |:resize| commands that should restore
  10022. the current window sizes. Only works properly when no windows
  10023. are opened or closed and the current window and tab page is
  10024. unchanged.
  10025. Example: >vim
  10026. let cmd = winrestcmd()
  10027. call MessWithWindowSizes()
  10028. exe cmd
  10029. <
  10030. Return: ~
  10031. (`any`)
  10032. winrestview({dict}) *winrestview()*
  10033. Uses the |Dictionary| returned by |winsaveview()| to restore
  10034. the view of the current window.
  10035. Note: The {dict} does not have to contain all values, that are
  10036. returned by |winsaveview()|. If values are missing, those
  10037. settings won't be restored. So you can use: >vim
  10038. call winrestview({'curswant': 4})
  10039. <
  10040. This will only set the curswant value (the column the cursor
  10041. wants to move on vertical movements) of the cursor to column 5
  10042. (yes, that is 5), while all other settings will remain the
  10043. same. This is useful, if you set the cursor position manually.
  10044. If you have changed the values the result is unpredictable.
  10045. If the window size changed the result won't be the same.
  10046. Parameters: ~
  10047. • {dict} (`vim.fn.winrestview.dict`)
  10048. Return: ~
  10049. (`any`)
  10050. winsaveview() *winsaveview()*
  10051. Returns a |Dictionary| that contains information to restore
  10052. the view of the current window. Use |winrestview()| to
  10053. restore the view.
  10054. This is useful if you have a mapping that jumps around in the
  10055. buffer and you want to go back to the original view.
  10056. This does not save fold information. Use the 'foldenable'
  10057. option to temporarily switch off folding, so that folds are
  10058. not opened when moving around. This may have side effects.
  10059. The return value includes:
  10060. lnum cursor line number
  10061. col cursor column (Note: the first column
  10062. zero, as opposed to what |getcurpos()|
  10063. returns)
  10064. coladd cursor column offset for 'virtualedit'
  10065. curswant column for vertical movement (Note:
  10066. the first column is zero, as opposed
  10067. to what |getcurpos()| returns). After
  10068. |$| command it will be a very large
  10069. number equal to |v:maxcol|.
  10070. topline first line in the window
  10071. topfill filler lines, only in diff mode
  10072. leftcol first column displayed; only used when
  10073. 'wrap' is off
  10074. skipcol columns skipped
  10075. Note that no option values are saved.
  10076. Return: ~
  10077. (`vim.fn.winsaveview.ret`)
  10078. winwidth({nr}) *winwidth()*
  10079. The result is a Number, which is the width of window {nr}.
  10080. {nr} can be the window number or the |window-ID|.
  10081. When {nr} is zero, the width of the current window is
  10082. returned. When window {nr} doesn't exist, -1 is returned.
  10083. An existing window always has a width of zero or more.
  10084. Examples: >vim
  10085. echo "The current window has " .. winwidth(0) .. " columns."
  10086. if winwidth(0) <= 50
  10087. 50 wincmd |
  10088. endif
  10089. < For getting the terminal or screen size, see the 'columns'
  10090. option.
  10091. Parameters: ~
  10092. • {nr} (`integer`)
  10093. Return: ~
  10094. (`any`)
  10095. wordcount() *wordcount()*
  10096. The result is a dictionary of byte/chars/word statistics for
  10097. the current buffer. This is the same info as provided by
  10098. |g_CTRL-G|
  10099. The return value includes:
  10100. bytes Number of bytes in the buffer
  10101. chars Number of chars in the buffer
  10102. words Number of words in the buffer
  10103. cursor_bytes Number of bytes before cursor position
  10104. (not in Visual mode)
  10105. cursor_chars Number of chars before cursor position
  10106. (not in Visual mode)
  10107. cursor_words Number of words before cursor position
  10108. (not in Visual mode)
  10109. visual_bytes Number of bytes visually selected
  10110. (only in Visual mode)
  10111. visual_chars Number of chars visually selected
  10112. (only in Visual mode)
  10113. visual_words Number of words visually selected
  10114. (only in Visual mode)
  10115. Return: ~
  10116. (`any`)
  10117. writefile({object}, {fname} [, {flags}]) *writefile()*
  10118. When {object} is a |List| write it to file {fname}. Each list
  10119. item is separated with a NL. Each list item must be a String
  10120. or Number.
  10121. All NL characters are replaced with a NUL character.
  10122. Inserting CR characters needs to be done before passing {list}
  10123. to writefile().
  10124. When {object} is a |Blob| write the bytes to file {fname}
  10125. unmodified, also when binary mode is not specified.
  10126. {flags} must be a String. These characters are recognized:
  10127. 'b' Binary mode is used: There will not be a NL after the
  10128. last list item. An empty item at the end does cause the
  10129. last line in the file to end in a NL.
  10130. 'a' Append mode is used, lines are appended to the file: >vim
  10131. call writefile(["foo"], "event.log", "a")
  10132. call writefile(["bar"], "event.log", "a")
  10133. <
  10134. 'D' Delete the file when the current function ends. This
  10135. works like: >vim
  10136. defer delete({fname})
  10137. < Fails when not in a function. Also see |:defer|.
  10138. 's' fsync() is called after writing the file. This flushes
  10139. the file to disk, if possible. This takes more time but
  10140. avoids losing the file if the system crashes.
  10141. 'S' fsync() is not called, even when 'fsync' is set.
  10142. When {flags} does not contain "S" or "s" then fsync() is
  10143. called if the 'fsync' option is set.
  10144. An existing file is overwritten, if possible.
  10145. When the write fails -1 is returned, otherwise 0. There is an
  10146. error message if the file can't be created or when writing
  10147. fails.
  10148. Also see |readfile()|.
  10149. To copy a file byte for byte: >vim
  10150. let fl = readfile("foo", "b")
  10151. call writefile(fl, "foocopy", "b")
  10152. <
  10153. Parameters: ~
  10154. • {object} (`any`)
  10155. • {fname} (`string`)
  10156. • {flags} (`string?`)
  10157. Return: ~
  10158. (`any`)
  10159. xor({expr}, {expr}) *xor()*
  10160. Bitwise XOR on the two arguments. The arguments are converted
  10161. to a number. A List, Dict or Float argument causes an error.
  10162. Also see `and()` and `or()`.
  10163. Example: >vim
  10164. let bits = xor(bits, 0x80)
  10165. <
  10166. Parameters: ~
  10167. • {expr} (`number`)
  10168. • {expr1} (`number`)
  10169. Return: ~
  10170. (`any`)
  10171. ==============================================================================
  10172. 2. Matching a pattern in a String *string-match*
  10173. This is common between several functions. A regexp pattern as explained at
  10174. |pattern| is normally used to find a match in the buffer lines. When a
  10175. pattern is used to find a match in a String, almost everything works in the
  10176. same way. The difference is that a String is handled like it is one line.
  10177. When it contains a "\n" character, this is not seen as a line break for the
  10178. pattern. It can be matched with a "\n" in the pattern, or with ".". Example:
  10179. >vim
  10180. let a = "aaaa\nxxxx"
  10181. echo matchstr(a, "..\n..")
  10182. " aa
  10183. " xx
  10184. echo matchstr(a, "a.x")
  10185. " a
  10186. " x
  10187. Don't forget that "^" will only match at the first character of the String and
  10188. "$" at the last character of the string. They don't match after or before a
  10189. "\n".
  10190. vim:tw=78:ts=8:noet:ft=help:norl: