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