syntax.txt 230 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940
  1. *syntax.txt* For Vim version 9.0. Last change: 2022 Nov 24
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Syntax highlighting *syntax* *syntax-highlighting* *coloring*
  4. Syntax highlighting enables Vim to show parts of the text in another font or
  5. color. Those parts can be specific keywords or text matching a pattern. Vim
  6. doesn't parse the whole file (to keep it fast), so the highlighting has its
  7. limitations. Lexical highlighting might be a better name, but since everybody
  8. calls it syntax highlighting we'll stick with that.
  9. Vim supports syntax highlighting on all terminals. But since most ordinary
  10. terminals have very limited highlighting possibilities, it works best in the
  11. GUI version, gvim.
  12. In the User Manual:
  13. |usr_06.txt| introduces syntax highlighting.
  14. |usr_44.txt| introduces writing a syntax file.
  15. 1. Quick start |:syn-qstart|
  16. 2. Syntax files |:syn-files|
  17. 3. Syntax loading procedure |syntax-loading|
  18. 4. Converting to HTML |2html.vim|
  19. 5. Syntax file remarks |:syn-file-remarks|
  20. 6. Defining a syntax |:syn-define|
  21. 7. :syntax arguments |:syn-arguments|
  22. 8. Syntax patterns |:syn-pattern|
  23. 9. Syntax clusters |:syn-cluster|
  24. 10. Including syntax files |:syn-include|
  25. 11. Synchronizing |:syn-sync|
  26. 12. Listing syntax items |:syntax|
  27. 13. Colorschemes |color-schemes|
  28. 14. Highlight command |:highlight|
  29. 15. Linking groups |:highlight-link|
  30. 16. Cleaning up |:syn-clear|
  31. 17. Highlighting tags |tag-highlight|
  32. 18. Window-local syntax |:ownsyntax|
  33. 19. Color xterms |xterm-color|
  34. 20. When syntax is slow |:syntime|
  35. {Vi does not have any of these commands}
  36. Syntax highlighting is not available when the |+syntax| feature has been
  37. disabled at compile time.
  38. ==============================================================================
  39. 1. Quick start *:syn-qstart*
  40. *:syn-enable* *:syntax-enable*
  41. This command switches on syntax highlighting: >
  42. :syntax enable
  43. What this command actually does is to execute the command >
  44. :source $VIMRUNTIME/syntax/syntax.vim
  45. If the VIM environment variable is not set, Vim will try to find
  46. the path in another way (see |$VIMRUNTIME|). Usually this works just
  47. fine. If it doesn't, try setting the VIM environment variable to the
  48. directory where the Vim stuff is located. For example, if your syntax files
  49. are in the "/usr/vim/vim82/syntax" directory, set $VIMRUNTIME to
  50. "/usr/vim/vim82". You must do this in the shell, before starting Vim.
  51. This command also sources the |menu.vim| script when the GUI is running or
  52. will start soon. See |'go-M'| about avoiding that.
  53. *:syn-on* *:syntax-on*
  54. The `:syntax enable` command will keep most of your current color settings.
  55. This allows using `:highlight` commands to set your preferred colors before or
  56. after using this command. If you want Vim to overrule your settings with the
  57. defaults, use: >
  58. :syntax on
  59. <
  60. *:hi-normal* *:highlight-normal*
  61. If you are running in the GUI, you can get white text on a black background
  62. with: >
  63. :highlight Normal guibg=Black guifg=White
  64. For a color terminal see |:hi-normal-cterm|.
  65. For setting up your own colors syntax highlighting see |syncolor|.
  66. NOTE: The syntax files on MS-Windows have lines that end in <CR><NL>.
  67. The files for Unix end in <NL>. This means you should use the right type of
  68. file for your system. Although on MS-Windows the right format is
  69. automatically selected if the 'fileformats' option is not empty.
  70. NOTE: When using reverse video ("gvim -fg white -bg black"), the default value
  71. of 'background' will not be set until the GUI window is opened, which is after
  72. reading the |gvimrc|. This will cause the wrong default highlighting to be
  73. used. To set the default value of 'background' before switching on
  74. highlighting, include the ":gui" command in the |gvimrc|: >
  75. :gui " open window and set default for 'background'
  76. :syntax on " start highlighting, use 'background' to set colors
  77. NOTE: Using ":gui" in the |gvimrc| means that "gvim -f" won't start in the
  78. foreground! Use ":gui -f" then.
  79. *g:syntax_on*
  80. You can toggle the syntax on/off with this command: >
  81. :if exists("g:syntax_on") | syntax off | else | syntax enable | endif
  82. To put this into a mapping, you can use: >
  83. :map <F7> :if exists("g:syntax_on") <Bar>
  84. \ syntax off <Bar>
  85. \ else <Bar>
  86. \ syntax enable <Bar>
  87. \ endif <CR>
  88. [using the |<>| notation, type this literally]
  89. Details:
  90. The ":syntax" commands are implemented by sourcing a file. To see exactly how
  91. this works, look in the file:
  92. command file ~
  93. :syntax enable $VIMRUNTIME/syntax/syntax.vim
  94. :syntax on $VIMRUNTIME/syntax/syntax.vim
  95. :syntax manual $VIMRUNTIME/syntax/manual.vim
  96. :syntax off $VIMRUNTIME/syntax/nosyntax.vim
  97. Also see |syntax-loading|.
  98. NOTE: If displaying long lines is slow and switching off syntax highlighting
  99. makes it fast, consider setting the 'synmaxcol' option to a lower value.
  100. ==============================================================================
  101. 2. Syntax files *:syn-files*
  102. The syntax and highlighting commands for one language are normally stored in
  103. a syntax file. The name convention is: "{name}.vim". Where {name} is the
  104. name of the language, or an abbreviation (to fit the name in 8.3 characters,
  105. a requirement in case the file is used on a DOS filesystem).
  106. Examples:
  107. c.vim perl.vim java.vim html.vim
  108. cpp.vim sh.vim csh.vim
  109. The syntax file can contain any Ex commands, just like a vimrc file. But
  110. the idea is that only commands for a specific language are included. When a
  111. language is a superset of another language, it may include the other one,
  112. for example, the cpp.vim file could include the c.vim file: >
  113. :so $VIMRUNTIME/syntax/c.vim
  114. The .vim files are normally loaded with an autocommand. For example: >
  115. :au Syntax c runtime! syntax/c.vim
  116. :au Syntax cpp runtime! syntax/cpp.vim
  117. These commands are normally in the file $VIMRUNTIME/syntax/synload.vim.
  118. MAKING YOUR OWN SYNTAX FILES *mysyntaxfile*
  119. When you create your own syntax files, and you want to have Vim use these
  120. automatically with ":syntax enable", do this:
  121. 1. Create your user runtime directory. You would normally use the first item
  122. of the 'runtimepath' option. Example for Unix: >
  123. mkdir ~/.vim
  124. 2. Create a directory in there called "syntax". For Unix: >
  125. mkdir ~/.vim/syntax
  126. 3. Write the Vim syntax file. Or download one from the internet. Then write
  127. it in your syntax directory. For example, for the "mine" syntax: >
  128. :w ~/.vim/syntax/mine.vim
  129. Now you can start using your syntax file manually: >
  130. :set syntax=mine
  131. You don't have to exit Vim to use this.
  132. If you also want Vim to detect the type of file, see |new-filetype|.
  133. If you are setting up a system with many users and you don't want each user
  134. to add the same syntax file, you can use another directory from 'runtimepath'.
  135. ADDING TO AN EXISTING SYNTAX FILE *mysyntaxfile-add*
  136. If you are mostly satisfied with an existing syntax file, but would like to
  137. add a few items or change the highlighting, follow these steps:
  138. 1. Create your user directory from 'runtimepath', see above.
  139. 2. Create a directory in there called "after/syntax". For Unix: >
  140. mkdir ~/.vim/after
  141. mkdir ~/.vim/after/syntax
  142. 3. Write a Vim script that contains the commands you want to use. For
  143. example, to change the colors for the C syntax: >
  144. highlight cComment ctermfg=Green guifg=Green
  145. 4. Write that file in the "after/syntax" directory. Use the name of the
  146. syntax, with ".vim" added. For our C syntax: >
  147. :w ~/.vim/after/syntax/c.vim
  148. That's it. The next time you edit a C file the Comment color will be
  149. different. You don't even have to restart Vim.
  150. If you have multiple files, you can use the filetype as the directory name.
  151. All the "*.vim" files in this directory will be used, for example:
  152. ~/.vim/after/syntax/c/one.vim
  153. ~/.vim/after/syntax/c/two.vim
  154. REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
  155. If you don't like a distributed syntax file, or you have downloaded a new
  156. version, follow the same steps as for |mysyntaxfile| above. Just make sure
  157. that you write the syntax file in a directory that is early in 'runtimepath'.
  158. Vim will only load the first syntax file found, assuming that it sets
  159. b:current_syntax.
  160. NAMING CONVENTIONS *group-name* *{group-name}* *E669* *W18*
  161. A syntax group name is to be used for syntax items that match the same kind of
  162. thing. These are then linked to a highlight group that specifies the color.
  163. A syntax group name doesn't specify any color or attributes itself.
  164. The name for a highlight or syntax group must consist of ASCII letters, digits
  165. and the underscore. As a regexp: "[a-zA-Z0-9_]*". However, Vim does not give
  166. an error when using other characters. The maximum length of a group name is
  167. about 200 bytes. *E1249*
  168. To be able to allow each user to pick their favorite set of colors, there must
  169. be preferred names for highlight groups that are common for many languages.
  170. These are the suggested group names (if syntax highlighting works properly
  171. you can see the actual color, except for "Ignore"):
  172. *Comment any comment
  173. *Constant any constant
  174. String a string constant: "this is a string"
  175. Character a character constant: 'c', '\n'
  176. Number a number constant: 234, 0xff
  177. Boolean a boolean constant: TRUE, false
  178. Float a floating point constant: 2.3e10
  179. *Identifier any variable name
  180. Function function name (also: methods for classes)
  181. *Statement any statement
  182. Conditional if, then, else, endif, switch, etc.
  183. Repeat for, do, while, etc.
  184. Label case, default, etc.
  185. Operator "sizeof", "+", "*", etc.
  186. Keyword any other keyword
  187. Exception try, catch, throw
  188. *PreProc generic Preprocessor
  189. Include preprocessor #include
  190. Define preprocessor #define
  191. Macro same as Define
  192. PreCondit preprocessor #if, #else, #endif, etc.
  193. *Type int, long, char, etc.
  194. StorageClass static, register, volatile, etc.
  195. Structure struct, union, enum, etc.
  196. Typedef A typedef
  197. *Special any special symbol
  198. SpecialChar special character in a constant
  199. Tag you can use CTRL-] on this
  200. Delimiter character that needs attention
  201. SpecialComment special things inside a comment
  202. Debug debugging statements
  203. *Underlined text that stands out, HTML links
  204. *Ignore left blank, hidden |hl-Ignore|
  205. *Error any erroneous construct
  206. *Todo anything that needs extra attention; mostly the
  207. keywords TODO FIXME and XXX
  208. The names marked with * are the preferred groups; the others are minor groups.
  209. For the preferred groups, the "syntax.vim" file contains default highlighting.
  210. The minor groups are linked to the preferred groups, so they get the same
  211. highlighting. You can override these defaults by using ":highlight" commands
  212. after sourcing the "syntax.vim" file.
  213. Note that highlight group names are not case sensitive. "String" and "string"
  214. can be used for the same group.
  215. The following names are reserved and cannot be used as a group name:
  216. NONE ALL ALLBUT contains contained
  217. *hl-Ignore*
  218. When using the Ignore group, you may also consider using the conceal
  219. mechanism. See |conceal|.
  220. ==============================================================================
  221. 3. Syntax loading procedure *syntax-loading*
  222. This explains the details that happen when the command ":syntax enable" is
  223. issued. When Vim initializes itself, it finds out where the runtime files are
  224. located. This is used here as the variable |$VIMRUNTIME|.
  225. ":syntax enable" and ":syntax on" do the following:
  226. Source $VIMRUNTIME/syntax/syntax.vim
  227. |
  228. +- Clear out any old syntax by sourcing $VIMRUNTIME/syntax/nosyntax.vim
  229. |
  230. +- Source first syntax/synload.vim in 'runtimepath'
  231. | |
  232. | +- Setup the colors for syntax highlighting. If a color scheme is
  233. | | defined it is loaded again with ":colors {name}". Otherwise
  234. | | ":runtime! syntax/syncolor.vim" is used. ":syntax on" overrules
  235. | | existing colors, ":syntax enable" only sets groups that weren't
  236. | | set yet.
  237. | |
  238. | +- Set up syntax autocmds to load the appropriate syntax file when
  239. | | the 'syntax' option is set. *synload-1*
  240. | |
  241. | +- Source the user's optional file, from the |mysyntaxfile| variable.
  242. | This is for backwards compatibility with Vim 5.x only. *synload-2*
  243. |
  244. +- Do ":filetype on", which does ":runtime! filetype.vim". It loads any
  245. | filetype.vim files found. It should always Source
  246. | $VIMRUNTIME/filetype.vim, which does the following.
  247. | |
  248. | +- Install autocmds based on suffix to set the 'filetype' option
  249. | | This is where the connection between file name and file type is
  250. | | made for known file types. *synload-3*
  251. | |
  252. | +- Source the user's optional file, from the *myfiletypefile*
  253. | | variable. This is for backwards compatibility with Vim 5.x only.
  254. | | *synload-4*
  255. | |
  256. | +- Install one autocommand which sources scripts.vim when no file
  257. | | type was detected yet. *synload-5*
  258. | |
  259. | +- Source $VIMRUNTIME/menu.vim, to setup the Syntax menu. |menu.vim|
  260. |
  261. +- Install a FileType autocommand to set the 'syntax' option when a file
  262. | type has been detected. *synload-6*
  263. |
  264. +- Execute syntax autocommands to start syntax highlighting for each
  265. already loaded buffer.
  266. Upon loading a file, Vim finds the relevant syntax file as follows:
  267. Loading the file triggers the BufReadPost autocommands.
  268. |
  269. +- If there is a match with one of the autocommands from |synload-3|
  270. | (known file types) or |synload-4| (user's file types), the 'filetype'
  271. | option is set to the file type.
  272. |
  273. +- The autocommand at |synload-5| is triggered. If the file type was not
  274. | found yet, then scripts.vim is searched for in 'runtimepath'. This
  275. | should always load $VIMRUNTIME/scripts.vim, which does the following.
  276. | |
  277. | +- Source the user's optional file, from the *myscriptsfile*
  278. | | variable. This is for backwards compatibility with Vim 5.x only.
  279. | |
  280. | +- If the file type is still unknown, check the contents of the file,
  281. | again with checks like "getline(1) =~ pattern" as to whether the
  282. | file type can be recognized, and set 'filetype'.
  283. |
  284. +- When the file type was determined and 'filetype' was set, this
  285. | triggers the FileType autocommand |synload-6| above. It sets
  286. | 'syntax' to the determined file type.
  287. |
  288. +- When the 'syntax' option was set above, this triggers an autocommand
  289. | from |synload-1| (and |synload-2|). This find the main syntax file in
  290. | 'runtimepath', with this command:
  291. | runtime! syntax/<name>.vim
  292. |
  293. +- Any other user installed FileType or Syntax autocommands are
  294. triggered. This can be used to change the highlighting for a specific
  295. syntax.
  296. ==============================================================================
  297. 4. Conversion to HTML *2html.vim* *convert-to-HTML*
  298. 2html is not a syntax file itself, but a script that converts the current
  299. window into HTML. Vim opens a new window in which it builds the HTML file.
  300. After you save the resulting file, you can view it with any browser. The
  301. colors should be exactly the same as you see them in Vim. With
  302. |g:html_line_ids| you can jump to specific lines by adding (for example) #L123
  303. or #123 to the end of the URL in your browser's address bar. And with
  304. |g:html_dynamic_folds| enabled, you can show or hide the text that is folded
  305. in Vim.
  306. You are not supposed to set the 'filetype' or 'syntax' option to "2html"!
  307. Source the script to convert the current file: >
  308. :runtime! syntax/2html.vim
  309. <
  310. Many variables affect the output of 2html.vim; see below. Any of the on/off
  311. options listed below can be enabled or disabled by setting them explicitly to
  312. the desired value, or restored to their default by removing the variable using
  313. |:unlet|.
  314. Remarks:
  315. - Some truly ancient browsers may not show the background colors.
  316. - From most browsers you can also print the file (in color)!
  317. - The latest TOhtml may actually work with older versions of Vim, but some
  318. features such as conceal support will not function, and the colors may be
  319. incorrect for an old Vim without GUI support compiled in.
  320. Here is an example how to run the script over all .c and .h files from a
  321. Unix shell: >
  322. for f in *.[ch]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done
  323. <
  324. *g:html_start_line* *g:html_end_line*
  325. To restrict the conversion to a range of lines, use a range with the |:TOhtml|
  326. command below, or set "g:html_start_line" and "g:html_end_line" to the first
  327. and last line to be converted. Example, using the last set Visual area: >
  328. :let g:html_start_line = line("'<")
  329. :let g:html_end_line = line("'>")
  330. :runtime! syntax/2html.vim
  331. <
  332. *:TOhtml*
  333. :[range]TOhtml The ":TOhtml" command is defined in a standard plugin.
  334. This command will source |2html.vim| for you. When a
  335. range is given, this command sets |g:html_start_line|
  336. and |g:html_end_line| to the start and end of the
  337. range, respectively. Default range is the entire
  338. buffer.
  339. If the current window is part of a |diff|, unless
  340. |g:html_diff_one_file| is set, :TOhtml will convert
  341. all windows which are part of the diff in the current
  342. tab and place them side-by-side in a <table> element
  343. in the generated HTML. With |g:html_line_ids| you can
  344. jump to lines in specific windows with (for example)
  345. #W1L42 for line 42 in the first diffed window, or
  346. #W3L87 for line 87 in the third.
  347. Examples: >
  348. :10,40TOhtml " convert lines 10-40 to html
  349. :'<,'>TOhtml " convert current/last visual selection
  350. :TOhtml " convert entire buffer
  351. <
  352. *g:html_diff_one_file*
  353. Default: 0.
  354. When 0, and using |:TOhtml| all windows involved in a |diff| in the current tab
  355. page are converted to HTML and placed side-by-side in a <table> element. When
  356. 1, only the current buffer is converted.
  357. Example: >
  358. let g:html_diff_one_file = 1
  359. <
  360. *g:html_whole_filler*
  361. Default: 0.
  362. When 0, if |g:html_diff_one_file| is 1, a sequence of more than 3 filler lines
  363. is displayed as three lines with the middle line mentioning the total number
  364. of inserted lines.
  365. When 1, always display all inserted lines as if |g:html_diff_one_file| were
  366. not set.
  367. >
  368. :let g:html_whole_filler = 1
  369. <
  370. *TOhtml-performance* *g:html_no_progress*
  371. Default: 0.
  372. When 0, display a progress bar in the statusline for each major step in the
  373. 2html.vim conversion process.
  374. When 1, do not display the progress bar. This offers a minor speed improvement
  375. but you won't have any idea how much longer the conversion might take; for big
  376. files it can take a long time!
  377. Example: >
  378. let g:html_no_progress = 1
  379. <
  380. You can obtain better performance improvements by also instructing Vim to not
  381. run interactively, so that too much time is not taken to redraw as the script
  382. moves through the buffer, switches windows, and the like: >
  383. vim -E -s -c "let g:html_no_progress=1" -c "syntax on" -c "set ft=c" -c "runtime syntax/2html.vim" -cwqa myfile.c
  384. <
  385. Note that the -s flag prevents loading your .vimrc and any plugins, so you
  386. need to explicitly source/enable anything that will affect the HTML
  387. conversion. See |-E| and |-s-ex| for details. It is probably best to create a
  388. script to replace all the -c commands and use it with the -u flag instead of
  389. specifying each command separately.
  390. *hl-TOhtmlProgress* *TOhtml-progress-color*
  391. When displayed, the progress bar will show colored boxes along the statusline
  392. as the HTML conversion proceeds. By default, the background color as the
  393. current "DiffDelete" highlight group is used. If "DiffDelete" and "StatusLine"
  394. have the same background color, TOhtml will automatically adjust the color to
  395. differ. If you do not like the automatically selected colors, you can define
  396. your own highlight colors for the progress bar. Example: >
  397. hi TOhtmlProgress guifg=#c0ffee ctermbg=7
  398. <
  399. *g:html_number_lines*
  400. Default: Current 'number' setting.
  401. When 0, buffer text is displayed in the generated HTML without line numbering.
  402. When 1, a column of line numbers is added to the generated HTML with the same
  403. highlighting as the line number column in Vim (|hl-LineNr|).
  404. Force line numbers even if 'number' is not set: >
  405. :let g:html_number_lines = 1
  406. Force to omit the line numbers: >
  407. :let g:html_number_lines = 0
  408. Go back to the default to use 'number' by deleting the variable: >
  409. :unlet g:html_number_lines
  410. <
  411. *g:html_line_ids*
  412. Default: 1 if |g:html_number_lines| is set, 0 otherwise.
  413. When 1, adds an HTML id attribute to each line number, or to an empty <span>
  414. inserted for that purpose if no line numbers are shown. This ID attribute
  415. takes the form of L123 for single-buffer HTML pages, or W2L123 for diff-view
  416. pages, and is used to jump to a specific line (in a specific window of a diff
  417. view). Javascript is inserted to open any closed dynamic folds
  418. (|g:html_dynamic_folds|) containing the specified line before jumping. The
  419. javascript also allows omitting the window ID in the url, and the leading L.
  420. For example: >
  421. page.html#L123 jumps to line 123 in a single-buffer file
  422. page.html#123 does the same
  423. diff.html#W1L42 jumps to line 42 in the first window in a diff
  424. diff.html#42 does the same
  425. <
  426. *g:html_use_css*
  427. Default: 1.
  428. When 1, generate valid HTML 5 markup with CSS styling, supported in all modern
  429. browsers and many old browsers.
  430. When 0, generate <font> tags and similar outdated markup. This is not
  431. recommended but it may work better in really old browsers, email clients,
  432. forum posts, and similar situations where basic CSS support is unavailable.
  433. Example: >
  434. :let g:html_use_css = 0
  435. <
  436. *g:html_ignore_conceal*
  437. Default: 0.
  438. When 0, concealed text is removed from the HTML and replaced with a character
  439. from |:syn-cchar| or 'listchars' as appropriate, depending on the current
  440. value of 'conceallevel'.
  441. When 1, include all text from the buffer in the generated HTML, even if it is
  442. |conceal|ed.
  443. Either of the following commands will ensure that all text in the buffer is
  444. included in the generated HTML (unless it is folded): >
  445. :let g:html_ignore_conceal = 1
  446. :setl conceallevel=0
  447. <
  448. *g:html_ignore_folding*
  449. Default: 0.
  450. When 0, text in a closed fold is replaced by the text shown for the fold in
  451. Vim (|fold-foldtext|). See |g:html_dynamic_folds| if you also want to allow
  452. the user to expand the fold as in Vim to see the text inside.
  453. When 1, include all text from the buffer in the generated HTML; whether the
  454. text is in a fold has no impact at all. |g:html_dynamic_folds| has no effect.
  455. Either of these commands will ensure that all text in the buffer is included
  456. in the generated HTML (unless it is concealed): >
  457. zR
  458. :let g:html_ignore_folding = 1
  459. <
  460. *g:html_dynamic_folds*
  461. Default: 0.
  462. When 0, text in a closed fold is not included at all in the generated HTML.
  463. When 1, generate javascript to open a fold and show the text within, just like
  464. in Vim.
  465. Setting this variable to 1 causes 2html.vim to always use CSS for styling,
  466. regardless of what |g:html_use_css| is set to.
  467. This variable is ignored when |g:html_ignore_folding| is set.
  468. >
  469. :let g:html_dynamic_folds = 1
  470. <
  471. *g:html_no_foldcolumn*
  472. Default: 0.
  473. When 0, if |g:html_dynamic_folds| is 1, generate a column of text similar to
  474. Vim's foldcolumn (|fold-foldcolumn|) the user can click on to toggle folds
  475. open or closed. The minimum width of the generated text column is the current
  476. 'foldcolumn' setting.
  477. When 1, do not generate this column; instead, hovering the mouse cursor over
  478. folded text will open the fold as if |g:html_hover_unfold| were set.
  479. >
  480. :let g:html_no_foldcolumn = 1
  481. <
  482. *TOhtml-uncopyable-text* *g:html_prevent_copy*
  483. Default: Empty string.
  484. This option prevents certain regions of the generated HTML from being copied,
  485. when you select all text in document rendered in a browser and copy it. Useful
  486. for allowing users to copy-paste only the source text even if a fold column or
  487. line numbers are shown in the generated content. Specify regions to be
  488. affected in this way as follows:
  489. f: fold column
  490. n: line numbers (also within fold text)
  491. t: fold text
  492. d: diff filler
  493. Example, to make the fold column and line numbers uncopyable: >
  494. :let g:html_prevent_copy = "fn"
  495. <
  496. The method used to prevent copying in the generated page depends on the value
  497. of |g:html_use_input_for_pc|.
  498. *g:html_use_input_for_pc*
  499. Default: "fallback"
  500. If |g:html_prevent_copy| is non-empty, then:
  501. When "all", read-only <input> elements are used in place of normal text for
  502. uncopyable regions. In some browsers, especially older browsers, after
  503. selecting an entire page and copying the selection, the <input> tags are not
  504. pasted with the page text. If |g:html_no_invalid| is 0, the <input> tags have
  505. invalid type; this works in more browsers, but the page will not validate.
  506. Note: This method does NOT work in recent versions of Chrome and equivalent
  507. browsers; the <input> tags get pasted with the text.
  508. When "fallback" (default value), the same <input> elements are generated for
  509. older browsers, but newer browsers (detected by CSS feature query) hide the
  510. <input> elements and instead use generated content in an ::before pseudoelement
  511. to display the uncopyable text. This method should work with the largest
  512. number of browsers, both old and new.
  513. When "none", the <input> elements are not generated at all. Only the
  514. generated-content method is used. This means that old browsers, notably
  515. Internet Explorer, will either copy the text intended not to be copyable, or
  516. the non-copyable text may not appear at all. However, this is the most
  517. standards-based method, and there will be much less markup.
  518. *g:html_no_invalid*
  519. Default: 0.
  520. When 0, if |g:html_prevent_copy| is non-empty and |g:html_use_input_for_pc| is
  521. not "none", an invalid attribute is intentionally inserted into the <input>
  522. element for the uncopyable areas. This prevents pasting the <input> elements
  523. in some applications. Specifically, some versions of Microsoft Word will not
  524. paste the <input> elements if they contain this invalid attribute. When 1, no
  525. invalid markup is inserted, and the generated page should validate. However,
  526. <input> elements may be pasted into some applications and can be difficult to
  527. remove afterward.
  528. *g:html_hover_unfold*
  529. Default: 0.
  530. When 0, the only way to open a fold generated by 2html.vim with
  531. |g:html_dynamic_folds| set, is to click on the generated fold column.
  532. When 1, use CSS 2.0 to allow the user to open a fold by moving the mouse
  533. cursor over the displayed fold text. This is useful to allow users with
  534. disabled javascript to view the folded text.
  535. Note that old browsers (notably Internet Explorer 6) will not support this
  536. feature. Browser-specific markup for IE6 is included to fall back to the
  537. normal CSS1 styling so that the folds show up correctly for this browser, but
  538. they will not be openable without a foldcolumn.
  539. >
  540. :let g:html_hover_unfold = 1
  541. <
  542. *g:html_id_expr*
  543. Default: ""
  544. Dynamic folding and jumping to line IDs rely on unique IDs within the document
  545. to work. If generated HTML is copied into a larger document, these IDs are no
  546. longer guaranteed to be unique. Set g:html_id_expr to an expression Vim can
  547. evaluate to get a unique string to append to each ID used in a given document,
  548. so that the full IDs will be unique even when combined with other content in a
  549. larger HTML document. Example, to append _ and the buffer number to each ID: >
  550. :let g:html_id_expr = '"_" .. bufnr("%")'
  551. <
  552. To append a string "_mystring" to the end of each ID: >
  553. :let g:html_id_expr = '"_mystring"'
  554. <
  555. Note: When converting a diff view to HTML, the expression will only be
  556. evaluated for the first window in the diff, and the result used for all the
  557. windows.
  558. *TOhtml-wrap-text* *g:html_pre_wrap*
  559. Default: Current 'wrap' setting.
  560. When 0, if |g:html_no_pre| is 0 or unset, the text in the generated HTML does
  561. not wrap at the edge of the browser window.
  562. When 1, if |g:html_use_css| is 1, the CSS 2.0 "white-space:pre-wrap" value is
  563. used, causing the text to wrap at whitespace at the edge of the browser
  564. window.
  565. Explicitly enable text wrapping: >
  566. :let g:html_pre_wrap = 1
  567. Explicitly disable wrapping: >
  568. :let g:html_pre_wrap = 0
  569. Go back to default, determine wrapping from 'wrap' setting: >
  570. :unlet g:html_pre_wrap
  571. <
  572. *g:html_no_pre*
  573. Default: 0.
  574. When 0, buffer text in the generated HTML is surrounded by <pre>...</pre>
  575. tags. Series of whitespace is shown as in Vim without special markup, and tab
  576. characters can be included literally (see |g:html_expand_tabs|).
  577. When 1 (not recommended), the <pre> tags are omitted, and a plain <div> is
  578. used instead. Whitespace is replaced by a series of &nbsp; character
  579. references, and <br> is used to end each line. This is another way to allow
  580. text in the generated HTML is wrap (see |g:html_pre_wrap|) which also works in
  581. old browsers, but may cause noticeable differences between Vim's display and
  582. the rendered page generated by 2html.vim.
  583. >
  584. :let g:html_no_pre = 1
  585. <
  586. *g:html_no_doc*
  587. Default: 0.
  588. When 1 it doesn't generate a full HTML document with a DOCTYPE, <head>,
  589. <body>, etc. If |g:html_use_css| is enabled (the default) you'll have to
  590. define the CSS manually. The |g:html_dynamic_folds| and |g:html_line_ids|
  591. settings (off by default) also insert some JavaScript.
  592. *g:html_no_links*
  593. Default: 0.
  594. Don't generate <a> tags for text that looks like an URL.
  595. *g:html_no_modeline*
  596. Default: 0.
  597. Don't generate a modeline disabling folding.
  598. *g:html_expand_tabs*
  599. Default: 0 if 'tabstop' is 8, 'expandtab' is 0, 'vartabstop' is not in use,
  600. and no fold column or line numbers occur in the generated HTML;
  601. 1 otherwise.
  602. When 1, <Tab> characters in the buffer text are replaced with an appropriate
  603. number of space characters, or &nbsp; references if |g:html_no_pre| is 1.
  604. When 0, if |g:html_no_pre| is 0 or unset, <Tab> characters in the buffer text
  605. are included as-is in the generated HTML. This is useful for when you want to
  606. allow copy and paste from a browser without losing the actual whitespace in
  607. the source document. Note that this can easily break text alignment and
  608. indentation in the HTML, unless set by default.
  609. Force |2html.vim| to keep <Tab> characters: >
  610. :let g:html_expand_tabs = 0
  611. <
  612. Force tabs to be expanded: >
  613. :let g:html_expand_tabs = 1
  614. <
  615. *TOhtml-encoding-detect* *TOhtml-encoding*
  616. It is highly recommended to set your desired encoding with
  617. |g:html_use_encoding| for any content which will be placed on a web server.
  618. If you do not specify an encoding, |2html.vim| uses the preferred IANA name
  619. for the current value of 'fileencoding' if set, or 'encoding' if not.
  620. 'encoding' is always used for certain 'buftype' values. 'fileencoding' will be
  621. set to match the chosen document encoding.
  622. Automatic detection works for the encodings mentioned specifically by name in
  623. |encoding-names|, but TOhtml will only automatically use those encodings with
  624. wide browser support. However, you can override this to support specific
  625. encodings that may not be automatically detected by default (see options
  626. below). See http://www.iana.org/assignments/character-sets for the IANA names.
  627. Note: By default all Unicode encodings are converted to UTF-8 with no BOM in
  628. the generated HTML, as recommended by W3C:
  629. http://www.w3.org/International/questions/qa-choosing-encodings
  630. http://www.w3.org/International/questions/qa-byte-order-mark
  631. *g:html_use_encoding*
  632. Default: none, uses IANA name for current 'fileencoding' as above.
  633. To overrule all automatic charset detection, set g:html_use_encoding to the
  634. name of the charset to be used. It is recommended to set this variable to
  635. something widely supported, like UTF-8, for anything you will be hosting on a
  636. webserver: >
  637. :let g:html_use_encoding = "UTF-8"
  638. You can also use this option to omit the line that specifies the charset
  639. entirely, by setting g:html_use_encoding to an empty string (NOT recommended): >
  640. :let g:html_use_encoding = ""
  641. To go back to the automatic mechanism, delete the |g:html_use_encoding|
  642. variable: >
  643. :unlet g:html_use_encoding
  644. <
  645. *g:html_encoding_override*
  646. Default: none, autoload/tohtml.vim contains default conversions for encodings
  647. mentioned by name at |encoding-names|.
  648. This option allows |2html.vim| to detect the correct 'fileencoding' when you
  649. specify an encoding with |g:html_use_encoding| which is not in the default
  650. list of conversions.
  651. This is a dictionary of charset-encoding pairs that will replace existing
  652. pairs automatically detected by TOhtml, or supplement with new pairs.
  653. Detect the HTML charset "windows-1252" as the encoding "8bit-cp1252": >
  654. :let g:html_encoding_override = {'windows-1252': '8bit-cp1252'}
  655. <
  656. *g:html_charset_override*
  657. Default: none, autoload/tohtml.vim contains default conversions for encodings
  658. mentioned by name at |encoding-names| and which have wide
  659. browser support.
  660. This option allows |2html.vim| to detect the HTML charset for any
  661. 'fileencoding' or 'encoding' which is not detected automatically. You can also
  662. use it to override specific existing encoding-charset pairs. For example,
  663. TOhtml will by default use UTF-8 for all Unicode/UCS encodings. To use UTF-16
  664. and UTF-32 instead, use: >
  665. :let g:html_charset_override = {'ucs-4': 'UTF-32', 'utf-16': 'UTF-16'}
  666. Note that documents encoded in either UTF-32 or UTF-16 have known
  667. compatibility problems with some major browsers.
  668. *g:html_font*
  669. Default: "monospace"
  670. You can specify the font or fonts used in the converted document using
  671. g:html_font. If this option is set to a string, then the value will be
  672. surrounded with single quotes. If this option is set to a list then each list
  673. item is surrounded by single quotes and the list is joined with commas. Either
  674. way, "monospace" is added as the fallback generic family name and the entire
  675. result used as the font family (using CSS) or font face (if not using CSS).
  676. Examples: >
  677. " font-family: 'Consolas', monospace;
  678. :let g:html_font = "Consolas"
  679. " font-family: 'DejaVu Sans Mono', 'Consolas', monospace;
  680. :let g:html_font = ["DejaVu Sans Mono", "Consolas"]
  681. <
  682. *convert-to-XML* *convert-to-XHTML* *g:html_use_xhtml*
  683. Default: 0.
  684. When 0, generate standard HTML 4.01 (strict when possible).
  685. When 1, generate XHTML 1.0 instead (XML compliant HTML).
  686. >
  687. :let g:html_use_xhtml = 1
  688. <
  689. ==============================================================================
  690. 5. Syntax file remarks *:syn-file-remarks*
  691. *b:current_syntax-variable*
  692. Vim stores the name of the syntax that has been loaded in the
  693. "b:current_syntax" variable. You can use this if you want to load other
  694. settings, depending on which syntax is active. Example: >
  695. :au BufReadPost * if b:current_syntax == "csh"
  696. :au BufReadPost * do-some-things
  697. :au BufReadPost * endif
  698. ABEL *abel.vim* *ft-abel-syntax*
  699. ABEL highlighting provides some user-defined options. To enable them, assign
  700. any value to the respective variable. Example: >
  701. :let abel_obsolete_ok=1
  702. To disable them use ":unlet". Example: >
  703. :unlet abel_obsolete_ok
  704. Variable Highlight ~
  705. abel_obsolete_ok obsolete keywords are statements, not errors
  706. abel_cpp_comments_illegal do not interpret '//' as inline comment leader
  707. ADA
  708. See |ft-ada-syntax|
  709. ANT *ant.vim* *ft-ant-syntax*
  710. The ant syntax file provides syntax highlighting for javascript and python
  711. by default. Syntax highlighting for other script languages can be installed
  712. by the function AntSyntaxScript(), which takes the tag name as first argument
  713. and the script syntax file name as second argument. Example: >
  714. :call AntSyntaxScript('perl', 'perl.vim')
  715. will install syntax perl highlighting for the following ant code >
  716. <script language = 'perl'><![CDATA[
  717. # everything inside is highlighted as perl
  718. ]]></script>
  719. See |mysyntaxfile-add| for installing script languages permanently.
  720. APACHE *apache.vim* *ft-apache-syntax*
  721. The apache syntax file provides syntax highlighting for Apache HTTP server
  722. version 2.2.3.
  723. *asm.vim* *asmh8300.vim* *nasm.vim* *masm.vim* *asm68k*
  724. ASSEMBLY *ft-asm-syntax* *ft-asmh8300-syntax* *ft-nasm-syntax*
  725. *ft-masm-syntax* *ft-asm68k-syntax* *fasm.vim*
  726. Files matching "*.i" could be Progress or Assembly. If the automatic detection
  727. doesn't work for you, or you don't edit Progress at all, use this in your
  728. startup vimrc: >
  729. :let filetype_i = "asm"
  730. Replace "asm" with the type of assembly you use.
  731. There are many types of assembly languages that all use the same file name
  732. extensions. Therefore you will have to select the type yourself, or add a
  733. line in the assembly file that Vim will recognize. Currently these syntax
  734. files are included:
  735. asm GNU assembly (the default)
  736. asm68k Motorola 680x0 assembly
  737. asmh8300 Hitachi H-8300 version of GNU assembly
  738. ia64 Intel Itanium 64
  739. fasm Flat assembly (http://flatassembler.net)
  740. masm Microsoft assembly (probably works for any 80x86)
  741. nasm Netwide assembly
  742. tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and
  743. MMX)
  744. pic PIC assembly (currently for PIC16F84)
  745. The most flexible is to add a line in your assembly file containing: >
  746. asmsyntax=nasm
  747. Replace "nasm" with the name of the real assembly syntax. This line must be
  748. one of the first five lines in the file. No non-white text must be
  749. immediately before or after this text. Note that specifying asmsyntax=foo is
  750. equivalent to setting ft=foo in a |modeline|, and that in case of a conflict
  751. between the two settings the one from the modeline will take precedence (in
  752. particular, if you have ft=asm in the modeline, you will get the GNU syntax
  753. highlighting regardless of what is specified as asmsyntax).
  754. The syntax type can always be overruled for a specific buffer by setting the
  755. b:asmsyntax variable: >
  756. :let b:asmsyntax = "nasm"
  757. If b:asmsyntax is not set, either automatically or by hand, then the value of
  758. the global variable asmsyntax is used. This can be seen as a default assembly
  759. language: >
  760. :let asmsyntax = "nasm"
  761. As a last resort, if nothing is defined, the "asm" syntax is used.
  762. Netwide assembler (nasm.vim) optional highlighting ~
  763. To enable a feature: >
  764. :let {variable}=1|set syntax=nasm
  765. To disable a feature: >
  766. :unlet {variable} |set syntax=nasm
  767. Variable Highlight ~
  768. nasm_loose_syntax unofficial parser allowed syntax not as Error
  769. (parser dependent; not recommended)
  770. nasm_ctx_outside_macro contexts outside macro not as Error
  771. nasm_no_warn potentially risky syntax not as ToDo
  772. ASPPERL and ASPVBS *ft-aspperl-syntax* *ft-aspvbs-syntax*
  773. *.asp and *.asa files could be either Perl or Visual Basic script. Since it's
  774. hard to detect this you can set two global variables to tell Vim what you are
  775. using. For Perl script use: >
  776. :let g:filetype_asa = "aspperl"
  777. :let g:filetype_asp = "aspperl"
  778. For Visual Basic use: >
  779. :let g:filetype_asa = "aspvbs"
  780. :let g:filetype_asp = "aspvbs"
  781. BAAN *baan.vim* *baan-syntax*
  782. The baan.vim gives syntax support for BaanC of release BaanIV up to SSA ERP LN
  783. for both 3 GL and 4 GL programming. Large number of standard defines/constants
  784. are supported.
  785. Some special violation of coding standards will be signalled when one specify
  786. in ones |.vimrc|: >
  787. let baan_code_stds=1
  788. *baan-folding*
  789. Syntax folding can be enabled at various levels through the variables
  790. mentioned below (Set those in your |.vimrc|). The more complex folding on
  791. source blocks and SQL can be CPU intensive.
  792. To allow any folding and enable folding at function level use: >
  793. let baan_fold=1
  794. Folding can be enabled at source block level as if, while, for ,... The
  795. indentation preceding the begin/end keywords has to match (spaces are not
  796. considered equal to a tab). >
  797. let baan_fold_block=1
  798. Folding can be enabled for embedded SQL blocks as SELECT, SELECTDO,
  799. SELECTEMPTY, ... The indentation preceding the begin/end keywords has to
  800. match (spaces are not considered equal to a tab). >
  801. let baan_fold_sql=1
  802. Note: Block folding can result in many small folds. It is suggested to |:set|
  803. the options 'foldminlines' and 'foldnestmax' in |.vimrc| or use |:setlocal| in
  804. .../after/syntax/baan.vim (see |after-directory|). Eg: >
  805. set foldminlines=5
  806. set foldnestmax=6
  807. BASIC *basic.vim* *vb.vim* *ft-basic-syntax* *ft-vb-syntax*
  808. Both Visual Basic and "normal" BASIC use the extension ".bas". To detect
  809. which one should be used, Vim checks for the string "VB_Name" in the first
  810. five lines of the file. If it is not found, filetype will be "basic",
  811. otherwise "vb". Files with the ".frm" extension will always be seen as Visual
  812. Basic.
  813. If the automatic detection doesn't work for you or you only edit, for
  814. example, FreeBASIC files, use this in your startup vimrc: >
  815. :let filetype_bas = "freebasic"
  816. C *c.vim* *ft-c-syntax*
  817. A few things in C highlighting are optional. To enable them assign any value
  818. (including zero) to the respective variable. Example: >
  819. :let c_comment_strings = 1
  820. :let c_no_bracket_error = 0
  821. To disable them use `:unlet`. Example: >
  822. :unlet c_comment_strings
  823. Setting the value to zero doesn't work!
  824. An alternative is to switch to the C++ highlighting: >
  825. :set filetype=cpp
  826. Variable Highlight ~
  827. *c_gnu* GNU gcc specific items
  828. *c_comment_strings* strings and numbers inside a comment
  829. *c_space_errors* trailing white space and spaces before a <Tab>
  830. *c_no_trail_space_error* ... but no trailing spaces
  831. *c_no_tab_space_error* ... but no spaces before a <Tab>
  832. *c_no_bracket_error* don't highlight {}; inside [] as errors
  833. *c_no_curly_error* don't highlight {}; inside [] and () as errors;
  834. except { and } in first column
  835. Default is to highlight them, otherwise you
  836. can't spot a missing ")".
  837. *c_curly_error* highlight a missing } by finding all pairs; this
  838. forces syncing from the start of the file, can be slow
  839. *c_no_ansi* don't do standard ANSI types and constants
  840. *c_ansi_typedefs* ... but do standard ANSI types
  841. *c_ansi_constants* ... but do standard ANSI constants
  842. *c_no_utf* don't highlight \u and \U in strings
  843. *c_syntax_for_h* for *.h files use C syntax instead of C++ and use objc
  844. syntax instead of objcpp
  845. *c_no_if0* don't highlight "#if 0" blocks as comments
  846. *c_no_cformat* don't highlight %-formats in strings
  847. *c_no_c99* don't highlight C99 standard items
  848. *c_no_c11* don't highlight C11 standard items
  849. *c_no_bsd* don't highlight BSD specific types
  850. When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will
  851. become a fold. If you don't want comments to become a fold use: >
  852. :let c_no_comment_fold = 1
  853. "#if 0" blocks are also folded, unless: >
  854. :let c_no_if0_fold = 1
  855. If you notice highlighting errors while scrolling backwards, which are fixed
  856. when redrawing with CTRL-L, try setting the "c_minlines" internal variable
  857. to a larger number: >
  858. :let c_minlines = 100
  859. This will make the syntax synchronization start 100 lines before the first
  860. displayed line. The default value is 50 (15 when c_no_if0 is set). The
  861. disadvantage of using a larger number is that redrawing can become slow.
  862. When using the "#if 0" / "#endif" comment highlighting, notice that this only
  863. works when the "#if 0" is within "c_minlines" from the top of the window. If
  864. you have a long "#if 0" construct it will not be highlighted correctly.
  865. To match extra items in comments, use the cCommentGroup cluster.
  866. Example: >
  867. :au Syntax c call MyCadd()
  868. :function MyCadd()
  869. : syn keyword cMyItem contained Ni
  870. : syn cluster cCommentGroup add=cMyItem
  871. : hi link cMyItem Title
  872. :endfun
  873. ANSI constants will be highlighted with the "cConstant" group. This includes
  874. "NULL", "SIG_IGN" and others. But not "TRUE", for example, because this is
  875. not in the ANSI standard. If you find this confusing, remove the cConstant
  876. highlighting: >
  877. :hi link cConstant NONE
  878. If you see '{' and '}' highlighted as an error where they are OK, reset the
  879. highlighting for cErrInParen and cErrInBracket.
  880. If you want to use folding in your C files, you can add these lines in a file
  881. in the "after" directory in 'runtimepath'. For Unix this would be
  882. ~/.vim/after/syntax/c.vim. >
  883. syn sync fromstart
  884. set foldmethod=syntax
  885. CH *ch.vim* *ft-ch-syntax*
  886. C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon
  887. the C syntax file. See |c.vim| for all the settings that are available for C.
  888. By setting a variable you can tell Vim to use Ch syntax for *.h files, instead
  889. of C or C++: >
  890. :let ch_syntax_for_h = 1
  891. CHILL *chill.vim* *ft-chill-syntax*
  892. Chill syntax highlighting is similar to C. See |c.vim| for all the settings
  893. that are available. Additionally there is:
  894. chill_space_errors like c_space_errors
  895. chill_comment_string like c_comment_strings
  896. chill_minlines like c_minlines
  897. CHANGELOG *changelog.vim* *ft-changelog-syntax*
  898. ChangeLog supports highlighting spaces at the start of a line.
  899. If you do not like this, add following line to your .vimrc: >
  900. let g:changelog_spacing_errors = 0
  901. This works the next time you edit a changelog file. You can also use
  902. "b:changelog_spacing_errors" to set this per buffer (before loading the syntax
  903. file).
  904. You can change the highlighting used, e.g., to flag the spaces as an error: >
  905. :hi link ChangelogError Error
  906. Or to avoid the highlighting: >
  907. :hi link ChangelogError NONE
  908. This works immediately.
  909. CLOJURE *ft-clojure-syntax*
  910. *g:clojure_syntax_keywords*
  911. Syntax highlighting of public vars in "clojure.core" is provided by default,
  912. but additional symbols can be highlighted by adding them to the
  913. |g:clojure_syntax_keywords| variable. The value should be a |Dictionary| of
  914. syntax group names, each containing a |List| of identifiers.
  915. >
  916. let g:clojure_syntax_keywords = {
  917. \ 'clojureMacro': ["defproject", "defcustom"],
  918. \ 'clojureFunc': ["string/join", "string/replace"]
  919. \ }
  920. <
  921. Refer to the Clojure syntax script for valid syntax group names.
  922. There is also *b:clojure_syntax_keywords* which is a buffer-local variant of
  923. this variable intended for use by plugin authors to highlight symbols
  924. dynamically.
  925. By setting the *b:clojure_syntax_without_core_keywords* variable, vars from
  926. "clojure.core" will not be highlighted by default. This is useful for
  927. namespaces that have set `(:refer-clojure :only [])`
  928. *g:clojure_fold*
  929. Setting |g:clojure_fold| to `1` will enable the folding of Clojure code. Any
  930. list, vector or map that extends over more than one line can be folded using
  931. the standard Vim |fold-commands|.
  932. *g:clojure_discard_macro*
  933. Set this variable to `1` to enable basic highlighting of Clojure's "discard
  934. reader macro".
  935. >
  936. #_(defn foo [x]
  937. (println x))
  938. <
  939. Note that this option will not correctly highlight stacked discard macros
  940. (e.g. `#_#_`).
  941. COBOL *cobol.vim* *ft-cobol-syntax*
  942. COBOL highlighting has different needs for legacy code than it does for fresh
  943. development. This is due to differences in what is being done (maintenance
  944. versus development) and other factors. To enable legacy code highlighting,
  945. add this line to your .vimrc: >
  946. :let cobol_legacy_code = 1
  947. To disable it again, use this: >
  948. :unlet cobol_legacy_code
  949. COLD FUSION *coldfusion.vim* *ft-coldfusion-syntax*
  950. The ColdFusion has its own version of HTML comments. To turn on ColdFusion
  951. comment highlighting, add the following line to your startup file: >
  952. :let html_wrong_comments = 1
  953. The ColdFusion syntax file is based on the HTML syntax file.
  954. CPP *cpp.vim* *ft-cpp-syntax*
  955. Most things are the same as |ft-c-syntax|.
  956. Variable Highlight ~
  957. cpp_no_cpp11 don't highlight C++11 standard items
  958. cpp_no_cpp14 don't highlight C++14 standard items
  959. cpp_no_cpp17 don't highlight C++17 standard items
  960. cpp_no_cpp20 don't highlight C++20 standard items
  961. CSH *csh.vim* *ft-csh-syntax*
  962. This covers the shell named "csh". Note that on some systems tcsh is actually
  963. used.
  964. Detecting whether a file is csh or tcsh is notoriously hard. Some systems
  965. symlink /bin/csh to /bin/tcsh, making it almost impossible to distinguish
  966. between csh and tcsh. In case VIM guesses wrong you can set the
  967. "filetype_csh" variable. For using csh: *g:filetype_csh*
  968. >
  969. :let g:filetype_csh = "csh"
  970. For using tcsh: >
  971. :let g:filetype_csh = "tcsh"
  972. Any script with a tcsh extension or a standard tcsh filename (.tcshrc,
  973. tcsh.tcshrc, tcsh.login) will have filetype tcsh. All other tcsh/csh scripts
  974. will be classified as tcsh, UNLESS the "filetype_csh" variable exists. If the
  975. "filetype_csh" variable exists, the filetype will be set to the value of the
  976. variable.
  977. CYNLIB *cynlib.vim* *ft-cynlib-syntax*
  978. Cynlib files are C++ files that use the Cynlib class library to enable
  979. hardware modelling and simulation using C++. Typically Cynlib files have a .cc
  980. or a .cpp extension, which makes it very difficult to distinguish them from a
  981. normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
  982. line to your .vimrc file: >
  983. :let cynlib_cyntax_for_cc=1
  984. Similarly for cpp files (this extension is only usually used in Windows) >
  985. :let cynlib_cyntax_for_cpp=1
  986. To disable these again, use this: >
  987. :unlet cynlib_cyntax_for_cc
  988. :unlet cynlib_cyntax_for_cpp
  989. <
  990. CWEB *cweb.vim* *ft-cweb-syntax*
  991. Files matching "*.w" could be Progress or cweb. If the automatic detection
  992. doesn't work for you, or you don't edit Progress at all, use this in your
  993. startup vimrc: >
  994. :let filetype_w = "cweb"
  995. DART *dart.vim* *ft-dart-syntax*
  996. Dart is an object-oriented, typed, class defined, garbage collected language
  997. used for developing mobile, desktop, web, and back-end applications. Dart uses
  998. a C-like syntax derived from C, Java, and JavaScript, with features adopted
  999. from Smalltalk, Python, Ruby, and others.
  1000. More information about the language and its development environment at the
  1001. official Dart language website at https://dart.dev
  1002. dart.vim syntax detects and highlights Dart statements, reserved words,
  1003. type declarations, storage classes, conditionals, loops, interpolated values,
  1004. and comments. There is no support idioms from Flutter or any other Dart
  1005. framework.
  1006. Changes, fixes? Submit an issue or pull request via:
  1007. https://github.com/pr3d4t0r/dart-vim-syntax/
  1008. DESKTOP *desktop.vim* *ft-desktop-syntax*
  1009. Primary goal of this syntax file is to highlight .desktop and .directory files
  1010. according to freedesktop.org standard:
  1011. https://specifications.freedesktop.org/desktop-entry-spec/latest/
  1012. To highlight nonstandard extensions that does not begin with X-, set >
  1013. let g:desktop_enable_nonstd = 1
  1014. Note that this may cause wrong highlight.
  1015. To highlight KDE-reserved features, set >
  1016. let g:desktop_enable_kde = 1
  1017. g:desktop_enable_kde follows g:desktop_enable_nonstd if not supplied
  1018. DIFF *diff.vim*
  1019. The diff highlighting normally finds translated headers. This can be slow if
  1020. there are very long lines in the file. To disable translations: >
  1021. :let diff_translations = 0
  1022. Also see |diff-slow|.
  1023. DIRCOLORS *dircolors.vim* *ft-dircolors-syntax*
  1024. The dircolors utility highlighting definition has one option. It exists to
  1025. provide compatibility with the Slackware GNU/Linux distributions version of
  1026. the command. It adds a few keywords that are generally ignored by most
  1027. versions. On Slackware systems, however, the utility accepts the keywords and
  1028. uses them for processing. To enable the Slackware keywords add the following
  1029. line to your startup file: >
  1030. let dircolors_is_slackware = 1
  1031. DOCBOOK *docbk.vim* *ft-docbk-syntax* *docbook*
  1032. DOCBOOK XML *docbkxml.vim* *ft-docbkxml-syntax*
  1033. DOCBOOK SGML *docbksgml.vim* *ft-docbksgml-syntax*
  1034. There are two types of DocBook files: SGML and XML. To specify what type you
  1035. are using the "b:docbk_type" variable should be set. Vim does this for you
  1036. automatically if it can recognize the type. When Vim can't guess it the type
  1037. defaults to XML.
  1038. You can set the type manually: >
  1039. :let docbk_type = "sgml"
  1040. or: >
  1041. :let docbk_type = "xml"
  1042. You need to do this before loading the syntax file, which is complicated.
  1043. Simpler is setting the filetype to "docbkxml" or "docbksgml": >
  1044. :set filetype=docbksgml
  1045. or: >
  1046. :set filetype=docbkxml
  1047. You can specify the DocBook version: >
  1048. :let docbk_ver = 3
  1049. When not set 4 is used.
  1050. DOSBATCH *dosbatch.vim* *ft-dosbatch-syntax*
  1051. There is one option with highlighting DOS batch files. This covers new
  1052. extensions to the Command Interpreter introduced with Windows 2000 and
  1053. is controlled by the variable dosbatch_cmdextversion. For Windows NT
  1054. this should have the value 1, and for Windows 2000 it should be 2.
  1055. Select the version you want with the following line: >
  1056. :let dosbatch_cmdextversion = 1
  1057. If this variable is not defined it defaults to a value of 2 to support
  1058. Windows 2000.
  1059. A second option covers whether *.btm files should be detected as type
  1060. "dosbatch" (MS-DOS batch files) or type "btm" (4DOS batch files). The latter
  1061. is used by default. You may select the former with the following line: >
  1062. :let g:dosbatch_syntax_for_btm = 1
  1063. If this variable is undefined or zero, btm syntax is selected.
  1064. DOXYGEN *doxygen.vim* *doxygen-syntax*
  1065. Doxygen generates code documentation using a special documentation format
  1066. (similar to Javadoc). This syntax script adds doxygen highlighting to c, cpp,
  1067. idl and php files, and should also work with java.
  1068. There are a few of ways to turn on doxygen formatting. It can be done
  1069. explicitly or in a modeline by appending '.doxygen' to the syntax of the file.
  1070. Example: >
  1071. :set syntax=c.doxygen
  1072. or >
  1073. // vim:syntax=c.doxygen
  1074. It can also be done automatically for C, C++, C#, IDL and PHP files by setting
  1075. the global or buffer-local variable load_doxygen_syntax. This is done by
  1076. adding the following to your .vimrc. >
  1077. :let g:load_doxygen_syntax=1
  1078. There are a couple of variables that have an effect on syntax highlighting,
  1079. and are to do with non-standard highlighting options.
  1080. Variable Default Effect ~
  1081. g:doxygen_enhanced_color
  1082. g:doxygen_enhanced_colour 0 Use non-standard highlighting for
  1083. doxygen comments.
  1084. doxygen_my_rendering 0 Disable rendering of HTML bold, italic
  1085. and html_my_rendering underline.
  1086. doxygen_javadoc_autobrief 1 Set to 0 to disable javadoc autobrief
  1087. colour highlighting.
  1088. doxygen_end_punctuation '[.]' Set to regexp match for the ending
  1089. punctuation of brief
  1090. There are also some highlight groups worth mentioning as they can be useful in
  1091. configuration.
  1092. Highlight Effect ~
  1093. doxygenErrorComment The colour of an end-comment when missing
  1094. punctuation in a code, verbatim or dot section
  1095. doxygenLinkError The colour of an end-comment when missing the
  1096. \endlink from a \link section.
  1097. DTD *dtd.vim* *ft-dtd-syntax*
  1098. The DTD syntax highlighting is case sensitive by default. To disable
  1099. case-sensitive highlighting, add the following line to your startup file: >
  1100. :let dtd_ignore_case=1
  1101. The DTD syntax file will highlight unknown tags as errors. If
  1102. this is annoying, it can be turned off by setting: >
  1103. :let dtd_no_tag_errors=1
  1104. before sourcing the dtd.vim syntax file.
  1105. Parameter entity names are highlighted in the definition using the
  1106. 'Type' highlighting group and 'Comment' for punctuation and '%'.
  1107. Parameter entity instances are highlighted using the 'Constant'
  1108. highlighting group and the 'Type' highlighting group for the
  1109. delimiters % and ;. This can be turned off by setting: >
  1110. :let dtd_no_param_entities=1
  1111. The DTD syntax file is also included by xml.vim to highlight included dtd's.
  1112. EIFFEL *eiffel.vim* *ft-eiffel-syntax*
  1113. While Eiffel is not case-sensitive, its style guidelines are, and the
  1114. syntax highlighting file encourages their use. This also allows to
  1115. highlight class names differently. If you want to disable case-sensitive
  1116. highlighting, add the following line to your startup file: >
  1117. :let eiffel_ignore_case=1
  1118. Case still matters for class names and TODO marks in comments.
  1119. Conversely, for even stricter checks, add one of the following lines: >
  1120. :let eiffel_strict=1
  1121. :let eiffel_pedantic=1
  1122. Setting eiffel_strict will only catch improper capitalization for the
  1123. five predefined words "Current", "Void", "Result", "Precursor", and
  1124. "NONE", to warn against their accidental use as feature or class names.
  1125. Setting eiffel_pedantic will enforce adherence to the Eiffel style
  1126. guidelines fairly rigorously (like arbitrary mixes of upper- and
  1127. lowercase letters as well as outdated ways to capitalize keywords).
  1128. If you want to use the lower-case version of "Current", "Void",
  1129. "Result", and "Precursor", you can use >
  1130. :let eiffel_lower_case_predef=1
  1131. instead of completely turning case-sensitive highlighting off.
  1132. Support for ISE's proposed new creation syntax that is already
  1133. experimentally handled by some compilers can be enabled by: >
  1134. :let eiffel_ise=1
  1135. Finally, some vendors support hexadecimal constants. To handle them, add >
  1136. :let eiffel_hex_constants=1
  1137. to your startup file.
  1138. EUPHORIA *euphoria3.vim* *euphoria4.vim* *ft-euphoria-syntax*
  1139. Two syntax highlighting files exist for Euphoria. One for Euphoria
  1140. version 3.1.1, which is the default syntax highlighting file, and one for
  1141. Euphoria version 4.0.5 or later.
  1142. Euphoria version 3.1.1 (http://www.rapideuphoria.com/) is still necessary
  1143. for developing applications for the DOS platform, which Euphoria version 4
  1144. (http://www.openeuphoria.org/) does not support.
  1145. The following file extensions are auto-detected as Euphoria file type:
  1146. *.e, *.eu, *.ew, *.ex, *.exu, *.exw
  1147. *.E, *.EU, *.EW, *.EX, *.EXU, *.EXW
  1148. To select syntax highlighting file for Euphoria, as well as for
  1149. auto-detecting the *.e and *.E file extensions as Euphoria file type,
  1150. add the following line to your startup file: >
  1151. :let g:filetype_euphoria = "euphoria3"
  1152. < or >
  1153. :let g:filetype_euphoria = "euphoria4"
  1154. Elixir and Euphoria share the *.ex file extension. If the filetype is
  1155. specifically set as Euphoria with the g:filetype_euphoria variable, or the
  1156. file is determined to be Euphoria based on keywords in the file, then the
  1157. filetype will be set as Euphoria. Otherwise, the filetype will default to
  1158. Elixir.
  1159. ERLANG *erlang.vim* *ft-erlang-syntax*
  1160. Erlang is a functional programming language developed by Ericsson. Files with
  1161. the following extensions are recognized as Erlang files: erl, hrl, yaws.
  1162. The BIFs (built-in functions) are highlighted by default. To disable this,
  1163. put the following line in your vimrc: >
  1164. :let g:erlang_highlight_bifs = 0
  1165. To enable highlighting some special atoms, put this in your vimrc: >
  1166. :let g:erlang_highlight_special_atoms = 1
  1167. ELIXIR *elixir.vim* *ft-elixir-syntax*
  1168. Elixir is a dynamic, functional language for building scalable and
  1169. maintainable applications.
  1170. The following file extensions are auto-detected as Elixir file types:
  1171. *.ex, *.exs, *.eex, *.leex, *.lock
  1172. Elixir and Euphoria share the *.ex file extension. If the filetype is
  1173. specifically set as Euphoria with the g:filetype_euphoria variable, or the
  1174. file is determined to be Euphoria based on keywords in the file, then the
  1175. filetype will be set as Euphoria. Otherwise, the filetype will default to
  1176. Elixir.
  1177. FLEXWIKI *flexwiki.vim* *ft-flexwiki-syntax*
  1178. FlexWiki is an ASP.NET-based wiki package available at http://www.flexwiki.com
  1179. NOTE: This site currently doesn't work, on Wikipedia is mentioned that
  1180. development stopped in 2009.
  1181. Syntax highlighting is available for the most common elements of FlexWiki
  1182. syntax. The associated ftplugin script sets some buffer-local options to make
  1183. editing FlexWiki pages more convenient. FlexWiki considers a newline as the
  1184. start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length),
  1185. 'wrap' (wrap long lines instead of using horizontal scrolling), 'linebreak'
  1186. (to wrap at a character in 'breakat' instead of at the last char on screen),
  1187. and so on. It also includes some keymaps that are disabled by default.
  1188. If you want to enable the keymaps that make "j" and "k" and the cursor keys
  1189. move up and down by display lines, add this to your .vimrc: >
  1190. :let flexwiki_maps = 1
  1191. FORM *form.vim* *ft-form-syntax*
  1192. The coloring scheme for syntax elements in the FORM file uses the default
  1193. modes Conditional, Number, Statement, Comment, PreProc, Type, and String,
  1194. following the language specifications in 'Symbolic Manipulation with FORM' by
  1195. J.A.M. Vermaseren, CAN, Netherlands, 1991.
  1196. If you want to include your own changes to the default colors, you have to
  1197. redefine the following syntax groups:
  1198. - formConditional
  1199. - formNumber
  1200. - formStatement
  1201. - formHeaderStatement
  1202. - formComment
  1203. - formPreProc
  1204. - formDirective
  1205. - formType
  1206. - formString
  1207. Note that the form.vim syntax file implements FORM preprocessor commands and
  1208. directives per default in the same syntax group.
  1209. A predefined enhanced color mode for FORM is available to distinguish between
  1210. header statements and statements in the body of a FORM program. To activate
  1211. this mode define the following variable in your vimrc file >
  1212. :let form_enhanced_color=1
  1213. The enhanced mode also takes advantage of additional color features for a dark
  1214. gvim display. Here, statements are colored LightYellow instead of Yellow, and
  1215. conditionals are LightBlue for better distinction.
  1216. Both Visual Basic and FORM use the extension ".frm". To detect which one
  1217. should be used, Vim checks for the string "VB_Name" in the first five lines of
  1218. the file. If it is found, filetype will be "vb", otherwise "form".
  1219. If the automatic detection doesn't work for you or you only edit, for
  1220. example, FORM files, use this in your startup vimrc: >
  1221. :let filetype_frm = "form"
  1222. FORTH *forth.vim* *ft-forth-syntax*
  1223. Files matching "*.fs" could be F# or Forth. If the automatic detection
  1224. doesn't work for you, or you don't edit F# at all, use this in your
  1225. startup vimrc: >
  1226. :let filetype_fs = "forth"
  1227. FORTRAN *fortran.vim* *ft-fortran-syntax*
  1228. Default highlighting and dialect ~
  1229. Highlighting appropriate for Fortran 2008 is used by default. This choice
  1230. should be appropriate for most users most of the time because Fortran 2008 is
  1231. almost a superset of previous versions (Fortran 2003, 95, 90, and 77).
  1232. Fortran source code form ~
  1233. Fortran code can be in either fixed or free source form. Note that the
  1234. syntax highlighting will not be correct if the form is incorrectly set.
  1235. When you create a new fortran file, the syntax script assumes fixed source
  1236. form. If you always use free source form, then >
  1237. :let fortran_free_source=1
  1238. in your .vimrc prior to the :syntax on command. If you always use fixed
  1239. source form, then >
  1240. :let fortran_fixed_source=1
  1241. in your .vimrc prior to the :syntax on command.
  1242. If the form of the source code depends, in a non-standard way, upon the file
  1243. extension, then it is most convenient to set fortran_free_source in a ftplugin
  1244. file. For more information on ftplugin files, see |ftplugin|. Note that this
  1245. will work only if the "filetype plugin indent on" command precedes the "syntax
  1246. on" command in your .vimrc file.
  1247. When you edit an existing fortran file, the syntax script will assume free
  1248. source form if the fortran_free_source variable has been set, and assumes
  1249. fixed source form if the fortran_fixed_source variable has been set. If
  1250. neither of these variables have been set, the syntax script attempts to
  1251. determine which source form has been used by examining the file extension
  1252. using conventions common to the ifort, gfortran, Cray, NAG, and PathScale
  1253. compilers (.f, .for, .f77 for fixed-source, .f90, .f95, .f03, .f08 for
  1254. free-source). If none of this works, then the script examines the first five
  1255. columns of the first 500 lines of your file. If no signs of free source form
  1256. are detected, then the file is assumed to be in fixed source form. The
  1257. algorithm should work in the vast majority of cases. In some cases, such as a
  1258. file that begins with 500 or more full-line comments, the script may
  1259. incorrectly decide that the fortran code is in fixed form. If that happens,
  1260. just add a non-comment statement beginning anywhere in the first five columns
  1261. of the first twenty-five lines, save (:w) and then reload (:e!) the file.
  1262. Tabs in fortran files ~
  1263. Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
  1264. fixed format fortran source code which requires fixed column boundaries.
  1265. Therefore, tabs are marked as errors. Nevertheless, some programmers like
  1266. using tabs. If your fortran files contain tabs, then you should set the
  1267. variable fortran_have_tabs in your .vimrc with a command such as >
  1268. :let fortran_have_tabs=1
  1269. placed prior to the :syntax on command. Unfortunately, the use of tabs will
  1270. mean that the syntax file will not be able to detect incorrect margins.
  1271. Syntax folding of fortran files ~
  1272. If you wish to use foldmethod=syntax, then you must first set the variable
  1273. fortran_fold with a command such as >
  1274. :let fortran_fold=1
  1275. to instruct the syntax script to define fold regions for program units, that
  1276. is main programs starting with a program statement, subroutines, function
  1277. subprograms, block data subprograms, interface blocks, and modules. If you
  1278. also set the variable fortran_fold_conditionals with a command such as >
  1279. :let fortran_fold_conditionals=1
  1280. then fold regions will also be defined for do loops, if blocks, and select
  1281. case constructs. If you also set the variable
  1282. fortran_fold_multilinecomments with a command such as >
  1283. :let fortran_fold_multilinecomments=1
  1284. then fold regions will also be defined for three or more consecutive comment
  1285. lines. Note that defining fold regions can be slow for large files.
  1286. If fortran_fold, and possibly fortran_fold_conditionals and/or
  1287. fortran_fold_multilinecomments, have been set, then vim will fold your file if
  1288. you set foldmethod=syntax. Comments or blank lines placed between two program
  1289. units are not folded because they are seen as not belonging to any program
  1290. unit.
  1291. More precise fortran syntax ~
  1292. If you set the variable fortran_more_precise with a command such as >
  1293. :let fortran_more_precise=1
  1294. then the syntax coloring will be more precise but slower. In particular,
  1295. statement labels used in do, goto and arithmetic if statements will be
  1296. recognized, as will construct names at the end of a do, if, select or forall
  1297. construct.
  1298. Non-default fortran dialects ~
  1299. The syntax script supports two Fortran dialects: f08 and F. You will probably
  1300. find the default highlighting (f08) satisfactory. A few legacy constructs
  1301. deleted or declared obsolescent in the 2008 standard are highlighted as todo
  1302. items.
  1303. If you use F, the advantage of setting the dialect appropriately is that
  1304. other legacy features excluded from F will be highlighted as todo items and
  1305. that free source form will be assumed.
  1306. The dialect can be selected in various ways. If all your fortran files use
  1307. the same dialect, set the global variable fortran_dialect in your .vimrc prior
  1308. to your syntax on statement. The case-sensitive, permissible values of
  1309. fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
  1310. ignored.
  1311. If the dialect depends upon the file extension, then it is most convenient to
  1312. set a buffer-local variable in a ftplugin file. For more information on
  1313. ftplugin files, see |ftplugin|. For example, if all your fortran files with
  1314. an .f90 extension are written in the F subset, your ftplugin file should
  1315. contain the code >
  1316. let s:extfname = expand("%:e")
  1317. if s:extfname ==? "f90"
  1318. let b:fortran_dialect="F"
  1319. else
  1320. unlet! b:fortran_dialect
  1321. endif
  1322. Note that this will work only if the "filetype plugin indent on" command
  1323. precedes the "syntax on" command in your .vimrc file.
  1324. Finer control is necessary if the file extension does not uniquely identify
  1325. the dialect. You can override the default dialect, on a file-by-file basis,
  1326. by including a comment with the directive "fortran_dialect=xx" (where xx=F or
  1327. f08) in one of the first three lines in your file. For example, your older .f
  1328. files may be legacy code but your newer ones may be F codes, and you would
  1329. identify the latter by including in the first three lines of those files a
  1330. Fortran comment of the form >
  1331. ! fortran_dialect=F
  1332. For previous versions of the syntax, you may have set fortran_dialect to the
  1333. now-obsolete values "f77", "f90", "f95", or "elf". Such settings will be
  1334. silently handled as "f08". Users of "elf" may wish to experiment with "F"
  1335. instead.
  1336. The syntax/fortran.vim script contains embedded comments that tell you how to
  1337. comment and/or uncomment some lines to (a) activate recognition of some
  1338. non-standard, vendor-supplied intrinsics and (b) to prevent features deleted
  1339. or declared obsolescent in the 2008 standard from being highlighted as todo
  1340. items.
  1341. Limitations ~
  1342. Parenthesis checking does not catch too few closing parentheses. Hollerith
  1343. strings are not recognized. Some keywords may be highlighted incorrectly
  1344. because Fortran90 has no reserved words.
  1345. For further information related to fortran, see |ft-fortran-indent| and
  1346. |ft-fortran-plugin|.
  1347. FREEBASIC *freebasic.vim* *ft-freebasic-syntax*
  1348. FreeBASIC files will be highlighted differently for each of the four available
  1349. dialects, "fb", "qb", "fblite" and "deprecated". See |ft-freebasic-plugin|
  1350. for how to select the correct dialect.
  1351. Highlighting is further configurable via the following variables.
  1352. Variable Highlight ~
  1353. *freebasic_no_comment_fold* disable multiline comment folding
  1354. *freebasic_operators* non-alpha operators
  1355. *freebasic_space_errors* trailing white space and spaces before a <Tab>
  1356. *freebasic_type_suffixes* QuickBASIC style type suffixes
  1357. FVWM CONFIGURATION FILES *fvwm.vim* *ft-fvwm-syntax*
  1358. In order for Vim to recognize Fvwm configuration files that do not match
  1359. the patterns *fvwmrc* or *fvwm2rc* , you must put additional patterns
  1360. appropriate to your system in your myfiletypes.vim file. For these
  1361. patterns, you must set the variable "b:fvwm_version" to the major version
  1362. number of Fvwm, and the 'filetype' option to fvwm.
  1363. For example, to make Vim identify all files in /etc/X11/fvwm2/
  1364. as Fvwm2 configuration files, add the following: >
  1365. :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 |
  1366. \ set filetype=fvwm
  1367. GSP *gsp.vim* *ft-gsp-syntax*
  1368. The default coloring style for GSP pages is defined by |html.vim|, and
  1369. the coloring for java code (within java tags or inline between backticks)
  1370. is defined by |java.vim|. The following HTML groups defined in |html.vim|
  1371. are redefined to incorporate and highlight inline java code:
  1372. htmlString
  1373. htmlValue
  1374. htmlEndTag
  1375. htmlTag
  1376. htmlTagN
  1377. Highlighting should look fine most of the places where you'd see inline
  1378. java code, but in some special cases it may not. To add another HTML
  1379. group where you will have inline java code where it does not highlight
  1380. correctly, just copy the line you want from |html.vim| and add gspJava
  1381. to the contains clause.
  1382. The backticks for inline java are highlighted according to the htmlError
  1383. group to make them easier to see.
  1384. GROFF *groff.vim* *ft-groff-syntax*
  1385. The groff syntax file is a wrapper for |nroff.vim|, see the notes
  1386. under that heading for examples of use and configuration. The purpose
  1387. of this wrapper is to set up groff syntax extensions by setting the
  1388. filetype from a |modeline| or in a personal filetype definitions file
  1389. (see |filetype.txt|).
  1390. HASKELL *haskell.vim* *lhaskell.vim* *ft-haskell-syntax*
  1391. The Haskell syntax files support plain Haskell code as well as literate
  1392. Haskell code, the latter in both Bird style and TeX style. The Haskell
  1393. syntax highlighting will also highlight C preprocessor directives.
  1394. If you want to highlight delimiter characters (useful if you have a
  1395. light-coloured background), add to your .vimrc: >
  1396. :let hs_highlight_delimiters = 1
  1397. To treat True and False as keywords as opposed to ordinary identifiers,
  1398. add: >
  1399. :let hs_highlight_boolean = 1
  1400. To also treat the names of primitive types as keywords: >
  1401. :let hs_highlight_types = 1
  1402. And to treat the names of even more relatively common types as keywords: >
  1403. :let hs_highlight_more_types = 1
  1404. If you want to highlight the names of debugging functions, put in
  1405. your .vimrc: >
  1406. :let hs_highlight_debug = 1
  1407. The Haskell syntax highlighting also highlights C preprocessor
  1408. directives, and flags lines that start with # but are not valid
  1409. directives as erroneous. This interferes with Haskell's syntax for
  1410. operators, as they may start with #. If you want to highlight those
  1411. as operators as opposed to errors, put in your .vimrc: >
  1412. :let hs_allow_hash_operator = 1
  1413. The syntax highlighting for literate Haskell code will try to
  1414. automatically guess whether your literate Haskell code contains
  1415. TeX markup or not, and correspondingly highlight TeX constructs
  1416. or nothing at all. You can override this globally by putting
  1417. in your .vimrc >
  1418. :let lhs_markup = none
  1419. for no highlighting at all, or >
  1420. :let lhs_markup = tex
  1421. to force the highlighting to always try to highlight TeX markup.
  1422. For more flexibility, you may also use buffer local versions of
  1423. this variable, so e.g. >
  1424. :let b:lhs_markup = tex
  1425. will force TeX highlighting for a particular buffer. It has to be
  1426. set before turning syntax highlighting on for the buffer or
  1427. loading a file.
  1428. HTML *html.vim* *ft-html-syntax*
  1429. The coloring scheme for tags in the HTML file works as follows.
  1430. The <> of opening tags are colored differently than the </> of a closing tag.
  1431. This is on purpose! For opening tags the 'Function' color is used, while for
  1432. closing tags the 'Identifier' color is used (See syntax.vim to check how those
  1433. are defined for you)
  1434. Known tag names are colored the same way as statements in C. Unknown tag
  1435. names are colored with the same color as the <> or </> respectively which
  1436. makes it easy to spot errors
  1437. Note that the same is true for argument (or attribute) names. Known attribute
  1438. names are colored differently than unknown ones.
  1439. Some HTML tags are used to change the rendering of text. The following tags
  1440. are recognized by the html.vim syntax coloring file and change the way normal
  1441. text is shown: <B> <I> <U> <EM> <STRONG> (<EM> is used as an alias for <I>,
  1442. while <STRONG> as an alias for <B>), <H1> - <H6>, <HEAD>, <TITLE> and <A>, but
  1443. only if used as a link (that is, it must include a href as in
  1444. <A href="somefile.html">).
  1445. If you want to change how such text is rendered, you must redefine the
  1446. following syntax groups:
  1447. - htmlBold
  1448. - htmlBoldUnderline
  1449. - htmlBoldUnderlineItalic
  1450. - htmlUnderline
  1451. - htmlUnderlineItalic
  1452. - htmlItalic
  1453. - htmlTitle for titles
  1454. - htmlH1 - htmlH6 for headings
  1455. To make this redefinition work you must redefine them all with the exception
  1456. of the last two (htmlTitle and htmlH[1-6], which are optional) and define the
  1457. following variable in your vimrc (this is due to the order in which the files
  1458. are read during initialization) >
  1459. :let html_my_rendering=1
  1460. If you'd like to see an example download mysyntax.vim at
  1461. http://www.fleiner.com/vim/download.html
  1462. You can also disable this rendering by adding the following line to your
  1463. vimrc file: >
  1464. :let html_no_rendering=1
  1465. HTML comments are rather special (see an HTML reference document for the
  1466. details), and the syntax coloring scheme will highlight all errors.
  1467. However, if you prefer to use the wrong style (starts with <!-- and
  1468. ends with -->) you can define >
  1469. :let html_wrong_comments=1
  1470. JavaScript and Visual Basic embedded inside HTML documents are highlighted as
  1471. 'Special' with statements, comments, strings and so on colored as in standard
  1472. programming languages. Note that only JavaScript and Visual Basic are
  1473. currently supported, no other scripting language has been added yet.
  1474. Embedded and inlined cascading style sheets (CSS) are highlighted too.
  1475. There are several html preprocessor languages out there. html.vim has been
  1476. written such that it should be trivial to include it. To do so add the
  1477. following two lines to the syntax coloring file for that language
  1478. (the example comes from the asp.vim file):
  1479. >
  1480. runtime! syntax/html.vim
  1481. syn cluster htmlPreproc add=asp
  1482. Now you just need to make sure that you add all regions that contain
  1483. the preprocessor language to the cluster htmlPreproc.
  1484. *html-folding*
  1485. The HTML syntax file provides syntax |folding| (see |:syn-fold|) between start
  1486. and end tags. This can be turned on by >
  1487. :let g:html_syntax_folding = 1
  1488. :set foldmethod=syntax
  1489. Note: Syntax folding might slow down syntax highlighting significantly,
  1490. especially for large files.
  1491. HTML/OS (by Aestiva) *htmlos.vim* *ft-htmlos-syntax*
  1492. The coloring scheme for HTML/OS works as follows:
  1493. Functions and variable names are the same color by default, because VIM
  1494. doesn't specify different colors for Functions and Identifiers. To change
  1495. this (which is recommended if you want function names to be recognizable in a
  1496. different color) you need to add the following line to either your ~/.vimrc: >
  1497. :hi Function term=underline cterm=bold ctermfg=LightGray
  1498. Of course, the ctermfg can be a different color if you choose.
  1499. Another issues that HTML/OS runs into is that there is no special filetype to
  1500. signify that it is a file with HTML/OS coding. You can change this by opening
  1501. a file and turning on HTML/OS syntax by doing the following: >
  1502. :set syntax=htmlos
  1503. Lastly, it should be noted that the opening and closing characters to begin a
  1504. block of HTML/OS code can either be << or [[ and >> or ]], respectively.
  1505. IA64 *ia64.vim* *intel-itanium* *ft-ia64-syntax*
  1506. Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
  1507. how to recognize this filetype.
  1508. To have *.inc files be recognized as IA64, add this to your .vimrc file: >
  1509. :let g:filetype_inc = "ia64"
  1510. INFORM *inform.vim* *ft-inform-syntax*
  1511. Inform highlighting includes symbols provided by the Inform Library, as
  1512. most programs make extensive use of it. If do not wish Library symbols
  1513. to be highlighted add this to your vim startup: >
  1514. :let inform_highlight_simple=1
  1515. By default it is assumed that Inform programs are Z-machine targeted,
  1516. and highlights Z-machine assembly language symbols appropriately. If
  1517. you intend your program to be targeted to a Glulx/Glk environment you
  1518. need to add this to your startup sequence: >
  1519. :let inform_highlight_glulx=1
  1520. This will highlight Glulx opcodes instead, and also adds glk() to the
  1521. set of highlighted system functions.
  1522. The Inform compiler will flag certain obsolete keywords as errors when
  1523. it encounters them. These keywords are normally highlighted as errors
  1524. by Vim. To prevent such error highlighting, you must add this to your
  1525. startup sequence: >
  1526. :let inform_suppress_obsolete=1
  1527. By default, the language features highlighted conform to Compiler
  1528. version 6.30 and Library version 6.11. If you are using an older
  1529. Inform development environment, you may with to add this to your
  1530. startup sequence: >
  1531. :let inform_highlight_old=1
  1532. IDL *idl.vim* *idl-syntax*
  1533. IDL (Interface Definition Language) files are used to define RPC calls. In
  1534. Microsoft land, this is also used for defining COM interfaces and calls.
  1535. IDL's structure is simple enough to permit a full grammar based approach to
  1536. rather than using a few heuristics. The result is large and somewhat
  1537. repetitive but seems to work.
  1538. There are some Microsoft extensions to idl files that are here. Some of them
  1539. are disabled by defining idl_no_ms_extensions.
  1540. The more complex of the extensions are disabled by defining idl_no_extensions.
  1541. Variable Effect ~
  1542. idl_no_ms_extensions Disable some of the Microsoft specific
  1543. extensions
  1544. idl_no_extensions Disable complex extensions
  1545. idlsyntax_showerror Show IDL errors (can be rather intrusive, but
  1546. quite helpful)
  1547. idlsyntax_showerror_soft Use softer colours by default for errors
  1548. JAVA *java.vim* *ft-java-syntax*
  1549. The java.vim syntax highlighting file offers several options:
  1550. In Java 1.0.2 it was never possible to have braces inside parens, so this was
  1551. flagged as an error. Since Java 1.1 this is possible (with anonymous
  1552. classes), and therefore is no longer marked as an error. If you prefer the
  1553. old way, put the following line into your vim startup file: >
  1554. :let java_mark_braces_in_parens_as_errors=1
  1555. All identifiers in java.lang.* are always visible in all classes. To
  1556. highlight them use: >
  1557. :let java_highlight_java_lang_ids=1
  1558. You can also highlight identifiers of most standard Java packages if you
  1559. download the javaid.vim script at http://www.fleiner.com/vim/download.html.
  1560. If you prefer to only highlight identifiers of a certain package, say java.io
  1561. use the following: >
  1562. :let java_highlight_java_io=1
  1563. Check the javaid.vim file for a list of all the packages that are supported.
  1564. Function names are not highlighted, as the way to find functions depends on
  1565. how you write Java code. The syntax file knows two possible ways to highlight
  1566. functions:
  1567. If you write function declarations that are always indented by either
  1568. a tab, 8 spaces or 2 spaces you may want to set >
  1569. :let java_highlight_functions="indent"
  1570. However, if you follow the Java guidelines about how functions and classes are
  1571. supposed to be named (with respect to upper and lowercase), use >
  1572. :let java_highlight_functions="style"
  1573. If both options do not work for you, but you would still want function
  1574. declarations to be highlighted create your own definitions by changing the
  1575. definitions in java.vim or by creating your own java.vim which includes the
  1576. original one and then adds the code to highlight functions.
  1577. In Java 1.1 the functions System.out.println() and System.err.println() should
  1578. only be used for debugging. Therefore it is possible to highlight debugging
  1579. statements differently. To do this you must add the following definition in
  1580. your startup file: >
  1581. :let java_highlight_debug=1
  1582. The result will be that those statements are highlighted as 'Special'
  1583. characters. If you prefer to have them highlighted differently you must define
  1584. new highlightings for the following groups.:
  1585. Debug, DebugSpecial, DebugString, DebugBoolean, DebugType
  1586. which are used for the statement itself, special characters used in debug
  1587. strings, strings, boolean constants and types (this, super) respectively. I
  1588. have opted to choose another background for those statements.
  1589. Javadoc is a program that takes special comments out of Java program files and
  1590. creates HTML pages. The standard configuration will highlight this HTML code
  1591. similarly to HTML files (see |html.vim|). You can even add Javascript
  1592. and CSS inside this code (see below). There are four differences however:
  1593. 1. The title (all characters up to the first '.' which is followed by
  1594. some white space or up to the first '@') is colored differently (to change
  1595. the color change the group CommentTitle).
  1596. 2. The text is colored as 'Comment'.
  1597. 3. HTML comments are colored as 'Special'
  1598. 4. The special Javadoc tags (@see, @param, ...) are highlighted as specials
  1599. and the argument (for @see, @param, @exception) as Function.
  1600. To turn this feature off add the following line to your startup file: >
  1601. :let java_ignore_javadoc=1
  1602. If you use the special Javadoc comment highlighting described above you
  1603. can also turn on special highlighting for Javascript, visual basic
  1604. scripts and embedded CSS (stylesheets). This makes only sense if you
  1605. actually have Javadoc comments that include either Javascript or embedded
  1606. CSS. The options to use are >
  1607. :let java_javascript=1
  1608. :let java_css=1
  1609. :let java_vb=1
  1610. In order to highlight nested parens with different colors define colors
  1611. for javaParen, javaParen1 and javaParen2, for example with >
  1612. :hi link javaParen Comment
  1613. or >
  1614. :hi javaParen ctermfg=blue guifg=#0000ff
  1615. If you notice highlighting errors while scrolling backwards, which are fixed
  1616. when redrawing with CTRL-L, try setting the "java_minlines" internal variable
  1617. to a larger number: >
  1618. :let java_minlines = 50
  1619. This will make the syntax synchronization start 50 lines before the first
  1620. displayed line. The default value is 10. The disadvantage of using a larger
  1621. number is that redrawing can become slow.
  1622. JSON *json.vim* *ft-json-syntax*
  1623. The json syntax file provides syntax highlighting with conceal support by
  1624. default. To disable concealment: >
  1625. let g:vim_json_conceal = 0
  1626. To disable syntax highlighting of errors: >
  1627. let g:vim_json_warnings = 0
  1628. LACE *lace.vim* *ft-lace-syntax*
  1629. Lace (Language for Assembly of Classes in Eiffel) is case insensitive, but the
  1630. style guide lines are not. If you prefer case insensitive highlighting, just
  1631. define the vim variable 'lace_case_insensitive' in your startup file: >
  1632. :let lace_case_insensitive=1
  1633. LEX *lex.vim* *ft-lex-syntax*
  1634. Lex uses brute-force synchronizing as the "^%%$" section delimiter
  1635. gives no clue as to what section follows. Consequently, the value for >
  1636. :syn sync minlines=300
  1637. may be changed by the user if s/he is experiencing synchronization
  1638. difficulties (such as may happen with large lex files).
  1639. LIFELINES *lifelines.vim* *ft-lifelines-syntax*
  1640. To highlight deprecated functions as errors, add in your .vimrc: >
  1641. :let g:lifelines_deprecated = 1
  1642. <
  1643. LISP *lisp.vim* *ft-lisp-syntax*
  1644. The lisp syntax highlighting provides two options: >
  1645. g:lisp_instring : If it exists, then "(...)" strings are highlighted
  1646. as if the contents of the string were lisp.
  1647. Useful for AutoLisp.
  1648. g:lisp_rainbow : If it exists and is nonzero, then differing levels
  1649. of parenthesization will receive different
  1650. highlighting.
  1651. <
  1652. The g:lisp_rainbow option provides 10 levels of individual colorization for
  1653. the parentheses and backquoted parentheses. Because of the quantity of
  1654. colorization levels, unlike non-rainbow highlighting, the rainbow mode
  1655. specifies its highlighting using ctermfg and guifg, thereby bypassing the
  1656. usual color scheme control using standard highlighting groups. The actual
  1657. highlighting used depends on the dark/bright setting (see |'bg'|).
  1658. LITE *lite.vim* *ft-lite-syntax*
  1659. There are two options for the lite syntax highlighting.
  1660. If you like SQL syntax highlighting inside Strings, use this: >
  1661. :let lite_sql_query = 1
  1662. For syncing, minlines defaults to 100. If you prefer another value, you can
  1663. set "lite_minlines" to the value you desire. Example: >
  1664. :let lite_minlines = 200
  1665. LPC *lpc.vim* *ft-lpc-syntax*
  1666. LPC stands for a simple, memory-efficient language: Lars Pensjö C. The
  1667. file name of LPC is usually *.c. Recognizing these files as LPC would bother
  1668. users writing only C programs. If you want to use LPC syntax in Vim, you
  1669. should set a variable in your .vimrc file: >
  1670. :let lpc_syntax_for_c = 1
  1671. If it doesn't work properly for some particular C or LPC files, use a
  1672. modeline. For a LPC file:
  1673. // vim:set ft=lpc:
  1674. For a C file that is recognized as LPC:
  1675. // vim:set ft=c:
  1676. If you don't want to set the variable, use the modeline in EVERY LPC file.
  1677. There are several implementations for LPC, we intend to support most widely
  1678. used ones. Here the default LPC syntax is for MudOS series, for MudOS v22
  1679. and before, you should turn off the sensible modifiers, and this will also
  1680. assert the new efuns after v22 to be invalid, don't set this variable when
  1681. you are using the latest version of MudOS: >
  1682. :let lpc_pre_v22 = 1
  1683. For LpMud 3.2 series of LPC: >
  1684. :let lpc_compat_32 = 1
  1685. For LPC4 series of LPC: >
  1686. :let lpc_use_lpc4_syntax = 1
  1687. For uLPC series of LPC:
  1688. uLPC has been developed to Pike, so you should use Pike syntax
  1689. instead, and the name of your source file should be *.pike
  1690. LUA *lua.vim* *ft-lua-syntax*
  1691. The Lua syntax file can be used for versions 4.0, 5.0, 5.1 and 5.2 (5.2 is
  1692. the default). You can select one of these versions using the global variables
  1693. lua_version and lua_subversion. For example, to activate Lua
  1694. 5.1 syntax highlighting, set the variables like this:
  1695. :let lua_version = 5
  1696. :let lua_subversion = 1
  1697. MAIL *mail.vim* *ft-mail.vim*
  1698. Vim highlights all the standard elements of an email (headers, signatures,
  1699. quoted text and URLs / email addresses). In keeping with standard conventions,
  1700. signatures begin in a line containing only "--" followed optionally by
  1701. whitespaces and end with a newline.
  1702. Vim treats lines beginning with ']', '}', '|', '>' or a word followed by '>'
  1703. as quoted text. However Vim highlights headers and signatures in quoted text
  1704. only if the text is quoted with '>' (optionally followed by one space).
  1705. By default mail.vim synchronises syntax to 100 lines before the first
  1706. displayed line. If you have a slow machine, and generally deal with emails
  1707. with short headers, you can change this to a smaller value: >
  1708. :let mail_minlines = 30
  1709. MAKE *make.vim* *ft-make-syntax*
  1710. In makefiles, commands are usually highlighted to make it easy for you to spot
  1711. errors. However, this may be too much coloring for you. You can turn this
  1712. feature off by using: >
  1713. :let make_no_commands = 1
  1714. MAPLE *maple.vim* *ft-maple-syntax*
  1715. Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
  1716. supports many packages of functions which are selectively loaded by the user.
  1717. The standard set of packages' functions as supplied in Maple V release 4 may be
  1718. highlighted at the user's discretion. Users may place in their .vimrc file: >
  1719. :let mvpkg_all= 1
  1720. to get all package functions highlighted, or users may select any subset by
  1721. choosing a variable/package from the table below and setting that variable to
  1722. 1, also in their .vimrc file (prior to sourcing
  1723. $VIMRUNTIME/syntax/syntax.vim).
  1724. Table of Maple V Package Function Selectors >
  1725. mv_DEtools mv_genfunc mv_networks mv_process
  1726. mv_Galois mv_geometry mv_numapprox mv_simplex
  1727. mv_GaussInt mv_grobner mv_numtheory mv_stats
  1728. mv_LREtools mv_group mv_orthopoly mv_student
  1729. mv_combinat mv_inttrans mv_padic mv_sumtools
  1730. mv_combstruct mv_liesymm mv_plots mv_tensor
  1731. mv_difforms mv_linalg mv_plottools mv_totorder
  1732. mv_finance mv_logic mv_powseries
  1733. MARKDOWN *ft-markdown-syntax*
  1734. If you have long regions there might be wrong highlighting. At the cost of
  1735. slowing down displaying, you can have the engine look further back to sync on
  1736. the start of a region, for example 500 lines: >
  1737. :let g:markdown_minlines = 500
  1738. MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
  1739. Empty *.m files will automatically be presumed to be Matlab files unless you
  1740. have the following in your .vimrc: >
  1741. let filetype_m = "mma"
  1742. MOO *moo.vim* *ft-moo-syntax*
  1743. If you use C-style comments inside expressions and find it mangles your
  1744. highlighting, you may want to use extended (slow!) matches for C-style
  1745. comments: >
  1746. :let moo_extended_cstyle_comments = 1
  1747. To disable highlighting of pronoun substitution patterns inside strings: >
  1748. :let moo_no_pronoun_sub = 1
  1749. To disable highlighting of the regular expression operator '%|', and matching
  1750. '%(' and '%)' inside strings: >
  1751. :let moo_no_regexp = 1
  1752. Unmatched double quotes can be recognized and highlighted as errors: >
  1753. :let moo_unmatched_quotes = 1
  1754. To highlight builtin properties (.name, .location, .programmer etc.): >
  1755. :let moo_builtin_properties = 1
  1756. Unknown builtin functions can be recognized and highlighted as errors. If you
  1757. use this option, add your own extensions to the mooKnownBuiltinFunction group.
  1758. To enable this option: >
  1759. :let moo_unknown_builtin_functions = 1
  1760. An example of adding sprintf() to the list of known builtin functions: >
  1761. :syn keyword mooKnownBuiltinFunction sprintf contained
  1762. MSQL *msql.vim* *ft-msql-syntax*
  1763. There are two options for the msql syntax highlighting.
  1764. If you like SQL syntax highlighting inside Strings, use this: >
  1765. :let msql_sql_query = 1
  1766. For syncing, minlines defaults to 100. If you prefer another value, you can
  1767. set "msql_minlines" to the value you desire. Example: >
  1768. :let msql_minlines = 200
  1769. N1QL *n1ql.vim* *ft-n1ql-syntax*
  1770. N1QL is a SQL-like declarative language for manipulating JSON documents in
  1771. Couchbase Server databases.
  1772. Vim syntax highlights N1QL statements, keywords, operators, types, comments,
  1773. and special values. Vim ignores syntactical elements specific to SQL or its
  1774. many dialects, like COLUMN or CHAR, that don't exist in N1QL.
  1775. NCF *ncf.vim* *ft-ncf-syntax*
  1776. There is one option for NCF syntax highlighting.
  1777. If you want to have unrecognized (by ncf.vim) statements highlighted as
  1778. errors, use this: >
  1779. :let ncf_highlight_unknowns = 1
  1780. If you don't want to highlight these errors, leave it unset.
  1781. NROFF *nroff.vim* *ft-nroff-syntax*
  1782. The nroff syntax file works with AT&T n/troff out of the box. You need to
  1783. activate the GNU groff extra features included in the syntax file before you
  1784. can use them.
  1785. For example, Linux and BSD distributions use groff as their default text
  1786. processing package. In order to activate the extra syntax highlighting
  1787. features for groff, arrange for files to be recognized as groff (see
  1788. |ft-groff-syntax|) or add the following option to your start-up files: >
  1789. :let nroff_is_groff = 1
  1790. Groff is different from the old AT&T n/troff that you may still find in
  1791. Solaris. Groff macro and request names can be longer than 2 characters and
  1792. there are extensions to the language primitives. For example, in AT&T troff
  1793. you access the year as a 2-digit number with the request \(yr. In groff you
  1794. can use the same request, recognized for compatibility, or you can use groff's
  1795. native syntax, \[yr]. Furthermore, you can use a 4-digit year directly:
  1796. \[year]. Macro requests can be longer than 2 characters, for example, GNU mm
  1797. accepts the requests ".VERBON" and ".VERBOFF" for creating verbatim
  1798. environments.
  1799. In order to obtain the best formatted output g/troff can give you, you should
  1800. follow a few simple rules about spacing and punctuation.
  1801. 1. Do not leave empty spaces at the end of lines.
  1802. 2. Leave one space and one space only after an end-of-sentence period,
  1803. exclamation mark, etc.
  1804. 3. For reasons stated below, it is best to follow all period marks with a
  1805. carriage return.
  1806. The reason behind these unusual tips is that g/n/troff have a line breaking
  1807. algorithm that can be easily upset if you don't follow the rules given above.
  1808. Unlike TeX, troff fills text line-by-line, not paragraph-by-paragraph and,
  1809. furthermore, it does not have a concept of glue or stretch, all horizontal and
  1810. vertical space input will be output as is.
  1811. Therefore, you should be careful about not using more space between sentences
  1812. than you intend to have in your final document. For this reason, the common
  1813. practice is to insert a carriage return immediately after all punctuation
  1814. marks. If you want to have "even" text in your final processed output, you
  1815. need to maintain regular spacing in the input text. To mark both trailing
  1816. spaces and two or more spaces after a punctuation as an error, use: >
  1817. :let nroff_space_errors = 1
  1818. Another technique to detect extra spacing and other errors that will interfere
  1819. with the correct typesetting of your file, is to define an eye-catching
  1820. highlighting definition for the syntax groups "nroffDefinition" and
  1821. "nroffDefSpecial" in your configuration files. For example: >
  1822. hi def nroffDefinition term=italic cterm=italic gui=reverse
  1823. hi def nroffDefSpecial term=italic,bold cterm=italic,bold
  1824. \ gui=reverse,bold
  1825. If you want to navigate preprocessor entries in your source file as easily as
  1826. with section markers, you can activate the following option in your .vimrc
  1827. file: >
  1828. let b:preprocs_as_sections = 1
  1829. As well, the syntax file adds an extra paragraph marker for the extended
  1830. paragraph macro (.XP) in the ms package.
  1831. Finally, there is a |groff.vim| syntax file that can be used for enabling
  1832. groff syntax highlighting either on a file basis or globally by default.
  1833. OCAML *ocaml.vim* *ft-ocaml-syntax*
  1834. The OCaml syntax file handles files having the following prefixes: .ml,
  1835. .mli, .mll and .mly. By setting the following variable >
  1836. :let ocaml_revised = 1
  1837. you can switch from standard OCaml-syntax to revised syntax as supported
  1838. by the camlp4 preprocessor. Setting the variable >
  1839. :let ocaml_noend_error = 1
  1840. prevents highlighting of "end" as error, which is useful when sources
  1841. contain very long structures that Vim does not synchronize anymore.
  1842. PAPP *papp.vim* *ft-papp-syntax*
  1843. The PApp syntax file handles .papp files and, to a lesser extent, .pxml
  1844. and .pxsl files which are all a mixture of perl/xml/html/other using xml
  1845. as the top-level file format. By default everything inside phtml or pxml
  1846. sections is treated as a string with embedded preprocessor commands. If
  1847. you set the variable: >
  1848. :let papp_include_html=1
  1849. in your startup file it will try to syntax-highlight html code inside phtml
  1850. sections, but this is relatively slow and much too colourful to be able to
  1851. edit sensibly. ;)
  1852. The newest version of the papp.vim syntax file can usually be found at
  1853. http://papp.plan9.de.
  1854. PASCAL *pascal.vim* *ft-pascal-syntax*
  1855. Files matching "*.p" could be Progress or Pascal and those matching "*.pp"
  1856. could be Puppet or Pascal. If the automatic detection doesn't work for you,
  1857. or you only edit Pascal files, use this in your startup vimrc: >
  1858. :let filetype_p = "pascal"
  1859. :let filetype_pp = "pascal"
  1860. The Pascal syntax file has been extended to take into account some extensions
  1861. provided by Turbo Pascal, Free Pascal Compiler and GNU Pascal Compiler.
  1862. Delphi keywords are also supported. By default, Turbo Pascal 7.0 features are
  1863. enabled. If you prefer to stick with the standard Pascal keywords, add the
  1864. following line to your startup file: >
  1865. :let pascal_traditional=1
  1866. To switch on Delphi specific constructions (such as one-line comments,
  1867. keywords, etc): >
  1868. :let pascal_delphi=1
  1869. The option pascal_symbol_operator controls whether symbol operators such as +,
  1870. *, .., etc. are displayed using the Operator color or not. To colorize symbol
  1871. operators, add the following line to your startup file: >
  1872. :let pascal_symbol_operator=1
  1873. Some functions are highlighted by default. To switch it off: >
  1874. :let pascal_no_functions=1
  1875. Furthermore, there are specific variables for some compilers. Besides
  1876. pascal_delphi, there are pascal_gpc and pascal_fpc. Default extensions try to
  1877. match Turbo Pascal. >
  1878. :let pascal_gpc=1
  1879. or >
  1880. :let pascal_fpc=1
  1881. To ensure that strings are defined on a single line, you can define the
  1882. pascal_one_line_string variable. >
  1883. :let pascal_one_line_string=1
  1884. If you dislike <Tab> chars, you can set the pascal_no_tabs variable. Tabs
  1885. will be highlighted as Error. >
  1886. :let pascal_no_tabs=1
  1887. PERL *perl.vim* *ft-perl-syntax*
  1888. There are a number of possible options to the perl syntax highlighting.
  1889. Inline POD highlighting is now turned on by default. If you don't wish
  1890. to have the added complexity of highlighting POD embedded within Perl
  1891. files, you may set the 'perl_include_pod' option to 0: >
  1892. :let perl_include_pod = 0
  1893. To reduce the complexity of parsing (and increase performance) you can switch
  1894. off two elements in the parsing of variable names and contents. >
  1895. To handle package references in variable and function names not differently
  1896. from the rest of the name (like 'PkgName::' in '$PkgName::VarName'): >
  1897. :let perl_no_scope_in_variables = 1
  1898. (In Vim 6.x it was the other way around: "perl_want_scope_in_variables"
  1899. enabled it.)
  1900. If you do not want complex things like '@{${"foo"}}' to be parsed: >
  1901. :let perl_no_extended_vars = 1
  1902. (In Vim 6.x it was the other way around: "perl_extended_vars" enabled it.)
  1903. The coloring strings can be changed. By default strings and qq friends will
  1904. be highlighted like the first line. If you set the variable
  1905. perl_string_as_statement, it will be highlighted as in the second line.
  1906. "hello world!"; qq|hello world|;
  1907. ^^^^^^^^^^^^^^NN^^^^^^^^^^^^^^^N (unlet perl_string_as_statement)
  1908. S^^^^^^^^^^^^SNNSSS^^^^^^^^^^^SN (let perl_string_as_statement)
  1909. (^ = perlString, S = perlStatement, N = None at all)
  1910. The syncing has 3 options. The first two switch off some triggering of
  1911. synchronization and should only be needed in case it fails to work properly.
  1912. If while scrolling all of a sudden the whole screen changes color completely
  1913. then you should try and switch off one of those. Let me know if you can
  1914. figure out the line that causes the mistake.
  1915. One triggers on "^\s*sub\s*" and the other on "^[$@%]" more or less. >
  1916. :let perl_no_sync_on_sub
  1917. :let perl_no_sync_on_global_var
  1918. Below you can set the maximum distance VIM should look for starting points for
  1919. its attempts in syntax highlighting. >
  1920. :let perl_sync_dist = 100
  1921. If you want to use folding with perl, set perl_fold: >
  1922. :let perl_fold = 1
  1923. If you want to fold blocks in if statements, etc. as well set the following: >
  1924. :let perl_fold_blocks = 1
  1925. Subroutines are folded by default if 'perl_fold' is set. If you do not want
  1926. this, you can set 'perl_nofold_subs': >
  1927. :let perl_nofold_subs = 1
  1928. Anonymous subroutines are not folded by default; you may enable their folding
  1929. via 'perl_fold_anonymous_subs': >
  1930. :let perl_fold_anonymous_subs = 1
  1931. Packages are also folded by default if 'perl_fold' is set. To disable this
  1932. behavior, set 'perl_nofold_packages': >
  1933. :let perl_nofold_packages = 1
  1934. PHP3 and PHP4 *php.vim* *php3.vim* *ft-php-syntax* *ft-php3-syntax*
  1935. [Note: Previously this was called "php3", but since it now also supports php4
  1936. it has been renamed to "php"]
  1937. There are the following options for the php syntax highlighting.
  1938. If you like SQL syntax highlighting inside Strings: >
  1939. let php_sql_query = 1
  1940. For highlighting the Baselib methods: >
  1941. let php_baselib = 1
  1942. Enable HTML syntax highlighting inside strings: >
  1943. let php_htmlInStrings = 1
  1944. Using the old colorstyle: >
  1945. let php_oldStyle = 1
  1946. Enable highlighting ASP-style short tags: >
  1947. let php_asp_tags = 1
  1948. Disable short tags: >
  1949. let php_noShortTags = 1
  1950. For highlighting parent error ] or ): >
  1951. let php_parent_error_close = 1
  1952. For skipping a php end tag, if there exists an open ( or [ without a closing
  1953. one: >
  1954. let php_parent_error_open = 1
  1955. Enable folding for classes and functions: >
  1956. let php_folding = 1
  1957. Selecting syncing method: >
  1958. let php_sync_method = x
  1959. x = -1 to sync by search (default),
  1960. x > 0 to sync at least x lines backwards,
  1961. x = 0 to sync from start.
  1962. PLAINTEX *plaintex.vim* *ft-plaintex-syntax*
  1963. TeX is a typesetting language, and plaintex is the file type for the "plain"
  1964. variant of TeX. If you never want your *.tex files recognized as plain TeX,
  1965. see |ft-tex-plugin|.
  1966. This syntax file has the option >
  1967. let g:plaintex_delimiters = 1
  1968. if you want to highlight brackets "[]" and braces "{}".
  1969. PPWIZARD *ppwiz.vim* *ft-ppwiz-syntax*
  1970. PPWizard is a preprocessor for HTML and OS/2 INF files
  1971. This syntax file has the options:
  1972. - ppwiz_highlight_defs : Determines highlighting mode for PPWizard's
  1973. definitions. Possible values are
  1974. ppwiz_highlight_defs = 1 : PPWizard #define statements retain the
  1975. colors of their contents (e.g. PPWizard macros and variables).
  1976. ppwiz_highlight_defs = 2 : Preprocessor #define and #evaluate
  1977. statements are shown in a single color with the exception of line
  1978. continuation symbols.
  1979. The default setting for ppwiz_highlight_defs is 1.
  1980. - ppwiz_with_html : If the value is 1 (the default), highlight literal
  1981. HTML code; if 0, treat HTML code like ordinary text.
  1982. PHTML *phtml.vim* *ft-phtml-syntax*
  1983. There are two options for the phtml syntax highlighting.
  1984. If you like SQL syntax highlighting inside Strings, use this: >
  1985. :let phtml_sql_query = 1
  1986. For syncing, minlines defaults to 100. If you prefer another value, you can
  1987. set "phtml_minlines" to the value you desire. Example: >
  1988. :let phtml_minlines = 200
  1989. POSTSCRIPT *postscr.vim* *ft-postscr-syntax*
  1990. There are several options when it comes to highlighting PostScript.
  1991. First which version of the PostScript language to highlight. There are
  1992. currently three defined language versions, or levels. Level 1 is the original
  1993. and base version, and includes all extensions prior to the release of level 2.
  1994. Level 2 is the most common version around, and includes its own set of
  1995. extensions prior to the release of level 3. Level 3 is currently the highest
  1996. level supported. You select which level of the PostScript language you want
  1997. highlighted by defining the postscr_level variable as follows: >
  1998. :let postscr_level=2
  1999. If this variable is not defined it defaults to 2 (level 2) since this is
  2000. the most prevalent version currently.
  2001. Note: Not all PS interpreters will support all language features for a
  2002. particular language level. In particular the %!PS-Adobe-3.0 at the start of
  2003. PS files does NOT mean the PostScript present is level 3 PostScript!
  2004. If you are working with Display PostScript, you can include highlighting of
  2005. Display PS language features by defining the postscr_display variable as
  2006. follows: >
  2007. :let postscr_display=1
  2008. If you are working with Ghostscript, you can include highlighting of
  2009. Ghostscript specific language features by defining the variable
  2010. postscr_ghostscript as follows: >
  2011. :let postscr_ghostscript=1
  2012. PostScript is a large language, with many predefined elements. While it
  2013. useful to have all these elements highlighted, on slower machines this can
  2014. cause Vim to slow down. In an attempt to be machine friendly font names and
  2015. character encodings are not highlighted by default. Unless you are working
  2016. explicitly with either of these this should be ok. If you want them to be
  2017. highlighted you should set one or both of the following variables: >
  2018. :let postscr_fonts=1
  2019. :let postscr_encodings=1
  2020. There is a stylistic option to the highlighting of and, or, and not. In
  2021. PostScript the function of these operators depends on the types of their
  2022. operands - if the operands are booleans then they are the logical operators,
  2023. if they are integers then they are binary operators. As binary and logical
  2024. operators can be highlighted differently they have to be highlighted one way
  2025. or the other. By default they are treated as logical operators. They can be
  2026. highlighted as binary operators by defining the variable
  2027. postscr_andornot_binary as follows: >
  2028. :let postscr_andornot_binary=1
  2029. <
  2030. *ptcap.vim* *ft-printcap-syntax*
  2031. PRINTCAP + TERMCAP *ft-ptcap-syntax* *ft-termcap-syntax*
  2032. This syntax file applies to the printcap and termcap databases.
  2033. In order for Vim to recognize printcap/termcap files that do not match
  2034. the patterns *printcap*, or *termcap*, you must put additional patterns
  2035. appropriate to your system in your |myfiletypefile| file. For these
  2036. patterns, you must set the variable "b:ptcap_type" to either "print" or
  2037. "term", and then the 'filetype' option to ptcap.
  2038. For example, to make Vim identify all files in /etc/termcaps/ as termcap
  2039. files, add the following: >
  2040. :au BufNewFile,BufRead /etc/termcaps/* let b:ptcap_type = "term" |
  2041. \ set filetype=ptcap
  2042. If you notice highlighting errors while scrolling backwards, which
  2043. are fixed when redrawing with CTRL-L, try setting the "ptcap_minlines"
  2044. internal variable to a larger number: >
  2045. :let ptcap_minlines = 50
  2046. (The default is 20 lines.)
  2047. PROGRESS *progress.vim* *ft-progress-syntax*
  2048. Files matching "*.w" could be Progress or cweb. If the automatic detection
  2049. doesn't work for you, or you don't edit cweb at all, use this in your
  2050. startup vimrc: >
  2051. :let filetype_w = "progress"
  2052. The same happens for "*.i", which could be assembly, and "*.p", which could be
  2053. Pascal. Use this if you don't use assembly and Pascal: >
  2054. :let filetype_i = "progress"
  2055. :let filetype_p = "progress"
  2056. PYTHON *python.vim* *ft-python-syntax*
  2057. There are six options to control Python syntax highlighting.
  2058. For highlighted numbers: >
  2059. :let python_no_number_highlight = 1
  2060. For highlighted builtin functions: >
  2061. :let python_no_builtin_highlight = 1
  2062. For highlighted standard exceptions: >
  2063. :let python_no_exception_highlight = 1
  2064. For highlighted doctests and code inside: >
  2065. :let python_no_doctest_highlight = 1
  2066. or >
  2067. :let python_no_doctest_code_highlight = 1
  2068. (first option implies second one).
  2069. For highlighted trailing whitespace and mix of spaces and tabs: >
  2070. :let python_space_error_highlight = 1
  2071. If you want all possible Python highlighting (the same as setting the
  2072. preceding last option and unsetting all other ones): >
  2073. :let python_highlight_all = 1
  2074. Note: Only existence of these options matter, not their value. You can replace
  2075. 1 above with anything.
  2076. QUAKE *quake.vim* *ft-quake-syntax*
  2077. The Quake syntax definition should work for most FPS (First Person Shooter)
  2078. based on one of the Quake engines. However, the command names vary a bit
  2079. between the three games (Quake, Quake 2, and Quake 3 Arena) so the syntax
  2080. definition checks for the existence of three global variables to allow users
  2081. to specify what commands are legal in their files. The three variables can
  2082. be set for the following effects:
  2083. set to highlight commands only available in Quake: >
  2084. :let quake_is_quake1 = 1
  2085. set to highlight commands only available in Quake 2: >
  2086. :let quake_is_quake2 = 1
  2087. set to highlight commands only available in Quake 3 Arena: >
  2088. :let quake_is_quake3 = 1
  2089. Any combination of these three variables is legal, but might highlight more
  2090. commands than are actually available to you by the game.
  2091. R *r.vim* *ft-r-syntax*
  2092. The parsing of R code for syntax highlight starts 40 lines backwards, but you
  2093. can set a different value in your |vimrc|. Example: >
  2094. let r_syntax_minlines = 60
  2095. You can also turn off syntax highlighting of ROxygen: >
  2096. let r_syntax_hl_roxygen = 0
  2097. enable folding of code delimited by parentheses, square brackets and curly
  2098. braces: >
  2099. let r_syntax_folding = 1
  2100. and highlight as functions all keywords followed by an opening parenthesis: >
  2101. let r_syntax_fun_pattern = 1
  2102. R MARKDOWN *rmd.vim* *ft-rmd-syntax*
  2103. To disable syntax highlight of YAML header, add to your |vimrc|: >
  2104. let rmd_syn_hl_yaml = 0
  2105. To disable syntax highlighting of citation keys: >
  2106. let rmd_syn_hl_citations = 0
  2107. To highlight R code in knitr chunk headers: >
  2108. let rmd_syn_hl_chunk = 1
  2109. By default, chunks of R code will be highlighted following the rules of R
  2110. language. If you want proper syntax highlighting of chunks of other languages,
  2111. you should add them to either `markdown_fenced_languages` or
  2112. `rmd_fenced_languages`. For example to properly highlight both R and Python,
  2113. you may add this to your |vimrc|: >
  2114. let rmd_fenced_languages = ['r', 'python']
  2115. R RESTRUCTURED TEXT *rrst.vim* *ft-rrst-syntax*
  2116. To highlight R code in knitr chunk headers, add to your |vimrc|: >
  2117. let rrst_syn_hl_chunk = 1
  2118. READLINE *readline.vim* *ft-readline-syntax*
  2119. The readline library is primarily used by the BASH shell, which adds quite a
  2120. few commands and options to the ones already available. To highlight these
  2121. items as well you can add the following to your |vimrc| or just type it in the
  2122. command line before loading a file with the readline syntax: >
  2123. let readline_has_bash = 1
  2124. This will add highlighting for the commands that BASH (version 2.05a and
  2125. later, and part earlier) adds.
  2126. REGO *rego.vim* *ft-rego-syntax*
  2127. Rego is a query language developed by Styra. It is mostly used as a policy
  2128. language for kubernetes, but can be applied to almost anything. Files with
  2129. the following extensions are recognized as rego files: .rego.
  2130. RESTRUCTURED TEXT *rst.vim* *ft-rst-syntax*
  2131. Syntax highlighting is enabled for code blocks within the document for a
  2132. select number of file types. See $VIMRUNTIME/syntax/rst.vim for the default
  2133. syntax list.
  2134. To set a user-defined list of code block syntax highlighting: >
  2135. let rst_syntax_code_list = ['vim', 'lisp', ...]
  2136. To assign multiple code block types to a single syntax, define
  2137. `rst_syntax_code_list` as a mapping: >
  2138. let rst_syntax_code_list = {
  2139. \ 'cpp': ['cpp', 'c++'],
  2140. \ 'bash': ['bash', 'sh'],
  2141. ...
  2142. \ }
  2143. To use color highlighting for emphasis text: >
  2144. let rst_use_emphasis_colors = 1
  2145. To enable folding of sections: >
  2146. let rst_fold_enabled = 1
  2147. Note that folding can cause performance issues on some platforms.
  2148. REXX *rexx.vim* *ft-rexx-syntax*
  2149. If you notice highlighting errors while scrolling backwards, which are fixed
  2150. when redrawing with CTRL-L, try setting the "rexx_minlines" internal variable
  2151. to a larger number: >
  2152. :let rexx_minlines = 50
  2153. This will make the syntax synchronization start 50 lines before the first
  2154. displayed line. The default value is 10. The disadvantage of using a larger
  2155. number is that redrawing can become slow.
  2156. Vim tries to guess what type a ".r" file is. If it can't be detected (from
  2157. comment lines), the default is "r". To make the default rexx add this line to
  2158. your .vimrc: *g:filetype_r*
  2159. >
  2160. :let g:filetype_r = "r"
  2161. RUBY *ruby.vim* *ft-ruby-syntax*
  2162. Ruby: Operator highlighting |ruby_operators|
  2163. Ruby: Whitespace errors |ruby_space_errors|
  2164. Ruby: Folding |ruby_fold| |ruby_foldable_groups|
  2165. Ruby: Reducing expensive operations |ruby_no_expensive| |ruby_minlines|
  2166. Ruby: Spellchecking strings |ruby_spellcheck_strings|
  2167. *ruby_operators*
  2168. Ruby: Operator highlighting ~
  2169. Operators can be highlighted by defining "ruby_operators": >
  2170. :let ruby_operators = 1
  2171. <
  2172. *ruby_space_errors*
  2173. Ruby: Whitespace errors ~
  2174. Whitespace errors can be highlighted by defining "ruby_space_errors": >
  2175. :let ruby_space_errors = 1
  2176. <
  2177. This will highlight trailing whitespace and tabs preceded by a space character
  2178. as errors. This can be refined by defining "ruby_no_trail_space_error" and
  2179. "ruby_no_tab_space_error" which will ignore trailing whitespace and tabs after
  2180. spaces respectively.
  2181. *ruby_fold* *ruby_foldable_groups*
  2182. Ruby: Folding ~
  2183. Folding can be enabled by defining "ruby_fold": >
  2184. :let ruby_fold = 1
  2185. <
  2186. This will set the value of 'foldmethod' to "syntax" locally to the current
  2187. buffer or window, which will enable syntax-based folding when editing Ruby
  2188. filetypes.
  2189. Default folding is rather detailed, i.e., small syntax units like "if", "do",
  2190. "%w[]" may create corresponding fold levels.
  2191. You can set "ruby_foldable_groups" to restrict which groups are foldable: >
  2192. :let ruby_foldable_groups = 'if case %'
  2193. <
  2194. The value is a space-separated list of keywords:
  2195. keyword meaning ~
  2196. -------- ------------------------------------- ~
  2197. ALL Most block syntax (default)
  2198. NONE Nothing
  2199. if "if" or "unless" block
  2200. def "def" block
  2201. class "class" block
  2202. module "module" block
  2203. do "do" block
  2204. begin "begin" block
  2205. case "case" block
  2206. for "for", "while", "until" loops
  2207. { Curly bracket block or hash literal
  2208. [ Array literal
  2209. % Literal with "%" notation, e.g.: %w(STRING), %!STRING!
  2210. / Regexp
  2211. string String and shell command output (surrounded by ', ", `)
  2212. : Symbol
  2213. # Multiline comment
  2214. << Here documents
  2215. __END__ Source code after "__END__" directive
  2216. *ruby_no_expensive*
  2217. Ruby: Reducing expensive operations ~
  2218. By default, the "end" keyword is colorized according to the opening statement
  2219. of the block it closes. While useful, this feature can be expensive; if you
  2220. experience slow redrawing (or you are on a terminal with poor color support)
  2221. you may want to turn it off by defining the "ruby_no_expensive" variable: >
  2222. :let ruby_no_expensive = 1
  2223. <
  2224. In this case the same color will be used for all control keywords.
  2225. *ruby_minlines*
  2226. If you do want this feature enabled, but notice highlighting errors while
  2227. scrolling backwards, which are fixed when redrawing with CTRL-L, try setting
  2228. the "ruby_minlines" variable to a value larger than 50: >
  2229. :let ruby_minlines = 100
  2230. <
  2231. Ideally, this value should be a number of lines large enough to embrace your
  2232. largest class or module.
  2233. *ruby_spellcheck_strings*
  2234. Ruby: Spellchecking strings ~
  2235. Ruby syntax will perform spellchecking of strings if you define
  2236. "ruby_spellcheck_strings": >
  2237. :let ruby_spellcheck_strings = 1
  2238. <
  2239. SCHEME *scheme.vim* *ft-scheme-syntax*
  2240. By default only R7RS keywords are highlighted and properly indented.
  2241. scheme.vim also supports extensions of the CHICKEN Scheme->C compiler.
  2242. Define b:is_chicken or g:is_chicken, if you need them.
  2243. SDL *sdl.vim* *ft-sdl-syntax*
  2244. The SDL highlighting probably misses a few keywords, but SDL has so many
  2245. of them it's almost impossibly to cope.
  2246. The new standard, SDL-2000, specifies that all identifiers are
  2247. case-sensitive (which was not so before), and that all keywords can be
  2248. used either completely lowercase or completely uppercase. To have the
  2249. highlighting reflect this, you can set the following variable: >
  2250. :let sdl_2000=1
  2251. This also sets many new keywords. If you want to disable the old
  2252. keywords, which is probably a good idea, use: >
  2253. :let SDL_no_96=1
  2254. The indentation is probably also incomplete, but right now I am very
  2255. satisfied with it for my own projects.
  2256. SED *sed.vim* *ft-sed-syntax*
  2257. To make tabs stand out from regular blanks (accomplished by using Todo
  2258. highlighting on the tabs), define "g:sed_highlight_tabs" by putting >
  2259. :let g:sed_highlight_tabs = 1
  2260. <
  2261. in the vimrc file. (This special highlighting only applies for tabs
  2262. inside search patterns, replacement texts, addresses or text included
  2263. by an Append/Change/Insert command.) If you enable this option, it is
  2264. also a good idea to set the tab width to one character; by doing that,
  2265. you can easily count the number of tabs in a string.
  2266. GNU sed allows comments after text on the same line. BSD sed only allows
  2267. comments where "#" is the first character of the line. To enforce BSD-style
  2268. comments, i.e. mark end-of-line comments as errors, use: >
  2269. :let g:sed_dialect = "bsd"
  2270. <
  2271. Note that there are other differences between GNU sed and BSD sed which are
  2272. not (yet) affected by this setting.
  2273. Bugs:
  2274. The transform command (y) is treated exactly like the substitute
  2275. command. This means that, as far as this syntax file is concerned,
  2276. transform accepts the same flags as substitute, which is wrong.
  2277. (Transform accepts no flags.) I tolerate this bug because the
  2278. involved commands need very complex treatment (95 patterns, one for
  2279. each plausible pattern delimiter).
  2280. SGML *sgml.vim* *ft-sgml-syntax*
  2281. The coloring scheme for tags in the SGML file works as follows.
  2282. The <> of opening tags are colored differently than the </> of a closing tag.
  2283. This is on purpose! For opening tags the 'Function' color is used, while for
  2284. closing tags the 'Type' color is used (See syntax.vim to check how those are
  2285. defined for you)
  2286. Known tag names are colored the same way as statements in C. Unknown tag
  2287. names are not colored which makes it easy to spot errors.
  2288. Note that the same is true for argument (or attribute) names. Known attribute
  2289. names are colored differently than unknown ones.
  2290. Some SGML tags are used to change the rendering of text. The following tags
  2291. are recognized by the sgml.vim syntax coloring file and change the way normal
  2292. text is shown: <varname> <emphasis> <command> <function> <literal>
  2293. <replaceable> <ulink> and <link>.
  2294. If you want to change how such text is rendered, you must redefine the
  2295. following syntax groups:
  2296. - sgmlBold
  2297. - sgmlBoldItalic
  2298. - sgmlUnderline
  2299. - sgmlItalic
  2300. - sgmlLink for links
  2301. To make this redefinition work you must redefine them all and define the
  2302. following variable in your vimrc (this is due to the order in which the files
  2303. are read during initialization) >
  2304. let sgml_my_rendering=1
  2305. You can also disable this rendering by adding the following line to your
  2306. vimrc file: >
  2307. let sgml_no_rendering=1
  2308. (Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>)
  2309. *ft-posix-syntax* *ft-dash-syntax*
  2310. SH *sh.vim* *ft-sh-syntax* *ft-bash-syntax* *ft-ksh-syntax*
  2311. This covers syntax highlighting for the older Unix (Bourne) sh, and newer
  2312. shells such as bash, dash, posix, and the Korn shells.
  2313. Vim attempts to determine which shell type is in use by specifying that
  2314. various filenames are of specific types, e.g.: >
  2315. ksh : .kshrc* *.ksh
  2316. bash: .bashrc* bashrc bash.bashrc .bash_profile* *.bash
  2317. <
  2318. See $VIMRUNTIME/filetype.vim for the full list of patterns. If none of these
  2319. cases pertain, then the first line of the file is examined (ex. looking for
  2320. /bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype, then
  2321. that shelltype is used. However some files (ex. .profile) are known to be
  2322. shell files but the type is not apparent. Furthermore, on many systems sh is
  2323. symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
  2324. One may specify a global default by instantiating one of the following
  2325. variables in your <.vimrc>:
  2326. ksh: >
  2327. let g:is_kornshell = 1
  2328. < posix: (using this is nearly the same as setting g:is_kornshell to 1) >
  2329. let g:is_posix = 1
  2330. < bash: >
  2331. let g:is_bash = 1
  2332. < sh: (default) Bourne shell >
  2333. let g:is_sh = 1
  2334. < (dash users should use posix)
  2335. If there's no "#! ..." line, and the user hasn't availed himself/herself of a
  2336. default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
  2337. the Bourne shell syntax. No need to quote RFCs or market penetration
  2338. statistics in error reports, please -- just select the default version of the
  2339. sh your system uses and install the associated "let..." in your <.vimrc>.
  2340. The syntax/sh.vim file provides several levels of syntax-based folding: >
  2341. let g:sh_fold_enabled= 0 (default, no syntax folding)
  2342. let g:sh_fold_enabled= 1 (enable function folding)
  2343. let g:sh_fold_enabled= 2 (enable heredoc folding)
  2344. let g:sh_fold_enabled= 4 (enable if/do/for folding)
  2345. >
  2346. then various syntax items (ie. HereDocuments and function bodies) become
  2347. syntax-foldable (see |:syn-fold|). You also may add these together
  2348. to get multiple types of folding: >
  2349. let g:sh_fold_enabled= 3 (enables function and heredoc folding)
  2350. If you notice highlighting errors while scrolling backwards which are fixed
  2351. when one redraws with CTRL-L, try setting the "sh_minlines" internal variable
  2352. to a larger number. Example: >
  2353. let sh_minlines = 500
  2354. This will make syntax synchronization start 500 lines before the first
  2355. displayed line. The default value is 200. The disadvantage of using a larger
  2356. number is that redrawing can become slow.
  2357. If you don't have much to synchronize on, displaying can be very slow. To
  2358. reduce this, the "sh_maxlines" internal variable can be set. Example: >
  2359. let sh_maxlines = 100
  2360. <
  2361. The default is to use the twice sh_minlines. Set it to a smaller number to
  2362. speed up displaying. The disadvantage is that highlight errors may appear.
  2363. syntax/sh.vim tries to flag certain problems as errors; usually things like
  2364. unmatched "]", "done", "fi", etc. If you find the error handling problematic
  2365. for your purposes, you may suppress such error highlighting by putting
  2366. the following line in your .vimrc: >
  2367. let g:sh_no_error= 1
  2368. <
  2369. *sh-embed* *sh-awk*
  2370. Sh: EMBEDDING LANGUAGES~
  2371. You may wish to embed languages into sh. I'll give an example courtesy of
  2372. Lorance Stinson on how to do this with awk as an example. Put the following
  2373. file into $HOME/.vim/after/syntax/sh/awkembed.vim: >
  2374. " AWK Embedding:
  2375. " ==============
  2376. " Shamelessly ripped from aspperl.vim by Aaron Hope.
  2377. if exists("b:current_syntax")
  2378. unlet b:current_syntax
  2379. endif
  2380. syn include @AWKScript syntax/awk.vim
  2381. syn region AWKScriptCode matchgroup=AWKCommand start=+[=\\]\@<!'+ skip=+\\'+ end=+'+ contains=@AWKScript contained
  2382. syn region AWKScriptEmbedded matchgroup=AWKCommand start=+\<awk\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1 contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
  2383. syn cluster shCommandSubList add=AWKScriptEmbedded
  2384. hi def link AWKCommand Type
  2385. <
  2386. This code will then let the awk code in the single quotes: >
  2387. awk '...awk code here...'
  2388. be highlighted using the awk highlighting syntax. Clearly this may be
  2389. extended to other languages.
  2390. SPEEDUP *spup.vim* *ft-spup-syntax*
  2391. (AspenTech plant simulator)
  2392. The Speedup syntax file has some options:
  2393. - strict_subsections : If this variable is defined, only keywords for
  2394. sections and subsections will be highlighted as statements but not
  2395. other keywords (like WITHIN in the OPERATION section).
  2396. - highlight_types : Definition of this variable causes stream types
  2397. like temperature or pressure to be highlighted as Type, not as a
  2398. plain Identifier. Included are the types that are usually found in
  2399. the DECLARE section; if you defined own types, you have to include
  2400. them in the syntax file.
  2401. - oneline_comments : This value ranges from 1 to 3 and determines the
  2402. highlighting of # style comments.
  2403. oneline_comments = 1 : Allow normal Speedup code after an even
  2404. number of #s.
  2405. oneline_comments = 2 : Show code starting with the second # as
  2406. error. This is the default setting.
  2407. oneline_comments = 3 : Show the whole line as error if it contains
  2408. more than one #.
  2409. Since especially OPERATION sections tend to become very large due to
  2410. PRESETting variables, syncing may be critical. If your computer is
  2411. fast enough, you can increase minlines and/or maxlines near the end of
  2412. the syntax file.
  2413. SQL *sql.vim* *ft-sql-syntax*
  2414. *sqlinformix.vim* *ft-sqlinformix-syntax*
  2415. *sqlanywhere.vim* *ft-sqlanywhere-syntax*
  2416. While there is an ANSI standard for SQL, most database engines add their own
  2417. custom extensions. Vim currently supports the Oracle and Informix dialects of
  2418. SQL. Vim assumes "*.sql" files are Oracle SQL by default.
  2419. Vim currently has SQL support for a variety of different vendors via syntax
  2420. scripts. You can change Vim's default from Oracle to any of the current SQL
  2421. supported types. You can also easily alter the SQL dialect being used on a
  2422. buffer by buffer basis.
  2423. For more detailed instructions see |ft_sql.txt|.
  2424. SQUIRREL *squirrel.vim* *ft-squirrel-syntax*
  2425. Squirrel is a high level imperative, object-oriented programming language,
  2426. designed to be a light-weight scripting language that fits in the size, memory
  2427. bandwidth, and real-time requirements of applications like video games. Files
  2428. with the following extensions are recognized as squirrel files: .nut.
  2429. TCSH *tcsh.vim* *ft-tcsh-syntax*
  2430. This covers the shell named "tcsh". It is a superset of csh. See |csh.vim|
  2431. for how the filetype is detected.
  2432. Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
  2433. is set. If you want VIM to assume that no backslash quote constructs exist
  2434. add this line to your .vimrc: >
  2435. :let tcsh_backslash_quote = 0
  2436. If you notice highlighting errors while scrolling backwards, which are fixed
  2437. when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable
  2438. to a larger number: >
  2439. :let tcsh_minlines = 1000
  2440. This will make the syntax synchronization start 1000 lines before the first
  2441. displayed line. If you set "tcsh_minlines" to "fromstart", then
  2442. synchronization is done from the start of the file. The default value for
  2443. tcsh_minlines is 100. The disadvantage of using a larger number is that
  2444. redrawing can become slow.
  2445. TEX *tex.vim* *ft-tex-syntax* *latex-syntax*
  2446. *syntax-tex* *syntax-latex*
  2447. Tex Contents~
  2448. Tex: Want Syntax Folding? |tex-folding|
  2449. Tex: No Spell Checking Wanted |g:tex_nospell|
  2450. Tex: Don't Want Spell Checking In Comments? |tex-nospell|
  2451. Tex: Want Spell Checking in Verbatim Zones? |tex-verb|
  2452. Tex: Run-on Comments or MathZones |tex-runon|
  2453. Tex: Slow Syntax Highlighting? |tex-slow|
  2454. Tex: Want To Highlight More Commands? |tex-morecommands|
  2455. Tex: Excessive Error Highlighting? |tex-error|
  2456. Tex: Need a new Math Group? |tex-math|
  2457. Tex: Starting a New Style? |tex-style|
  2458. Tex: Taking Advantage of Conceal Mode |tex-conceal|
  2459. Tex: Selective Conceal Mode |g:tex_conceal|
  2460. Tex: Controlling iskeyword |g:tex_isk|
  2461. Tex: Fine Subscript and Superscript Control |tex-supersub|
  2462. Tex: Match Check Control |tex-matchcheck|
  2463. *tex-folding* *g:tex_fold_enabled*
  2464. Tex: Want Syntax Folding? ~
  2465. As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
  2466. sections, subsections, etc are supported. Put >
  2467. let g:tex_fold_enabled=1
  2468. in your <.vimrc>, and :set fdm=syntax. I suggest doing the latter via a
  2469. modeline at the end of your LaTeX file: >
  2470. % vim: fdm=syntax
  2471. If your system becomes too slow, then you might wish to look into >
  2472. https://vimhelp.org/vim_faq.txt.html#faq-29.7
  2473. <
  2474. *g:tex_nospell*
  2475. Tex: No Spell Checking Wanted~
  2476. If you don't want spell checking anywhere in your LaTeX document, put >
  2477. let g:tex_nospell=1
  2478. into your .vimrc. If you merely wish to suppress spell checking inside
  2479. comments only, see |g:tex_comment_nospell|.
  2480. *tex-nospell* *g:tex_comment_nospell*
  2481. Tex: Don't Want Spell Checking In Comments? ~
  2482. Some folks like to include things like source code in comments and so would
  2483. prefer that spell checking be disabled in comments in LaTeX files. To do
  2484. this, put the following in your <.vimrc>: >
  2485. let g:tex_comment_nospell= 1
  2486. If you want to suppress spell checking everywhere inside your LaTeX document,
  2487. see |g:tex_nospell|.
  2488. *tex-verb* *g:tex_verbspell*
  2489. Tex: Want Spell Checking in Verbatim Zones?~
  2490. Often verbatim regions are used for things like source code; seldom does
  2491. one want source code spell-checked. However, for those of you who do
  2492. want your verbatim zones spell-checked, put the following in your <.vimrc>: >
  2493. let g:tex_verbspell= 1
  2494. <
  2495. *tex-runon* *tex-stopzone*
  2496. Tex: Run-on Comments or MathZones ~
  2497. The <syntax/tex.vim> highlighting supports TeX, LaTeX, and some AmsTeX. The
  2498. highlighting supports three primary zones/regions: normal, texZone, and
  2499. texMathZone. Although considerable effort has been made to have these zones
  2500. terminate properly, zones delineated by $..$ and $$..$$ cannot be synchronized
  2501. as there's no difference between start and end patterns. Consequently, a
  2502. special "TeX comment" has been provided >
  2503. %stopzone
  2504. which will forcibly terminate the highlighting of either a texZone or a
  2505. texMathZone.
  2506. *tex-slow* *tex-sync*
  2507. Tex: Slow Syntax Highlighting? ~
  2508. If you have a slow computer, you may wish to reduce the values for >
  2509. :syn sync maxlines=200
  2510. :syn sync minlines=50
  2511. (especially the latter). If your computer is fast, you may wish to
  2512. increase them. This primarily affects synchronizing (i.e. just what group,
  2513. if any, is the text at the top of the screen supposed to be in?).
  2514. Another cause of slow highlighting is due to syntax-driven folding; see
  2515. |tex-folding| for a way around this.
  2516. *g:tex_fast*
  2517. Finally, if syntax highlighting is still too slow, you may set >
  2518. :let g:tex_fast= ""
  2519. in your .vimrc. Used this way, the g:tex_fast variable causes the syntax
  2520. highlighting script to avoid defining any regions and associated
  2521. synchronization. The result will be much faster syntax highlighting; the
  2522. price: you will no longer have as much highlighting or any syntax-based
  2523. folding, and you will be missing syntax-based error checking.
  2524. You may decide that some syntax is acceptable; you may use the following table
  2525. selectively to enable just some syntax highlighting: >
  2526. b : allow bold and italic syntax
  2527. c : allow texComment syntax
  2528. m : allow texMatcher syntax (ie. {...} and [...])
  2529. M : allow texMath syntax
  2530. p : allow parts, chapter, section, etc syntax
  2531. r : allow texRefZone syntax (nocite, bibliography, label, pageref, eqref)
  2532. s : allow superscript/subscript regions
  2533. S : allow texStyle syntax
  2534. v : allow verbatim syntax
  2535. V : allow texNewEnv and texNewCmd syntax
  2536. <
  2537. As an example, let g:tex_fast= "M" will allow math-associated highlighting
  2538. but suppress all the other region-based syntax highlighting.
  2539. (also see: |g:tex_conceal| and |tex-supersub|)
  2540. *tex-morecommands* *tex-package*
  2541. Tex: Want To Highlight More Commands? ~
  2542. LaTeX is a programmable language, and so there are thousands of packages full
  2543. of specialized LaTeX commands, syntax, and fonts. If you're using such a
  2544. package you'll often wish that the distributed syntax/tex.vim would support
  2545. it. However, clearly this is impractical. So please consider using the
  2546. techniques in |mysyntaxfile-add| to extend or modify the highlighting provided
  2547. by syntax/tex.vim. Please consider uploading any extensions that you write,
  2548. which typically would go in $HOME/after/syntax/tex/[pkgname].vim, to
  2549. http://vim.sf.net/.
  2550. I've included some support for various popular packages on my website: >
  2551. http://www.drchip.org/astronaut/vim/index.html#LATEXPKGS
  2552. <
  2553. The syntax files there go into your .../after/syntax/tex/ directory.
  2554. *tex-error* *g:tex_no_error*
  2555. Tex: Excessive Error Highlighting? ~
  2556. The <tex.vim> supports lexical error checking of various sorts. Thus,
  2557. although the error checking is ofttimes very useful, it can indicate
  2558. errors where none actually are. If this proves to be a problem for you,
  2559. you may put in your <.vimrc> the following statement: >
  2560. let g:tex_no_error=1
  2561. and all error checking by <syntax/tex.vim> will be suppressed.
  2562. *tex-math*
  2563. Tex: Need a new Math Group? ~
  2564. If you want to include a new math group in your LaTeX, the following
  2565. code shows you an example as to how you might do so: >
  2566. call TexNewMathZone(sfx,mathzone,starform)
  2567. You'll want to provide the new math group with a unique suffix
  2568. (currently, A-L and V-Z are taken by <syntax/tex.vim> itself).
  2569. As an example, consider how eqnarray is set up by <syntax/tex.vim>: >
  2570. call TexNewMathZone("D","eqnarray",1)
  2571. You'll need to change "mathzone" to the name of your new math group,
  2572. and then to the call to it in .vim/after/syntax/tex.vim.
  2573. The "starform" variable, if true, implies that your new math group
  2574. has a starred form (ie. eqnarray*).
  2575. *tex-style* *b:tex_stylish*
  2576. Tex: Starting a New Style? ~
  2577. One may use "\makeatletter" in *.tex files, thereby making the use of "@" in
  2578. commands available. However, since the *.tex file doesn't have one of the
  2579. following suffices: sty cls clo dtx ltx, the syntax highlighting will flag
  2580. such use of @ as an error. To solve this: >
  2581. :let b:tex_stylish = 1
  2582. :set ft=tex
  2583. Putting "let g:tex_stylish=1" into your <.vimrc> will make <syntax/tex.vim>
  2584. always accept such use of @.
  2585. *tex-cchar* *tex-cole* *tex-conceal*
  2586. Tex: Taking Advantage of Conceal Mode~
  2587. If you have |'conceallevel'| set to 2 and if your encoding is utf-8, then a
  2588. number of character sequences can be translated into appropriate utf-8 glyphs,
  2589. including various accented characters, Greek characters in MathZones, and
  2590. superscripts and subscripts in MathZones. Not all characters can be made into
  2591. superscripts or subscripts; the constraint is due to what utf-8 supports.
  2592. In fact, only a few characters are supported as subscripts.
  2593. One way to use this is to have vertically split windows (see |CTRL-W_v|); one
  2594. with |'conceallevel'| at 0 and the other at 2; and both using |'scrollbind'|.
  2595. *g:tex_conceal*
  2596. Tex: Selective Conceal Mode~
  2597. You may selectively use conceal mode by setting g:tex_conceal in your
  2598. <.vimrc>. By default, g:tex_conceal is set to "admgs" to enable concealment
  2599. for the following sets of characters: >
  2600. a = accents/ligatures
  2601. b = bold and italic
  2602. d = delimiters
  2603. m = math symbols
  2604. g = Greek
  2605. s = superscripts/subscripts
  2606. <
  2607. By leaving one or more of these out, the associated conceal-character
  2608. substitution will not be made.
  2609. *g:tex_isk* *g:tex_stylish*
  2610. Tex: Controlling iskeyword~
  2611. Normally, LaTeX keywords support 0-9, a-z, A-z, and 192-255 only. Latex
  2612. keywords don't support the underscore - except when in *.sty files. The
  2613. syntax highlighting script handles this with the following logic:
  2614. * If g:tex_stylish exists and is 1
  2615. then the file will be treated as a "sty" file, so the "_"
  2616. will be allowed as part of keywords
  2617. (regardless of g:tex_isk)
  2618. * Else if the file's suffix is sty, cls, clo, dtx, or ltx,
  2619. then the file will be treated as a "sty" file, so the "_"
  2620. will be allowed as part of keywords
  2621. (regardless of g:tex_isk)
  2622. * If g:tex_isk exists, then it will be used for the local 'iskeyword'
  2623. * Else the local 'iskeyword' will be set to 48-57,a-z,A-Z,192-255
  2624. *tex-supersub* *g:tex_superscripts* *g:tex_subscripts*
  2625. Tex: Fine Subscript and Superscript Control~
  2626. See |tex-conceal| for how to enable concealed character replacement.
  2627. See |g:tex_conceal| for selectively concealing accents, bold/italic,
  2628. math, Greek, and superscripts/subscripts.
  2629. One may exert fine control over which superscripts and subscripts one
  2630. wants syntax-based concealment for (see |:syn-cchar|). Since not all
  2631. fonts support all characters, one may override the
  2632. concealed-replacement lists; by default these lists are given by: >
  2633. let g:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]"
  2634. let g:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]"
  2635. <
  2636. For example, I use Luxi Mono Bold; it doesn't support subscript
  2637. characters for "hklmnpst", so I put >
  2638. let g:tex_subscripts= "[0-9aeijoruvx,+-/().]"
  2639. < in ~/.vim/ftplugin/tex/tex.vim in order to avoid having inscrutable
  2640. utf-8 glyphs appear.
  2641. *tex-matchcheck* *g:tex_matchcheck*
  2642. Tex: Match Check Control~
  2643. Sometimes one actually wants mismatched parentheses, square braces,
  2644. and or curly braces; for example, \text{(1,10]} is a range from but
  2645. not including 1 to and including 10. This wish, of course, conflicts
  2646. with the desire to provide delimiter mismatch detection. To
  2647. accommodate these conflicting goals, syntax/tex.vim provides >
  2648. g:tex_matchcheck = '[({[]'
  2649. < which is shown along with its default setting. So, if one doesn't
  2650. want [] and () to be checked for mismatches, try using >
  2651. let g:tex_matchcheck= '[{}]'
  2652. < If you don't want matching to occur inside bold and italicized
  2653. regions, >
  2654. let g:tex_excludematcher= 1
  2655. < will prevent the texMatcher group from being included in those regions.
  2656. TF *tf.vim* *ft-tf-syntax*
  2657. There is one option for the tf syntax highlighting.
  2658. For syncing, minlines defaults to 100. If you prefer another value, you can
  2659. set "tf_minlines" to the value you desire. Example: >
  2660. :let tf_minlines = your choice
  2661. <
  2662. VIM *vim.vim* *ft-vim-syntax*
  2663. *g:vimsyn_minlines* *g:vimsyn_maxlines*
  2664. There is a trade-off between more accurate syntax highlighting versus screen
  2665. updating speed. To improve accuracy, you may wish to increase the
  2666. g:vimsyn_minlines variable. The g:vimsyn_maxlines variable may be used to
  2667. improve screen updating rates (see |:syn-sync| for more on this). >
  2668. g:vimsyn_minlines : used to set synchronization minlines
  2669. g:vimsyn_maxlines : used to set synchronization maxlines
  2670. <
  2671. (g:vim_minlines and g:vim_maxlines are deprecated variants of
  2672. these two options)
  2673. *g:vimsyn_embed*
  2674. The g:vimsyn_embed option allows users to select what, if any, types of
  2675. embedded script highlighting they wish to have. >
  2676. g:vimsyn_embed == 0 : don't support any embedded scripts
  2677. g:vimsyn_embed =~ 'l' : support embedded lua
  2678. g:vimsyn_embed =~ 'm' : support embedded mzscheme
  2679. g:vimsyn_embed =~ 'p' : support embedded perl
  2680. g:vimsyn_embed =~ 'P' : support embedded python
  2681. g:vimsyn_embed =~ 'r' : support embedded ruby
  2682. g:vimsyn_embed =~ 't' : support embedded tcl
  2683. <
  2684. By default, g:vimsyn_embed is a string supporting interpreters that your vim
  2685. itself supports. Concatenate multiple characters to support multiple types
  2686. of embedded interpreters; ie. g:vimsyn_embed= "mp" supports embedded mzscheme
  2687. and embedded perl.
  2688. *g:vimsyn_folding*
  2689. Some folding is now supported with syntax/vim.vim: >
  2690. g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding
  2691. g:vimsyn_folding =~ 'a' : augroups
  2692. g:vimsyn_folding =~ 'f' : fold functions
  2693. g:vimsyn_folding =~ 'l' : fold lua script
  2694. g:vimsyn_folding =~ 'm' : fold mzscheme script
  2695. g:vimsyn_folding =~ 'p' : fold perl script
  2696. g:vimsyn_folding =~ 'P' : fold python script
  2697. g:vimsyn_folding =~ 'r' : fold ruby script
  2698. g:vimsyn_folding =~ 't' : fold tcl script
  2699. <
  2700. *g:vimsyn_noerror*
  2701. Not all error highlighting that syntax/vim.vim does may be correct; Vim script
  2702. is a difficult language to highlight correctly. A way to suppress error
  2703. highlighting is to put the following line in your |vimrc|: >
  2704. let g:vimsyn_noerror = 1
  2705. <
  2706. WDL *wdl.vim* *wdl-syntax*
  2707. The Workflow Description Language is a way to specify data processing workflows
  2708. with a human-readable and writeable syntax. This is used a lot in
  2709. bioinformatics. More info on the spec can be found here:
  2710. https://github.com/openwdl/wdl
  2711. XF86CONFIG *xf86conf.vim* *ft-xf86conf-syntax*
  2712. The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both
  2713. variants are supported. Automatic detection is used, but is far from perfect.
  2714. You may need to specify the version manually. Set the variable
  2715. xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
  2716. your .vimrc. Example: >
  2717. :let xf86conf_xfree86_version=3
  2718. When using a mix of versions, set the b:xf86conf_xfree86_version variable.
  2719. Note that spaces and underscores in option names are not supported. Use
  2720. "SyncOnGreen" instead of "__s yn con gr_e_e_n" if you want the option name
  2721. highlighted.
  2722. XML *xml.vim* *ft-xml-syntax*
  2723. Xml namespaces are highlighted by default. This can be inhibited by
  2724. setting a global variable: >
  2725. :let g:xml_namespace_transparent=1
  2726. <
  2727. *xml-folding*
  2728. The xml syntax file provides syntax |folding| (see |:syn-fold|) between
  2729. start and end tags. This can be turned on by >
  2730. :let g:xml_syntax_folding = 1
  2731. :set foldmethod=syntax
  2732. Note: Syntax folding might slow down syntax highlighting significantly,
  2733. especially for large files.
  2734. X Pixmaps (XPM) *xpm.vim* *ft-xpm-syntax*
  2735. xpm.vim creates its syntax items dynamically based upon the contents of the
  2736. XPM file. Thus if you make changes e.g. in the color specification strings,
  2737. you have to source it again e.g. with ":set syn=xpm".
  2738. To copy a pixel with one of the colors, yank a "pixel" with "yl" and insert it
  2739. somewhere else with "P".
  2740. Do you want to draw with the mouse? Try the following: >
  2741. :function! GetPixel()
  2742. : let c = getline(".")[col(".") - 1]
  2743. : echo c
  2744. : exe "noremap <LeftMouse> <LeftMouse>r" .. c
  2745. : exe "noremap <LeftDrag> <LeftMouse>r" .. c
  2746. :endfunction
  2747. :noremap <RightMouse> <LeftMouse>:call GetPixel()<CR>
  2748. :set guicursor=n:hor20 " to see the color beneath the cursor
  2749. This turns the right button into a pipette and the left button into a pen.
  2750. It will work with XPM files that have one character per pixel only and you
  2751. must not click outside of the pixel strings, but feel free to improve it.
  2752. It will look much better with a font in a quadratic cell size, e.g. for X: >
  2753. :set guifont=-*-clean-medium-r-*-*-8-*-*-*-*-80-*
  2754. YAML *yaml.vim* *ft-yaml-syntax*
  2755. *g:yaml_schema* *b:yaml_schema*
  2756. A YAML schema is a combination of a set of tags and a mechanism for resolving
  2757. non-specific tags. For user this means that YAML parser may, depending on
  2758. plain scalar contents, treat plain scalar (which can actually be only string
  2759. and nothing else) as a value of the other type: null, boolean, floating-point,
  2760. integer. `g:yaml_schema` option determines according to which schema values
  2761. will be highlighted specially. Supported schemas are
  2762. Schema Description ~
  2763. failsafe No additional highlighting.
  2764. json Supports JSON-style numbers, booleans and null.
  2765. core Supports more number, boolean and null styles.
  2766. pyyaml In addition to core schema supports highlighting timestamps,
  2767. but there are some differences in what is recognized as
  2768. numbers and many additional boolean values not present in core
  2769. schema.
  2770. Default schema is `core`.
  2771. Note that schemas are not actually limited to plain scalars, but this is the
  2772. only difference between schemas defined in YAML specification and the only
  2773. difference defined in the syntax file.
  2774. ZSH *zsh.vim* *ft-zsh-syntax*
  2775. The syntax script for zsh allows for syntax-based folding: >
  2776. :let g:zsh_fold_enable = 1
  2777. ==============================================================================
  2778. 6. Defining a syntax *:syn-define* *E410*
  2779. Vim understands three types of syntax items:
  2780. 1. Keyword
  2781. It can only contain keyword characters, according to the 'iskeyword'
  2782. option. It cannot contain other syntax items. It will only match with a
  2783. complete word (there are no keyword characters before or after the match).
  2784. The keyword "if" would match in "if(a=b)", but not in "ifdef x", because
  2785. "(" is not a keyword character and "d" is.
  2786. 2. Match
  2787. This is a match with a single regexp pattern.
  2788. 3. Region
  2789. This starts at a match of the "start" regexp pattern and ends with a match
  2790. with the "end" regexp pattern. Any other text can appear in between. A
  2791. "skip" regexp pattern can be used to avoid matching the "end" pattern.
  2792. Several syntax ITEMs can be put into one syntax GROUP. For a syntax group
  2793. you can give highlighting attributes. For example, you could have an item
  2794. to define a "/* .. */" comment and another one that defines a "// .." comment,
  2795. and put them both in the "Comment" group. You can then specify that a
  2796. "Comment" will be in bold font and have a blue color. You are free to make
  2797. one highlight group for one syntax item, or put all items into one group.
  2798. This depends on how you want to specify your highlighting attributes. Putting
  2799. each item in its own group results in having to specify the highlighting
  2800. for a lot of groups.
  2801. Note that a syntax group and a highlight group are similar. For a highlight
  2802. group you will have given highlight attributes. These attributes will be used
  2803. for the syntax group with the same name.
  2804. In case more than one item matches at the same position, the one that was
  2805. defined LAST wins. Thus you can override previously defined syntax items by
  2806. using an item that matches the same text. But a keyword always goes before a
  2807. match or region. And a keyword with matching case always goes before a
  2808. keyword with ignoring case.
  2809. PRIORITY *:syn-priority*
  2810. When several syntax items may match, these rules are used:
  2811. 1. When multiple Match or Region items start in the same position, the item
  2812. defined last has priority.
  2813. 2. A Keyword has priority over Match and Region items.
  2814. 3. An item that starts in an earlier position has priority over items that
  2815. start in later positions.
  2816. DEFINING CASE *:syn-case* *E390*
  2817. :sy[ntax] case [match | ignore]
  2818. This defines if the following ":syntax" commands will work with
  2819. matching case, when using "match", or with ignoring case, when using
  2820. "ignore". Note that any items before this are not affected, and all
  2821. items until the next ":syntax case" command are affected.
  2822. :sy[ntax] case
  2823. Show either "syntax case match" or "syntax case ignore".
  2824. DEFINING FOLDLEVEL *:syn-foldlevel*
  2825. :sy[ntax] foldlevel start
  2826. :sy[ntax] foldlevel minimum
  2827. This defines how the foldlevel of a line is computed when using
  2828. foldmethod=syntax (see |fold-syntax| and |:syn-fold|):
  2829. start: Use level of item containing start of line.
  2830. minimum: Use lowest local-minimum level of items on line.
  2831. The default is "start". Use "minimum" to search a line horizontally
  2832. for the lowest level contained on the line that is followed by a
  2833. higher level. This produces more natural folds when syntax items
  2834. may close and open horizontally within a line.
  2835. :sy[ntax] foldlevel
  2836. Show the current foldlevel method, either "syntax foldlevel start" or
  2837. "syntax foldlevel minimum".
  2838. {not meaningful when Vim was compiled without |+folding| feature}
  2839. SPELL CHECKING *:syn-spell*
  2840. :sy[ntax] spell toplevel
  2841. :sy[ntax] spell notoplevel
  2842. :sy[ntax] spell default
  2843. This defines where spell checking is to be done for text that is not
  2844. in a syntax item:
  2845. toplevel: Text is spell checked.
  2846. notoplevel: Text is not spell checked.
  2847. default: When there is a @Spell cluster no spell checking.
  2848. For text in syntax items use the @Spell and @NoSpell clusters
  2849. |spell-syntax|. When there is no @Spell and no @NoSpell cluster then
  2850. spell checking is done for "default" and "toplevel".
  2851. To activate spell checking the 'spell' option must be set.
  2852. :sy[ntax] spell
  2853. Show the current syntax spell checking method, either "syntax spell
  2854. toplevel", "syntax spell notoplevel" or "syntax spell default".
  2855. SYNTAX ISKEYWORD SETTING *:syn-iskeyword*
  2856. :sy[ntax] iskeyword [clear | {option}]
  2857. This defines the keyword characters. It's like the 'iskeyword' option
  2858. for but only applies to syntax highlighting.
  2859. clear: Syntax specific iskeyword setting is disabled and the
  2860. buffer-local 'iskeyword' setting is used.
  2861. {option} Set the syntax 'iskeyword' option to a new value.
  2862. Example: >
  2863. :syntax iskeyword @,48-57,192-255,$,_
  2864. <
  2865. This would set the syntax specific iskeyword option to include all
  2866. alphabetic characters, plus the numeric characters, all accented
  2867. characters and also includes the "_" and the "$".
  2868. If no argument is given, the current value will be output.
  2869. Setting this option influences what |/\k| matches in syntax patterns
  2870. and also determines where |:syn-keyword| will be checked for a new
  2871. match.
  2872. It is recommended when writing syntax files, to use this command to
  2873. set the correct value for the specific syntax language and not change
  2874. the 'iskeyword' option.
  2875. DEFINING KEYWORDS *:syn-keyword*
  2876. :sy[ntax] keyword {group-name} [{options}] {keyword} .. [{options}]
  2877. This defines a number of keywords.
  2878. {group-name} Is a syntax group name such as "Comment".
  2879. [{options}] See |:syn-arguments| below.
  2880. {keyword} .. Is a list of keywords which are part of this group.
  2881. Example: >
  2882. :syntax keyword Type int long char
  2883. <
  2884. The {options} can be given anywhere in the line. They will apply to
  2885. all keywords given, also for options that come after a keyword.
  2886. These examples do exactly the same: >
  2887. :syntax keyword Type contained int long char
  2888. :syntax keyword Type int long contained char
  2889. :syntax keyword Type int long char contained
  2890. < *E789* *E890*
  2891. When you have a keyword with an optional tail, like Ex commands in
  2892. Vim, you can put the optional characters inside [], to define all the
  2893. variations at once: >
  2894. :syntax keyword vimCommand ab[breviate] n[ext]
  2895. <
  2896. Don't forget that a keyword can only be recognized if all the
  2897. characters are included in the 'iskeyword' option. If one character
  2898. isn't, the keyword will never be recognized.
  2899. Multi-byte characters can also be used. These do not have to be in
  2900. 'iskeyword'.
  2901. See |:syn-iskeyword| for defining syntax specific iskeyword settings.
  2902. A keyword always has higher priority than a match or region, the
  2903. keyword is used if more than one item matches. Keywords do not nest
  2904. and a keyword can't contain anything else.
  2905. Note that when you have a keyword that is the same as an option (even
  2906. one that isn't allowed here), you can not use it. Use a match
  2907. instead.
  2908. The maximum length of a keyword is 80 characters.
  2909. The same keyword can be defined multiple times, when its containment
  2910. differs. For example, you can define the keyword once not contained
  2911. and use one highlight group, and once contained, and use a different
  2912. highlight group. Example: >
  2913. :syn keyword vimCommand tag
  2914. :syn keyword vimSetting contained tag
  2915. < When finding "tag" outside of any syntax item, the "vimCommand"
  2916. highlight group is used. When finding "tag" in a syntax item that
  2917. contains "vimSetting", the "vimSetting" group is used.
  2918. DEFINING MATCHES *:syn-match*
  2919. :sy[ntax] match {group-name} [{options}]
  2920. [excludenl]
  2921. [keepend]
  2922. {pattern}
  2923. [{options}]
  2924. This defines one match.
  2925. {group-name} A syntax group name such as "Comment".
  2926. [{options}] See |:syn-arguments| below.
  2927. [excludenl] Don't make a pattern with the end-of-line "$"
  2928. extend a containing match or region. Must be
  2929. given before the pattern. |:syn-excludenl|
  2930. keepend Don't allow contained matches to go past a
  2931. match with the end pattern. See
  2932. |:syn-keepend|.
  2933. {pattern} The search pattern that defines the match.
  2934. See |:syn-pattern| below.
  2935. Note that the pattern may match more than one
  2936. line, which makes the match depend on where
  2937. Vim starts searching for the pattern. You
  2938. need to make sure syncing takes care of this.
  2939. Example (match a character constant): >
  2940. :syntax match Character /'.'/hs=s+1,he=e-1
  2941. <
  2942. DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
  2943. *E398* *E399*
  2944. :sy[ntax] region {group-name} [{options}]
  2945. [matchgroup={group-name}]
  2946. [keepend]
  2947. [extend]
  2948. [excludenl]
  2949. start={start-pattern} ..
  2950. [skip={skip-pattern}]
  2951. end={end-pattern} ..
  2952. [{options}]
  2953. This defines one region. It may span several lines.
  2954. {group-name} A syntax group name such as "Comment".
  2955. [{options}] See |:syn-arguments| below.
  2956. [matchgroup={group-name}] The syntax group to use for the following
  2957. start or end pattern matches only. Not used
  2958. for the text in between the matched start and
  2959. end patterns. Use NONE to reset to not using
  2960. a different group for the start or end match.
  2961. See |:syn-matchgroup|.
  2962. keepend Don't allow contained matches to go past a
  2963. match with the end pattern. See
  2964. |:syn-keepend|.
  2965. extend Override a "keepend" for an item this region
  2966. is contained in. See |:syn-extend|.
  2967. excludenl Don't make a pattern with the end-of-line "$"
  2968. extend a containing match or item. Only
  2969. useful for end patterns. Must be given before
  2970. the patterns it applies to. |:syn-excludenl|
  2971. start={start-pattern} The search pattern that defines the start of
  2972. the region. See |:syn-pattern| below.
  2973. skip={skip-pattern} The search pattern that defines text inside
  2974. the region where not to look for the end
  2975. pattern. See |:syn-pattern| below.
  2976. end={end-pattern} The search pattern that defines the end of
  2977. the region. See |:syn-pattern| below.
  2978. Example: >
  2979. :syntax region String start=+"+ skip=+\\"+ end=+"+
  2980. <
  2981. The start/skip/end patterns and the options can be given in any order.
  2982. There can be zero or one skip pattern. There must be one or more
  2983. start and end patterns. This means that you can omit the skip
  2984. pattern, but you must give at least one start and one end pattern. It
  2985. is allowed to have white space before and after the equal sign
  2986. (although it mostly looks better without white space).
  2987. When more than one start pattern is given, a match with one of these
  2988. is sufficient. This means there is an OR relation between the start
  2989. patterns. The last one that matches is used. The same is true for
  2990. the end patterns.
  2991. The search for the end pattern starts right after the start pattern.
  2992. Offsets are not used for this. This implies that the match for the
  2993. end pattern will never overlap with the start pattern.
  2994. The skip and end pattern can match across line breaks, but since the
  2995. search for the pattern can start in any line it often does not do what
  2996. you want. The skip pattern doesn't avoid a match of an end pattern in
  2997. the next line. Use single-line patterns to avoid trouble.
  2998. Note: The decision to start a region is only based on a matching start
  2999. pattern. There is no check for a matching end pattern. This does NOT
  3000. work: >
  3001. :syn region First start="(" end=":"
  3002. :syn region Second start="(" end=";"
  3003. < The Second always matches before the First (last defined pattern has
  3004. higher priority). The Second region then continues until the next
  3005. ';', no matter if there is a ':' before it. Using a match does work: >
  3006. :syn match First "(\_.\{-}:"
  3007. :syn match Second "(\_.\{-};"
  3008. < This pattern matches any character or line break with "\_." and
  3009. repeats that with "\{-}" (repeat as few as possible).
  3010. *:syn-keepend*
  3011. By default, a contained match can obscure a match for the end pattern.
  3012. This is useful for nesting. For example, a region that starts with
  3013. "{" and ends with "}", can contain another region. An encountered "}"
  3014. will then end the contained region, but not the outer region:
  3015. { starts outer "{}" region
  3016. { starts contained "{}" region
  3017. } ends contained "{}" region
  3018. } ends outer "{} region
  3019. If you don't want this, the "keepend" argument will make the matching
  3020. of an end pattern of the outer region also end any contained item.
  3021. This makes it impossible to nest the same region, but allows for
  3022. contained items to highlight parts of the end pattern, without causing
  3023. that to skip the match with the end pattern. Example: >
  3024. :syn match vimComment +"[^"]\+$+
  3025. :syn region vimCommand start="set" end="$" contains=vimComment keepend
  3026. < The "keepend" makes the vimCommand always end at the end of the line,
  3027. even though the contained vimComment includes a match with the <EOL>.
  3028. When "keepend" is not used, a match with an end pattern is retried
  3029. after each contained match. When "keepend" is included, the first
  3030. encountered match with an end pattern is used, truncating any
  3031. contained matches.
  3032. *:syn-extend*
  3033. The "keepend" behavior can be changed by using the "extend" argument.
  3034. When an item with "extend" is contained in an item that uses
  3035. "keepend", the "keepend" is ignored and the containing region will be
  3036. extended.
  3037. This can be used to have some contained items extend a region while
  3038. others don't. Example: >
  3039. :syn region htmlRef start=+<a>+ end=+</a>+ keepend contains=htmlItem,htmlScript
  3040. :syn match htmlItem +<[^>]*>+ contained
  3041. :syn region htmlScript start=+<script+ end=+</script[^>]*>+ contained extend
  3042. < Here the htmlItem item does not make the htmlRef item continue
  3043. further, it is only used to highlight the <> items. The htmlScript
  3044. item does extend the htmlRef item.
  3045. Another example: >
  3046. :syn region xmlFold start="<a>" end="</a>" fold transparent keepend extend
  3047. < This defines a region with "keepend", so that its end cannot be
  3048. changed by contained items, like when the "</a>" is matched to
  3049. highlight it differently. But when the xmlFold region is nested (it
  3050. includes itself), the "extend" applies, so that the "</a>" of a nested
  3051. region only ends that region, and not the one it is contained in.
  3052. *:syn-excludenl*
  3053. When a pattern for a match or end pattern of a region includes a '$'
  3054. to match the end-of-line, it will make a region item that it is
  3055. contained in continue on the next line. For example, a match with
  3056. "\\$" (backslash at the end of the line) can make a region continue
  3057. that would normally stop at the end of the line. This is the default
  3058. behavior. If this is not wanted, there are two ways to avoid it:
  3059. 1. Use "keepend" for the containing item. This will keep all
  3060. contained matches from extending the match or region. It can be
  3061. used when all contained items must not extend the containing item.
  3062. 2. Use "excludenl" in the contained item. This will keep that match
  3063. from extending the containing match or region. It can be used if
  3064. only some contained items must not extend the containing item.
  3065. "excludenl" must be given before the pattern it applies to.
  3066. *:syn-matchgroup*
  3067. "matchgroup" can be used to highlight the start and/or end pattern
  3068. differently than the body of the region. Example: >
  3069. :syntax region String matchgroup=Quote start=+"+ skip=+\\"+ end=+"+
  3070. < This will highlight the quotes with the "Quote" group, and the text in
  3071. between with the "String" group.
  3072. The "matchgroup" is used for all start and end patterns that follow,
  3073. until the next "matchgroup". Use "matchgroup=NONE" to go back to not
  3074. using a matchgroup.
  3075. In a start or end pattern that is highlighted with "matchgroup" the
  3076. contained items of the region are not used. This can be used to avoid
  3077. that a contained item matches in the start or end pattern match. When
  3078. using "transparent", this does not apply to a start or end pattern
  3079. match that is highlighted with "matchgroup".
  3080. Here is an example, which highlights three levels of parentheses in
  3081. different colors: >
  3082. :sy region par1 matchgroup=par1 start=/(/ end=/)/ contains=par2
  3083. :sy region par2 matchgroup=par2 start=/(/ end=/)/ contains=par3 contained
  3084. :sy region par3 matchgroup=par3 start=/(/ end=/)/ contains=par1 contained
  3085. :hi par1 ctermfg=red guifg=red
  3086. :hi par2 ctermfg=blue guifg=blue
  3087. :hi par3 ctermfg=darkgreen guifg=darkgreen
  3088. <
  3089. *E849*
  3090. The maximum number of syntax groups is 19999.
  3091. ==============================================================================
  3092. 7. :syntax arguments *:syn-arguments*
  3093. The :syntax commands that define syntax items take a number of arguments.
  3094. The common ones are explained here. The arguments may be given in any order
  3095. and may be mixed with patterns.
  3096. Not all commands accept all arguments. This table shows which arguments
  3097. can not be used for all commands:
  3098. *E395*
  3099. contains oneline fold display extend concealends~
  3100. :syntax keyword - - - - - -
  3101. :syntax match yes - yes yes yes -
  3102. :syntax region yes yes yes yes yes yes
  3103. These arguments can be used for all three commands:
  3104. conceal
  3105. cchar
  3106. contained
  3107. containedin
  3108. nextgroup
  3109. transparent
  3110. skipwhite
  3111. skipnl
  3112. skipempty
  3113. conceal *conceal* *:syn-conceal*
  3114. When the "conceal" argument is given, the item is marked as concealable.
  3115. Whether or not it is actually concealed depends on the value of the
  3116. 'conceallevel' option. The 'concealcursor' option is used to decide whether
  3117. concealable items in the current line are displayed unconcealed to be able to
  3118. edit the line.
  3119. Another way to conceal text is with |matchadd()|.
  3120. concealends *:syn-concealends*
  3121. When the "concealends" argument is given, the start and end matches of
  3122. the region, but not the contents of the region, are marked as concealable.
  3123. Whether or not they are actually concealed depends on the setting on the
  3124. 'conceallevel' option. The ends of a region can only be concealed separately
  3125. in this way when they have their own highlighting via "matchgroup"
  3126. cchar *:syn-cchar*
  3127. *E844*
  3128. The "cchar" argument defines the character shown in place of the item
  3129. when it is concealed (setting "cchar" only makes sense when the conceal
  3130. argument is given.) If "cchar" is not set then the default conceal
  3131. character defined in the 'listchars' option is used. The character cannot be
  3132. a control character such as Tab. Example: >
  3133. :syntax match Entity "&amp;" conceal cchar=&
  3134. See |hl-Conceal| for highlighting.
  3135. contained *:syn-contained*
  3136. When the "contained" argument is given, this item will not be recognized at
  3137. the top level, but only when it is mentioned in the "contains" field of
  3138. another match. Example: >
  3139. :syntax keyword Todo TODO contained
  3140. :syntax match Comment "//.*" contains=Todo
  3141. display *:syn-display*
  3142. If the "display" argument is given, this item will be skipped when the
  3143. detected highlighting will not be displayed. This will speed up highlighting,
  3144. by skipping this item when only finding the syntax state for the text that is
  3145. to be displayed.
  3146. Generally, you can use "display" for match and region items that meet these
  3147. conditions:
  3148. - The item does not continue past the end of a line. Example for C: A region
  3149. for a "/*" comment can't contain "display", because it continues on the next
  3150. line.
  3151. - The item does not contain items that continue past the end of the line or
  3152. make it continue on the next line.
  3153. - The item does not change the size of any item it is contained in. Example
  3154. for C: A match with "\\$" in a preprocessor match can't have "display",
  3155. because it may make that preprocessor match shorter.
  3156. - The item does not allow other items to match that didn't match otherwise,
  3157. and that item may extend the match too far. Example for C: A match for a
  3158. "//" comment can't use "display", because a "/*" inside that comment would
  3159. match then and start a comment which extends past the end of the line.
  3160. Examples, for the C language, where "display" can be used:
  3161. - match with a number
  3162. - match with a label
  3163. transparent *:syn-transparent*
  3164. If the "transparent" argument is given, this item will not be highlighted
  3165. itself, but will take the highlighting of the item it is contained in. This
  3166. is useful for syntax items that don't need any highlighting but are used
  3167. only to skip over a part of the text.
  3168. The "contains=" argument is also inherited from the item it is contained in,
  3169. unless a "contains" argument is given for the transparent item itself. To
  3170. avoid that unwanted items are contained, use "contains=NONE". Example, which
  3171. highlights words in strings, but makes an exception for "vim": >
  3172. :syn match myString /'[^']*'/ contains=myWord,myVim
  3173. :syn match myWord /\<[a-z]*\>/ contained
  3174. :syn match myVim /\<vim\>/ transparent contained contains=NONE
  3175. :hi link myString String
  3176. :hi link myWord Comment
  3177. Since the "myVim" match comes after "myWord" it is the preferred match (last
  3178. match in the same position overrules an earlier one). The "transparent"
  3179. argument makes the "myVim" match use the same highlighting as "myString". But
  3180. it does not contain anything. If the "contains=NONE" argument would be left
  3181. out, then "myVim" would use the contains argument from myString and allow
  3182. "myWord" to be contained, which will be highlighted as a Comment. This
  3183. happens because a contained match doesn't match inside itself in the same
  3184. position, thus the "myVim" match doesn't overrule the "myWord" match here.
  3185. When you look at the colored text, it is like looking at layers of contained
  3186. items. The contained item is on top of the item it is contained in, thus you
  3187. see the contained item. When a contained item is transparent, you can look
  3188. through, thus you see the item it is contained in. In a picture:
  3189. look from here
  3190. | | | | | |
  3191. V V V V V V
  3192. xxxx yyy more contained items
  3193. .................... contained item (transparent)
  3194. ============================= first item
  3195. The 'x', 'y' and '=' represent a highlighted syntax item. The '.' represent a
  3196. transparent group.
  3197. What you see is:
  3198. =======xxxx=======yyy========
  3199. Thus you look through the transparent "....".
  3200. oneline *:syn-oneline*
  3201. The "oneline" argument indicates that the region does not cross a line
  3202. boundary. It must match completely in the current line. However, when the
  3203. region has a contained item that does cross a line boundary, it continues on
  3204. the next line anyway. A contained item can be used to recognize a line
  3205. continuation pattern. But the "end" pattern must still match in the first
  3206. line, otherwise the region doesn't even start.
  3207. When the start pattern includes a "\n" to match an end-of-line, the end
  3208. pattern must be found in the same line as where the start pattern ends. The
  3209. end pattern may also include an end-of-line. Thus the "oneline" argument
  3210. means that the end of the start pattern and the start of the end pattern must
  3211. be within one line. This can't be changed by a skip pattern that matches a
  3212. line break.
  3213. fold *:syn-fold*
  3214. The "fold" argument makes the fold level increase by one for this item.
  3215. Example: >
  3216. :syn region myFold start="{" end="}" transparent fold
  3217. :syn sync fromstart
  3218. :set foldmethod=syntax
  3219. This will make each {} block form one fold.
  3220. The fold will start on the line where the item starts, and end where the item
  3221. ends. If the start and end are within the same line, there is no fold.
  3222. The 'foldnestmax' option limits the nesting of syntax folds.
  3223. See |:syn-foldlevel| to control how the foldlevel of a line is computed
  3224. from its syntax items.
  3225. {not available when Vim was compiled without |+folding| feature}
  3226. *:syn-contains* *E405* *E406* *E407* *E408* *E409*
  3227. contains={group-name},..
  3228. The "contains" argument is followed by a list of syntax group names. These
  3229. groups will be allowed to begin inside the item (they may extend past the
  3230. containing group's end). This allows for recursive nesting of matches and
  3231. regions. If there is no "contains" argument, no groups will be contained in
  3232. this item. The group names do not need to be defined before they can be used
  3233. here.
  3234. contains=ALL
  3235. If the only item in the contains list is "ALL", then all
  3236. groups will be accepted inside the item.
  3237. contains=ALLBUT,{group-name},..
  3238. If the first item in the contains list is "ALLBUT", then all
  3239. groups will be accepted inside the item, except the ones that
  3240. are listed. Example: >
  3241. :syntax region Block start="{" end="}" ... contains=ALLBUT,Function
  3242. contains=TOP
  3243. If the first item in the contains list is "TOP", then all
  3244. groups will be accepted that don't have the "contained"
  3245. argument.
  3246. contains=TOP,{group-name},..
  3247. Like "TOP", but excluding the groups that are listed.
  3248. contains=CONTAINED
  3249. If the first item in the contains list is "CONTAINED", then
  3250. all groups will be accepted that have the "contained"
  3251. argument.
  3252. contains=CONTAINED,{group-name},..
  3253. Like "CONTAINED", but excluding the groups that are
  3254. listed.
  3255. The {group-name} in the "contains" list can be a pattern. All group names
  3256. that match the pattern will be included (or excluded, if "ALLBUT" is used).
  3257. The pattern cannot contain white space or a ','. Example: >
  3258. ... contains=Comment.*,Keyw[0-3]
  3259. The matching will be done at moment the syntax command is executed. Groups
  3260. that are defined later will not be matched. Also, if the current syntax
  3261. command defines a new group, it is not matched. Be careful: When putting
  3262. syntax commands in a file you can't rely on groups NOT being defined, because
  3263. the file may have been sourced before, and ":syn clear" doesn't remove the
  3264. group names.
  3265. The contained groups will also match in the start and end patterns of a
  3266. region. If this is not wanted, the "matchgroup" argument can be used
  3267. |:syn-matchgroup|. The "ms=" and "me=" offsets can be used to change the
  3268. region where contained items do match. Note that this may also limit the
  3269. area that is highlighted
  3270. containedin={group-name}... *:syn-containedin*
  3271. The "containedin" argument is followed by a list of syntax group names. The
  3272. item will be allowed to begin inside these groups. This works as if the
  3273. containing item has a "contains=" argument that includes this item.
  3274. The {group-name}... can be used just like for "contains", as explained above.
  3275. This is useful when adding a syntax item afterwards. An item can be told to
  3276. be included inside an already existing item, without changing the definition
  3277. of that item. For example, to highlight a word in a C comment after loading
  3278. the C syntax: >
  3279. :syn keyword myword HELP containedin=cComment contained
  3280. Note that "contained" is also used, to avoid that the item matches at the top
  3281. level.
  3282. Matches for "containedin" are added to the other places where the item can
  3283. appear. A "contains" argument may also be added as usual. Don't forget that
  3284. keywords never contain another item, thus adding them to "containedin" won't
  3285. work.
  3286. nextgroup={group-name},.. *:syn-nextgroup*
  3287. The "nextgroup" argument is followed by a list of syntax group names,
  3288. separated by commas (just like with "contains", so you can also use patterns).
  3289. If the "nextgroup" argument is given, the mentioned syntax groups will be
  3290. tried for a match, after the match or region ends. If none of the groups have
  3291. a match, highlighting continues normally. If there is a match, this group
  3292. will be used, even when it is not mentioned in the "contains" field of the
  3293. current group. This is like giving the mentioned group priority over all
  3294. other groups. Example: >
  3295. :syntax match ccFoobar "Foo.\{-}Bar" contains=ccFoo
  3296. :syntax match ccFoo "Foo" contained nextgroup=ccFiller
  3297. :syntax region ccFiller start="." matchgroup=ccBar end="Bar" contained
  3298. This will highlight "Foo" and "Bar" differently, and only when there is a
  3299. "Bar" after "Foo". In the text line below, "f" shows where ccFoo is used for
  3300. highlighting, and "bbb" where ccBar is used. >
  3301. Foo asdfasd Bar asdf Foo asdf Bar asdf
  3302. fff bbb fff bbb
  3303. Note the use of ".\{-}" to skip as little as possible until the next Bar.
  3304. when ".*" would be used, the "asdf" in between "Bar" and "Foo" would be
  3305. highlighted according to the "ccFoobar" group, because the ccFooBar match
  3306. would include the first "Foo" and the last "Bar" in the line (see |pattern|).
  3307. skipwhite *:syn-skipwhite*
  3308. skipnl *:syn-skipnl*
  3309. skipempty *:syn-skipempty*
  3310. These arguments are only used in combination with "nextgroup". They can be
  3311. used to allow the next group to match after skipping some text:
  3312. skipwhite skip over space and tab characters
  3313. skipnl skip over the end of a line
  3314. skipempty skip over empty lines (implies a "skipnl")
  3315. When "skipwhite" is present, the white space is only skipped if there is no
  3316. next group that matches the white space.
  3317. When "skipnl" is present, the match with nextgroup may be found in the next
  3318. line. This only happens when the current item ends at the end of the current
  3319. line! When "skipnl" is not present, the nextgroup will only be found after
  3320. the current item in the same line.
  3321. When skipping text while looking for a next group, the matches for other
  3322. groups are ignored. Only when no next group matches, other items are tried
  3323. for a match again. This means that matching a next group and skipping white
  3324. space and <EOL>s has a higher priority than other items.
  3325. Example: >
  3326. :syn match ifstart "\<if.*" nextgroup=ifline skipwhite skipempty
  3327. :syn match ifline "[^ \t].*" nextgroup=ifline skipwhite skipempty contained
  3328. :syn match ifline "endif" contained
  3329. Note that the "[^ \t].*" match matches all non-white text. Thus it would also
  3330. match "endif". Therefore the "endif" match is put last, so that it takes
  3331. precedence.
  3332. Note that this example doesn't work for nested "if"s. You need to add
  3333. "contains" arguments to make that work (omitted for simplicity of the
  3334. example).
  3335. IMPLICIT CONCEAL *:syn-conceal-implicit*
  3336. :sy[ntax] conceal [on|off]
  3337. This defines if the following ":syntax" commands will define keywords,
  3338. matches or regions with the "conceal" flag set. After ":syn conceal
  3339. on", all subsequent ":syn keyword", ":syn match" or ":syn region"
  3340. defined will have the "conceal" flag set implicitly. ":syn conceal
  3341. off" returns to the normal state where the "conceal" flag must be
  3342. given explicitly.
  3343. :sy[ntax] conceal
  3344. Show either "syntax conceal on" or "syntax conceal off".
  3345. ==============================================================================
  3346. 8. Syntax patterns *:syn-pattern* *E401* *E402*
  3347. In the syntax commands, a pattern must be surrounded by two identical
  3348. characters. This is like it works for the ":s" command. The most common to
  3349. use is the double quote. But if the pattern contains a double quote, you can
  3350. use another character that is not used in the pattern. Examples: >
  3351. :syntax region Comment start="/\*" end="\*/"
  3352. :syntax region String start=+"+ end=+"+ skip=+\\"+
  3353. See |pattern| for the explanation of what a pattern is. Syntax patterns are
  3354. always interpreted like the 'magic' option is set, no matter what the actual
  3355. value of 'magic' is. And the patterns are interpreted like the 'l' flag is
  3356. not included in 'cpoptions'. This was done to make syntax files portable and
  3357. independent of 'compatible' and 'magic' settings.
  3358. Try to avoid patterns that can match an empty string, such as "[a-z]*".
  3359. This slows down the highlighting a lot, because it matches everywhere.
  3360. *:syn-pattern-offset*
  3361. The pattern can be followed by a character offset. This can be used to
  3362. change the highlighted part, and to change the text area included in the
  3363. match or region (which only matters when trying to match other items). Both
  3364. are relative to the matched pattern. The character offset for a skip
  3365. pattern can be used to tell where to continue looking for an end pattern.
  3366. The offset takes the form of "{what}={offset}"
  3367. The {what} can be one of seven strings:
  3368. ms Match Start offset for the start of the matched text
  3369. me Match End offset for the end of the matched text
  3370. hs Highlight Start offset for where the highlighting starts
  3371. he Highlight End offset for where the highlighting ends
  3372. rs Region Start offset for where the body of a region starts
  3373. re Region End offset for where the body of a region ends
  3374. lc Leading Context offset past "leading context" of pattern
  3375. The {offset} can be:
  3376. s start of the matched pattern
  3377. s+{nr} start of the matched pattern plus {nr} chars to the right
  3378. s-{nr} start of the matched pattern plus {nr} chars to the left
  3379. e end of the matched pattern
  3380. e+{nr} end of the matched pattern plus {nr} chars to the right
  3381. e-{nr} end of the matched pattern plus {nr} chars to the left
  3382. {nr} (for "lc" only): start matching {nr} chars right of the start
  3383. Examples: "ms=s+1", "hs=e-2", "lc=3".
  3384. Although all offsets are accepted after any pattern, they are not always
  3385. meaningful. This table shows which offsets are actually used:
  3386. ms me hs he rs re lc ~
  3387. match item yes yes yes yes - - yes
  3388. region item start yes - yes - yes - yes
  3389. region item skip - yes - - - - yes
  3390. region item end - yes - yes - yes yes
  3391. Offsets can be concatenated, with a ',' in between. Example: >
  3392. :syn match String /"[^"]*"/hs=s+1,he=e-1
  3393. <
  3394. some "string" text
  3395. ^^^^^^ highlighted
  3396. Notes:
  3397. - There must be no white space between the pattern and the character
  3398. offset(s).
  3399. - The highlighted area will never be outside of the matched text.
  3400. - A negative offset for an end pattern may not always work, because the end
  3401. pattern may be detected when the highlighting should already have stopped.
  3402. - Before Vim 7.2 the offsets were counted in bytes instead of characters.
  3403. This didn't work well for multibyte characters, so it was changed with the
  3404. Vim 7.2 release.
  3405. - The start of a match cannot be in a line other than where the pattern
  3406. matched. This doesn't work: "a\nb"ms=e. You can make the highlighting
  3407. start in another line, this does work: "a\nb"hs=e.
  3408. Example (match a comment but don't highlight the /* and */): >
  3409. :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1
  3410. <
  3411. /* this is a comment */
  3412. ^^^^^^^^^^^^^^^^^^^ highlighted
  3413. A more complicated Example: >
  3414. :syn region Exa matchgroup=Foo start="foo"hs=s+2,rs=e+2 matchgroup=Bar end="bar"me=e-1,he=e-1,re=s-1
  3415. <
  3416. abcfoostringbarabc
  3417. mmmmmmmmmmm match
  3418. sssrrreee highlight start/region/end ("Foo", "Exa" and "Bar")
  3419. Leading context *:syn-lc* *:syn-leading* *:syn-context*
  3420. Note: This is an obsolete feature, only included for backwards compatibility
  3421. with previous Vim versions. It's now recommended to use the |/\@<=| construct
  3422. in the pattern. You can also often use |/\zs|.
  3423. The "lc" offset specifies leading context -- a part of the pattern that must
  3424. be present, but is not considered part of the match. An offset of "lc=n" will
  3425. cause Vim to step back n columns before attempting the pattern match, allowing
  3426. characters which have already been matched in previous patterns to also be
  3427. used as leading context for this match. This can be used, for instance, to
  3428. specify that an "escaping" character must not precede the match: >
  3429. :syn match ZNoBackslash "[^\\]z"ms=s+1
  3430. :syn match WNoBackslash "[^\\]w"lc=1
  3431. :syn match Underline "_\+"
  3432. <
  3433. ___zzzz ___wwww
  3434. ^^^ ^^^ matches Underline
  3435. ^ ^ matches ZNoBackslash
  3436. ^^^^ matches WNoBackslash
  3437. The "ms" offset is automatically set to the same value as the "lc" offset,
  3438. unless you set "ms" explicitly.
  3439. Multi-line patterns *:syn-multi-line*
  3440. The patterns can include "\n" to match an end-of-line. Mostly this works as
  3441. expected, but there are a few exceptions.
  3442. When using a start pattern with an offset, the start of the match is not
  3443. allowed to start in a following line. The highlighting can start in a
  3444. following line though. Using the "\zs" item also requires that the start of
  3445. the match doesn't move to another line.
  3446. The skip pattern can include the "\n", but the search for an end pattern will
  3447. continue in the first character of the next line, also when that character is
  3448. matched by the skip pattern. This is because redrawing may start in any line
  3449. halfway a region and there is no check if the skip pattern started in a
  3450. previous line. For example, if the skip pattern is "a\nb" and an end pattern
  3451. is "b", the end pattern does match in the second line of this: >
  3452. x x a
  3453. b x x
  3454. Generally this means that the skip pattern should not match any characters
  3455. after the "\n".
  3456. External matches *:syn-ext-match*
  3457. These extra regular expression items are available in region patterns:
  3458. */\z(* */\z(\)* *E50* *E52* *E879*
  3459. \z(\) Marks the sub-expression as "external", meaning that it can be
  3460. accessed from another pattern match. Currently only usable in
  3461. defining a syntax region start pattern.
  3462. */\z1* */\z2* */\z3* */\z4* */\z5*
  3463. \z1 ... \z9 */\z6* */\z7* */\z8* */\z9* *E66* *E67*
  3464. Matches the same string that was matched by the corresponding
  3465. sub-expression in a previous start pattern match.
  3466. Sometimes the start and end patterns of a region need to share a common
  3467. sub-expression. A common example is the "here" document in Perl and many Unix
  3468. shells. This effect can be achieved with the "\z" special regular expression
  3469. items, which marks a sub-expression as "external", in the sense that it can be
  3470. referenced from outside the pattern in which it is defined. The here-document
  3471. example, for instance, can be done like this: >
  3472. :syn region hereDoc start="<<\z(\I\i*\)" end="^\z1$"
  3473. As can be seen here, the \z actually does double duty. In the start pattern,
  3474. it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it
  3475. changes the \z1 back-reference into an external reference referring to the
  3476. first external sub-expression in the start pattern. External references can
  3477. also be used in skip patterns: >
  3478. :syn region foo start="start \z(\I\i*\)" skip="not end \z1" end="end \z1"
  3479. Note that normal and external sub-expressions are completely orthogonal and
  3480. indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied
  3481. to the string "aabb", then \1 will refer to "bb" and \z1 will refer to "aa".
  3482. Note also that external sub-expressions cannot be accessed as back-references
  3483. within the same pattern like normal sub-expressions. If you want to use one
  3484. sub-expression as both a normal and an external sub-expression, you can nest
  3485. the two, as in "\(\z(...\)\)".
  3486. Note that only matches within a single line can be used. Multi-line matches
  3487. cannot be referred to.
  3488. ==============================================================================
  3489. 9. Syntax clusters *:syn-cluster* *E400*
  3490. :sy[ntax] cluster {cluster-name} [contains={group-name}..]
  3491. [add={group-name}..]
  3492. [remove={group-name}..]
  3493. This command allows you to cluster a list of syntax groups together under a
  3494. single name.
  3495. contains={group-name}..
  3496. The cluster is set to the specified list of groups.
  3497. add={group-name}..
  3498. The specified groups are added to the cluster.
  3499. remove={group-name}..
  3500. The specified groups are removed from the cluster.
  3501. A cluster so defined may be referred to in a contains=.., containedin=..,
  3502. nextgroup=.., add=.. or remove=.. list with a "@" prefix. You can also use
  3503. this notation to implicitly declare a cluster before specifying its contents.
  3504. Example: >
  3505. :syntax match Thing "# [^#]\+ #" contains=@ThingMembers
  3506. :syntax cluster ThingMembers contains=ThingMember1,ThingMember2
  3507. As the previous example suggests, modifications to a cluster are effectively
  3508. retroactive; the membership of the cluster is checked at the last minute, so
  3509. to speak: >
  3510. :syntax keyword A aaa
  3511. :syntax keyword B bbb
  3512. :syntax cluster AandB contains=A
  3513. :syntax match Stuff "( aaa bbb )" contains=@AandB
  3514. :syntax cluster AandB add=B " now both keywords are matched in Stuff
  3515. This also has implications for nested clusters: >
  3516. :syntax keyword A aaa
  3517. :syntax keyword B bbb
  3518. :syntax cluster SmallGroup contains=B
  3519. :syntax cluster BigGroup contains=A,@SmallGroup
  3520. :syntax match Stuff "( aaa bbb )" contains=@BigGroup
  3521. :syntax cluster BigGroup remove=B " no effect, since B isn't in BigGroup
  3522. :syntax cluster SmallGroup remove=B " now bbb isn't matched within Stuff
  3523. <
  3524. *E848*
  3525. The maximum number of clusters is 9767.
  3526. ==============================================================================
  3527. 10. Including syntax files *:syn-include* *E397*
  3528. It is often useful for one language's syntax file to include a syntax file for
  3529. a related language. Depending on the exact relationship, this can be done in
  3530. two different ways:
  3531. - If top-level syntax items in the included syntax file are to be
  3532. allowed at the top level in the including syntax, you can simply use
  3533. the |:runtime| command: >
  3534. " In cpp.vim:
  3535. :runtime! syntax/c.vim
  3536. :unlet b:current_syntax
  3537. < - If top-level syntax items in the included syntax file are to be
  3538. contained within a region in the including syntax, you can use the
  3539. ":syntax include" command:
  3540. :sy[ntax] include [@{grouplist-name}] {file-name}
  3541. All syntax items declared in the included file will have the
  3542. "contained" flag added. In addition, if a group list is specified,
  3543. all top-level syntax items in the included file will be added to
  3544. that list. >
  3545. " In perl.vim:
  3546. :syntax include @Pod <sfile>:p:h/pod.vim
  3547. :syntax region perlPOD start="^=head" end="^=cut" contains=@Pod
  3548. <
  3549. When {file-name} is an absolute path (starts with "/", "c:", "$VAR"
  3550. or "<sfile>") that file is sourced. When it is a relative path
  3551. (e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'.
  3552. All matching files are loaded. Using a relative path is
  3553. recommended, because it allows a user to replace the included file
  3554. with their own version, without replacing the file that does the
  3555. ":syn include".
  3556. *E847*
  3557. The maximum number of includes is 999.
  3558. ==============================================================================
  3559. 11. Synchronizing *:syn-sync* *E403* *E404*
  3560. Vim wants to be able to start redrawing in any position in the document. To
  3561. make this possible it needs to know the syntax state at the position where
  3562. redrawing starts.
  3563. :sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
  3564. There are four ways to synchronize:
  3565. 1. Always parse from the start of the file.
  3566. |:syn-sync-first|
  3567. 2. Based on C-style comments. Vim understands how C-comments work and can
  3568. figure out if the current line starts inside or outside a comment.
  3569. |:syn-sync-second|
  3570. 3. Jumping back a certain number of lines and start parsing there.
  3571. |:syn-sync-third|
  3572. 4. Searching backwards in the text for a pattern to sync on.
  3573. |:syn-sync-fourth|
  3574. *:syn-sync-maxlines* *:syn-sync-minlines*
  3575. For the last three methods, the line range where the parsing can start is
  3576. limited by "minlines" and "maxlines".
  3577. If the "minlines={N}" argument is given, the parsing always starts at least
  3578. that many lines backwards. This can be used if the parsing may take a few
  3579. lines before it's correct, or when it's not possible to use syncing.
  3580. If the "maxlines={N}" argument is given, the number of lines that are searched
  3581. for a comment or syncing pattern is restricted to N lines backwards (after
  3582. adding "minlines"). This is useful if you have few things to sync on and a
  3583. slow machine. Example: >
  3584. :syntax sync maxlines=500 ccomment
  3585. <
  3586. *:syn-sync-linebreaks*
  3587. When using a pattern that matches multiple lines, a change in one line may
  3588. cause a pattern to no longer match in a previous line. This means has to
  3589. start above where the change was made. How many lines can be specified with
  3590. the "linebreaks" argument. For example, when a pattern may include one line
  3591. break use this: >
  3592. :syntax sync linebreaks=1
  3593. The result is that redrawing always starts at least one line before where a
  3594. change was made. The default value for "linebreaks" is zero. Usually the
  3595. value for "minlines" is bigger than "linebreaks".
  3596. First syncing method: *:syn-sync-first*
  3597. >
  3598. :syntax sync fromstart
  3599. The file will be parsed from the start. This makes syntax highlighting
  3600. accurate, but can be slow for long files. Vim caches previously parsed text,
  3601. so that it's only slow when parsing the text for the first time. However,
  3602. when making changes some part of the text needs to be parsed again (worst
  3603. case: to the end of the file).
  3604. Using "fromstart" is equivalent to using "minlines" with a very large number.
  3605. Second syncing method: *:syn-sync-second* *:syn-sync-ccomment*
  3606. For the second method, only the "ccomment" argument needs to be given.
  3607. Example: >
  3608. :syntax sync ccomment
  3609. When Vim finds that the line where displaying starts is inside a C-style
  3610. comment, the last region syntax item with the group-name "Comment" will be
  3611. used. This requires that there is a region with the group-name "Comment"!
  3612. An alternate group name can be specified, for example: >
  3613. :syntax sync ccomment javaComment
  3614. This means that the last item specified with "syn region javaComment" will be
  3615. used for the detected C comment region. This only works properly if that
  3616. region does have a start pattern "\/*" and an end pattern "*\/".
  3617. The "maxlines" argument can be used to restrict the search to a number of
  3618. lines. The "minlines" argument can be used to at least start a number of
  3619. lines back (e.g., for when there is some construct that only takes a few
  3620. lines, but it hard to sync on).
  3621. Note: Syncing on a C comment doesn't work properly when strings are used
  3622. that cross a line and contain a "*/". Since letting strings cross a line
  3623. is a bad programming habit (many compilers give a warning message), and the
  3624. chance of a "*/" appearing inside a comment is very small, this restriction
  3625. is hardly ever noticed.
  3626. Third syncing method: *:syn-sync-third*
  3627. For the third method, only the "minlines={N}" argument needs to be given.
  3628. Vim will subtract {N} from the line number and start parsing there. This
  3629. means {N} extra lines need to be parsed, which makes this method a bit slower.
  3630. Example: >
  3631. :syntax sync minlines=50
  3632. "lines" is equivalent to "minlines" (used by older versions).
  3633. Fourth syncing method: *:syn-sync-fourth*
  3634. The idea is to synchronize on the end of a few specific regions, called a
  3635. sync pattern. Only regions can cross lines, so when we find the end of some
  3636. region, we might be able to know in which syntax item we are. The search
  3637. starts in the line just above the one where redrawing starts. From there
  3638. the search continues backwards in the file.
  3639. This works just like the non-syncing syntax items. You can use contained
  3640. matches, nextgroup, etc. But there are a few differences:
  3641. - Keywords cannot be used.
  3642. - The syntax items with the "sync" keyword form a completely separated group
  3643. of syntax items. You can't mix syncing groups and non-syncing groups.
  3644. - The matching works backwards in the buffer (line by line), instead of
  3645. forwards.
  3646. - A line continuation pattern can be given. It is used to decide which group
  3647. of lines need to be searched like they were one line. This means that the
  3648. search for a match with the specified items starts in the first of the
  3649. consecutive lines that contain the continuation pattern.
  3650. - When using "nextgroup" or "contains", this only works within one line (or
  3651. group of continued lines).
  3652. - When using a region, it must start and end in the same line (or group of
  3653. continued lines). Otherwise the end is assumed to be at the end of the
  3654. line (or group of continued lines).
  3655. - When a match with a sync pattern is found, the rest of the line (or group of
  3656. continued lines) is searched for another match. The last match is used.
  3657. This is used when a line can contain both the start end the end of a region
  3658. (e.g., in a C-comment like /* this */, the last "*/" is used).
  3659. There are two ways how a match with a sync pattern can be used:
  3660. 1. Parsing for highlighting starts where redrawing starts (and where the
  3661. search for the sync pattern started). The syntax group that is expected
  3662. to be valid there must be specified. This works well when the regions
  3663. that cross lines cannot contain other regions.
  3664. 2. Parsing for highlighting continues just after the match. The syntax group
  3665. that is expected to be present just after the match must be specified.
  3666. This can be used when the previous method doesn't work well. It's much
  3667. slower, because more text needs to be parsed.
  3668. Both types of sync patterns can be used at the same time.
  3669. Besides the sync patterns, other matches and regions can be specified, to
  3670. avoid finding unwanted matches.
  3671. [The reason that the sync patterns are given separately, is that mostly the
  3672. search for the sync point can be much simpler than figuring out the
  3673. highlighting. The reduced number of patterns means it will go (much)
  3674. faster.]
  3675. *syn-sync-grouphere* *E393* *E394*
  3676. :syntax sync match {sync-group-name} grouphere {group-name} "pattern" ..
  3677. Define a match that is used for syncing. {group-name} is the
  3678. name of a syntax group that follows just after the match. Parsing
  3679. of the text for highlighting starts just after the match. A region
  3680. must exist for this {group-name}. The first one defined will be used.
  3681. "NONE" can be used for when there is no syntax group after the match.
  3682. *syn-sync-groupthere*
  3683. :syntax sync match {sync-group-name} groupthere {group-name} "pattern" ..
  3684. Like "grouphere", but {group-name} is the name of a syntax group that
  3685. is to be used at the start of the line where searching for the sync
  3686. point started. The text between the match and the start of the sync
  3687. pattern searching is assumed not to change the syntax highlighting.
  3688. For example, in C you could search backwards for "/*" and "*/". If
  3689. "/*" is found first, you know that you are inside a comment, so the
  3690. "groupthere" is "cComment". If "*/" is found first, you know that you
  3691. are not in a comment, so the "groupthere" is "NONE". (in practice
  3692. it's a bit more complicated, because the "/*" and "*/" could appear
  3693. inside a string. That's left as an exercise to the reader...).
  3694. :syntax sync match ..
  3695. :syntax sync region ..
  3696. Without a "groupthere" argument. Define a region or match that is
  3697. skipped while searching for a sync point.
  3698. *syn-sync-linecont*
  3699. :syntax sync linecont {pattern}
  3700. When {pattern} matches in a line, it is considered to continue in
  3701. the next line. This means that the search for a sync point will
  3702. consider the lines to be concatenated.
  3703. If the "maxlines={N}" argument is given too, the number of lines that are
  3704. searched for a match is restricted to N. This is useful if you have very
  3705. few things to sync on and a slow machine. Example: >
  3706. :syntax sync maxlines=100
  3707. You can clear all sync settings with: >
  3708. :syntax sync clear
  3709. You can clear specific sync patterns with: >
  3710. :syntax sync clear {sync-group-name} ..
  3711. ==============================================================================
  3712. 12. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
  3713. This command lists all the syntax items: >
  3714. :sy[ntax] [list]
  3715. To show the syntax items for one syntax group: >
  3716. :sy[ntax] list {group-name}
  3717. To list the syntax groups in one cluster: *E392* >
  3718. :sy[ntax] list @{cluster-name}
  3719. See above for other arguments for the ":syntax" command.
  3720. Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
  3721. is mostly used, because it looks better.
  3722. ==============================================================================
  3723. 13. Colorschemes *color-schemes*
  3724. In the next section you can find information about indivisual highlight groups
  3725. and how to specify colors for them. Most likely you want to just select a set
  3726. of colors by using the `:colorscheme` command, for example: >
  3727. colorscheme pablo
  3728. <
  3729. *:colo* *:colorscheme* *E185*
  3730. :colo[rscheme] Output the name of the currently active color scheme.
  3731. This is basically the same as >
  3732. :echo g:colors_name
  3733. < In case g:colors_name has not been defined :colo will
  3734. output "default". When compiled without the |+eval|
  3735. feature it will output "unknown".
  3736. :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
  3737. for the file "colors/{name}.vim". The first one that
  3738. is found is loaded.
  3739. Also searches all plugins in 'packpath', first below
  3740. "start" and then under "opt".
  3741. Doesn't work recursively, thus you can't use
  3742. ":colorscheme" in a color scheme script.
  3743. You have two options for customizing a color scheme. For changing the
  3744. appearance of specific colors, you can redefine a color name before loading
  3745. the scheme. The desert scheme uses the khaki color for the cursor. To use a
  3746. darker variation of the same color: >
  3747. let v:colornames['khaki'] = '#bdb76b'
  3748. colorscheme desert
  3749. <
  3750. For further customization, such as changing |:highlight-link| associations,
  3751. use another name, e.g. "~/.vim/colors/mine.vim", and use `:runtime` to load
  3752. the original color scheme: >
  3753. runtime colors/evening.vim
  3754. hi Statement ctermfg=Blue guifg=Blue
  3755. Before the color scheme will be loaded all default color list scripts
  3756. (`colors/lists/default.vim`) will be executed and then the |ColorSchemePre|
  3757. autocommand event is triggered. After the color scheme has been loaded the
  3758. |ColorScheme| autocommand event is triggered.
  3759. *colorscheme-override*
  3760. If a color scheme is almost right, you can add modifications on top of it by
  3761. using the |ColorScheme| autocommand. For example, to remove the background
  3762. color (can make it transparent in some terminals): >
  3763. augroup my_colorschemes
  3764. au!
  3765. au Colorscheme pablo hi Normal ctermbg=NONE
  3766. augroup END
  3767. Change a couple more colors: >
  3768. augroup my_colorschemes
  3769. au!
  3770. au Colorscheme pablo hi Normal ctermbg=NONE
  3771. \ | highlight Special ctermfg=63
  3772. \ | highlight Identifier ctermfg=44
  3773. augroup END
  3774. If you make a lot of changes it might be better to copy the distributed
  3775. colorscheme to your home directory and change it: >
  3776. :!cp $VIMRUNTIME/colors/pablo.vim ~/.vim/colors
  3777. :edit ~/.vim/colors/pablo.vim
  3778. With Vim 9.0 the collection of color schemes was updated and made work in many
  3779. different terminals. One change was to often define the Normal highlight
  3780. group to make sure the colors work well. In case you prefer the old version,
  3781. you can find them here:
  3782. https://github.com/vim/colorschemes/blob/master/legacy_colors/
  3783. For info about writing a color scheme file: >
  3784. :edit $VIMRUNTIME/colors/README.txt
  3785. ==============================================================================
  3786. 14. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
  3787. There are three types of highlight groups:
  3788. - The ones used for specific languages. For these the name starts with the
  3789. name of the language. Many of these don't have any attributes, but are
  3790. linked to a group of the second type.
  3791. - The ones used for all syntax languages.
  3792. - The ones used for the 'highlight' option.
  3793. *hitest.vim*
  3794. You can see all the groups currently active with this command: >
  3795. :so $VIMRUNTIME/syntax/hitest.vim
  3796. This will open a new window containing all highlight group names, displayed
  3797. in their own color.
  3798. :hi[ghlight] List all the current highlight groups that have
  3799. attributes set.
  3800. :hi[ghlight] {group-name}
  3801. List one highlight group.
  3802. *highlight-clear* *:hi-clear*
  3803. :hi[ghlight] clear Reset all highlighting to the defaults. Removes all
  3804. highlighting for groups added by the user!
  3805. Uses the current value of 'background' to decide which
  3806. default colors to use.
  3807. If there was a default link, restore it. |:hi-link|
  3808. :hi[ghlight] clear {group-name}
  3809. :hi[ghlight] {group-name} NONE
  3810. Disable the highlighting for one highlight group. It
  3811. is _not_ set back to the default colors.
  3812. :hi[ghlight] [default] {group-name} {key}={arg} ..
  3813. Add a highlight group, or change the highlighting for
  3814. an existing group. If a given color name is not
  3815. recognized, each `colors/lists/default.vim` found on
  3816. |'runtimepath'| will be loaded.
  3817. See |highlight-args| for the {key}={arg} arguments.
  3818. See |:highlight-default| for the optional [default]
  3819. argument.
  3820. Normally a highlight group is added once when starting up. This sets the
  3821. default values for the highlighting. After that, you can use additional
  3822. highlight commands to change the arguments that you want to set to non-default
  3823. values. The value "NONE" can be used to switch the value off or go back to
  3824. the default value.
  3825. A simple way to change colors is with the |:colorscheme| command. This loads
  3826. a file with ":highlight" commands such as this: >
  3827. :hi Comment gui=bold
  3828. Note that all settings that are not included remain the same, only the
  3829. specified field is used, and settings are merged with previous ones. So, the
  3830. result is like this single command has been used: >
  3831. :hi Comment term=bold ctermfg=Cyan guifg=#80a0ff gui=bold
  3832. <
  3833. *:highlight-verbose*
  3834. When listing a highlight group and 'verbose' is non-zero, the listing will
  3835. also tell where it was last set. Example: >
  3836. :verbose hi Comment
  3837. < Comment xxx term=bold ctermfg=4 guifg=Blue ~
  3838. Last set from /home/mool/vim/vim7/runtime/syntax/syncolor.vim ~
  3839. When ":hi clear" is used then the script where this command is used will be
  3840. mentioned for the default values. See |:verbose-cmd| for more information.
  3841. *highlight-args* *E416* *E417* *E423*
  3842. There are three types of terminals for highlighting:
  3843. term a normal terminal (vt100, xterm)
  3844. cterm a color terminal (MS-Windows console, color-xterm, these have the "Co"
  3845. termcap entry)
  3846. gui the GUI
  3847. For each type the highlighting can be given. This makes it possible to use
  3848. the same syntax file on all terminals, and use the optimal highlighting.
  3849. 1. highlight arguments for normal terminals
  3850. *bold* *underline* *undercurl*
  3851. *underdouble* *underdotted*
  3852. *underdashed* *inverse* *italic*
  3853. *standout* *nocombine* *strikethrough*
  3854. term={attr-list} *attr-list* *highlight-term* *E418*
  3855. attr-list is a comma-separated list (without spaces) of the
  3856. following items (in any order):
  3857. bold
  3858. underline
  3859. undercurl not always available
  3860. underdouble not always available
  3861. underdotted not always available
  3862. underdashed not always available
  3863. strikethrough not always available
  3864. reverse
  3865. inverse same as reverse
  3866. italic
  3867. standout
  3868. nocombine override attributes instead of combining them
  3869. NONE no attributes used (used to reset it)
  3870. Note that "bold" can be used here and by using a bold font. They
  3871. have the same effect.
  3872. *underline-codes*
  3873. "undercurl" is a curly underline. When "undercurl" is not possible
  3874. then "underline" is used. In general "undercurl" and "strikethrough"
  3875. are only available in the GUI and some terminals. The color is set
  3876. with |highlight-guisp| or |highlight-ctermul|. You can try these
  3877. termcap entries to make undercurl work in a terminal: >
  3878. let &t_Cs = "\e[4:3m"
  3879. let &t_Ce = "\e[4:0m"
  3880. < "underdouble" is a double underline, "underdotted" is a dotted
  3881. underline and "underdashed" is a dashed underline. These are only
  3882. supported by some terminals. If your terminal supports them you may
  3883. have to specify the codes like this: >
  3884. let &t_Us = "\e[4:2m"
  3885. let &t_ds = "\e[4:4m"
  3886. let &t_Ds = "\e[4:5m"
  3887. < They are reset with |t_Ce|, the same as curly underline (undercurl).
  3888. When t_Us, t_ds or t_Ds is not set then underline will be used as a
  3889. fallback.
  3890. start={term-list} *highlight-start* *E422*
  3891. stop={term-list} *term-list* *highlight-stop*
  3892. These lists of terminal codes can be used to get
  3893. non-standard attributes on a terminal.
  3894. The escape sequence specified with the "start" argument
  3895. is written before the characters in the highlighted
  3896. area. It can be anything that you want to send to the
  3897. terminal to highlight this area. The escape sequence
  3898. specified with the "stop" argument is written after the
  3899. highlighted area. This should undo the "start" argument.
  3900. Otherwise the screen will look messed up.
  3901. The {term-list} can have two forms:
  3902. 1. A string with escape sequences.
  3903. This is any string of characters, except that it can't start with
  3904. "t_" and blanks are not allowed. The <> notation is recognized
  3905. here, so you can use things like "<Esc>" and "<Space>". Example:
  3906. start=<Esc>[27h;<Esc>[<Space>r;
  3907. 2. A list of terminal codes.
  3908. Each terminal code has the form "t_xx", where "xx" is the name of
  3909. the termcap entry. The codes have to be separated with commas.
  3910. White space is not allowed. Example:
  3911. start=t_C1,t_BL
  3912. The terminal codes must exist for this to work.
  3913. 2. highlight arguments for color terminals
  3914. cterm={attr-list} *highlight-cterm*
  3915. See above for the description of {attr-list} |attr-list|.
  3916. The "cterm" argument is likely to be different from "term", when
  3917. colors are used. For example, in a normal terminal comments could
  3918. be underlined, in a color terminal they can be made Blue.
  3919. Note: Some terminals (e.g., DOS console) can't mix these attributes
  3920. with coloring. To be portable, use only one of "cterm=" OR "ctermfg="
  3921. OR "ctermbg=".
  3922. ctermfg={color-nr} *highlight-ctermfg* *E421*
  3923. ctermbg={color-nr} *highlight-ctermbg*
  3924. ctermul={color-nr} *highlight-ctermul*
  3925. These give the foreground (ctermfg), background (ctermbg) and
  3926. underline (ctermul) color to use in the terminal.
  3927. The {color-nr} argument is a color number. Its range is zero to
  3928. (not including) the number given by the termcap entry "Co".
  3929. The actual color with this number depends on the type of terminal
  3930. and its settings. Sometimes the color also depends on the settings of
  3931. "cterm". For example, on some systems "cterm=bold ctermfg=3" gives
  3932. another color, on others you just get color 3.
  3933. For an xterm this depends on your resources, and is a bit
  3934. unpredictable. See your xterm documentation for the defaults. The
  3935. colors for a color-xterm can be changed from the .Xdefaults file.
  3936. Unfortunately this means that it's not possible to get the same colors
  3937. for each user. See |xterm-color| for info about color xterms.
  3938. *tmux*
  3939. When using tmux you may want to use this in the tmux config: >
  3940. # tmux colors
  3941. set -s default-terminal "tmux-256color"
  3942. set -as terminal-overrides ",*-256color:Tc"
  3943. < More info at:
  3944. https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-a-256-colour-terminal
  3945. https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-rgb-colour
  3946. The MS-Windows standard colors are fixed (in a console window), so
  3947. these have been used for the names. But the meaning of color names in
  3948. X11 are fixed, so these color settings have been used, to make the
  3949. highlighting settings portable (complicated, isn't it?). The
  3950. following names are recognized, with the color number used:
  3951. *cterm-colors*
  3952. NR-16 NR-8 COLOR NAME ~
  3953. 0 0 Black
  3954. 1 4 DarkBlue
  3955. 2 2 DarkGreen
  3956. 3 6 DarkCyan
  3957. 4 1 DarkRed
  3958. 5 5 DarkMagenta
  3959. 6 3 Brown, DarkYellow
  3960. 7 7 LightGray, LightGrey, Gray, Grey
  3961. 8 0* DarkGray, DarkGrey
  3962. 9 4* Blue, LightBlue
  3963. 10 2* Green, LightGreen
  3964. 11 6* Cyan, LightCyan
  3965. 12 1* Red, LightRed
  3966. 13 5* Magenta, LightMagenta
  3967. 14 3* Yellow, LightYellow
  3968. 15 7* White
  3969. The number under "NR-16" is used for 16-color terminals ('t_Co'
  3970. greater than or equal to 16). The number under "NR-8" is used for
  3971. 8-color terminals ('t_Co' less than 16). The '*' indicates that the
  3972. bold attribute is set for ctermfg. In many 8-color terminals (e.g.,
  3973. "linux"), this causes the bright colors to appear. This doesn't work
  3974. for background colors! Without the '*' the bold attribute is removed.
  3975. If you want to set the bold attribute in a different way, put a
  3976. "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument. Or use
  3977. a number instead of a color name.
  3978. The case of the color names is ignored.
  3979. Note that for 16 color ansi style terminals (including xterms), the
  3980. numbers in the NR-8 column is used. Here '*' means 'add 8' so that
  3981. Blue is 12, DarkGray is 8 etc.
  3982. Note that for some color terminals these names may result in the wrong
  3983. colors!
  3984. You can also use "NONE" to remove the color.
  3985. *:hi-normal-cterm*
  3986. When setting the "ctermfg" or "ctermbg" colors for the Normal group,
  3987. these will become the colors used for the non-highlighted text.
  3988. Example: >
  3989. :highlight Normal ctermfg=grey ctermbg=darkblue
  3990. < When setting the "ctermbg" color for the Normal group, the
  3991. 'background' option will be adjusted automatically, under the
  3992. condition that the color is recognized and 'background' was not set
  3993. explicitly. This causes the highlight groups that depend on
  3994. 'background' to change! This means you should set the colors for
  3995. Normal first, before setting other colors.
  3996. When a color scheme is being used, changing 'background' causes it to
  3997. be reloaded, which may reset all colors (including Normal). First
  3998. delete the "g:colors_name" variable when you don't want this.
  3999. When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
  4000. needs to reset the color when exiting. This is done with the "op"
  4001. termcap entry |t_op|. If this doesn't work correctly, try setting the
  4002. 't_op' option in your .vimrc.
  4003. *E419* *E420* *E453*
  4004. When Vim knows the normal foreground, background and underline colors,
  4005. "fg", "bg" and "ul" can be used as color names. This only works after
  4006. setting the colors for the Normal group and for the MS-Windows
  4007. console. Example, for reverse video: >
  4008. :highlight Visual ctermfg=bg ctermbg=fg
  4009. < Note that the colors are used that are valid at the moment this
  4010. command is given. If the Normal group colors are changed later, the
  4011. "fg" and "bg" colors will not be adjusted.
  4012. 3. highlight arguments for the GUI
  4013. gui={attr-list} *highlight-gui*
  4014. These give the attributes to use in the GUI mode.
  4015. See |attr-list| for a description.
  4016. Note that "bold" can be used here and by using a bold font. They
  4017. have the same effect.
  4018. Note that the attributes are ignored for the "Normal" group.
  4019. font={font-name} *highlight-font*
  4020. font-name is the name of a font, as it is used on the system Vim
  4021. runs on. For X11 this is a complicated name, for example: >
  4022. font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
  4023. <
  4024. The font-name "NONE" can be used to revert to the default font.
  4025. When setting the font for the "Normal" group, this becomes the default
  4026. font (until the 'guifont' option is changed; the last one set is
  4027. used).
  4028. The following only works with Motif, not with other GUIs:
  4029. When setting the font for the "Menu" group, the menus will be changed.
  4030. When setting the font for the "Tooltip" group, the tooltips will be
  4031. changed.
  4032. All fonts used, except for Menu and Tooltip, should be of the same
  4033. character size as the default font! Otherwise redrawing problems will
  4034. occur.
  4035. To use a font name with an embedded space or other special character,
  4036. put it in single quotes. The single quote cannot be used then.
  4037. Example: >
  4038. :hi comment font='Monospace 10'
  4039. guifg={color-name} *highlight-guifg*
  4040. guibg={color-name} *highlight-guibg*
  4041. guisp={color-name} *highlight-guisp*
  4042. These give the foreground (guifg), background (guibg) and special
  4043. (guisp) color to use in the GUI. "guisp" is used for undercurl and
  4044. strikethrough.
  4045. There are a few special names:
  4046. NONE no color (transparent)
  4047. bg use normal background color
  4048. background use normal background color
  4049. fg use normal foreground color
  4050. foreground use normal foreground color
  4051. To use a color name with an embedded space or other special character,
  4052. put it in single quotes. The single quote cannot be used then.
  4053. Example: >
  4054. :hi comment guifg='salmon pink'
  4055. <
  4056. *gui-colors*
  4057. Suggested color names (these are available on most systems):
  4058. Red LightRed DarkRed
  4059. Green LightGreen DarkGreen SeaGreen
  4060. Blue LightBlue DarkBlue SlateBlue
  4061. Cyan LightCyan DarkCyan
  4062. Magenta LightMagenta DarkMagenta
  4063. Yellow LightYellow Brown DarkYellow
  4064. Gray LightGray DarkGray
  4065. Black White
  4066. Orange Purple Violet
  4067. In the Win32 GUI version, additional system colors are available. See
  4068. |win32-colors|.
  4069. You can also specify a color by its Red, Green and Blue values.
  4070. The format is "#rrggbb", where
  4071. "rr" is the Red value
  4072. "gg" is the Green value
  4073. "bb" is the Blue value
  4074. All values are hexadecimal, range from "00" to "ff". Examples: >
  4075. :highlight Comment guifg=#11f0c3 guibg=#ff00ff
  4076. <
  4077. If you are authoring a color scheme and use the same hexadecimal value
  4078. repeatedly, you can define a name for it in |v:colornames|. For
  4079. example: >
  4080. # provide a default value for this color but allow the user to
  4081. # override it.
  4082. :call extend(v:colornames, {'alt_turquoise': '#11f0c3'}, 'keep')
  4083. :highlight Comment guifg=alt_turquoise guibg=magenta
  4084. <
  4085. If you are using a color scheme that relies on named colors and you
  4086. would like to adjust the precise appearance of those colors, you can
  4087. do so by overriding the values in |v:colornames| prior to loading the
  4088. scheme: >
  4089. let v:colornames['alt_turquoise'] = '#22f0d3'
  4090. colorscheme alt
  4091. <
  4092. If you want to develop a color list that can be relied on by others,
  4093. it is best to prefix your color names. By convention these color lists
  4094. are placed in the colors/lists directory. You can see an example in
  4095. '$VIMRUNTIME/colors/lists/csscolors.vim'. This list would be sourced
  4096. by a color scheme using: >
  4097. :runtime colors/lists/csscolors.vim
  4098. :highlight Comment guifg=css_turquoise
  4099. <
  4100. *highlight-groups* *highlight-default*
  4101. These are the default highlighting groups. These groups are used by the
  4102. 'highlight' option default. Note that the highlighting depends on the value
  4103. of 'background'. You can see the current settings with the ":highlight"
  4104. command.
  4105. When possible the name is highlighted in the used colors. If this makes it
  4106. unreadable use Visual selection.
  4107. *hl-ColorColumn*
  4108. ColorColumn Used for the columns set with 'colorcolumn'.
  4109. *hl-Conceal*
  4110. Conceal Placeholder characters substituted for concealed
  4111. text (see 'conceallevel').
  4112. *hl-Cursor*
  4113. Cursor Character under the cursor.
  4114. lCursor Character under the cursor when |language-mapping|
  4115. is used (see 'guicursor').
  4116. *hl-CursorIM*
  4117. CursorIM Like Cursor, but used when in IME mode. |CursorIM|
  4118. *hl-CursorColumn*
  4119. CursorColumn Screen column that the cursor is in when 'cursorcolumn' is set.
  4120. *hl-CursorLine*
  4121. CursorLine Screen line that the cursor is in when 'cursorline' is set.
  4122. *hl-Directory*
  4123. Directory Directory names (and other special names in listings).
  4124. *hl-DiffAdd*
  4125. DiffAdd Diff mode: Added line. |diff.txt|
  4126. *hl-DiffChange*
  4127. DiffChange Diff mode: Changed line. |diff.txt|
  4128. *hl-DiffDelete*
  4129. DiffDelete Diff mode: Deleted line. |diff.txt|
  4130. *hl-DiffText*
  4131. DiffText Diff mode: Changed text within a changed line. |diff.txt|
  4132. *hl-EndOfBuffer*
  4133. EndOfBuffer Filler lines (~) after the last line in the buffer.
  4134. By default, this is highlighted like |hl-NonText|.
  4135. *hl-ErrorMsg*
  4136. ErrorMsg Error messages on the command line.
  4137. *hl-VertSplit*
  4138. VertSplit Column separating vertically split windows.
  4139. *hl-Folded*
  4140. Folded Line used for closed folds.
  4141. *hl-FoldColumn*
  4142. FoldColumn 'foldcolumn'
  4143. *hl-SignColumn*
  4144. SignColumn Column where |signs| are displayed.
  4145. *hl-IncSearch*
  4146. IncSearch 'incsearch' highlighting; also used for the text replaced with
  4147. ":s///c".
  4148. *hl-LineNr*
  4149. LineNr Line number for ":number" and ":#" commands, and when 'number'
  4150. or 'relativenumber' option is set.
  4151. *hl-LineNrAbove*
  4152. LineNrAbove Line number for when the 'relativenumber'
  4153. option is set, above the cursor line.
  4154. *hl-LineNrBelow*
  4155. LineNrBelow Line number for when the 'relativenumber'
  4156. option is set, below the cursor line.
  4157. *hl-CursorLineNr*
  4158. CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt'
  4159. contains "number" or is "both", for the cursor line.
  4160. *hl-CursorLineFold*
  4161. CursorLineFold Like FoldColumn when 'cursorline' is set for the cursor line.
  4162. *hl-CursorLineSign*
  4163. CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line.
  4164. *hl-MatchParen*
  4165. MatchParen Character under the cursor or just before it, if it
  4166. is a paired bracket, and its match. |pi_paren.txt|
  4167. *hl-MessageWindow*
  4168. MessageWindow Messages popup window used by `:echowindow`. If not defined
  4169. |hl-WarningMsg| is used.
  4170. *hl-ModeMsg*
  4171. ModeMsg 'showmode' message (e.g., "-- INSERT --").
  4172. *hl-MoreMsg*
  4173. MoreMsg |more-prompt|
  4174. *hl-NonText*
  4175. NonText '@' at the end of the window, "<<<" at the start of the window
  4176. for 'smoothscroll', characters from 'showbreak' and other
  4177. characters that do not really exist in the text, such as the
  4178. ">" displayed when a double-wide character doesn't fit at the
  4179. end of the line.
  4180. *hl-Normal*
  4181. Normal Normal text.
  4182. *hl-Pmenu*
  4183. Pmenu Popup menu: Normal item.
  4184. *hl-PmenuSel*
  4185. PmenuSel Popup menu: Selected item.
  4186. *hl-PmenuSbar*
  4187. PmenuSbar Popup menu: Scrollbar.
  4188. *hl-PmenuThumb*
  4189. PmenuThumb Popup menu: Thumb of the scrollbar.
  4190. *hl-PopupNotification*
  4191. PopupNotification
  4192. Popup window created with |popup_notification()|. If not
  4193. defined |hl-WarningMsg| is used.
  4194. *hl-Question*
  4195. Question |hit-enter| prompt and yes/no questions.
  4196. *hl-QuickFixLine*
  4197. QuickFixLine Current |quickfix| item in the quickfix window.
  4198. *hl-Search*
  4199. Search Last search pattern highlighting (see 'hlsearch').
  4200. Also used for similar items that need to stand out.
  4201. *hl-CurSearch*
  4202. CurSearch Current match for the last search pattern (see 'hlsearch').
  4203. Note: This is correct after a search, but may get outdated if
  4204. changes are made or the screen is redrawn.
  4205. *hl-SpecialKey*
  4206. SpecialKey Meta and special keys listed with ":map", also for text used
  4207. to show unprintable characters in the text, 'listchars'.
  4208. Generally: Text that is displayed differently from what it
  4209. really is.
  4210. *hl-SpellBad*
  4211. SpellBad Word that is not recognized by the spellchecker. |spell|
  4212. This will be combined with the highlighting used otherwise.
  4213. *hl-SpellCap*
  4214. SpellCap Word that should start with a capital. |spell|
  4215. This will be combined with the highlighting used otherwise.
  4216. *hl-SpellLocal*
  4217. SpellLocal Word that is recognized by the spellchecker as one that is
  4218. used in another region. |spell|
  4219. This will be combined with the highlighting used otherwise.
  4220. *hl-SpellRare*
  4221. SpellRare Word that is recognized by the spellchecker as one that is
  4222. hardly ever used. |spell|
  4223. This will be combined with the highlighting used otherwise.
  4224. *hl-StatusLine*
  4225. StatusLine Status line of current window.
  4226. *hl-StatusLineNC*
  4227. StatusLineNC status lines of not-current windows
  4228. Note: If this is equal to "StatusLine", Vim will use "^^^" in
  4229. the status line of the current window.
  4230. *hl-StatusLineTerm*
  4231. StatusLineTerm Status line of current window, if it is a |terminal| window.
  4232. *hl-StatusLineTermNC*
  4233. StatusLineTermNC Status lines of not-current windows that is a
  4234. |terminal| window.
  4235. *hl-TabLine*
  4236. TabLine Tab pages line, not active tab page label.
  4237. *hl-TabLineFill*
  4238. TabLineFill Tab pages line, where there are no labels.
  4239. *hl-TabLineSel*
  4240. TabLineSel Tab pages line, active tab page label.
  4241. *hl-Terminal*
  4242. Terminal |terminal| window (see |terminal-size-color|).
  4243. *hl-Title*
  4244. Title Titles for output from ":set all", ":autocmd" etc.
  4245. *hl-Visual*
  4246. Visual Visual mode selection.
  4247. *hl-VisualNOS*
  4248. VisualNOS Visual mode selection when vim is "Not Owning the Selection".
  4249. Only X11 Gui's |gui-x11| and |xterm-clipboard| supports this.
  4250. *hl-WarningMsg*
  4251. WarningMsg Warning messages.
  4252. *hl-WildMenu*
  4253. WildMenu Current match in 'wildmenu' completion.
  4254. *hl-User1* *hl-User1..9* *hl-User9*
  4255. The 'statusline' syntax allows the use of 9 different highlights in the
  4256. statusline and ruler (via 'rulerformat'). The names are User1 to User9.
  4257. For the GUI you can use the following groups to set the colors for the menu,
  4258. scrollbars and tooltips. They don't have defaults. This doesn't work for the
  4259. Win32 GUI. Only three highlight arguments have any effect here: font, guibg,
  4260. and guifg.
  4261. *hl-Menu*
  4262. Menu Current font, background and foreground colors of the menus.
  4263. Also used for the toolbar.
  4264. Applicable highlight arguments: font, guibg, guifg.
  4265. NOTE: For Motif the font argument actually
  4266. specifies a fontset at all times, no matter if 'guifontset' is
  4267. empty, and as such it is tied to the current |:language| when
  4268. set.
  4269. *hl-Scrollbar*
  4270. Scrollbar Current background and foreground of the main window's
  4271. scrollbars.
  4272. Applicable highlight arguments: guibg, guifg.
  4273. *hl-Tooltip*
  4274. Tooltip Current font, background and foreground of the tooltips.
  4275. Applicable highlight arguments: font, guibg, guifg.
  4276. NOTE: For Motif the font argument actually
  4277. specifies a fontset at all times, no matter if 'guifontset' is
  4278. empty, and as such it is tied to the current |:language| when
  4279. set.
  4280. ==============================================================================
  4281. 15. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
  4282. When you want to use the same highlighting for several syntax groups, you
  4283. can do this more easily by linking the groups into one common highlight
  4284. group, and give the color attributes only for that group.
  4285. To set a link:
  4286. :hi[ghlight][!] [default] link {from-group} {to-group}
  4287. To remove a link:
  4288. :hi[ghlight][!] [default] link {from-group} NONE
  4289. Notes: *E414*
  4290. - If the {from-group} and/or {to-group} doesn't exist, it is created. You
  4291. don't get an error message for a non-existing group.
  4292. - As soon as you use a ":highlight" command for a linked group, the link is
  4293. removed.
  4294. - If there are already highlight settings for the {from-group}, the link is
  4295. not made, unless the '!' is given. For a ":highlight link" command in a
  4296. sourced file, you don't get an error message. This can be used to skip
  4297. links for groups that already have settings.
  4298. *:hi-default* *:highlight-default*
  4299. The [default] argument is used for setting the default highlighting for a
  4300. group. If highlighting has already been specified for the group the command
  4301. will be ignored. Also when there is an existing link.
  4302. Using [default] is especially useful to overrule the highlighting of a
  4303. specific syntax file. For example, the C syntax file contains: >
  4304. :highlight default link cComment Comment
  4305. If you like Question highlighting for C comments, put this in your vimrc file: >
  4306. :highlight link cComment Question
  4307. Without the "default" in the C syntax file, the highlighting would be
  4308. overruled when the syntax file is loaded.
  4309. To have a link survive `:highlight clear`, which is useful if you have
  4310. highlighting for a specific filetype and you want to keep it when selecting
  4311. another color scheme, put a command like this in the
  4312. "after/syntax/{filetype}.vim" file: >
  4313. highlight! default link cComment Question
  4314. ==============================================================================
  4315. 16. Cleaning up *:syn-clear* *E391*
  4316. If you want to clear the syntax stuff for the current buffer, you can use this
  4317. command: >
  4318. :syntax clear
  4319. This command should be used when you want to switch off syntax highlighting,
  4320. or when you want to switch to using another syntax. It's normally not needed
  4321. in a syntax file itself, because syntax is cleared by the autocommands that
  4322. load the syntax file.
  4323. The command also deletes the "b:current_syntax" variable, since no syntax is
  4324. loaded after this command.
  4325. To clean up specific syntax groups for the current buffer: >
  4326. :syntax clear {group-name} ..
  4327. This removes all patterns and keywords for {group-name}.
  4328. To clean up specific syntax group lists for the current buffer: >
  4329. :syntax clear @{grouplist-name} ..
  4330. This sets {grouplist-name}'s contents to an empty list.
  4331. *:syntax-off* *:syn-off*
  4332. If you want to disable syntax highlighting for all buffers, you need to remove
  4333. the autocommands that load the syntax files: >
  4334. :syntax off
  4335. What this command actually does, is executing the command >
  4336. :source $VIMRUNTIME/syntax/nosyntax.vim
  4337. See the "nosyntax.vim" file for details. Note that for this to work
  4338. $VIMRUNTIME must be valid. See |$VIMRUNTIME|.
  4339. *:syntax-reset* *:syn-reset*
  4340. If you have changed the colors and messed them up, use this command to get the
  4341. defaults back: >
  4342. :syntax reset
  4343. It is a bit of a wrong name, since it does not reset any syntax items, it only
  4344. affects the highlighting.
  4345. This doesn't change the colors for the 'highlight' option.
  4346. Note that the syntax colors that you set in your vimrc file will also be reset
  4347. back to their Vim default.
  4348. Note that if you are using a color scheme, the colors defined by the color
  4349. scheme for syntax highlighting will be lost.
  4350. What this actually does is: >
  4351. let g:syntax_cmd = "reset"
  4352. runtime! syntax/syncolor.vim
  4353. Note that this uses the 'runtimepath' option.
  4354. *syncolor*
  4355. If you want to use different colors for syntax highlighting, you can add a Vim
  4356. script file to set these colors. Put this file in a directory in
  4357. 'runtimepath' which comes after $VIMRUNTIME, so that your settings overrule
  4358. the default colors. This way these colors will be used after the ":syntax
  4359. reset" command.
  4360. For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: >
  4361. if &background == "light"
  4362. highlight comment ctermfg=darkgreen guifg=darkgreen
  4363. else
  4364. highlight comment ctermfg=green guifg=green
  4365. endif
  4366. <
  4367. *E679*
  4368. Do make sure this syncolor.vim script does not use a "syntax on", set the
  4369. 'background' option or uses a "colorscheme" command, because it results in an
  4370. endless loop.
  4371. Note that when a color scheme is used, there might be some confusion whether
  4372. your defined colors are to be used or the colors from the scheme. This
  4373. depends on the color scheme file. See |:colorscheme|.
  4374. *syntax_cmd*
  4375. The "syntax_cmd" variable is set to one of these values when the
  4376. syntax/syncolor.vim files are loaded:
  4377. "on" `:syntax on` command. Highlight colors are overruled but
  4378. links are kept
  4379. "enable" `:syntax enable` command. Only define colors for groups that
  4380. don't have highlighting yet. Use `:highlight default` .
  4381. "reset" `:syntax reset` command or loading a color scheme. Define all
  4382. the colors.
  4383. "skip" Don't define colors. Used to skip the default settings when a
  4384. syncolor.vim file earlier in 'runtimepath' has already set
  4385. them.
  4386. ==============================================================================
  4387. 17. Highlighting tags *tag-highlight*
  4388. If you want to highlight all the tags in your file, you can use the following
  4389. mappings.
  4390. <F11> -- Generate tags.vim file, and highlight tags.
  4391. <F12> -- Just highlight tags based on existing tags.vim file.
  4392. >
  4393. :map <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
  4394. :map <F12> :so tags.vim<CR>
  4395. WARNING: The longer the tags file, the slower this will be, and the more
  4396. memory Vim will consume.
  4397. Only highlighting typedefs, unions and structs can be done too. For this you
  4398. must use Universal Ctags (found at https://ctags.io) or Exuberant ctags (found
  4399. at http://ctags.sf.net).
  4400. Put these lines in your Makefile:
  4401. # Make a highlight file for types. Requires Universal/Exuberant ctags and awk
  4402. types: types.vim
  4403. types.vim: *.[ch]
  4404. ctags --c-kinds=gstu -o- *.[ch] |\
  4405. awk 'BEGIN{printf("syntax keyword Type\t")}\
  4406. {printf("%s ", $$1)}END{print ""}' > $@
  4407. And put these lines in your .vimrc: >
  4408. " load the types.vim highlighting file, if it exists
  4409. autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') .. '/types.vim'
  4410. autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
  4411. autocmd BufRead,BufNewFile *.[ch] exe 'so ' .. fname
  4412. autocmd BufRead,BufNewFile *.[ch] endif
  4413. ==============================================================================
  4414. 18. Window-local syntax *:ownsyntax*
  4415. Normally all windows on a buffer share the same syntax settings. It is
  4416. possible, however, to set a particular window on a file to have its own
  4417. private syntax setting. A possible example would be to edit LaTeX source
  4418. with conventional highlighting in one window, while seeing the same source
  4419. highlighted differently (so as to hide control sequences and indicate bold,
  4420. italic etc regions) in another. The 'scrollbind' option is useful here.
  4421. To set the current window to have the syntax "foo", separately from all other
  4422. windows on the buffer: >
  4423. :ownsyntax foo
  4424. < *w:current_syntax*
  4425. This will set the "w:current_syntax" variable to "foo". The value of
  4426. "b:current_syntax" does not change. This is implemented by saving and
  4427. restoring "b:current_syntax", since the syntax files do set
  4428. "b:current_syntax". The value set by the syntax file is assigned to
  4429. "w:current_syntax".
  4430. Note: This resets the 'spell', 'spellcapcheck' and 'spellfile' options.
  4431. Once a window has its own syntax, syntax commands executed from other windows
  4432. on the same buffer (including :syntax clear) have no effect. Conversely,
  4433. syntax commands executed from that window do not affect other windows on the
  4434. same buffer.
  4435. A window with its own syntax reverts to normal behavior when another buffer
  4436. is loaded into that window or the file is reloaded.
  4437. When splitting the window, the new window will use the original syntax.
  4438. ==============================================================================
  4439. 19. Color xterms *xterm-color* *color-xterm*
  4440. Most color xterms have only eight colors. If you don't get colors with the
  4441. default setup, it should work with these lines in your .vimrc: >
  4442. :if &term =~ "xterm"
  4443. : if has("terminfo")
  4444. : set t_Co=8
  4445. : set t_Sf=<Esc>[3%p1%dm
  4446. : set t_Sb=<Esc>[4%p1%dm
  4447. : else
  4448. : set t_Co=8
  4449. : set t_Sf=<Esc>[3%dm
  4450. : set t_Sb=<Esc>[4%dm
  4451. : endif
  4452. :endif
  4453. < [<Esc> is a real escape, type CTRL-V <Esc>]
  4454. You might want to change the first "if" to match the name of your terminal,
  4455. e.g. "dtterm" instead of "xterm".
  4456. Note: Do these settings BEFORE doing ":syntax on". Otherwise the colors may
  4457. be wrong.
  4458. *xiterm* *rxvt*
  4459. The above settings have been mentioned to work for xiterm and rxvt too.
  4460. But for using 16 colors in an rxvt these should work with terminfo: >
  4461. :set t_AB=<Esc>[%?%p1%{8}%<%t25;%p1%{40}%+%e5;%p1%{32}%+%;%dm
  4462. :set t_AF=<Esc>[%?%p1%{8}%<%t22;%p1%{30}%+%e1;%p1%{22}%+%;%dm
  4463. <
  4464. *colortest.vim*
  4465. To test your color setup, a file has been included in the Vim distribution.
  4466. To use it, execute this command: >
  4467. :runtime syntax/colortest.vim
  4468. Some versions of xterm (and other terminals, like the Linux console) can
  4469. output lighter foreground colors, even though the number of colors is defined
  4470. at 8. Therefore Vim sets the "cterm=bold" attribute for light foreground
  4471. colors, when 't_Co' is 8.
  4472. *xfree-xterm*
  4473. To get 16 colors or more, get the newest xterm version (which should be
  4474. included with XFree86 3.3 and later). You can also find the latest version
  4475. at: >
  4476. http://invisible-island.net/xterm/xterm.html
  4477. Here is a good way to configure it. This uses 88 colors and enables the
  4478. termcap-query feature, which allows Vim to ask the xterm how many colors it
  4479. supports. >
  4480. ./configure --disable-bold-color --enable-88-color --enable-tcap-query
  4481. If you only get 8 colors, check the xterm compilation settings.
  4482. (Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
  4483. This xterm should work with these lines in your .vimrc (for 16 colors): >
  4484. :if has("terminfo")
  4485. : set t_Co=16
  4486. : set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
  4487. : set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
  4488. :else
  4489. : set t_Co=16
  4490. : set t_Sf=<Esc>[3%dm
  4491. : set t_Sb=<Esc>[4%dm
  4492. :endif
  4493. < [<Esc> is a real escape, type CTRL-V <Esc>]
  4494. Without |+terminfo|, Vim will recognize these settings, and automatically
  4495. translate cterm colors of 8 and above to "<Esc>[9%dm" and "<Esc>[10%dm".
  4496. Colors above 16 are also translated automatically.
  4497. For 256 colors this has been reported to work: >
  4498. :set t_AB=<Esc>[48;5;%dm
  4499. :set t_AF=<Esc>[38;5;%dm
  4500. Or just set the TERM environment variable to "xterm-color" or "xterm-16color"
  4501. and try if that works.
  4502. You probably want to use these X resources (in your ~/.Xdefaults file):
  4503. XTerm*color0: #000000
  4504. XTerm*color1: #c00000
  4505. XTerm*color2: #008000
  4506. XTerm*color3: #808000
  4507. XTerm*color4: #0000c0
  4508. XTerm*color5: #c000c0
  4509. XTerm*color6: #008080
  4510. XTerm*color7: #c0c0c0
  4511. XTerm*color8: #808080
  4512. XTerm*color9: #ff6060
  4513. XTerm*color10: #00ff00
  4514. XTerm*color11: #ffff00
  4515. XTerm*color12: #8080ff
  4516. XTerm*color13: #ff40ff
  4517. XTerm*color14: #00ffff
  4518. XTerm*color15: #ffffff
  4519. Xterm*cursorColor: Black
  4520. [Note: The cursorColor is required to work around a bug, which changes the
  4521. cursor color to the color of the last drawn text. This has been fixed by a
  4522. newer version of xterm, but not everybody is using it yet.]
  4523. To get these right away, reload the .Xdefaults file to the X Option database
  4524. Manager (you only need to do this when you just changed the .Xdefaults file): >
  4525. xrdb -merge ~/.Xdefaults
  4526. <
  4527. *xterm-blink* *xterm-blinking-cursor*
  4528. To make the cursor blink in an xterm, see tools/blink.c. Or use Thomas
  4529. Dickey's xterm above patchlevel 107 (see above for where to get it), with
  4530. these resources:
  4531. XTerm*cursorBlink: on
  4532. XTerm*cursorOnTime: 400
  4533. XTerm*cursorOffTime: 250
  4534. XTerm*cursorColor: White
  4535. *hpterm-color*
  4536. These settings work (more or less) for an hpterm, which only supports 8
  4537. foreground colors: >
  4538. :if has("terminfo")
  4539. : set t_Co=8
  4540. : set t_Sf=<Esc>[&v%p1%dS
  4541. : set t_Sb=<Esc>[&v7S
  4542. :else
  4543. : set t_Co=8
  4544. : set t_Sf=<Esc>[&v%dS
  4545. : set t_Sb=<Esc>[&v7S
  4546. :endif
  4547. < [<Esc> is a real escape, type CTRL-V <Esc>]
  4548. *Eterm* *enlightened-terminal*
  4549. These settings have been reported to work for the Enlightened terminal
  4550. emulator, or Eterm. They might work for all xterm-like terminals that use the
  4551. bold attribute to get bright colors. Add an ":if" like above when needed. >
  4552. :set t_Co=16
  4553. :set t_AF=^[[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
  4554. :set t_AB=^[[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m
  4555. <
  4556. *TTpro-telnet*
  4557. These settings should work for TTpro telnet. Tera Term Pro is a freeware /
  4558. open-source program for MS-Windows. >
  4559. set t_Co=16
  4560. set t_AB=^[[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{32}%+5;%;%dm
  4561. set t_AF=^[[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{22}%+1;%;%dm
  4562. Also make sure TTpro's Setup / Window / Full Color is enabled, and make sure
  4563. that Setup / Font / Enable Bold is NOT enabled.
  4564. (info provided by John Love-Jensen <eljay@Adobe.COM>)
  4565. ==============================================================================
  4566. 20. When syntax is slow *:syntime*
  4567. This is aimed at authors of a syntax file.
  4568. If your syntax causes redrawing to be slow, here are a few hints on making it
  4569. faster. To see slowness switch on some features that usually interfere, such
  4570. as 'relativenumber' and |folding|.
  4571. Note: This is only available when compiled with the |+profile| feature.
  4572. You many need to build Vim with "huge" features.
  4573. To find out what patterns are consuming most time, get an overview with this
  4574. sequence: >
  4575. :syntime on
  4576. [ redraw the text at least once with CTRL-L ]
  4577. :syntime report
  4578. This will display a list of syntax patterns that were used, sorted by the time
  4579. it took to match them against the text.
  4580. :syntime on Start measuring syntax times. This will add some
  4581. overhead to compute the time spent on syntax pattern
  4582. matching.
  4583. :syntime off Stop measuring syntax times.
  4584. :syntime clear Set all the counters to zero, restart measuring.
  4585. :syntime report Show the syntax items used since ":syntime on" in the
  4586. current window. Use a wider display to see more of
  4587. the output.
  4588. The list is sorted by total time. The columns are:
  4589. TOTAL Total time in seconds spent on
  4590. matching this pattern.
  4591. COUNT Number of times the pattern was used.
  4592. MATCH Number of times the pattern actually
  4593. matched
  4594. SLOWEST The longest time for one try.
  4595. AVERAGE The average time for one try.
  4596. NAME Name of the syntax item. Note that
  4597. this is not unique.
  4598. PATTERN The pattern being used.
  4599. Pattern matching gets slow when it has to try many alternatives. Try to
  4600. include as much literal text as possible to reduce the number of ways a
  4601. pattern does NOT match.
  4602. When using the "\@<=" and "\@<!" items, add a maximum size to avoid trying at
  4603. all positions in the current and previous line. For example, if the item is
  4604. literal text specify the size of that text (in bytes):
  4605. "<\@<=span" Matches "span" in "<span". This tries matching with "<" in
  4606. many places.
  4607. "<\@1<=span" Matches the same, but only tries one byte before "span".
  4608. vim:tw=78:sw=4:ts=8:noet:ft=help:norl: