robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1*syntax.txt* Nvim 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 23 Type |gO| to see the table of contents. 24 25============================================================================== 261. Quick start *:syn-qstart* 27 28 *:syn-enable* *:syntax-enable* *:syn-on* *:syntax-on* 29Syntax highlighting is enabled by default. If you need to enable it again 30after it was disabled (see below), use: > 31 32 :syntax enable 33 34Alternatively: > 35 36 :syntax on 37 38What this command actually does is to execute the command > 39 :source $VIMRUNTIME/syntax/syntax.vim 40 41If the VIM environment variable is not set, Vim will try to find 42the path in another way (see |$VIMRUNTIME|). Usually this works just 43fine. If it doesn't, try setting the VIM environment variable to the 44directory where the Vim stuff is located. For example, if your syntax files 45are in the "/usr/vim/vim82/syntax" directory, set $VIMRUNTIME to 46"/usr/vim/vim82". You must do this in the shell, before starting Vim. 47This command also sources the |menu.vim| script when the GUI is running or 48will start soon. 49 50 *:hi-normal* *:highlight-normal* 51If you are running in the GUI, you can get white text on a black background 52with: > 53 :highlight Normal guibg=Black guifg=White 54For a color terminal see |:hi-normal-cterm|. 55 56NOTE: The syntax files on MS-Windows have lines that end in <CR><NL>. 57The files for Unix end in <NL>. This means you should use the right type of 58file for your system. Although on MS-Windows the right format is 59automatically selected if the 'fileformats' option is not empty. 60 61NOTE: When using reverse video ("gvim -fg white -bg black"), the default value 62of 'background' will not be set until the GUI window is opened, which is after 63reading the |gvimrc|. This will cause the wrong default highlighting to be 64used. To set the default value of 'background' before switching on 65highlighting, include the ":gui" command in the |gvimrc|: > 66 67 :gui " open window and set default for 'background' 68 :syntax on " start highlighting, use 'background' to set colors 69 70NOTE: Using ":gui" in the |gvimrc| means that "gvim -f" won't start in the 71foreground! Use ":gui -f" then. 72 73 *g:syntax_on* 74You can toggle the syntax on/off with this command: > 75 :if exists("g:syntax_on") | syntax off | else | syntax enable | endif 76 77To put this into a mapping, you can use: > 78 :map <F7> :if exists("g:syntax_on") <Bar> 79 \ syntax off <Bar> 80 \ else <Bar> 81 \ syntax enable <Bar> 82 \ endif <CR> 83[using the |<>| notation, type this literally] 84 85Details: 86The ":syntax" commands are implemented by sourcing a file. To see exactly how 87this works, look in the file: 88 command file ~ 89 :syntax enable $VIMRUNTIME/syntax/syntax.vim 90 :syntax on $VIMRUNTIME/syntax/syntax.vim 91 :syntax manual $VIMRUNTIME/syntax/manual.vim 92 :syntax off $VIMRUNTIME/syntax/nosyntax.vim 93Also see |syntax-loading|. 94 95NOTE: If displaying long lines is slow and switching off syntax highlighting 96makes it fast, consider setting the 'synmaxcol' option to a lower value. 97 98============================================================================== 992. Syntax files *:syn-files* 100 101The syntax and highlighting commands for one language are normally stored in 102a syntax file. The name convention is: "{name}.vim". Where {name} is the 103name of the language, or an abbreviation (to fit the name in 8.3 characters, 104a requirement in case the file is used on a DOS filesystem). 105Examples: 106 c.vim perl.vim java.vim html.vim 107 cpp.vim sh.vim csh.vim 108 109The syntax file can contain any Ex commands, just like a vimrc file. But 110the idea is that only commands for a specific language are included. When a 111language is a superset of another language, it may include the other one, 112for example, the cpp.vim file could include the c.vim file: > 113 :so $VIMRUNTIME/syntax/c.vim 114 115The .vim files are normally loaded with an autocommand. For example: > 116 :au Syntax c runtime! syntax/c.vim 117 :au Syntax cpp runtime! syntax/cpp.vim 118These commands are normally in the file $VIMRUNTIME/syntax/synload.vim. 119 120 121MAKING YOUR OWN SYNTAX FILES *mysyntaxfile* 122 123When you create your own syntax files, and you want to have Vim use these 124automatically with ":syntax enable", do this: 125 1261. Create your user runtime directory. You would normally use the first item 127 of the 'runtimepath' option. Example for Unix: > 128 mkdir ~/.config/nvim 129 1302. Create a directory in there called "syntax". For Unix: > 131 mkdir ~/.config/nvim/syntax 132 1333. Write the Vim syntax file. Or download one from the internet. Then write 134 it in your syntax directory. For example, for the "mine" syntax: > 135 :w ~/.config/nvim/syntax/mine.vim 136 137Now you can start using your syntax file manually: > 138 :set syntax=mine 139You don't have to exit Vim to use this. 140 141If you also want Vim to detect the type of file, see |new-filetype|. 142 143If you are setting up a system with many users and you don't want each user 144to add the same syntax file, you can use another directory from 'runtimepath'. 145 146 147ADDING TO AN EXISTING SYNTAX FILE *mysyntaxfile-add* 148 149If you are mostly satisfied with an existing syntax file, but would like to 150add a few items or change the highlighting, follow these steps: 151 1521. Create your user directory from 'runtimepath', see above. 153 1542. Create a directory in there called "after/syntax". For Unix: > 155 mkdir -p ~/.config/nvim/after/syntax 156 1573. Write a Vim script that contains the commands you want to use. For 158 example, to change the colors for the C syntax: > 159 highlight cComment ctermfg=Green guifg=Green 160 1614. Write that file in the "after/syntax" directory. Use the name of the 162 syntax, with ".vim" added. For our C syntax: > 163 :w ~/.config/nvim/after/syntax/c.vim 164 165That's it. The next time you edit a C file the Comment color will be 166different. You don't even have to restart Vim. 167 168If you have multiple files, you can use the filetype as the directory name. 169All the "*.vim" files in this directory will be used, for example: 170 ~/.config/nvim/after/syntax/c/one.vim 171 ~/.config/nvim/after/syntax/c/two.vim 172 173 174REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace* 175 176If you don't like a distributed syntax file, or you have downloaded a new 177version, follow the same steps as for |mysyntaxfile| above. Just make sure 178that you write the syntax file in a directory that is early in 'runtimepath'. 179Vim will only load the first syntax file found, assuming that it sets 180b:current_syntax. 181 182 183NAMING CONVENTIONS *group-name* *{group-name}* *E669* *E5248* 184 185A syntax group name is to be used for syntax items that match the same kind of 186thing. These are then linked to a highlight group that specifies the color. 187A syntax group name doesn't specify any color or attributes itself. 188 189The name for a highlight or syntax group must consist of ASCII letters, 190digits, underscores, dots, hyphens, or `@`. As a regexp: `[a-zA-Z0-9_.@-]*`. 191The maximum length of a group name is about 200 bytes. *E1249* 192 193To be able to allow each user to pick their favorite set of colors, there must 194be preferred names for highlight groups that are common for many languages. 195These are the suggested group names (if syntax highlighting works properly 196you can see the actual color, except for "Ignore"): 197 198Comment any comment 199 200Constant any constant 201String a string constant: "this is a string" 202Character a character constant: 'c', '\n' 203Number a number constant: 234, 0xff 204Boolean a boolean constant: TRUE, false 205Regexp a regular expression constant: /ab*c/ 206Float a floating point constant: 2.3e10 207 208Identifier any variable name 209Function function name (also: methods for classes) 210 211Statement any statement 212Conditional if, then, else, endif, switch, etc. 213Repeat for, do, while, etc. 214Label case, default, etc. 215Operator "sizeof", "+", "*", etc. 216Keyword any other keyword 217Exception try, catch, throw 218 219PreProc generic Preprocessor 220Include preprocessor #include 221Define preprocessor #define 222Macro same as Define 223PreCondit preprocessor #if, #else, #endif, etc. 224 225Type int, long, char, etc. 226StorageClass static, register, volatile, etc. 227Structure struct, union, enum, etc. 228Typedef a typedef 229 230Special any special symbol 231SpecialChar special character in a constant 232Tag you can use CTRL-] on this 233Delimiter character that needs attention 234SpecialComment special things inside a comment 235Debug debugging statements 236 237Underlined text that stands out, HTML links 238Bold bold text 239Italic italic text 240BoldItalic bold and italic text 241Dimmed text that is de-emphasized 242 243Ignore left blank, hidden |hl-Ignore| 244 245Error any erroneous construct 246 247Todo anything that needs extra attention; mostly the 248 keywords TODO FIXME and XXX 249 250Added added line in a diff 251Changed changed line in a diff 252Removed removed line in a diff 253 254Note that highlight group names are not case sensitive. "String" and "string" 255can be used for the same group. 256 257The following names are reserved and cannot be used as a group name: 258 NONE ALL ALLBUT contains contained 259 260 *hl-Ignore* 261When using the Ignore group, you may also consider using the conceal 262mechanism. See |conceal|. 263 264============================================================================== 2653. Syntax loading procedure *syntax-loading* 266 267This explains the details that happen when the command ":syntax enable" is 268issued. When Vim initializes itself, it finds out where the runtime files are 269located. This is used here as the variable |$VIMRUNTIME|. 270 271":syntax enable" and ":syntax on" do the following: 272 273 Source $VIMRUNTIME/syntax/syntax.vim 274 | 275 +- Clear out any old syntax by sourcing $VIMRUNTIME/syntax/nosyntax.vim 276 | 277 +- Source first syntax/synload.vim in 'runtimepath' 278 | | 279 | +- Set up syntax autocmds to load the appropriate syntax file when 280 | | the 'syntax' option is set. *synload-1* 281 | | 282 | +- Source the user's optional file, from the |mysyntaxfile| variable. 283 | This is for backwards compatibility with Vim 5.x only. *synload-2* 284 | 285 +- Do ":filetype on", which does ":runtime! filetype.vim". It loads any 286 | filetype.vim files found. It should always Source 287 | $VIMRUNTIME/filetype.vim, which does the following. 288 | | 289 | +- Install autocmds based on suffix to set the 'filetype' option 290 | | This is where the connection between file name and file type is 291 | | made for known file types. *synload-3* 292 | | 293 | +- Source the user's optional file, from the *myfiletypefile* 294 | | variable. This is for backwards compatibility with Vim 5.x only. 295 | | *synload-4* 296 | | 297 | +- Install one autocommand which sources scripts.vim when no file 298 | | type was detected yet. *synload-5* 299 | | 300 | +- Source $VIMRUNTIME/menu.vim, to setup the Syntax menu. |menu.vim| 301 | 302 +- Install a FileType autocommand to set the 'syntax' option when a file 303 | type has been detected. *synload-6* 304 | 305 +- Execute syntax autocommands to start syntax highlighting for each 306 already loaded buffer. 307 308 309Upon loading a file, Vim finds the relevant syntax file as follows: 310 311 Loading the file triggers the BufReadPost autocommands. 312 | 313 +- If there is a match with one of the autocommands from |synload-3| 314 | (known file types) or |synload-4| (user's file types), the 'filetype' 315 | option is set to the file type. 316 | 317 +- The autocommand at |synload-5| is triggered. If the file type was not 318 | found yet, then scripts.vim is searched for in 'runtimepath'. This 319 | should always load $VIMRUNTIME/scripts.vim, which does the following. 320 | | 321 | +- Source the user's optional file, from the *myscriptsfile* 322 | | variable. This is for backwards compatibility with Vim 5.x only. 323 | | 324 | +- If the file type is still unknown, check the contents of the file, 325 | again with checks like "getline(1) =~ pattern" as to whether the 326 | file type can be recognized, and set 'filetype'. 327 | 328 +- When the file type was determined and 'filetype' was set, this 329 | triggers the FileType autocommand |synload-6| above. It sets 330 | 'syntax' to the determined file type. 331 | 332 +- When the 'syntax' option was set above, this triggers an autocommand 333 | from |synload-1| (and |synload-2|). This find the main syntax file in 334 | 'runtimepath', with this command: 335 | runtime! syntax/<name>.vim 336 | 337 +- Any other user installed FileType or Syntax autocommands are 338 triggered. This can be used to change the highlighting for a specific 339 syntax. 340 341============================================================================== 3424. Conversion to HTML *convert-to-HTML* *2html.vim* 343 344The old to html converter has been replaced by a Lua version and the 345documentation has been moved to |:TOhtml|. 346 347============================================================================== 3485. Syntax file remarks *:syn-file-remarks* 349 350 *b:current_syntax-variable* 351Vim stores the name of the syntax that has been loaded in the 352"b:current_syntax" variable. You can use this if you want to load other 353settings, depending on which syntax is active. Example: > 354 :au BufReadPost * if b:current_syntax == "csh" 355 :au BufReadPost * do-some-things 356 :au BufReadPost * endif 357 358 359 360ABEL *ft-abel-syntax* 361 362ABEL highlighting provides some user-defined options. To enable them, assign 363any value to the respective variable. Example: > 364 :let abel_obsolete_ok=1 365To disable them use ":unlet". Example: > 366 :unlet abel_obsolete_ok 367 368Variable Highlight ~ 369abel_obsolete_ok obsolete keywords are statements, not errors 370abel_cpp_comments_illegal do not interpret '//' as inline comment leader 371 372 373ADA 374 375See |ft-ada-syntax| 376 377 378ALGOL 68 *algol68* *ft-algol68-syntax* 379 380This syntax file currently targets the Algol 68 Genie project using the 381default UPPER stropping regime. It should also be usable in other 382environments using the UPPER stropping regime, though somewhat less complete. 383 384Highlighting can be further configured with the following variables. 385 386Variable Highlight ~ 387*algol68_no_preludes* no prelude identifiers, procedures or 388 operators 389 390 391ANT *ft-ant-syntax* 392 393The ant syntax file provides syntax highlighting for javascript and python 394by default. Syntax highlighting for other script languages can be installed 395by the function AntSyntaxScript(), which takes the tag name as first argument 396and the script syntax file name as second argument. Example: > 397 398 :call AntSyntaxScript('perl', 'perl.vim') 399 400will install syntax perl highlighting for the following ant code > 401 402 <script language = 'perl'><![CDATA[ 403 # everything inside is highlighted as perl 404 ]]></script> 405 406See |mysyntaxfile-add| for installing script languages permanently. 407 408 409APACHE *ft-apache-syntax* 410 411The apache syntax file provides syntax highlighting for Apache HTTP server 412version 2.2.3. 413 414 415ASSEMBLY *asm68k* *ft-asm-syntax* *ft-asmh8300-syntax* *ft-nasm-syntax* 416 *ft-masm-syntax* *ft-asm68k-syntax* 417 418Files matching "*.i" could be Progress or Assembly. If the automatic 419detection doesn't work for you, or you don't edit Progress at all, use this in 420your startup vimrc: > 421 :let filetype_i = "asm" 422Replace "asm" with the type of assembly you use. 423 424There are many types of assembly languages that all use the same file name 425extensions. Therefore you will have to select the type yourself, or add a 426line in the assembly file that Vim will recognize. Currently these syntax 427files are included: 428 asm GNU assembly (usually have .s or .S extension and were 429 already built using C compiler such as GCC or CLANG) 430 asm68k Motorola 680x0 assembly 431 asmh8300 Hitachi H-8300 version of GNU assembly 432 ia64 Intel Itanium 64 433 fasm Flat assembly (https://flatassembler.net) 434 masm Microsoft assembly (.masm files are compiled with 435 Microsoft's Macro Assembler. This is only supported 436 for x86, x86_64, ARM and AARCH64 CPU families) 437 nasm Netwide assembly 438 tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and 439 MMX) 440 pic PIC assembly (currently for PIC16F84) 441 442The most flexible is to add a line in your assembly file containing: > 443 asmsyntax=nasm 444Replace "nasm" with the name of the real assembly syntax. This line must be 445one of the first five lines in the file. No non-white text must be 446immediately before or after this text. Note that specifying asmsyntax=foo is 447equivalent to setting ft=foo in a |modeline|, and that in case of a conflict 448between the two settings the one from the modeline will take precedence (in 449particular, if you have ft=asm in the modeline, you will get the GNU syntax 450highlighting regardless of what is specified as asmsyntax). 451 452The syntax type can always be overruled for a specific buffer by setting the 453b:asmsyntax variable: > 454 :let b:asmsyntax = "nasm" 455 456If b:asmsyntax is not set, either automatically or by hand, then the value of 457the global variable asmsyntax is used. This can be seen as a default assembly 458language: > 459 :let asmsyntax = "nasm" 460 461As a last resort, if nothing is defined, the "asm" syntax is used. 462 463 464Netwide assembler (nasm.vim) optional highlighting ~ 465 466To enable a feature: > 467 :let {variable}=1|set syntax=nasm 468To disable a feature: > 469 :unlet {variable} |set syntax=nasm 470 471Variable Highlight ~ 472nasm_loose_syntax unofficial parser allowed syntax not as Error 473 (parser dependent; not recommended) 474nasm_ctx_outside_macro contexts outside macro not as Error 475nasm_no_warn potentially risky syntax not as ToDo 476 477ASTRO *ft-astro-syntax* 478 479Configuration 480 481The following variables control certain syntax highlighting features. 482You can add them to your .vimrc. 483 484To enable TypeScript and TSX for ".astro" files (default "disable"): > 485 let g:astro_typescript = "enable" 486< 487To enable Stylus for ".astro" files (default "disable"): > 488 let g:astro_stylus = "enable" 489< 490NOTE: You need to install an external plugin to support stylus in astro files. 491 492 493ASPPERL *ft-aspperl-syntax* 494ASPVBS *ft-aspvbs-syntax* 495 496`*.asp` and `*.asa` files could be either Perl or Visual Basic script. Since it's 497hard to detect this you can set two global variables to tell Vim what you are 498using. For Perl script use: > 499 :let g:filetype_asa = "aspperl" 500 :let g:filetype_asp = "aspperl" 501For Visual Basic use: > 502 :let g:filetype_asa = "aspvbs" 503 :let g:filetype_asp = "aspvbs" 504 505ASYMPTOTE *ft-asy-syntax* 506 507By default, only basic Asymptote keywords are highlighted. To highlight 508extended geometry keywords: > 509 510 :let g:asy_syn_plain = 1 511 512and for highlighting keywords related to 3D constructions: > 513 514 :let g:asy_syn_three = 1 515 516By default, Asymptote-defined colors (e.g: lightblue) are highlighted. To 517highlight TeX-defined colors (e.g: BlueViolet) use: > 518 519 :let g:asy_syn_texcolors = 1 520 521or for Xorg colors (e.g: AliceBlue): > 522 523 :let g:asy_syn_x11colors = 1 524 525BAAN *baan-syntax* 526 527The baan.vim gives syntax support for BaanC of release BaanIV up to SSA ERP LN 528for both 3 GL and 4 GL programming. Large number of standard 529defines/constants are supported. 530 531Some special violation of coding standards will be signalled when one specify 532in ones |init.vim|: > 533 let baan_code_stds=1 534 535*baan-folding* 536 537Syntax folding can be enabled at various levels through the variables 538mentioned below (Set those in your |init.vim|). The more complex folding on 539source blocks and SQL can be CPU intensive. 540 541To allow any folding and enable folding at function level use: > 542 let baan_fold=1 543Folding can be enabled at source block level as if, while, for ,... The 544indentation preceding the begin/end keywords has to match (spaces are not 545considered equal to a tab). > 546 let baan_fold_block=1 547Folding can be enabled for embedded SQL blocks as SELECT, SELECTDO, 548SELECTEMPTY, ... The indentation preceding the begin/end keywords has to 549match (spaces are not considered equal to a tab). > 550 let baan_fold_sql=1 551Note: Block folding can result in many small folds. It is suggested to |:set| 552the options 'foldminlines' and 'foldnestmax' in |init.vim| or use |:setlocal| 553in .../after/syntax/baan.vim (see |after-directory|). Eg: > 554 set foldminlines=5 555 set foldnestmax=6 556 557 558BASIC *ft-basic-syntax* *ft-vb-syntax* 559 560Both Visual Basic and "normal" BASIC use the extension ".bas". To detect 561which one should be used, Vim checks for the string "VB_Name" in the first 562five lines of the file. If it is not found, filetype will be "basic", 563otherwise "vb". Files with the ".frm" extension will always be seen as Visual 564Basic. 565 566If the automatic detection doesn't work for you or you only edit, for 567example, FreeBASIC files, use this in your startup vimrc: > 568 :let filetype_bas = "freebasic" 569 570 571C *ft-c-syntax* 572 573A few things in C highlighting are optional. To enable them assign any value 574(including zero) to the respective variable. Example: > 575 :let c_comment_strings = 1 576 :let c_no_bracket_error = 0 577To disable them use `:unlet`. Example: > 578 :unlet c_comment_strings 579Setting the value to zero doesn't work! 580 581An alternative is to switch to the C++ highlighting: > 582 :set filetype=cpp 583 584Variable Highlight ~ 585*c_gnu* GNU gcc specific items 586*c_comment_strings* strings and numbers inside a comment 587*c_space_errors* trailing white space and spaces before a <Tab> 588*c_no_trail_space_error* ... but no trailing spaces 589*c_no_tab_space_error* ... but no spaces before a <Tab> 590*c_no_bracket_error* don't highlight {}; inside [] as errors 591*c_no_curly_error* don't highlight {}; inside [] and () as errors; 592 ...except { and } in first column 593 Default is to highlight them, otherwise you 594 can't spot a missing ")". 595*c_curly_error* highlight a missing } by finding all pairs; this 596 forces syncing from the start of the file, can be slow 597*c_no_ansi* don't do standard ANSI types and constants 598*c_ansi_typedefs* ... but do standard ANSI types 599*c_ansi_constants* ... but do standard ANSI constants 600*c_no_utf* don't highlight \u and \U in strings 601*c_syntax_for_h* use C syntax for `*.h` files instead of C++/ObjC/ObjC++ 602 (NOTE: This variable is deprecated and no longer 603 necessary, as `*.h` files now default to C, unless the 604 file contains C++ or Objective-C syntax. If the 605 automated detection fails, the default filetype can 606 be adjusted using `g:filetype_h`.) 607*c_no_if0* don't highlight "#if 0" blocks as comments 608*c_no_cformat* don't highlight %-formats in strings 609*c_no_c99* don't highlight C99 standard items 610*c_no_c11* don't highlight C11 standard items 611*c_no_c23* don't highlight C23 standard items 612*c_no_c29* don't highlight C29 standard items 613*c_no_bsd* don't highlight BSD specific types 614*c_functions* highlight function calls and definitions 615*c_function_pointers* highlight function pointers definitions 616 617When 'foldmethod' is set to "syntax" then `/* */` comments and { } blocks will 618become a fold. If you don't want comments to become a fold use: > 619 :let c_no_comment_fold = 1 620"#if 0" blocks are also folded, unless: > 621 :let c_no_if0_fold = 1 622 623If you notice highlighting errors while scrolling backwards, which are fixed 624when redrawing with CTRL-L, try setting the "c_minlines" internal variable 625to a larger number: > 626 :let c_minlines = 100 627This will make the syntax synchronization start 100 lines before the first 628displayed line. The default value is 50 (15 when c_no_if0 is set). The 629disadvantage of using a larger number is that redrawing can become slow. 630 631When using the "#if 0" / "#endif" comment highlighting, notice that this only 632works when the "#if 0" is within "c_minlines" from the top of the window. If 633you have a long "#if 0" construct it will not be highlighted correctly. 634 635To match extra items in comments, use the cCommentGroup cluster. 636Example: > 637 :au Syntax c call MyCadd() 638 :function MyCadd() 639 : syn keyword cMyItem contained Ni 640 : syn cluster cCommentGroup add=cMyItem 641 : hi link cMyItem Title 642 :endfun 643 644ANSI constants will be highlighted with the "cConstant" group. This includes 645"NULL", "SIG_IGN" and others. But not "TRUE", for example, because this is 646not in the ANSI standard. If you find this confusing, remove the cConstant 647highlighting: > 648 :hi link cConstant NONE 649 650If you see '{' and '}' highlighted as an error where they are OK, reset the 651highlighting for cErrInParen and cErrInBracket. 652 653If you want to use folding in your C files, you can add these lines in a file 654in the "after" directory in 'runtimepath'. For Unix this would be 655~/.config/nvim/after/syntax/c.vim. > 656 syn sync fromstart 657 set foldmethod=syntax 658 659CANGJIE *ft-cangjie-syntax* 660 661This file provides syntax highlighting for the Cangjie programming language, a 662new-generation language oriented to full-scenario intelligence. 663 664All highlighting is enabled by default. To disable highlighting for a 665specific group, set the corresponding variable to 0 in your |vimrc|. 666All options to disable highlighting are: > 667 :let g:cangjie_builtin_color = 0 668 :let g:cangjie_comment_color = 0 669 :let g:cangjie_identifier_color = 0 670 :let g:cangjie_keyword_color = 0 671 :let g:cangjie_macro_color = 0 672 :let g:cangjie_number_color = 0 673 :let g:cangjie_operator_color = 0 674 :let g:cangjie_string_color = 0 675 :let g:cangjie_type_color = 0 676 677CH *ft-ch-syntax* 678 679C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon 680the C syntax file. See |ft-c-syntax| for all the settings that are available 681for C. 682 683By setting a variable you can tell Vim to use Ch syntax for `*.h` files, instead 684of C or C++: > 685 :let g:filetype_h = 'ch' 686 687 688CHILL *ft-chill-syntax* 689 690Chill syntax highlighting is similar to C. See |ft-c-syntax| for all the 691settings that are available. Additionally there is: 692 693chill_space_errors like c_space_errors 694chill_comment_string like c_comment_strings 695chill_minlines like c_minlines 696 697 698CHANGELOG *ft-changelog-syntax* 699 700ChangeLog supports highlighting spaces at the start of a line. 701If you do not like this, add following line to your vimrc: > 702 let g:changelog_spacing_errors = 0 703This works the next time you edit a changelog file. You can also use 704"b:changelog_spacing_errors" to set this per buffer (before loading the syntax 705file). 706 707You can change the highlighting used, e.g., to flag the spaces as an error: > 708 :hi link ChangelogError Error 709Or to avoid the highlighting: > 710 :hi link ChangelogError NONE 711This works immediately. 712 713 714CLOJURE *ft-clojure-syntax* 715 716 *g:clojure_syntax_keywords* 717 718Syntax highlighting of public vars in "clojure.core" is provided by default, 719but additional symbols can be highlighted by adding them to the 720|g:clojure_syntax_keywords| variable. The value should be a |Dictionary| of 721syntax group names, each containing a |List| of identifiers. 722> 723 let g:clojure_syntax_keywords = { 724 \ 'clojureMacro': ["defproject", "defcustom"], 725 \ 'clojureFunc': ["string/join", "string/replace"] 726 \ } 727< 728Refer to the Clojure syntax script for valid syntax group names. 729 730There is also *b:clojure_syntax_keywords* which is a buffer-local variant of 731this variable intended for use by plugin authors to highlight symbols 732dynamically. 733 734By setting the *b:clojure_syntax_without_core_keywords* variable, vars from 735"clojure.core" will not be highlighted by default. This is useful for 736namespaces that have set `(:refer-clojure :only [])` 737 738 739 *g:clojure_fold* 740 741Setting |g:clojure_fold| to `1` will enable the folding of Clojure code. Any 742list, vector or map that extends over more than one line can be folded using 743the standard Vim |fold-commands|. 744 745 746 *g:clojure_discard_macro* 747 748Set this variable to `1` to enable basic highlighting of Clojure's "discard 749reader macro". 750> 751 #_(defn foo [x] 752 (println x)) 753< 754Note that this option will not correctly highlight stacked discard macros 755(e.g. `#_#_`). 756 757 758COBOL *ft-cobol-syntax* 759 760COBOL highlighting has different needs for legacy code than it does for fresh 761development. This is due to differences in what is being done (maintenance 762versus development) and other factors. To enable legacy code highlighting, 763add this line to your vimrc: > 764 :let cobol_legacy_code = 1 765To disable it again, use this: > 766 :unlet cobol_legacy_code 767 768 769COLD FUSION *ft-coldfusion-syntax* 770 771The ColdFusion has its own version of HTML comments. To turn on ColdFusion 772comment highlighting, add the following line to your startup file: > 773 774 :let html_wrong_comments = 1 775 776The ColdFusion syntax file is based on the HTML syntax file. 777 778 779CPP *ft-cpp-syntax* 780 781Most things are the same as |ft-c-syntax|. 782 783Variable Highlight ~ 784cpp_no_cpp11 don't highlight C++11 standard items 785cpp_no_cpp14 don't highlight C++14 standard items 786cpp_no_cpp17 don't highlight C++17 standard items 787cpp_no_cpp20 don't highlight C++20 standard items 788cpp_no_cpp23 don't highlight C++23 standard items 789cpp_no_cpp26 don't highlight C++26 standard items 790 791 792CSH *ft-csh-syntax* 793 794This covers the shell named "csh". Note that on some systems tcsh is actually 795used. 796 797Detecting whether a file is csh or tcsh is notoriously hard. Some systems 798symlink /bin/csh to /bin/tcsh, making it almost impossible to distinguish 799between csh and tcsh. In case VIM guesses wrong you can set the 800"filetype_csh" variable. For using csh: *g:filetype_csh* 801> 802 :let g:filetype_csh = "csh" 803 804For using tcsh: > 805 806 :let g:filetype_csh = "tcsh" 807 808Any script with a tcsh extension or a standard tcsh filename (.tcshrc, 809tcsh.tcshrc, tcsh.login) will have filetype tcsh. All other tcsh/csh scripts 810will be classified as tcsh, UNLESS the "filetype_csh" variable exists. If the 811"filetype_csh" variable exists, the filetype will be set to the value of the 812variable. 813 814CSV *ft-csv-syntax* 815 816If you change the delimiter of a CSV file, its syntax highlighting will no 817longer match the changed file content. You will need to unlet the following 818variable: > 819 820 :unlet b:csv_delimiter 821 822And afterwards save and reload the file: > 823 824 :w 825 :e 826 827Now the syntax engine should determine the newly changed CSV delimiter. 828 829 830CYNLIB *ft-cynlib-syntax* 831 832Cynlib files are C++ files that use the Cynlib class library to enable 833hardware modelling and simulation using C++. Typically Cynlib files have a 834.cc or a .cpp extension, which makes it very difficult to distinguish them 835from a normal C++ file. Thus, to enable Cynlib highlighting for .cc files, 836add this line to your vimrc file: > 837 838 :let cynlib_cyntax_for_cc=1 839 840Similarly for cpp files (this extension is only usually used in Windows) > 841 842 :let cynlib_cyntax_for_cpp=1 843 844To disable these again, use this: > 845 846 :unlet cynlib_cyntax_for_cc 847 :unlet cynlib_cyntax_for_cpp 848< 849 850CWEB *ft-cweb-syntax* 851 852Files matching "*.w" could be Progress or cweb. If the automatic detection 853doesn't work for you, or you don't edit Progress at all, use this in your 854startup vimrc: > 855 :let filetype_w = "cweb" 856 857CSHARP *ft-cs-syntax* 858 859C# raw string literals may use any number of quote marks to encapsulate the 860block, and raw interpolated string literals may use any number of braces to 861encapsulate the interpolation, e.g. > 862 863 $$$""""Hello {{{name}}}"""" 864< 865By default, Vim highlights 3-8 quote marks, and 1-8 interpolation braces. 866The maximum numbers of quotes and braces recognized can configured using the 867following variables: 868 869 Variable Default ~ 870 g:cs_raw_string_quote_count 8 871 g:cs_raw_string_interpolation_brace_count 8 872 873DART *ft-dart-syntax* 874 875Dart is an object-oriented, typed, class defined, garbage collected language 876used for developing mobile, desktop, web, and back-end applications. Dart 877uses a C-like syntax derived from C, Java, and JavaScript, with features 878adopted from Smalltalk, Python, Ruby, and others. 879 880More information about the language and its development environment at the 881official Dart language website at https://dart.dev 882 883dart.vim syntax detects and highlights Dart statements, reserved words, 884type declarations, storage classes, conditionals, loops, interpolated values, 885and comments. There is no support idioms from Flutter or any other Dart 886framework. 887 888Changes, fixes? Submit an issue or pull request via: 889 890https://github.com/pr3d4t0r/dart-vim-syntax/ 891 892 893DESKTOP *ft-desktop-syntax* 894 895Primary goal of this syntax file is to highlight .desktop and .directory files 896according to freedesktop.org standard: 897https://specifications.freedesktop.org/desktop-entry-spec/latest/ 898To highlight nonstandard extensions that does not begin with X-, set > 899 let g:desktop_enable_nonstd = 1 900Note that this may cause wrong highlight. 901To highlight KDE-reserved features, set > 902 let g:desktop_enable_kde = 1 903g:desktop_enable_kde follows g:desktop_enable_nonstd if not supplied 904 905 906DIFF *diff.vim* 907 908The diff highlighting normally finds translated headers. This can be slow if 909there are very long lines in the file. To disable translations: > 910 911 :let diff_translations = 0 912 913Also see |diff-slow|. 914 915DIRCOLORS *ft-dircolors-syntax* 916 917The dircolors utility highlighting definition has one option. It exists to 918provide compatibility with the Slackware GNU/Linux distributions version of 919the command. It adds a few keywords that are generally ignored by most 920versions. On Slackware systems, however, the utility accepts the keywords and 921uses them for processing. To enable the Slackware keywords add the following 922line to your startup file: > 923 let dircolors_is_slackware = 1 924 925 926DOCBOOK *ft-docbk-syntax* *docbook* 927DOCBOOK XML *ft-docbkxml-syntax* 928DOCBOOK SGML *ft-docbksgml-syntax* 929 930There are two types of DocBook files: SGML and XML. To specify what type you 931are using the "b:docbk_type" variable should be set. Vim does this for you 932automatically if it can recognize the type. When Vim can't guess it the type 933defaults to XML. 934You can set the type manually: > 935 :let b:docbk_type = "sgml" 936or: > 937 :let b:docbk_type = "xml" 938You need to do this before loading the syntax file, which is complicated. 939Simpler is setting the filetype to "docbkxml" or "docbksgml": > 940 :set filetype=docbksgml 941or: > 942 :set filetype=docbkxml 943 944You can specify the DocBook version for the current buffer: > 945 :let b:docbk_ver = 3 946When "b:docbk_ver" is not set, "g:docbk_ver" is used as a global fallback: > 947 :let g:docbk_ver = 3 948When neither variable is set, version 4 is used. 949 950 951DOSBATCH *ft-dosbatch-syntax* 952 953Select the set of Windows Command interpreter extensions that should be 954supported with the variable dosbatch_cmdextversion. For versions of Windows 955NT (before Windows 2000) this should have the value of 1. For Windows 2000 956and later it should be 2. 957Select the version you want with the following line: > 958 959 :let dosbatch_cmdextversion = 1 960 961If this variable is not defined it defaults to a value of 2 to support 962Windows 2000 and later. 963 964The original MS-DOS supports an idiom of using a double colon (::) as an 965alternative way to enter a comment line. This idiom can be used with the 966current Windows Command Interpreter, but it can lead to problems when used 967inside ( ... ) command blocks. You can find a discussion about this on 968Stack Overflow - 969 970https://stackoverflow.com/questions/12407800/which-comment-style-should-i-use-in-batch-files 971 972To allow the use of the :: idiom for comments in command blocks with the 973Windows Command Interpreter set the dosbatch_colons_comment variable to 974anything: > 975 976 :let dosbatch_colons_comment = 1 977 978If this variable is set then a :: comment that is the last line in a command 979block will be highlighted as an error. 980 981There is an option that covers whether `*.btm` files should be detected as type 982"dosbatch" (MS-DOS batch files) or type "btm" (4DOS batch files). The latter 983is used by default. You may select the former with the following line: > 984 985 :let g:dosbatch_syntax_for_btm = 1 986 987If this variable is undefined or zero, btm syntax is selected. 988 989 990DOXYGEN *doxygen-syntax* 991 992Doxygen generates code documentation using a special documentation format 993(similar to Javadoc). This syntax script adds doxygen highlighting to c, cpp, 994idl and php files, and should also work with java. 995 996There are a few of ways to turn on doxygen formatting. It can be done 997explicitly or in a modeline by appending '.doxygen' to the syntax of the file. 998Example: > 999 :set syntax=c.doxygen 1000or > 1001 // vim:syntax=c.doxygen 1002 1003It can also be done automatically for C, C++, C#, IDL and PHP files by setting 1004the global or buffer-local variable load_doxygen_syntax. This is done by 1005adding the following to your vimrc. > 1006 :let g:load_doxygen_syntax=1 1007 1008There are a couple of variables that have an effect on syntax highlighting, 1009and are to do with non-standard highlighting options. 1010 1011Variable Default Effect ~ 1012g:doxygen_enhanced_color 1013g:doxygen_enhanced_colour 0 Use non-standard highlighting for 1014 doxygen comments. 1015 1016doxygen_my_rendering 0 Disable rendering of HTML bold, italic 1017 and html_my_rendering underline. 1018 1019doxygen_javadoc_autobrief 1 Set to 0 to disable javadoc autobrief 1020 colour highlighting. 1021 1022doxygen_end_punctuation '[.]' Set to regexp match for the ending 1023 punctuation of brief 1024 1025There are also some highlight groups worth mentioning as they can be useful in 1026configuration. 1027 1028Highlight Effect ~ 1029doxygenErrorComment The colour of an end-comment when missing 1030 punctuation in a code, verbatim or dot section 1031doxygenLinkError The colour of an end-comment when missing the 1032 \endlink from a \link section. 1033 1034 1035DTD *ft-dtd-syntax* 1036 1037The DTD syntax highlighting is case sensitive by default. To disable 1038case-sensitive highlighting, add the following line to your startup file: > 1039 1040 :let dtd_ignore_case=1 1041 1042The DTD syntax file will highlight unknown tags as errors. If 1043this is annoying, it can be turned off by setting: > 1044 1045 :let dtd_no_tag_errors=1 1046 1047before sourcing the dtd.vim syntax file. 1048Parameter entity names are highlighted in the definition using the 1049'Type' highlighting group and 'Comment' for punctuation and '%'. 1050Parameter entity instances are highlighted using the 'Constant' 1051highlighting group and the 'Type' highlighting group for the 1052delimiters % and ;. This can be turned off by setting: > 1053 1054 :let dtd_no_param_entities=1 1055 1056The DTD syntax file is also included by xml.vim to highlight included dtd's. 1057 1058 1059EIFFEL *ft-eiffel-syntax* 1060 1061While Eiffel is not case-sensitive, its style guidelines are, and the 1062syntax highlighting file encourages their use. This also allows to 1063highlight class names differently. If you want to disable case-sensitive 1064highlighting, add the following line to your startup file: > 1065 1066 :let eiffel_ignore_case=1 1067 1068Case still matters for class names and TODO marks in comments. 1069 1070Conversely, for even stricter checks, add one of the following lines: > 1071 1072 :let eiffel_strict=1 1073 :let eiffel_pedantic=1 1074 1075Setting eiffel_strict will only catch improper capitalization for the 1076five predefined words "Current", "Void", "Result", "Precursor", and 1077"NONE", to warn against their accidental use as feature or class names. 1078 1079Setting eiffel_pedantic will enforce adherence to the Eiffel style 1080guidelines fairly rigorously (like arbitrary mixes of upper- and 1081lowercase letters as well as outdated ways to capitalize keywords). 1082 1083If you want to use the lower-case version of "Current", "Void", 1084"Result", and "Precursor", you can use > 1085 1086 :let eiffel_lower_case_predef=1 1087 1088instead of completely turning case-sensitive highlighting off. 1089 1090Support for ISE's proposed new creation syntax that is already 1091experimentally handled by some compilers can be enabled by: > 1092 1093 :let eiffel_ise=1 1094 1095Finally, some vendors support hexadecimal constants. To handle them, add > 1096 1097 :let eiffel_hex_constants=1 1098 1099to your startup file. 1100 1101 1102EUPHORIA *ft-euphoria-syntax* 1103 1104Two syntax highlighting files exist for Euphoria. One for Euphoria 1105version 3.1.1, which is the default syntax highlighting file, and one for 1106Euphoria version 4.0.5 or later. 1107 1108Euphoria version 3.1.1 (https://www.rapideuphoria.com/ link seems dead) is 1109still necessary for developing applications for the DOS platform, which 1110Euphoria version 4 (https://www.openeuphoria.org/) does not support. 1111 1112The following file extensions are auto-detected as Euphoria file type: > 1113 1114 *.e, *.eu, *.ew, *.ex, *.exu, *.exw 1115 *.E, *.EU, *.EW, *.EX, *.EXU, *.EXW 1116 1117To select syntax highlighting file for Euphoria, as well as for 1118auto-detecting the `*.e` and `*.E` file extensions as Euphoria file type, 1119add the following line to your startup file: > 1120 1121 :let g:filetype_euphoria = "euphoria3" 1122 1123< or > 1124 1125 :let g:filetype_euphoria = "euphoria4" 1126 1127Elixir and Euphoria share the `*.ex` file extension. If the filetype is 1128specifically set as Euphoria with the g:filetype_euphoria variable, or the 1129file is determined to be Euphoria based on keywords in the file, then the 1130filetype will be set as Euphoria. Otherwise, the filetype will default to 1131Elixir. 1132 1133 1134ERLANG *ft-erlang-syntax* 1135 1136Erlang is a functional programming language developed by Ericsson. Files with 1137the following extensions are recognized as Erlang files: erl, hrl, yaws. 1138 1139Vim highlights triple-quoted docstrings as comments by default. 1140 1141If you want triple-quoted docstrings highlighted as Markdown, add the 1142following line to your |vimrc|: > 1143 1144 :let g:erlang_use_markdown_for_docs = 1 1145 1146The plain text inside the docstrings (that is, the characters that are not 1147highlighted by the Markdown syntax) is still highlighted as a comment. 1148 1149If you want to highlight the plain text inside the docstrings using a 1150different highlight group, add the following line to your |vimrc| (the 1151example highlights plain text using the String highlight group): > 1152 1153 :let g:erlang_docstring_default_highlight = 'String' 1154 1155If you don't enable Markdown, this line highlights the full docstrings 1156according to the specified highlight group. 1157 1158Use the following line to disable highlighting for the plain text: > 1159 1160 :let g:erlang_docstring_default_highlight = '' 1161 1162Configuration examples: > 1163 1164 " Highlight docstrings as Markdown. 1165 :let g:erlang_use_markdown_for_docs = 1 1166 1167 " 1. Highlight Markdown elements in docstrings as Markdown. 1168 " 2. Highlight the plain text in docstrings as String. 1169 :let g:erlang_use_markdown_for_docs = 1 1170 :let g:erlang_docstring_default_highlight = 'String' 1171 1172 " Highlight docstrings as strings (no Markdown). 1173 :let g:erlang_docstring_default_highlight = 'String' 1174 1175 " 1. Highlight Markdown elements in docstrings as Markdown. 1176 " 2. Don't highlight the plain text in docstrings. 1177 :let g:erlang_use_markdown_for_docs = 1 1178 :let g:erlang_docstring_default_highlight = '' 1179< 1180 1181ELIXIR *ft-elixir-syntax* 1182 1183Elixir is a dynamic, functional language for building scalable and 1184maintainable applications. 1185 1186The following file extensions are auto-detected as Elixir file types: > 1187 1188 *.ex, *.exs, *.eex, *.leex, *.lock 1189 1190Elixir and Euphoria share the `*.ex` file extension. If the filetype is 1191specifically set as Euphoria with the g:filetype_euphoria variable, or the 1192file is determined to be Euphoria based on keywords in the file, then the 1193filetype will be set as Euphoria. Otherwise, the filetype will default to 1194Elixir. 1195 1196 1197FLEXWIKI *ft-flexwiki-syntax* 1198 1199FlexWiki is an ASP.NET-based wiki package available at 1200www.flexwiki.com 1201NOTE: This site currently doesn't work, on Wikipedia is mentioned that 1202development stopped in 2009. 1203 1204Syntax highlighting is available for the most common elements of FlexWiki 1205syntax. The associated ftplugin script sets some buffer-local options to make 1206editing FlexWiki pages more convenient. FlexWiki considers a newline as the 1207start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length), 1208'wrap' (wrap long lines instead of using horizontal scrolling), 'linebreak' 1209(to wrap at a character in 'breakat' instead of at the last char on screen), 1210and so on. It also includes some keymaps that are disabled by default. 1211 1212If you want to enable the keymaps that make "j" and "k" and the cursor keys 1213move up and down by display lines, add this to your vimrc: > 1214 :let flexwiki_maps = 1 1215 1216 1217FORM *ft-form-syntax* 1218 1219The coloring scheme for syntax elements in the FORM file uses the default 1220modes Conditional, Number, Statement, Comment, PreProc, Type, and String, 1221following the language specifications in 'Symbolic Manipulation with FORM' by 1222J.A.M. Vermaseren, CAN, Netherlands, 1991. 1223 1224If you want to include your own changes to the default colors, you have to 1225redefine the following syntax groups: 1226 1227 - formConditional 1228 - formNumber 1229 - formStatement 1230 - formHeaderStatement 1231 - formComment 1232 - formPreProc 1233 - formDirective 1234 - formType 1235 - formString 1236 1237Note that the form.vim syntax file implements FORM preprocessor commands and 1238directives per default in the same syntax group. 1239 1240A predefined enhanced color mode for FORM is available to distinguish between 1241header statements and statements in the body of a FORM program. To activate 1242this mode define the following variable in your vimrc file > 1243 1244 :let form_enhanced_color=1 1245 1246The enhanced mode also takes advantage of additional color features for a dark 1247gvim display. Here, statements are colored LightYellow instead of Yellow, and 1248conditionals are LightBlue for better distinction. 1249 1250Both Visual Basic and FORM use the extension ".frm". To detect which one 1251should be used, Vim checks for the string "VB_Name" in the first five lines of 1252the file. If it is found, filetype will be "vb", otherwise "form". 1253 1254If the automatic detection doesn't work for you or you only edit, for 1255example, FORM files, use this in your startup vimrc: > 1256 :let filetype_frm = "form" 1257 1258 1259FORTH *ft-forth-syntax* 1260 1261Files matching "*.f" could be Fortran or Forth and those matching "*.fs" could 1262be F# or Forth. If the automatic detection doesn't work for you, or you don't 1263edit F# or Fortran at all, use this in your startup vimrc: > 1264 :let filetype_f = "forth" 1265 :let filetype_fs = "forth" 1266 1267 1268FORTRAN *ft-fortran-syntax* 1269 1270Default highlighting and dialect ~ 1271Vim highlights according to Fortran 2023 (the most recent standard). This 1272choice should be appropriate for most users most of the time because Fortran 12732023 is almost a superset of previous versions (Fortran 2018, 2008, 2003, 95, 127490, 77, and 66). A few legacy constructs deleted or declared obsolescent, 1275respectively, in recent Fortran standards are highlighted as errors and todo 1276items. 1277 1278The syntax script no longer supports Fortran dialects. The variable 1279fortran_dialect is now silently ignored. Since computers are much faster now, 1280the variable fortran_more_precise is no longer needed and is silently ignored. 1281 1282Fortran source code form ~ 1283Fortran code can be in either fixed or free source form. Note that the 1284syntax highlighting will not be correct if the form is incorrectly set. 1285 1286When you create a new Fortran file, the syntax script assumes fixed source 1287form. If you always use free source form, then > 1288 :let fortran_free_source=1 1289If you always use fixed source form, then > 1290 :let fortran_fixed_source=1 1291 1292If the form of the source code depends, in a non-standard way, upon the file 1293extension, then it is most convenient to set fortran_free_source in a ftplugin 1294file. For more information on ftplugin files, see |ftplugin|. Note that this 1295will work only if the "filetype plugin indent on" command precedes the "syntax 1296on" command in your .vimrc file. 1297 1298 1299When you edit an existing Fortran file, the syntax script will assume free 1300source form if the fortran_free_source variable has been set, and assumes 1301fixed source form if the fortran_fixed_source variable has been set. Suppose 1302neither of these variables have been set. In that case, the syntax script 1303attempts to determine which source form has been used by examining the file 1304extension using conventions common to the ifort, gfortran, Cray, NAG, and 1305PathScale compilers (.f, .for, .f77 for fixed-source, .f90, .f95, .f03, .f08 1306for free-source). No default is used for the .fpp and .ftn file extensions 1307because different compilers treat them differently. If none of this works, 1308then the script examines the first five columns of the first 500 lines of your 1309file. If no signs of free source form are detected, then the file is assumed 1310to be in fixed source form. The algorithm should work in the vast majority of 1311cases. In some cases, such as a file that begins with 500 or more full-line 1312comments, the script may incorrectly decide that the code is in fixed form. 1313If that happens, just add a non-comment statement beginning anywhere in the 1314first five columns of the first twenty-five lines, save (:w), and then reload 1315(:e!) the file. 1316 1317Vendor extensions ~ 1318Fixed-form Fortran requires a maximum line length of 72 characters but the 1319script allows a maximum line length of 80 characters as do all compilers 1320created in the last three decades. An even longer line length of 132 1321characters is allowed if you set the variable fortran_extended_line_length 1322with a command such as > 1323 :let fortran_extended_line_length=1 1324 1325If you want additional highlighting of the CUDA Fortran extensions, you should 1326set the variable fortran_CUDA with a command such as > 1327 :let fortran_CUDA=1 1328 1329To activate recognition of some common, non-standard, vendor-supplied 1330intrinsics, you should set the variable fortran_vendor_intrinsics with a 1331command such as > 1332 :let fortran_vendor_intrinsics=1 1333 1334Tabs in Fortran files ~ 1335Tabs are not recognized by the Fortran standards. Tabs are not a good idea in 1336fixed format Fortran source code which requires fixed column boundaries. 1337Therefore, tabs are marked as errors. Nevertheless, some programmers like 1338using tabs. If your Fortran files contain tabs, then you should set the 1339variable fortran_have_tabs in your vimrc with a command such as > 1340 :let fortran_have_tabs=1 1341Unfortunately, the use of tabs will mean that the syntax file will not be able 1342to detect incorrect margins. 1343 1344Syntax folding of Fortran files ~ 1345Vim will fold your file using foldmethod=syntax, if you set the variable 1346fortran_fold in your .vimrc with a command such as > 1347 :let fortran_fold=1 1348to instruct the syntax script to define fold regions for program units, that 1349is main programs starting with a program statement, subroutines, function 1350subprograms, modules, submodules, blocks of comment lines, and block data 1351units. Block, interface, associate, critical, type definition, and change 1352team constructs will also be folded. If you also set the variable 1353fortran_fold_conditionals with a command such as > 1354 :let fortran_fold_conditionals=1 1355then fold regions will also be defined for do loops, if blocks, select case, 1356select type, and select rank constructs. Note that defining fold regions can 1357be slow for large files. 1358 1359The syntax/fortran.vim script contains embedded comments that tell you how to 1360comment and/or uncomment some lines to (a) activate recognition of some 1361non-standard, vendor-supplied intrinsics and (b) to prevent features deleted 1362or declared obsolescent in the 2008 standard from being highlighted as todo 1363items. 1364 1365Limitations ~ 1366Parenthesis checking does not catch too few closing parentheses. Hollerith 1367strings are not recognized. Some keywords may be highlighted incorrectly 1368because Fortran90 has no reserved words. 1369 1370For further information related to Fortran, see |ft-fortran-indent| and 1371|ft-fortran-plugin|. 1372 1373FREEBASIC *ft-freebasic-syntax* 1374 1375FreeBASIC files will be highlighted differently for each of the four available 1376dialects, "fb", "qb", "fblite" and "deprecated". See |ft-freebasic-plugin| 1377for how to select the correct dialect. 1378 1379Highlighting is further configurable via the following variables. 1380 1381Variable Highlight ~ 1382*freebasic_no_comment_fold* disable multiline comment folding 1383*freebasic_operators* non-alpha operators 1384*freebasic_space_errors* trailing white space and spaces before a <Tab> 1385*freebasic_type_suffixes* QuickBASIC style type suffixes 1386 1387 1388 1389FVWM CONFIGURATION FILES *ft-fvwm-syntax* 1390 1391In order for Vim to recognize Fvwm configuration files that do not match 1392the patterns *fvwmrc* or *fvwm2rc* , you must put additional patterns 1393appropriate to your system in your myfiletypes.vim file. For these 1394patterns, you must set the variable "b:fvwm_version" to the major version 1395number of Fvwm, and the 'filetype' option to fvwm. 1396 1397For example, to make Vim identify all files in /etc/X11/fvwm2/ 1398as Fvwm2 configuration files, add the following: > 1399 1400 :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 | 1401 \ set filetype=fvwm 1402 1403 1404GSP *ft-gsp-syntax* 1405 1406The default coloring style for GSP pages is defined by |ft-html-syntax|, and 1407the coloring for java code (within java tags or inline between backticks) is 1408defined by |ft-java-syntax|. The following HTML groups defined in 1409|ft-html-syntax| are redefined to incorporate and highlight inline java code: 1410 1411 htmlString 1412 htmlValue 1413 htmlEndTag 1414 htmlTag 1415 htmlTagN 1416 1417Highlighting should look fine most of the places where you'd see inline 1418java code, but in some special cases it may not. To add another HTML 1419group where you will have inline java code where it does not highlight 1420correctly, just copy the line you want from |ft-html-syntax| and add gspJava 1421to the contains clause. 1422 1423The backticks for inline java are highlighted according to the htmlError 1424group to make them easier to see. 1425 1426 1427GDB *ft-gdb-syntax* 1428 1429The GDB syntax file provides syntax |folding| (see |:syn-fold|) for comments 1430and block statements. This can be enabled with: > 1431 1432 :set foldmethod=syntax 1433 1434 1435GROFF *ft-groff-syntax* 1436 1437The groff syntax file is a wrapper for |ft-nroff-syntax|, see the notes 1438under that heading for examples of use and configuration. The purpose 1439of this wrapper is to set up groff syntax extensions by setting the 1440filetype from a |modeline| or in a personal filetype definitions file 1441(see |filetype.txt|). 1442 1443 1444HASKELL *ft-haskell-syntax* 1445 1446The Haskell syntax files support plain Haskell code as well as literate 1447Haskell code, the latter in both Bird style and TeX style. The Haskell 1448syntax highlighting will also highlight C preprocessor directives. 1449 1450If you want to highlight delimiter characters (useful if you have a 1451light-coloured background), add to your vimrc: > 1452 :let hs_highlight_delimiters = 1 1453To treat True and False as keywords as opposed to ordinary identifiers, 1454add: > 1455 :let hs_highlight_boolean = 1 1456To also treat the names of primitive types as keywords: > 1457 :let hs_highlight_types = 1 1458And to treat the names of even more relatively common types as keywords: > 1459 :let hs_highlight_more_types = 1 1460If you want to highlight the names of debugging functions, put in 1461your vimrc: > 1462 :let hs_highlight_debug = 1 1463 1464The Haskell syntax highlighting also highlights C preprocessor 1465directives, and flags lines that start with # but are not valid 1466directives as erroneous. This interferes with Haskell's syntax for 1467operators, as they may start with #. If you want to highlight those 1468as operators as opposed to errors, put in your vimrc: > 1469 :let hs_allow_hash_operator = 1 1470 1471The syntax highlighting for literate Haskell code will try to 1472automatically guess whether your literate Haskell code contains 1473TeX markup or not, and correspondingly highlight TeX constructs 1474or nothing at all. You can override this globally by putting 1475in your vimrc > 1476 :let lhs_markup = none 1477for no highlighting at all, or > 1478 :let lhs_markup = tex 1479to force the highlighting to always try to highlight TeX markup. 1480For more flexibility, you may also use buffer local versions of 1481this variable, so e.g. > 1482 :let b:lhs_markup = tex 1483will force TeX highlighting for a particular buffer. It has to be 1484set before turning syntax highlighting on for the buffer or 1485loading a file. 1486 1487 1488HTML *ft-html-syntax* 1489 1490The coloring scheme for tags in the HTML file works as follows. 1491 1492The <> of opening tags are colored differently than the </> of a closing tag. 1493This is on purpose! For opening tags the 'Function' color is used, while for 1494closing tags the 'Identifier' color is used (See syntax.vim to check how those 1495are defined for you) 1496 1497Known tag names are colored the same way as statements in C. Unknown tag 1498names are colored with the same color as the <> or </> respectively which 1499makes it easy to spot errors 1500 1501Note that the same is true for argument (or attribute) names. Known attribute 1502names are colored differently than unknown ones. 1503 1504Some HTML tags are used to change the rendering of text. The following tags 1505are recognized by the html.vim syntax coloring file and change the way normal 1506text is shown: <B> <I> <U> <EM> <STRONG> (<EM> is used as an alias for <I>, 1507while <STRONG> as an alias for <B>), <H1> - <H6>, <HEAD>, <TITLE> and <A>, but 1508only if used as a link (that is, it must include a href as in 1509<A href="somefile.html">). 1510 1511If you want to change how such text is rendered, you must redefine the 1512following syntax groups: 1513 1514 - htmlBold 1515 - htmlBoldUnderline 1516 - htmlBoldUnderlineItalic 1517 - htmlUnderline 1518 - htmlUnderlineItalic 1519 - htmlItalic 1520 - htmlTitle for titles 1521 - htmlH1 - htmlH6 for headings 1522 1523To make this redefinition work you must redefine them all with the exception 1524of the last two (htmlTitle and htmlH[1-6], which are optional) and define the 1525following variable in your vimrc (this is due to the order in which the files 1526are read during initialization) > 1527 :let html_my_rendering=1 1528 1529If you'd like to see an example download mysyntax.vim at 1530https://web.archive.org/web/20241129015117/https://www.fleiner.com/vim/download.html 1531 1532You can also disable this rendering by adding the following line to your 1533vimrc file: > 1534 :let html_no_rendering=1 1535 1536By default Vim starts parsing 1.5 times "html_minlines" lines before the first 1537displayed line, and searches a further "html_maxlines" lines back for a 1538synchronization point. These values can be configured using: > 1539 :let html_minlines = 500 1540 :let html_maxlines = 750 1541< 1542HTML comments are rather special (see an HTML reference document for the 1543details), and the syntax coloring scheme will highlight all errors. 1544However, if you prefer to use the wrong style (starts with <!-- and 1545ends with -->) you can define > 1546 :let html_wrong_comments=1 1547 1548JavaScript and Visual Basic embedded inside HTML documents are highlighted as 1549'Special' with statements, comments, strings and so on colored as in standard 1550programming languages. Note that only JavaScript and Visual Basic are 1551currently supported, no other scripting language has been added yet. 1552 1553Embedded and inlined cascading style sheets (CSS) are highlighted too. 1554 1555There are several html preprocessor languages out there. html.vim has been 1556written such that it should be trivial to include it. To do so add the 1557following two lines to the syntax coloring file for that language 1558(the example comes from the asp.vim file): 1559> 1560 runtime! syntax/html.vim 1561 syn cluster htmlPreproc add=asp 1562 1563Now you just need to make sure that you add all regions that contain 1564the preprocessor language to the cluster htmlPreproc. 1565 1566 *html-folding* 1567The HTML syntax file provides syntax |folding| (see |:syn-fold|) between start 1568and end tags. This can be turned on by > 1569 1570 :let g:html_syntax_folding = 1 1571 :set foldmethod=syntax 1572 1573Note: Syntax folding might slow down syntax highlighting significantly, 1574especially for large files. 1575 1576 1577HTML/OS (BY AESTIVA) *ft-htmlos-syntax* 1578 1579The coloring scheme for HTML/OS works as follows: 1580 1581Functions and variable names are the same color by default, because VIM 1582doesn't specify different colors for Functions and Identifiers. To change 1583this (which is recommended if you want function names to be recognizable in a 1584different color) you need to add the following line to your vimrc: > 1585 :hi Function cterm=bold ctermfg=LightGray 1586 1587Of course, the ctermfg can be a different color if you choose. 1588 1589Another issues that HTML/OS runs into is that there is no special filetype to 1590signify that it is a file with HTML/OS coding. You can change this by opening 1591a file and turning on HTML/OS syntax by doing the following: > 1592 :set syntax=htmlos 1593 1594Lastly, it should be noted that the opening and closing characters to begin a 1595block of HTML/OS code can either be << or [[ and >> or ]], respectively. 1596 1597 1598IA64 *intel-itanium* *ft-ia64-syntax* 1599 1600Highlighting for the Intel Itanium 64 assembly language. See |ft-asm-syntax| 1601for how to recognize this filetype. 1602 1603To have `*.inc` files be recognized as IA64, add this to your vimrc file: > 1604 :let g:filetype_inc = "ia64" 1605 1606 1607 1608ICALENDAR *ft-icalendar-syntax* 1609 1610Highlighting for iCalendar files (RFC 5545), as used by calendaring 1611applications with an ".ics" extension. 1612 1613Component boundaries (BEGIN: and END:), property names, property 1614parameters and recurrence rule parts are highlighted separately. A content 1615line may be split across several lines by inserting a line break followed 1616by a space or a tab; such folded lines are highlighted as a single logical 1617line. 1618 1619Folding of components is provided by the filetype plugin and is off by 1620default; see |ft-icalendar-plugin|. 1621 1622INFORM *ft-inform-syntax* 1623 1624Inform highlighting includes symbols provided by the Inform Library, as 1625most programs make extensive use of it. If do not wish Library symbols 1626to be highlighted add this to your vim startup: > 1627 :let inform_highlight_simple=1 1628 1629By default it is assumed that Inform programs are Z-machine targeted, 1630and highlights Z-machine assembly language symbols appropriately. If 1631you intend your program to be targeted to a Glulx/Glk environment you 1632need to add this to your startup sequence: > 1633 :let inform_highlight_glulx=1 1634 1635This will highlight Glulx opcodes instead, and also adds glk() to the 1636set of highlighted system functions. 1637 1638The Inform compiler will flag certain obsolete keywords as errors when 1639it encounters them. These keywords are normally highlighted as errors 1640by Vim. To prevent such error highlighting, you must add this to your 1641startup sequence: > 1642 :let inform_suppress_obsolete=1 1643 1644By default, the language features highlighted conform to Compiler 1645version 6.30 and Library version 6.11. If you are using an older 1646Inform development environment, you may with to add this to your 1647startup sequence: > 1648 :let inform_highlight_old=1 1649 1650IDL *idl-syntax* 1651 1652IDL (Interface Definition Language) files are used to define RPC calls. In 1653Microsoft land, this is also used for defining COM interfaces and calls. 1654 1655IDL's structure is simple enough to permit a full grammar based approach to 1656rather than using a few heuristics. The result is large and somewhat 1657repetitive but seems to work. 1658 1659There are some Microsoft extensions to idl files that are here. Some of them 1660are disabled by defining idl_no_ms_extensions. 1661 1662The more complex of the extensions are disabled by defining idl_no_extensions. 1663 1664Variable Effect ~ 1665 1666idl_no_ms_extensions Disable some of the Microsoft specific 1667 extensions 1668idl_no_extensions Disable complex extensions 1669idlsyntax_showerror Show IDL errors (can be rather intrusive, but 1670 quite helpful) 1671idlsyntax_showerror_soft Use softer colours by default for errors 1672 1673 1674JAVA *ft-java-syntax* 1675 1676The java.vim syntax highlighting file offers several options. 1677 1678In Java 1.0.2, it was never possible to have braces inside parens, so this was 1679flagged as an error. Since Java 1.1, this is possible (with anonymous 1680classes); and, therefore, is no longer marked as an error. If you prefer the 1681old way, put the following line into your Vim startup file: > 1682 :let g:java_mark_braces_in_parens_as_errors = 1 1683 1684All (exported) public types declared in `java.lang` are always automatically 1685imported and available as simple names. To highlight them, use: > 1686 :let g:java_highlight_java_lang_ids = 1 1687You can also generate syntax items for other public and protected types and 1688opt in to highlight some of their names; see |java-package-info-url|. 1689 1690Headers of indented function declarations can be highlighted (along with parts 1691of lambda expressions and method reference expressions), but it depends on how 1692you write Java code. Two formats are recognized: 1693 16941) If you write function declarations that are consistently indented by either 1695a tab, or a space . . . or eight space character(s), you may want to set one 1696of > 1697 :let g:java_highlight_functions = "indent" 1698 :let g:java_highlight_functions = "indent1" 1699 :let g:java_highlight_functions = "indent2" 1700 :let g:java_highlight_functions = "indent3" 1701 :let g:java_highlight_functions = "indent4" 1702 :let g:java_highlight_functions = "indent5" 1703 :let g:java_highlight_functions = "indent6" 1704 :let g:java_highlight_functions = "indent7" 1705 :let g:java_highlight_functions = "indent8" 1706Note that in terms of 'shiftwidth', this is the leftmost step of indentation. 1707 17082) However, if you follow the Java guidelines about how functions and types 1709are supposed to be named (with respect to upper- and lowercase) and there is 1710any amount of indentation, you may want to set > 1711 :let g:java_highlight_functions = "style" 1712 1713In addition, you can combine any value of "g:java_highlight_functions" with > 1714 :let g:java_highlight_signature = 1 1715to have the name of a function with its parameter list parens distinctly 1716highlighted from its type parameters, return type, and formal parameters; and 1717to have the parameter list parens of a lambda expression with its arrow 1718distinctly highlighted from its formal parameters or identifiers. 1719 1720If neither setting does work for you, but you would still want headers of 1721function declarations to be highlighted, modify the current syntax definitions 1722or compose new ones. 1723 1724Higher-order function types can be hard to parse by eye, so uniformly toning 1725down some of their components may be of value. Provided that such type names 1726conform to the Java naming guidelines, you may arrange it with > 1727 :let g:java_highlight_generics = 1 1728 1729In Java 1.1, the functions `System.out.println()` and `System.err.println()` 1730should only be used for debugging. Consider adding the following definition 1731in your startup file: > 1732 :let g:java_highlight_debug = 1 1733to have the bulk of those statements colored as 1734 `*Debug` debugging statements, 1735and to make some of their own items further grouped and linked: 1736 `*Special` as DebugSpecial, 1737 `*String` as DebugString, 1738 `*Boolean` as DebugBoolean, 1739 `*Type` as DebugType, 1740which are used for special characters appearing in strings, strings proper, 1741boolean literals, and special instance references (`super`, `this`, `null`), 1742respectively. 1743 1744Javadoc is a program that takes special comments out of Java program files and 1745creates HTML pages. The standard configuration will highlight this HTML code 1746similarly to HTML files (see |ft-html-syntax|). You can even add JavaScript 1747and CSS inside this code (see below). The HTML rendering and the Markdown 1748rendering diverge as follows: 1749 1. The first sentence (all characters up to the first period `.`, which is 1750 followed by a whitespace character or a line terminator, or up to the 1751 first block tag, e.g. `@param`, `@return`) is colored as 1752 `*SpecialComment` special comments. 1753 2. The text is colored as 1754 `*Comment` comments. 1755 3. HTML comments are colored as 1756 `*Special` special symbols. 1757 4. The standard Javadoc tags (`@code`, `@see`, etc.) are colored as 1758 `*Special` special symbols 1759 and some of their arguments are colored as 1760 `*Function` function names. 1761To turn this feature off for both HTML and Markdown, add the following line to 1762your startup file: > 1763 :let g:java_ignore_javadoc = 1 1764Alternatively, only suppress HTML comments or Markdown comments: > 1765 :let g:java_ignore_html = 1 1766 :let g:java_ignore_markdown = 1 1767See |ft-java-plugin| for additional support available for Markdown comments. 1768 1769If you use the special Javadoc comment highlighting described above, you can 1770also turn on special highlighting for JavaScript, Visual Basic scripts, and 1771embedded CSS (stylesheets). This only makes sense if any of these languages 1772actually appear in Javadoc comments. The variables to use are > 1773 :let g:java_javascript = 1 1774 :let g:java_css = 1 1775 :let g:java_vb = 1 1776Note that these three variables are maintained in the HTML syntax file. 1777 1778Numbers and strings can be recognized in non-Javadoc comments with > 1779 :let g:java_comment_strings = 1 1780 1781When 'foldmethod' is set to "syntax", multi-line blocks of code ("b"), plain 1782comments ("c"), Javadoc comments ("d"), and adjacent "import" declarations 1783("i") will be folded by default. Syntax items of any supported kind will 1784remain NOT foldable when its abbreviated name is delisted with > 1785 :let g:java_ignore_folding = "bcdi" 1786No text is usually written in the first line of a multi-line comment, making 1787folded contents of Javadoc comments less informative with the default 1788'foldtext' value; you may opt for showing the contents of a second line for 1789any comments written in this way, and showing the contents of a first line 1790otherwise, with > 1791 :let g:java_foldtext_show_first_or_second_line = 1 1792HTML tags in Javadoc comments can additionally be folded by following the 1793instructions listed under |html-folding| and giving explicit consent with > 1794 :let g:java_consent_to_html_syntax_folding = 1 1795Do not default to this kind of folding unless ALL start tags and optional end 1796tags are balanced in Javadoc comments; otherwise, put up with creating runaway 1797folds that break syntax highlighting. 1798 1799Trailing whitespace characters or a run of space characters before a tab 1800character can be marked as an error with > 1801 :let g:java_space_errors = 1 1802but either kind of an error can be suppressed by also defining one of > 1803 :let g:java_no_trail_space_error = 1 1804 :let g:java_no_tab_space_error = 1 1805 1806In order to highlight nested parens with different colors, define colors for 1807`javaParen`, `javaParen1`, and `javaParen2`. For example, > 1808 :hi link javaParen Comment 1809or > 1810 :hi javaParen ctermfg=blue guifg=#0000ff 1811 1812Certain modifiers are incompatible with each other, e.g. `abstract` and 1813`final`: > 1814 :syn list javaConceptKind 1815and can be differently highlighted as a group than other modifiers with > 1816 :hi link javaConceptKind NonText 1817 1818All instances of variable-width lookbehind assertions (|/\@<!| and |/\@<=|), 1819resorted to in syntax item definitions, are confined to arbitrary byte counts. 1820Another arbitrary value can be selected for a related group of definitions. 1821For example: > 1822 :let g:java_lookbehind_byte_counts = {'javaMarkdownCommentTitle': 240} 1823Where each key name of this dictionary is the name of a syntax item. The use 1824of these assertions in syntax items may vary among revisions, so no definitive 1825set of supported key names is committed to. 1826 1827If you notice highlighting errors while scrolling backwards, which are fixed 1828when redrawing with CTRL-L, try setting the "g:java_minlines" variable to 1829a larger number: > 1830 :let g:java_minlines = 50 1831This will make the syntax synchronization start 50 lines before the first 1832displayed line. The default value is 10. The disadvantage of using a larger 1833number is that redrawing can become slow. 1834 1835Significant changes to the Java platform are gradually introduced in the form 1836of JDK Enhancement Proposals (JEPs) that can be implemented for a release and 1837offered as its preview features. It may take several JEPs and a few release 1838cycles for such a feature to become either integrated into the platform or 1839withdrawn from this effort. To cater for early adopters, there is optional 1840support in Vim for syntax related preview features that are implemented. You 1841can request it by specifying a list of preview feature numbers as follows: > 1842 :let g:java_syntax_previews = [532] 1843 1844The supported JEP numbers are to be drawn from this table: 1845 `430`: String Templates [JDK 21] 1846 `532`: Primitive types in Patterns, instanceof, and switch 1847 1848Note that as soon as the particular preview feature will have been integrated 1849into the Java platform, its entry will be removed from the table and related 1850optionality will be discontinued. 1851 *java-package-info-url* 1852https://github.com/zzzyxwvut/java-vim/blob/master/tools/javaid/src/javaid/package-info.java 1853 1854JSON *ft-json-syntax* *g:vim_json_conceal* 1855 *g:vim_json_warnings* 1856 1857The json syntax file provides syntax highlighting with conceal support by 1858default. To disable concealment: > 1859 let g:vim_json_conceal = 0 1860 1861To disable syntax highlighting of errors: > 1862 let g:vim_json_warnings = 0 1863 1864 1865JQ *jq_quote_highlight* *ft-jq-syntax* 1866 1867To disable numbers having their own color add the following to your vimrc: > 1868 hi link jqNumber Normal 1869 1870If you want quotes to have different highlighting than strings > 1871 let g:jq_quote_highlight = 1 1872 1873KCONFIG *ft-kconfig-syntax* 1874 1875Kconfig syntax highlighting language. For syntax syncing, you can configure 1876the following variable (default: 50): > 1877 1878 let kconfig_minlines = 50 1879 1880To configure a bit more (heavier) highlighting, set the following variable: > 1881 1882 let kconfig_syntax_heavy = 1 1883 1884LACE *ft-lace-syntax* 1885 1886Lace (Language for Assembly of Classes in Eiffel) is case insensitive, but the 1887style guide lines are not. If you prefer case insensitive highlighting, just 1888define the vim variable 'lace_case_insensitive' in your startup file: > 1889 :let lace_case_insensitive=1 1890 1891 1892LF (LFRC) *ft-lf-syntax* *g:lf_shell_syntax* 1893 *b:lf_shell_syntax* 1894 1895For the lf file manager configuration files (lfrc) the shell commands syntax 1896highlighting can be changed globally and per buffer by setting a different 1897'include' command search pattern using these variables: > 1898 let g:lf_shell_syntax = "syntax/dosbatch.vim" 1899 let b:lf_shell_syntax = "syntax/zsh.vim" 1900 1901These variables are unset by default. 1902 1903The default 'include' command search pattern is 'syntax/sh.vim'. 1904 1905 1906LEX *ft-lex-syntax* 1907 1908Lex uses brute-force synchronizing as the "^%%$" section delimiter 1909gives no clue as to what section follows. Consequently, the value for > 1910 :syn sync minlines=300 1911may be changed by the user if they are experiencing synchronization 1912difficulties (such as may happen with large lex files). 1913 1914 1915LIFELINES *ft-lifelines-syntax* 1916 1917To highlight deprecated functions as errors, add in your vimrc: > 1918 1919 :let g:lifelines_deprecated = 1 1920< 1921 1922LISP *ft-lisp-syntax* 1923 1924The lisp syntax highlighting provides two options: > 1925 1926 g:lisp_instring : If it exists, then "(...)" strings are highlighted 1927 as if the contents of the string were lisp. 1928 Useful for AutoLisp. 1929 g:lisp_rainbow : If it exists and is nonzero, then differing levels 1930 of parenthesization will receive different 1931 highlighting. 1932< 1933The g:lisp_rainbow option provides 10 levels of individual colorization for 1934the parentheses and backquoted parentheses. Because of the quantity of 1935colorization levels, unlike non-rainbow highlighting, the rainbow mode 1936specifies its highlighting using ctermfg and guifg, thereby bypassing the 1937usual color scheme control using standard highlighting groups. The actual 1938highlighting used depends on the dark/bright setting (see 'bg'). 1939 1940 1941LITE *ft-lite-syntax* 1942 1943There are two options for the lite syntax highlighting. 1944 1945If you like SQL syntax highlighting inside Strings, use this: > 1946 1947 :let lite_sql_query = 1 1948 1949For syncing, minlines defaults to 100. If you prefer another value, you can 1950set "lite_minlines" to the value you desire. Example: > 1951 1952 :let lite_minlines = 200 1953 1954LOG *ft-log-syntax* 1955 1956Vim comes with a simplistic generic log syntax highlighter. Because the log 1957file format is so generic, highlighting is not enabled by default, since it 1958can be distracting. If you want to enable this, simply set the "log" filetype 1959manually: > 1960 1961 :set ft=log 1962 1963To enable this automatically for "*.log" files, add the following to your 1964personal `filetype.vim` file (usually located in `~/.config/nvim/filetype.vim` 1965on Unix, see also |new-filetype|): > 1966 1967 augroup filetypedetect 1968 au! BufNewFile,BufRead *.log setfiletype log 1969 augroup END 1970 1971LPC *ft-lpc-syntax* 1972 1973LPC stands for a simple, memory-efficient language: Lars Pensjö C. The 1974file name of LPC is usually `*.c`. Recognizing these files as LPC would bother 1975users writing only C programs. If you want to use LPC syntax in Vim, you 1976should set a variable in your vimrc file: > 1977 1978 :let lpc_syntax_for_c = 1 1979 1980If it doesn't work properly for some particular C or LPC files, use a 1981modeline. For a LPC file: > 1982 1983 // vim:set ft=lpc: 1984 1985For a C file that is recognized as LPC: > 1986 1987 // vim:set ft=c: 1988 1989If you don't want to set the variable, use the modeline in EVERY LPC file. 1990 1991There are several implementations for LPC, we intend to support most widely 1992used ones. Here the default LPC syntax is for MudOS series, for MudOS v22 1993and before, you should turn off the sensible modifiers, and this will also 1994assert the new efuns after v22 to be invalid, don't set this variable when 1995you are using the latest version of MudOS: > 1996 1997 :let lpc_pre_v22 = 1 1998 1999For LpMud 3.2 series of LPC: > 2000 2001 :let lpc_compat_32 = 1 2002 2003For LPC4 series of LPC: > 2004 2005 :let lpc_use_lpc4_syntax = 1 2006 2007For uLPC series of LPC: 2008uLPC has been developed to Pike, so you should use Pike syntax 2009instead, and the name of your source file should be `*.pike` 2010 2011 2012LUA *ft-lua-syntax* 2013 2014The Lua syntax file can be used for versions 4.0, 5.0+. You can select one of 2015these versions using the global variables |g:lua_version| and 2016|g:lua_subversion|. 2017 2018 2019MAIL *ft-mail.vim* 2020 2021Vim highlights all the standard elements of an email (headers, signatures, 2022quoted text and URLs / email addresses). In keeping with standard 2023conventions, signatures begin in a line containing only "--" followed 2024optionally by whitespaces and end with a newline. 2025 2026Vim treats lines beginning with "]", "}", "|", ">" or a word followed by ">" 2027as quoted text. However Vim highlights headers and signatures in quoted text 2028only if the text is quoted with ">" (optionally followed by one space). 2029 2030By default mail.vim synchronises syntax to 100 lines before the first 2031displayed line. If you have a slow machine, and generally deal with emails 2032with short headers, you can change this to a smaller value: > 2033 2034 :let mail_minlines = 30 2035 2036 2037MAKE *ft-make-syntax* 2038 2039In makefiles, commands are usually highlighted to make it easy for you to spot 2040errors. However, this may be too much coloring for you. You can turn this 2041feature off by using: > 2042 2043 :let make_no_commands = 1 2044 2045Comments are also highlighted by default. You can turn this off by using: > 2046 2047 :let make_no_comments = 1 2048 2049There are various Make implementations, which add extensions other than the 2050POSIX specification and thus are mutually incompatible. If the filename is 2051BSDmakefile or GNUmakefile, the corresponding implementation is automatically 2052determined; otherwise vim tries to detect it by the file contents. If you see 2053any wrong highlights because of this, you can enforce a flavor by setting one 2054of the following: > 2055 2056 :let g:make_flavor = 'bsd' " or 2057 :let g:make_flavor = 'gnu' " or 2058 :let g:make_flavor = 'microsoft' 2059 2060 2061MAPLE *ft-maple-syntax* 2062 2063Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language 2064supports many packages of functions which are selectively loaded by the user. 2065The standard set of packages' functions as supplied in Maple V release 4 may 2066be highlighted at the user's discretion. Users may place in their vimrc 2067file: > 2068 2069 :let mvpkg_all= 1 2070 2071to get all package functions highlighted, or users may select any subset by 2072choosing a variable/package from the table below and setting that variable to 20731, also in their vimrc file (prior to sourcing 2074$VIMRUNTIME/syntax/syntax.vim). 2075 2076 Table of Maple V Package Function Selectors > 2077 mv_DEtools mv_genfunc mv_networks mv_process 2078 mv_Galois mv_geometry mv_numapprox mv_simplex 2079 mv_GaussInt mv_grobner mv_numtheory mv_stats 2080 mv_LREtools mv_group mv_orthopoly mv_student 2081 mv_combinat mv_inttrans mv_padic mv_sumtools 2082 mv_combstruct mv_liesymm mv_plots mv_tensor 2083 mv_difforms mv_linalg mv_plottools mv_totorder 2084 mv_finance mv_logic mv_powseries 2085 2086 2087MARKDOWN *ft-markdown-syntax* *g:markdown_minlines* 2088 *g:markdown_fenced_languages* *g:markdown_syntax_conceal* 2089 2090If you have long regions there may be incorrect highlighting. At the cost of 2091slowing down displaying, you can have the engine look further back to sync on 2092the start of a region, for example 500 lines (default is 50): > 2093 2094 :let g:markdown_minlines = 500 2095 2096If you want to enable fenced code block syntax highlighting in your Markdown 2097documents, set the following variable: > 2098 2099 :let g:markdown_fenced_languages = ['html', 'python', 'bash=sh'] 2100 2101To disable Markdown syntax concealing, add the following to your vimrc: > 2102 2103 :let g:markdown_syntax_conceal = 0 2104 2105For extended Markdown support with enhanced features such as citations, 2106footnotes, mathematical formulas, academic writing elements and embedded code 2107block highlighting, consider using the pandoc syntax plugin. Set 2108`g:filetype_md` to "pandoc" and see |ft-pandoc-syntax| for configuration 2109details. 2110 2111MATHEMATICA *ft-mma-syntax* *ft-mathematica-syntax* 2112 2113Empty `*.m` files will automatically be presumed to be Matlab files unless you 2114have the following in your vimrc: > 2115 2116 let filetype_m = "mma" 2117 2118MBSYNC *ft-mbsync-syntax* 2119 2120The mbsync application uses a configuration file to setup mailboxes names, 2121user and password. All files ending with `.mbsyncrc` or with the name 2122`isyncrc` will be recognized as mbsync configuration files. 2123 2124MEDIAWIKI *ft-mediawiki-syntax* 2125 2126By default, syntax highlighting includes basic HTML tags like style and 2127headers |ft-html-syntax|. For strict Mediawiki syntax highlighting: > 2128 2129 let g:html_no_rendering = 1 2130 2131If HTML highlighting is desired, terminal-based text formatting such as bold 2132and italic is possible by: > 2133 2134 let g:html_style_rendering = 1 2135 2136MODULA2 *ft-modula2-syntax* 2137 2138Vim will recognise comments with dialect tags to automatically select a given 2139dialect. 2140 2141The syntax for a dialect tag comment is: > 2142 2143 taggedComment := 2144 '(*!' dialectTag '*)' 2145 ; 2146 2147 dialectTag := 2148 m2pim | m2iso | m2r10 2149 ; 2150 2151 reserved words 2152 m2pim = 'm2pim', m2iso = 'm2iso', m2r10 = 'm2r10' 2153 2154A dialect tag comment is recognised by Vim if it occurs within the first 200 2155lines of the source file. Only the very first such comment is recognised, any 2156additional dialect tag comments are ignored. 2157 2158Example: > 2159 2160 DEFINITION MODULE FooLib; (*!m2pim*) 2161 ... 2162 2163Variable g:modula2_default_dialect sets the default Modula-2 dialect when the 2164dialect cannot be determined from the contents of the Modula-2 file: if 2165defined and set to 'm2pim', the default dialect is PIM. 2166 2167Example: > 2168 2169 let g:modula2_default_dialect = 'm2pim' 2170 2171 2172Highlighting is further configurable for each dialect via the following 2173variables. 2174 2175Variable Highlight ~ 2176*modula2_iso_allow_lowline* allow low line in identifiers 2177*modula2_iso_disallow_octals* disallow octal integer literals 2178*modula2_iso_disallow_synonyms* disallow "@", "&" and "~" synonyms 2179 2180*modula2_pim_allow_lowline* allow low line in identifiers 2181*modula2_pim_disallow_octals* disallow octal integer literals 2182*modula2_pim_disallow_synonyms* disallow "&" and "~" synonyms 2183 2184*modula2_r10_allow_lowline* allow low line in identifiers 2185 2186MOO *ft-moo-syntax* 2187 2188If you use C-style comments inside expressions and find it mangles your 2189highlighting, you may want to use extended (slow!) matches for C-style 2190comments: > 2191 2192 :let moo_extended_cstyle_comments = 1 2193 2194To disable highlighting of pronoun substitution patterns inside strings: > 2195 2196 :let moo_no_pronoun_sub = 1 2197 2198To disable highlighting of the regular expression operator "%|", and matching 2199"%(" and "%)" inside strings: > 2200 2201 :let moo_no_regexp = 1 2202 2203Unmatched double quotes can be recognized and highlighted as errors: > 2204 2205 :let moo_unmatched_quotes = 1 2206 2207To highlight builtin properties (.name, .location, .programmer etc.): > 2208 2209 :let moo_builtin_properties = 1 2210 2211Unknown builtin functions can be recognized and highlighted as errors. If you 2212use this option, add your own extensions to the mooKnownBuiltinFunction group. 2213To enable this option: > 2214 2215 :let moo_unknown_builtin_functions = 1 2216 2217An example of adding sprintf() to the list of known builtin functions: > 2218 2219 :syn keyword mooKnownBuiltinFunction sprintf contained 2220 2221 2222MSQL *ft-msql-syntax* 2223 2224There are two options for the msql syntax highlighting. 2225 2226If you like SQL syntax highlighting inside Strings, use this: > 2227 2228 :let msql_sql_query = 1 2229 2230For syncing, minlines defaults to 100. If you prefer another value, you can 2231set "msql_minlines" to the value you desire. Example: > 2232 2233 :let msql_minlines = 200 2234 2235 2236NEOMUTT *ft-neomuttrc-syntax* 2237 *ft-neomuttlog-syntax* 2238 2239To disable the default NeoMutt log colors: > 2240 2241 :let g:neolog_disable_default_colors = 1 2242 2243N1QL *ft-n1ql-syntax* 2244 2245N1QL is a SQL-like declarative language for manipulating JSON documents in 2246Couchbase Server databases. 2247 2248Vim syntax highlights N1QL statements, keywords, operators, types, comments, 2249and special values. Vim ignores syntactical elements specific to SQL or its 2250many dialects, like COLUMN or CHAR, that don't exist in N1QL. 2251 2252 2253NCF *ft-ncf-syntax* 2254 2255There is one option for NCF syntax highlighting. 2256 2257If you want to have unrecognized (by ncf.vim) statements highlighted as 2258errors, use this: > 2259 2260 :let ncf_highlight_unknowns = 1 2261 2262If you don't want to highlight these errors, leave it unset. 2263 2264 2265NROFF *ft-nroff-syntax* 2266 2267The nroff syntax file works with AT&T n/troff as-is. To support GNU troff 2268(groff), which Linux and BSD distributions use as their default typesetting 2269package, arrange for files to be recognized as groff input (see 2270|ft-groff-syntax|) or add the following option to your start-up files: > 2271 2272 :let nroff_is_groff = 1 2273 2274GNU troff differs from older AT&T n/troff programs (that you may still find in 2275Solaris or Plan 9) by extending the "*roff" language syntax. For example, in 2276AT&T troff, you access the count of years since 1900 with the escape sequence 2277\n(yr. In groff you can do the same, which it recognizes for compatibility, 2278or use groff's extended syntax, \n[yr]. AT&T troff documented the yr register 2279as storing the "last two digits of current year", but had a Y2K problem; in 2280groff, you can access the Gregorian year correctly: \n[year]. In groff, font, 2281register, macro, string, and request names can exceed two characters; for 2282example, with groff's mm package, the control lines ".VERBON" and ".VERBOFF" 2283call macros of those names to bracket displays of "verbatim" content. 2284 2285In order to obtain the best formatted output g/troff can give you, you should 2286follow a few simple rules about spacing and punctuation. 2287 22881. Break the line (put a carriage return) at the end of every sentence. Don't 2289 permit trailing spaces before the newline. 2290 22912. If a line ends with a period, question mark, or exclamation point that does 2292 not end a sentence, follow it with the dummy character escape sequence \&. 2293 22943. If you're using a macro package, employ its paragraphing macros to achieve 2295 indentation of paragraphs and spacing between them. 2296 22974. Use the empty request, a '.' on a line by itself, freely to visually 2298 separate material for ease of document maintenance. 2299 2300The reason for these tips is that g/n/troff attempts to detect the ends of 2301sentences, and can use that information to apply inter-sentence space. Using 2302them also minimizes the size of diffs where lines change due only to refilling 2303in the text editor. Macro packages typically employ inter-paragraph spacing 2304amounts other than one vee (which is the result of a blank input line), and 2305typically store that spacing amount, and that of paragraph indentation, in 2306user-configurable registers so that pages lay out consistently. 2307 2308Unlike TeX, troff fills text line-by-line, not paragraph-by-paragraph. If you 2309desire consistent spacing between words and sentences in formatted output, you 2310must maintain consistent spacing in the input text. To mark both trailing 2311spaces and two or more spaces after a punctuation as an error, use: > 2312 2313 :let nroff_space_errors = 1 2314 2315Another technique to detect extra spacing and other errors that will interfere 2316with the correct typesetting of your file, is to define an eye-catching 2317highlighting definition for the syntax groups "nroffDefinition" and 2318"nroffDefSpecial" in your configuration files. For example: > 2319 2320 hi def nroffDefinition cterm=italic gui=reverse 2321 hi def nroffDefSpecial cterm=italic,bold gui=reverse,bold 2322 2323If you want to navigate preprocessor entries in your source file as easily as 2324with section markers, you can activate the following option in your vimrc 2325file: > 2326 2327 let b:preprocs_as_sections = 1 2328 2329Further, the syntax file adds an extra paragraph marker for the XP 2330paragraphing macro in the ms package, a Berkeley and GNU extension. 2331 2332Finally, there is a |ft-groff-syntax| file that can be used to enable groff 2333syntax highlighting either on a per-file basis or globally by default. 2334 2335 2336OCAML *ft-ocaml-syntax* 2337 2338The OCaml syntax file handles files having the following prefixes: .ml, 2339.mli, .mll and .mly. By setting the following variable > 2340 2341 :let ocaml_revised = 1 2342 2343you can switch from standard OCaml-syntax to revised syntax as supported 2344by the camlp4 preprocessor. Setting the variable > 2345 2346 :let ocaml_noend_error = 1 2347 2348prevents highlighting of "end" as error, which is useful when sources 2349contain very long structures that Vim does not synchronize anymore. 2350 2351PANDOC *ft-pandoc-syntax* 2352 2353By default, markdown files will be detected as filetype "markdown". 2354Alternatively, you may want them to be detected as filetype "pandoc" instead. 2355To do so, set the *g:filetype_md* var: > 2356 2357 :let g:filetype_md = 'pandoc' 2358 2359The pandoc syntax plugin uses |conceal| for pretty highlighting. Default is 1 > 2360 2361 :let g:pandoc#syntax#conceal#use = 1 2362 2363To specify elements that should not be concealed, set the following variable: > 2364 2365 :let g:pandoc#syntax#conceal#blacklist = [] 2366 2367This is a list of the rules which can be used here: 2368 2369 - titleblock 2370 - image 2371 - block 2372 - subscript 2373 - superscript 2374 - strikeout 2375 - atx 2376 - codeblock_start 2377 - codeblock_delim 2378 - footnote 2379 - definition 2380 - list 2381 - newline 2382 - dashes 2383 - ellipses 2384 - quotes 2385 - inlinecode 2386 - inlinemath 2387 2388You can customize the way concealing works. For example, if you prefer to 2389mark footnotes with the `*` symbol: > 2390 2391 :let g:pandoc#syntax#conceal#cchar_overrides = {"footnote" : "*"} 2392 2393To conceal the urls in links, use: > 2394 2395 :let g:pandoc#syntax#conceal#urls = 1 2396 2397Prevent highlighting specific codeblock types so that they remain Normal. 2398Codeblock types include "definition" for codeblocks inside definition blocks 2399and "delimited" for delimited codeblocks. Default = [] > 2400 2401 :let g:pandoc#syntax#codeblocks#ignore = ['definition'] 2402 2403Use embedded highlighting for delimited codeblocks where a language is 2404specified. Default = 1 > 2405 2406 :let g:pandoc#syntax#codeblocks#embeds#use = 1 2407 2408For specify what languages and using what syntax files to highlight embeds. 2409This is a list of language names. When the language pandoc and vim use don't 2410match, you can use the "PANDOC=VIM" syntax. For example: > 2411 2412 :let g:pandoc#syntax#codeblocks#embeds#langs = ["ruby", "bash=sh"] 2413 2414To use italics and strong in emphases. Default = 1 > 2415 2416 :let g:pandoc#syntax#style#emphases = 1 2417 2418"0" will add "block" to g:pandoc#syntax#conceal#blacklist, because otherwise 2419you couldn't tell where the styles are applied. 2420 2421To add underline subscript, superscript and strikeout text styles. Default = 1 > 2422 2423 :let g:pandoc#syntax#style#underline_special = 1 2424 2425Detect and highlight definition lists. Disabling this can improve 2426performance. Default = 1 (i.e., enabled by default) > 2427 2428 :let g:pandoc#syntax#style#use_definition_lists = 1 2429 2430The pandoc syntax script also comes with the following commands: > 2431 2432 :PandocHighlight LANG 2433 2434Enables embedded highlighting for language LANG in codeblocks. Uses the 2435syntax for items in g:pandoc#syntax#codeblocks#embeds#langs. > 2436 2437 :PandocUnhighlight LANG 2438 2439Disables embedded highlighting for language LANG in codeblocks. 2440 2441PAPP *ft-papp-syntax* 2442 2443The PApp syntax file handles .papp files and, to a lesser extent, .pxml 2444and .pxsl files which are all a mixture of perl/xml/html/other using xml 2445as the top-level file format. By default everything inside phtml or pxml 2446sections is treated as a string with embedded preprocessor commands. If 2447you set the variable: > 2448 2449 :let papp_include_html=1 2450 2451in your startup file it will try to syntax-highlight html code inside phtml 2452sections, but this is relatively slow and much too colourful to be able to 2453edit sensibly. ;) 2454 2455The newest version of the papp.vim syntax file can usually be found at 2456http://papp.plan9.de. 2457 2458 2459PASCAL *ft-pascal-syntax* 2460 2461Files matching "*.p" could be Progress or Pascal and those matching "*.pp" 2462could be Puppet or Pascal. If the automatic detection doesn't work for you, 2463or you only edit Pascal files, use this in your startup vimrc: > 2464 2465 :let filetype_p = "pascal" 2466 :let filetype_pp = "pascal" 2467 2468The Pascal syntax file has been extended to take into account some extensions 2469provided by Turbo Pascal, Free Pascal Compiler and GNU Pascal Compiler. 2470Delphi keywords are also supported. By default, Turbo Pascal 7.0 features are 2471enabled. If you prefer to stick with the standard Pascal keywords, add the 2472following line to your startup file: > 2473 2474 :let pascal_traditional=1 2475 2476To switch on Delphi specific constructions (such as one-line comments, 2477keywords, etc): > 2478 2479 :let pascal_delphi=1 2480 2481 2482The option pascal_symbol_operator controls whether symbol operators such as +, 2483`*`, .., etc. are displayed using the Operator color or not. To colorize symbol 2484operators, add the following line to your startup file: > 2485 2486 :let pascal_symbol_operator=1 2487 2488Some functions are highlighted by default. To switch it off: > 2489 2490 :let pascal_no_functions=1 2491 2492Furthermore, there are specific variables for some compilers. Besides 2493pascal_delphi, there are pascal_gpc and pascal_fpc. Default extensions try to 2494match Turbo Pascal. > 2495 2496 :let pascal_gpc=1 2497 2498or > 2499 2500 :let pascal_fpc=1 2501 2502To ensure that strings are defined on a single line, you can define the 2503pascal_one_line_string variable. > 2504 2505 :let pascal_one_line_string=1 2506 2507If you dislike <Tab> chars, you can set the pascal_no_tabs variable. Tabs 2508will be highlighted as Error. > 2509 2510 :let pascal_no_tabs=1 2511 2512 2513 2514PERL *ft-perl-syntax* 2515 2516There are a number of possible options to the perl syntax highlighting. 2517 2518Inline POD highlighting is now turned on by default. If you don't wish 2519to have the added complexity of highlighting POD embedded within Perl 2520files, you may set the 'perl_include_pod' option to 0: > 2521 2522 :let perl_include_pod = 0 2523 2524To reduce the complexity of parsing (and increase performance) you can switch 2525off two elements in the parsing of variable names and contents. > 2526 2527To handle package references in variable and function names not differently 2528from the rest of the name (like 'PkgName::' in '$PkgName::VarName'): > 2529 2530 :let perl_no_scope_in_variables = 1 2531 2532(In Vim 6.x it was the other way around: "perl_want_scope_in_variables" 2533enabled it.) 2534 2535If you do not want complex things like `@{${"foo"}}` to be parsed: > 2536 2537 :let perl_no_extended_vars = 1 2538 2539(In Vim 6.x it was the other way around: "perl_extended_vars" enabled it.) 2540 2541The coloring strings can be changed. By default strings and qq friends will 2542be highlighted like the first line. If you set the variable 2543perl_string_as_statement, it will be highlighted as in the second line. 2544 2545 "hello world!"; qq|hello world|; 2546 ^^^^^^^^^^^^^^NN^^^^^^^^^^^^^^^N (unlet perl_string_as_statement) 2547 S^^^^^^^^^^^^SNNSSS^^^^^^^^^^^SN (let perl_string_as_statement) 2548 2549(^ = perlString, S = perlStatement, N = None at all) 2550 2551The syncing has 3 options. The first two switch off some triggering of 2552synchronization and should only be needed in case it fails to work properly. 2553If while scrolling all of a sudden the whole screen changes color completely 2554then you should try and switch off one of those. Let the developer know if 2555you can figure out the line that causes the mistake. 2556 2557One triggers on "^\s*sub\s*" and the other on "^[$@%]" more or less. > 2558 2559 :let perl_no_sync_on_sub 2560 :let perl_no_sync_on_global_var 2561 2562Below you can set the maximum distance VIM should look for starting points for 2563its attempts in syntax highlighting. > 2564 2565 :let perl_sync_dist = 100 2566 2567If you want to use folding with perl, set perl_fold: > 2568 2569 :let perl_fold = 1 2570 2571If you want to fold blocks in if statements, etc. as well set the following: > 2572 2573 :let perl_fold_blocks = 1 2574 2575Subroutines are folded by default if 'perl_fold' is set. If you do not want 2576this, you can set 'perl_nofold_subs': > 2577 2578 :let perl_nofold_subs = 1 2579 2580Anonymous subroutines are not folded by default; you may enable their folding 2581via 'perl_fold_anonymous_subs': > 2582 2583 :let perl_fold_anonymous_subs = 1 2584 2585Packages are also folded by default if 'perl_fold' is set. To disable this 2586behavior, set 'perl_nofold_packages': > 2587 2588 :let perl_nofold_packages = 1 2589 2590PHP3 and PHP4 *ft-php-syntax* *ft-php3-syntax* 2591 2592[Note: Previously this was called "php3", but since it now also supports php4 2593it has been renamed to "php"] 2594 2595There are the following options for the php syntax highlighting. 2596 2597If you like SQL syntax highlighting inside Strings: > 2598 2599 let php_sql_query = 1 2600 2601For highlighting the Baselib methods: > 2602 2603 let php_baselib = 1 2604 2605Enable HTML syntax highlighting inside strings: > 2606 2607 let php_htmlInStrings = 1 2608 2609Using the old colorstyle: > 2610 2611 let php_oldStyle = 1 2612 2613Enable highlighting ASP-style short tags: > 2614 2615 let php_asp_tags = 1 2616 2617Disable short tags: > 2618 2619 let php_noShortTags = 1 2620 2621For highlighting parent error ] or ): > 2622 2623 let php_parent_error_close = 1 2624 2625For skipping a php end tag, if there exists an open ( or [ without a closing 2626one: > 2627 2628 let php_parent_error_open = 1 2629 2630Enable folding for classes and functions: > 2631 2632 let php_folding = 1 2633 2634Selecting syncing method: > 2635 2636 let php_sync_method = x 2637 2638x = -1 to sync by search (default), 2639x > 0 to sync at least x lines backwards, 2640x = 0 to sync from start. 2641 2642 2643PLAINTEX *ft-plaintex-syntax* 2644 2645TeX is a typesetting language, and plaintex is the file type for the "plain" 2646variant of TeX. If you never want your `*.tex` files recognized as plain TeX, 2647see |ft-tex-plugin|. 2648 2649This syntax file has the option > 2650 2651 let g:plaintex_delimiters = 1 2652 2653if you want to highlight brackets "[]" and braces "{}". 2654 2655 2656PPWIZARD *ft-ppwiz-syntax* 2657 2658PPWizard is a preprocessor for HTML and OS/2 INF files 2659 2660This syntax file has the options: 2661 2662- ppwiz_highlight_defs : Determines highlighting mode for PPWizard's 2663 definitions. Possible values are 2664 2665 ppwiz_highlight_defs = 1 : PPWizard #define statements retain the 2666 colors of their contents (e.g. PPWizard macros and variables). 2667 2668 ppwiz_highlight_defs = 2 : Preprocessor #define and #evaluate 2669 statements are shown in a single color with the exception of line 2670 continuation symbols. 2671 2672 The default setting for ppwiz_highlight_defs is 1. 2673 2674- ppwiz_with_html : If the value is 1 (the default), highlight literal 2675 HTML code; if 0, treat HTML code like ordinary text. 2676 2677 2678PHTML *ft-phtml-syntax* 2679 2680There are two options for the phtml syntax highlighting. 2681 2682If you like SQL syntax highlighting inside Strings, use this: > 2683 2684 :let phtml_sql_query = 1 2685 2686For syncing, minlines defaults to 100. If you prefer another value, you can 2687set "phtml_minlines" to the value you desire. Example: > 2688 2689 :let phtml_minlines = 200 2690 2691 2692POSTSCRIPT *ft-postscr-syntax* 2693 2694There are several options when it comes to highlighting PostScript. 2695 2696First which version of the PostScript language to highlight. There are 2697currently three defined language versions, or levels. Level 1 is the original 2698and base version, and includes all extensions prior to the release of level 2. 2699Level 2 is the most common version around, and includes its own set of 2700extensions prior to the release of level 3. Level 3 is currently the highest 2701level supported. You select which level of the PostScript language you want 2702highlighted by defining the postscr_level variable as follows: > 2703 2704 :let postscr_level=2 2705 2706If this variable is not defined it defaults to 2 (level 2) since this is 2707the most prevalent version currently. 2708 2709Note: Not all PS interpreters will support all language features for a 2710particular language level. In particular the %!PS-Adobe-3.0 at the start of 2711PS files does NOT mean the PostScript present is level 3 PostScript! 2712 2713If you are working with Display PostScript, you can include highlighting of 2714Display PS language features by defining the postscr_display variable as 2715follows: > 2716 2717 :let postscr_display=1 2718 2719If you are working with Ghostscript, you can include highlighting of 2720Ghostscript specific language features by defining the variable 2721postscr_ghostscript as follows: > 2722 2723 :let postscr_ghostscript=1 2724 2725PostScript is a large language, with many predefined elements. While it 2726useful to have all these elements highlighted, on slower machines this can 2727cause Vim to slow down. In an attempt to be machine friendly font names and 2728character encodings are not highlighted by default. Unless you are working 2729explicitly with either of these this should be ok. If you want them to be 2730highlighted you should set one or both of the following variables: > 2731 2732 :let postscr_fonts=1 2733 :let postscr_encodings=1 2734 2735There is a stylistic option to the highlighting of and, or, and not. In 2736PostScript the function of these operators depends on the types of their 2737operands - if the operands are booleans then they are the logical operators, 2738if they are integers then they are binary operators. As binary and logical 2739operators can be highlighted differently they have to be highlighted one way 2740or the other. By default they are treated as logical operators. They can be 2741highlighted as binary operators by defining the variable 2742postscr_andornot_binary as follows: > 2743 2744 :let postscr_andornot_binary=1 2745< 2746 2747 *ft-printcap-syntax* 2748PRINTCAP + TERMCAP *ft-ptcap-syntax* *ft-termcap-syntax* 2749 2750This syntax file applies to the printcap and termcap databases. 2751 2752In order for Vim to recognize printcap/termcap files that do not match 2753the patterns "*printcap*", or "*termcap*", you must put additional patterns 2754appropriate to your system in your |myfiletypefile| file. For these 2755patterns, you must set the variable "b:ptcap_type" to either "print" or 2756"term", and then the 'filetype' option to ptcap. 2757 2758For example, to make Vim identify all files in /etc/termcaps/ as termcap 2759files, add the following: > 2760 2761 :au BufNewFile,BufRead /etc/termcaps/* let b:ptcap_type = "term" | 2762 \ set filetype=ptcap 2763 2764If you notice highlighting errors while scrolling backwards, which 2765are fixed when redrawing with CTRL-L, try setting the "ptcap_minlines" 2766internal variable to a larger number: > 2767 2768 :let ptcap_minlines = 50 2769 2770(The default is 20 lines.) 2771 2772 2773PROGRESS *ft-progress-syntax* 2774 2775Files matching "*.w" could be Progress or cweb. If the automatic detection 2776doesn't work for you, or you don't edit cweb at all, use this in your 2777startup vimrc: > 2778 :let filetype_w = "progress" 2779The same happens for "*.i", which could be assembly, and "*.p", which could be 2780Pascal. Use this if you don't use assembly and Pascal: > 2781 :let filetype_i = "progress" 2782 :let filetype_p = "progress" 2783 2784 2785PYTHON *ft-python-syntax* 2786 2787There are seven options to control Python syntax highlighting. 2788 2789For highlighted numbers: > 2790 :let python_no_number_highlight = 1 2791 2792For highlighted builtin functions: > 2793 :let python_no_builtin_highlight = 1 2794 2795For highlighted standard exceptions: > 2796 :let python_no_exception_highlight = 1 2797 2798For highlighted doctests and code inside: > 2799 :let python_no_doctest_highlight = 1 2800or > 2801 :let python_no_doctest_code_highlight = 1 2802The first option implies the second one. 2803 2804For highlighted trailing whitespace and mix of spaces and tabs: > 2805 :let python_space_error_highlight = 1 2806 2807For highlighted built-in constants distinguished from other keywords: > 2808 :let python_constant_highlight = 1 2809 2810If you want all possible Python highlighting: > 2811 :let python_highlight_all = 1 2812This has the same effect as setting python_space_error_highlight, 2813python_constant_highlight and unsetting all the other ones. 2814 2815If you use Python 2 or straddling code (Python 2 and 3 compatible), 2816you can enforce the use of an older syntax file with support for 2817Python 2 and up to Python 3.5. > 2818 :let python_use_python2_syntax = 1 2819This option will exclude all modern Python 3.6 or higher features. 2820 2821Note: Only existence of these options matters, not their value. 2822 You can replace 1 above with anything. 2823 2824 2825QUAKE *ft-quake-syntax* 2826 2827The Quake syntax definition should work for most FPS (First Person Shooter) 2828based on one of the Quake engines. However, the command names vary a bit 2829between the three games (Quake, Quake 2, and Quake 3 Arena) so the syntax 2830definition checks for the existence of three global variables to allow users 2831to specify what commands are legal in their files. The three variables can 2832be set for the following effects: 2833 2834set to highlight commands only available in Quake: > 2835 :let quake_is_quake1 = 1 2836 2837set to highlight commands only available in Quake 2: > 2838 :let quake_is_quake2 = 1 2839 2840set to highlight commands only available in Quake 3 Arena: > 2841 :let quake_is_quake3 = 1 2842 2843Any combination of these three variables is legal, but might highlight more 2844commands than are actually available to you by the game. 2845 2846 2847R *ft-r-syntax* 2848 2849The parsing of R code for syntax highlight starts 40 lines backwards, but you 2850can set a different value in your |vimrc|. Example: > 2851 let r_syntax_minlines = 60 2852 2853You can also turn off syntax highlighting of ROxygen: > 2854 let r_syntax_hl_roxygen = 0 2855 2856enable folding of code delimited by parentheses, square brackets and curly 2857braces: > 2858 let r_syntax_folding = 1 2859 2860and highlight as functions all keywords followed by an opening parenthesis: > 2861 let r_syntax_fun_pattern = 1 2862 2863 2864R MARKDOWN *ft-rmd-syntax* 2865 2866To disable syntax highlight of YAML header, add to your |vimrc|: > 2867 let rmd_syn_hl_yaml = 0 2868 2869To disable syntax highlighting of citation keys: > 2870 let rmd_syn_hl_citations = 0 2871 2872To highlight R code in knitr chunk headers: > 2873 let rmd_syn_hl_chunk = 1 2874 2875By default, chunks of R code will be highlighted following the rules of R 2876language. Moreover, whenever the buffer is saved, Vim scans the buffer and 2877highlights other languages if they are present in new chunks. LaTeX code also 2878is automatically recognized and highlighted when the buffer is saved. This 2879behavior can be controlled with the variables `rmd_dynamic_fenced_languages`, 2880and `rmd_include_latex` whose valid values are: > 2881 let rmd_dynamic_fenced_languages = 0 " No autodetection of languages 2882 let rmd_dynamic_fenced_languages = 1 " Autodetection of languages 2883 let rmd_include_latex = 0 " Don't highlight LaTeX code 2884 let rmd_include_latex = 1 " Autodetect LaTeX code 2885 let rmd_include_latex = 2 " Always include LaTeX highlighting 2886 2887If the value of `rmd_dynamic_fenced_languages` is 0, you still can set the 2888list of languages whose chunks of code should be properly highlighted, as in 2889the example: > 2890 let rmd_fenced_languages = ['r', 'python'] 2891 2892 2893R RESTRUCTURED TEXT *ft-rrst-syntax* 2894 2895To highlight R code in knitr chunk headers, add to your |vimrc|: > 2896 let rrst_syn_hl_chunk = 1 2897 2898 2899RASI *ft-rasi-syntax* 2900 2901Rasi stands for Rofi Advanced Style Information. It is used by the program 2902rofi to style the rendering of the search window. The language is heavily 2903inspired by CSS stylesheet. Files with the following extensions are 2904recognized as rasi files: .rasi. 2905 2906READLINE *ft-readline-syntax* 2907 2908The readline library is primarily used by the BASH shell, which adds quite a 2909few commands and options to the ones already available. To highlight these 2910items as well you can add the following to your |vimrc| or just type it in the 2911command line before loading a file with the readline syntax: > 2912 let readline_has_bash = 1 2913 2914This will add highlighting for the commands that BASH (version 2.05a and 2915later, and part earlier) adds. 2916 2917 2918REGO *ft-rego-syntax* 2919 2920Rego is a query language developed by Styra. It is mostly used as a policy 2921language for kubernetes, but can be applied to almost anything. Files with 2922the following extensions are recognized as rego files: .rego. 2923 2924 2925RESTRUCTURED TEXT *ft-rst-syntax* 2926 2927Syntax highlighting is enabled for code blocks within the document for a 2928select number of file types. See $VIMRUNTIME/syntax/rst.vim for the default 2929syntax list. 2930 2931To set a user-defined list of code block syntax highlighting: > 2932 let rst_syntax_code_list = ['vim', 'lisp', ...] 2933 2934To assign multiple code block types to a single syntax, define 2935`rst_syntax_code_list` as a mapping: > 2936 let rst_syntax_code_list = { 2937 \ 'cpp': ['cpp', 'c++'], 2938 \ 'bash': ['bash', 'sh'], 2939 ... 2940 \ } 2941 2942To use color highlighting for emphasis text: > 2943 let rst_use_emphasis_colors = 1 2944 2945To enable folding of sections: > 2946 let rst_fold_enabled = 1 2947 2948Note that folding can cause performance issues on some platforms. 2949 2950The minimum line syntax sync is set to 50. To modify this number: > 2951 let rst_minlines = 100 2952 2953 2954REXX *ft-rexx-syntax* 2955 2956If you notice highlighting errors while scrolling backwards, which are fixed 2957when redrawing with CTRL-L, try setting the "rexx_minlines" internal variable 2958to a larger number: > 2959 :let rexx_minlines = 50 2960This will make the syntax synchronization start 50 lines before the first 2961displayed line. The default value is 10. The disadvantage of using a larger 2962number is that redrawing can become slow. 2963 2964Vim tries to guess what type a ".r" file is. If it can't be detected (from 2965comment lines), the default is "r". To make the default rexx add this line to 2966your vimrc: *g:filetype_r* 2967> 2968 :let g:filetype_r = "r" 2969 2970 2971RUBY *ft-ruby-syntax* 2972 2973 Ruby: Operator highlighting |ruby_operators| 2974 Ruby: Whitespace errors |ruby_space_errors| 2975 Ruby: Folding |ruby_fold| |ruby_foldable_groups| 2976 Ruby: Reducing expensive operations |ruby_no_expensive| |ruby_minlines| 2977 Ruby: Spellchecking strings |ruby_spellcheck_strings| 2978 2979 *ruby_operators* 2980 Ruby: Operator highlighting ~ 2981 2982Operators can be highlighted by defining "ruby_operators": > 2983 2984 :let ruby_operators = 1 2985< 2986 *ruby_space_errors* 2987 Ruby: Whitespace errors ~ 2988 2989Whitespace errors can be highlighted by defining "ruby_space_errors": > 2990 2991 :let ruby_space_errors = 1 2992< 2993This will highlight trailing whitespace and tabs preceded by a space character 2994as errors. This can be refined by defining "ruby_no_trail_space_error" and 2995"ruby_no_tab_space_error" which will ignore trailing whitespace and tabs after 2996spaces respectively. 2997 2998 *ruby_fold* *ruby_foldable_groups* 2999 Ruby: Folding ~ 3000 3001Folding can be enabled by defining "ruby_fold": > 3002 3003 :let ruby_fold = 1 3004< 3005This will set the value of 'foldmethod' to "syntax" locally to the current 3006buffer or window, which will enable syntax-based folding when editing Ruby 3007filetypes. 3008 3009Default folding is rather detailed, i.e., small syntax units like "if", "do", 3010"%w[]" may create corresponding fold levels. 3011 3012You can set "ruby_foldable_groups" to restrict which groups are foldable: > 3013 3014 :let ruby_foldable_groups = 'if case %' 3015< 3016The value is a space-separated list of keywords: 3017 3018 keyword meaning ~ 3019 -------- ------------------------------------- ~ 3020 ALL Most block syntax (default) 3021 NONE Nothing 3022 if "if" or "unless" block 3023 def "def" block 3024 class "class" block 3025 module "module" block 3026 do "do" block 3027 begin "begin" block 3028 case "case" block 3029 for "for", "while", "until" loops 3030 { Curly bracket block or hash literal 3031 [ Array literal 3032 % Literal with "%" notation, e.g.: %w(STRING), %!STRING! 3033 / Regexp 3034 string String and shell command output (surrounded by ', ", "`") 3035 : Symbol 3036 # Multiline comment 3037 << Here documents 3038 __END__ Source code after "__END__" directive 3039 3040 *ruby_no_expensive* 3041 Ruby: Reducing expensive operations ~ 3042 3043By default, the "end" keyword is colorized according to the opening statement 3044of the block it closes. While useful, this feature can be expensive; if you 3045experience slow redrawing (or you are on a terminal with poor color support) 3046you may want to turn it off by defining the "ruby_no_expensive" variable: > 3047 3048 :let ruby_no_expensive = 1 3049< 3050In this case the same color will be used for all control keywords. 3051 3052 *ruby_minlines* 3053 3054If you do want this feature enabled, but notice highlighting errors while 3055scrolling backwards, which are fixed when redrawing with CTRL-L, try setting 3056the "ruby_minlines" variable to a value larger than 50: > 3057 3058 :let ruby_minlines = 100 3059< 3060Ideally, this value should be a number of lines large enough to embrace your 3061largest class or module. 3062 3063 *ruby_spellcheck_strings* 3064 Ruby: Spellchecking strings ~ 3065 3066Ruby syntax will perform spellchecking of strings if you define 3067"ruby_spellcheck_strings": > 3068 3069 :let ruby_spellcheck_strings = 1 3070< 3071 3072SCHEME *ft-scheme-syntax* 3073 3074By default only R7RS keywords are highlighted and properly indented. 3075 3076scheme.vim also supports extensions of the CHICKEN Scheme->C compiler. 3077Define b:is_chicken or g:is_chicken, if you need them. 3078 3079 3080SDL *ft-sdl-syntax* 3081 3082The SDL highlighting probably misses a few keywords, but SDL has so many 3083of them it's almost impossibly to cope. 3084 3085The new standard, SDL-2000, specifies that all identifiers are 3086case-sensitive (which was not so before), and that all keywords can be 3087used either completely lowercase or completely uppercase. To have the 3088highlighting reflect this, you can set the following variable: > 3089 :let sdl_2000=1 3090 3091This also sets many new keywords. If you want to disable the old 3092keywords, which is probably a good idea, use: > 3093 :let SDL_no_96=1 3094 3095 3096The indentation is probably also incomplete, but right now I am very 3097satisfied with it for my own projects. 3098 3099 3100SED *ft-sed-syntax* 3101 3102To make tabs stand out from regular blanks (accomplished by using Todo 3103highlighting on the tabs), define "g:sed_highlight_tabs" by putting > 3104 3105 :let g:sed_highlight_tabs = 1 3106< 3107in the vimrc file. (This special highlighting only applies for tabs 3108inside search patterns, replacement texts, addresses or text included 3109by an Append/Change/Insert command.) If you enable this option, it is 3110also a good idea to set the tab width to one character; by doing that, 3111you can easily count the number of tabs in a string. 3112 3113GNU sed allows comments after text on the same line. BSD sed only allows 3114comments where "#" is the first character of the line. To enforce BSD-style 3115comments, i.e. mark end-of-line comments as errors, use: > 3116 3117 :let g:sed_dialect = "bsd" 3118< 3119Note that there are other differences between GNU sed and BSD sed which are 3120not (yet) affected by this setting. 3121 3122Bugs: 3123 3124 The transform command (y) is treated exactly like the substitute 3125 command. This means that, as far as this syntax file is concerned, 3126 transform accepts the same flags as substitute, which is wrong. 3127 (Transform accepts no flags.) I tolerate this bug because the 3128 involved commands need very complex treatment (95 patterns, one for 3129 each plausible pattern delimiter). 3130 3131 3132SGML *ft-sgml-syntax* 3133 3134The coloring scheme for tags in the SGML file works as follows. 3135 3136The <> of opening tags are colored differently than the </> of a closing tag. 3137This is on purpose! For opening tags the 'Function' color is used, while for 3138closing tags the 'Type' color is used (See syntax.vim to check how those are 3139defined for you) 3140 3141Known tag names are colored the same way as statements in C. Unknown tag 3142names are not colored which makes it easy to spot errors. 3143 3144Note that the same is true for argument (or attribute) names. Known attribute 3145names are colored differently than unknown ones. 3146 3147Some SGML tags are used to change the rendering of text. The following tags 3148are recognized by the sgml.vim syntax coloring file and change the way normal 3149text is shown: <varname> <emphasis> <command> <function> <literal> 3150<replaceable> <ulink> and <link>. 3151 3152If you want to change how such text is rendered, you must redefine the 3153following syntax groups: 3154 3155 - sgmlBold 3156 - sgmlBoldItalic 3157 - sgmlUnderline 3158 - sgmlItalic 3159 - sgmlLink for links 3160 3161To make this redefinition work you must redefine them all and define the 3162following variable in your vimrc (this is due to the order in which the files 3163are read during initialization) > 3164 let sgml_my_rendering=1 3165 3166You can also disable this rendering by adding the following line to your 3167vimrc file: > 3168 let sgml_no_rendering=1 3169 3170(Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>) 3171 3172 3173 *ft-posix-syntax* *ft-dash-syntax* 3174SH *ft-sh-syntax* *ft-bash-syntax* *ft-ksh-syntax* 3175 3176This covers syntax highlighting for the older Unix (Bourne) sh, and newer 3177shells such as bash, dash, posix, and the Korn shells. 3178 3179Vim attempts to determine which shell type is in use by specifying that 3180various filenames are of specific types, e.g.: > 3181 3182 ksh : .kshrc* *.ksh 3183 bash: .bashrc* bashrc bash.bashrc .bash_profile* *.bash 3184< 3185See $VIMRUNTIME/filetype.vim for the full list of patterns. If none of these 3186cases pertain, then the first line of the file is examined (ex. looking for 3187/bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype, then 3188that shelltype is used. However some files (ex. .profile) are known to be 3189shell files but the type is not apparent. Furthermore, on many systems sh is 3190symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (POSIX). 3191 3192One may specify a global default by instantiating one of the following 3193variables in your vimrc: 3194 3195 ksh: > 3196 let g:is_kornshell = 1 3197< posix: (default) > 3198 let g:is_posix = 1 3199< bash: > 3200 let g:is_bash = 1 3201< dash: > 3202 let g:is_dash = 1 3203< sh: Bourne shell > 3204 let g:is_sh = 1 3205 3206Specific shell features are automatically enabled based on the shell detected 3207from the shebang line ("#! ..."). For KornShell Vim detects different shell 3208features for mksh, ksh88, ksh93, ksh93u, ksh93v, and ksh2020. 3209 3210If there's no "#! ..." line, and the user hasn't availed themself of a default 3211sh.vim syntax setting as just shown, then syntax/sh.vim will assume the POSIX 3212shell syntax. No need to quote RFCs or market penetration statistics in error 3213reports, please -- just select the default version of the sh your system uses 3214and install the associated "let..." in your <.vimrc>. 3215 3216The syntax/sh.vim file provides several levels of syntax-based folding: > 3217 3218 let g:sh_fold_enabled= 0 (default, no syntax folding) 3219 let g:sh_fold_enabled= 1 (enable function folding) 3220 let g:sh_fold_enabled= 2 (enable heredoc folding) 3221 let g:sh_fold_enabled= 4 (enable if/do/for folding) 3222 3223then various syntax items (ie. HereDocuments and function bodies) become 3224syntax-foldable (see |:syn-fold|). You also may add these together 3225to get multiple types of folding: > 3226 3227 let g:sh_fold_enabled= 3 (enables function and heredoc folding) 3228 3229If you notice highlighting errors while scrolling backwards which are fixed 3230when one redraws with CTRL-L, try setting the "sh_minlines" internal variable 3231to a larger number. Example: > 3232 3233 let sh_minlines = 500 3234 3235This will make syntax synchronization start 500 lines before the first 3236displayed line. The default value is 200. The disadvantage of using a larger 3237number is that redrawing can become slow. 3238 3239If you don't have much to synchronize on, displaying can be very slow. To 3240reduce this, the "sh_maxlines" internal variable can be set. Example: > 3241 3242 let sh_maxlines = 100 3243< 3244The default is to use the twice sh_minlines. Set it to a smaller number to 3245speed up displaying. The disadvantage is that highlight errors may appear. 3246 3247Unmatched "]", "done", "fi", etc., are highlighted as errors by default. If 3248you find this error handling problematic, you may suppress it with: > 3249 3250 let g:sh_no_error = 1 3251< 3252As a refinement, you may suppress particular classes of errors by looking up 3253their syntax rule names and listing them with: > 3254 3255 let g:sh_no_error_rules = ["shCurlyError", "shParenError"] 3256< 3257 3258 *sh-embed* *sh-awk* 3259 Sh: EMBEDDING LANGUAGES~ 3260 3261You may wish to embed languages into sh. I'll give an example courtesy of 3262Lorance Stinson on how to do this with awk as an example. Put the following 3263file into $HOME/.config/nvim/after/syntax/sh/awkembed.vim: > 3264 3265 " AWK Embedding: 3266 " ============== 3267 " Shamelessly ripped from aspperl.vim by Aaron Hope. 3268 if exists("b:current_syntax") 3269 unlet b:current_syntax 3270 endif 3271 syn include @AWKScript syntax/awk.vim 3272 syn region AWKScriptCode matchgroup=AWKCommand start=+[=\\]\@<!'+ skip=+\\'+ end=+'+ contains=@AWKScript contained 3273 syn region AWKScriptEmbedded matchgroup=AWKCommand start=+\<awk\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1 contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode 3274 syn cluster shCommandSubList add=AWKScriptEmbedded 3275 hi def link AWKCommand Type 3276< 3277This code will then let the awk code in the single quotes: > 3278 awk '...awk code here...' 3279be highlighted using the awk highlighting syntax. Clearly this may be 3280extended to other languages. 3281 3282 3283SPEEDUP *ft-spup-syntax* 3284(AspenTech plant simulator) 3285 3286The Speedup syntax file has some options: 3287 3288- strict_subsections : If this variable is defined, only keywords for 3289 sections and subsections will be highlighted as statements but not 3290 other keywords (like WITHIN in the OPERATION section). 3291 3292- highlight_types : Definition of this variable causes stream types 3293 like temperature or pressure to be highlighted as Type, not as a 3294 plain Identifier. Included are the types that are usually found in 3295 the DECLARE section; if you defined own types, you have to include 3296 them in the syntax file. 3297 3298- oneline_comments : This value ranges from 1 to 3 and determines the 3299 highlighting of # style comments. 3300 3301 oneline_comments = 1 : Allow normal Speedup code after an even 3302 number of #s. 3303 3304 oneline_comments = 2 : Show code starting with the second # as 3305 error. This is the default setting. 3306 3307 oneline_comments = 3 : Show the whole line as error if it contains 3308 more than one #. 3309 3310Since especially OPERATION sections tend to become very large due to 3311PRESETting variables, syncing may be critical. If your computer is 3312fast enough, you can increase minlines and/or maxlines near the end of 3313the syntax file. 3314 3315 3316SQL *ft-sql-syntax* 3317 *ft-sqlinformix-syntax* 3318 *ft-sqlanywhere-syntax* 3319 3320While there is an ANSI standard for SQL, most database engines add their own 3321custom extensions. Vim currently supports the Oracle and Informix dialects of 3322SQL. Vim assumes "*.sql" files are Oracle SQL by default. 3323 3324Vim currently has SQL support for a variety of different vendors via syntax 3325scripts. You can change Vim's default from Oracle to any of the current SQL 3326supported types. You can also easily alter the SQL dialect being used on a 3327buffer by buffer basis. 3328 3329For more detailed instructions see |ft_sql.txt|. 3330 3331 3332SQUIRREL *ft-squirrel-syntax* 3333 3334Squirrel is a high level imperative, object-oriented programming language, 3335designed to be a light-weight scripting language that fits in the size, memory 3336bandwidth, and real-time requirements of applications like video games. Files 3337with the following extensions are recognized as squirrel files: .nut. 3338 3339 3340TCSH *ft-tcsh-syntax* 3341 3342This covers the shell named "tcsh". It is a superset of csh. See 3343|ft-csh-syntax| for how the filetype is detected. 3344 3345Tcsh does not allow \" in strings unless the "backslash_quote" shell variable 3346is set. If you want VIM to assume that no backslash quote constructs exist 3347add this line to your vimrc: > 3348 3349 :let tcsh_backslash_quote = 0 3350 3351If you notice highlighting errors while scrolling backwards, which are fixed 3352when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable 3353to a larger number: > 3354 3355 :let tcsh_minlines = 1000 3356 3357This will make the syntax synchronization start 1000 lines before the first 3358displayed line. If you set "tcsh_minlines" to "fromstart", then 3359synchronization is done from the start of the file. The default value for 3360tcsh_minlines is 100. The disadvantage of using a larger number is that 3361redrawing can become slow. 3362 3363 3364TEX *ft-tex-syntax* *latex-syntax* 3365 *syntax-tex* *syntax-latex* 3366 3367 Tex Contents~ 3368 Tex: Want Syntax Folding? |tex-folding| 3369 Tex: No Spell Checking Wanted |g:tex_nospell| 3370 Tex: Don't Want Spell Checking In Comments? |tex-nospell| 3371 Tex: Want Spell Checking in Verbatim Zones? |tex-verb| 3372 Tex: Run-on Comments or MathZones |tex-runon| 3373 Tex: Slow Syntax Highlighting? |tex-slow| 3374 Tex: Want To Highlight More Commands? |tex-morecommands| 3375 Tex: Excessive Error Highlighting? |tex-error| 3376 Tex: Need a new Math Group? |tex-math| 3377 Tex: Starting a New Style? |tex-style| 3378 Tex: Taking Advantage of Conceal Mode |tex-conceal| 3379 Tex: Selective Conceal Mode |g:tex_conceal| 3380 Tex: Controlling iskeyword |g:tex_isk| 3381 Tex: Fine Subscript and Superscript Control |tex-supersub| 3382 Tex: Match Check Control |tex-matchcheck| 3383 3384 *tex-folding* *g:tex_fold_enabled* 3385 Tex: Want Syntax Folding? ~ 3386 3387As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters, 3388sections, subsections, etc are supported. Put > 3389 let g:tex_fold_enabled=1 3390in your vimrc, and :set fdm=syntax. I suggest doing the latter via a 3391modeline at the end of your LaTeX file: > 3392 % vim: fdm=syntax 3393If your system becomes too slow, then you might wish to look into > 3394 https://vimhelp.org/vim_faq.txt.html#faq-29.7 3395< 3396 *g:tex_nospell* 3397 Tex: No Spell Checking Wanted~ 3398 3399If you don't want spell checking anywhere in your LaTeX document, put > 3400 let g:tex_nospell=1 3401into your vimrc. If you merely wish to suppress spell checking inside 3402comments only, see |g:tex_comment_nospell|. 3403 3404 *tex-nospell* *g:tex_comment_nospell* 3405 Tex: Don't Want Spell Checking In Comments? ~ 3406 3407Some folks like to include things like source code in comments and so would 3408prefer that spell checking be disabled in comments in LaTeX files. To do 3409this, put the following in your vimrc: > 3410 let g:tex_comment_nospell= 1 3411If you want to suppress spell checking everywhere inside your LaTeX document, 3412see |g:tex_nospell|. 3413 3414 *tex-verb* *g:tex_verbspell* 3415 Tex: Want Spell Checking in Verbatim Zones?~ 3416 3417Often verbatim regions are used for things like source code; seldom does 3418one want source code spell-checked. However, for those of you who do 3419want your verbatim zones spell-checked, put the following in your vimrc: > 3420 let g:tex_verbspell= 1 3421< 3422 *tex-runon* *tex-stopzone* 3423 Tex: Run-on Comments or MathZones ~ 3424 3425The <syntax/tex.vim> highlighting supports TeX, LaTeX, and some AmsTeX. The 3426highlighting supports three primary zones/regions: normal, texZone, and 3427texMathZone. Although considerable effort has been made to have these zones 3428terminate properly, zones delineated by $..$ and $$..$$ cannot be synchronized 3429as there's no difference between start and end patterns. Consequently, a 3430special "TeX comment" has been provided > 3431 %stopzone 3432which will forcibly terminate the highlighting of either a texZone or a 3433texMathZone. 3434 3435 *tex-slow* *tex-sync* 3436 Tex: Slow Syntax Highlighting? ~ 3437 3438If you have a slow computer, you may wish to reduce the values for > 3439 :syn sync maxlines=200 3440 :syn sync minlines=50 3441(especially the latter). If your computer is fast, you may wish to 3442increase them. This primarily affects synchronizing (i.e. just what group, 3443if any, is the text at the top of the screen supposed to be in?). 3444 3445Another cause of slow highlighting is due to syntax-driven folding; see 3446|tex-folding| for a way around this. 3447 3448 *g:tex_fast* 3449 3450Finally, if syntax highlighting is still too slow, you may set > 3451 3452 :let g:tex_fast= "" 3453 3454in your vimrc. Used this way, the g:tex_fast variable causes the syntax 3455highlighting script to avoid defining any regions and associated 3456synchronization. The result will be much faster syntax highlighting; the 3457price: you will no longer have as much highlighting or any syntax-based 3458folding, and you will be missing syntax-based error checking. 3459 3460You may decide that some syntax is acceptable; you may use the following table 3461selectively to enable just some syntax highlighting: > 3462 3463 b : allow bold and italic syntax 3464 c : allow texComment syntax 3465 m : allow texMatcher syntax (ie. {...} and [...]) 3466 M : allow texMath syntax 3467 p : allow parts, chapter, section, etc syntax 3468 r : allow texRefZone syntax (nocite, bibliography, label, pageref, eqref) 3469 s : allow superscript/subscript regions 3470 S : allow texStyle syntax 3471 v : allow verbatim syntax 3472 V : allow texNewEnv and texNewCmd syntax 3473< 3474As an example, let g:tex_fast= "M" will allow math-associated highlighting 3475but suppress all the other region-based syntax highlighting. 3476(also see: |g:tex_conceal| and |tex-supersub|) 3477 3478 *tex-morecommands* *tex-package* 3479 Tex: Want To Highlight More Commands? ~ 3480 3481LaTeX is a programmable language, and so there are thousands of packages full 3482of specialized LaTeX commands, syntax, and fonts. If you're using such a 3483package you'll often wish that the distributed syntax/tex.vim would support 3484it. However, clearly this is impractical. So please consider using the 3485techniques in |mysyntaxfile-add| to extend or modify the highlighting provided 3486by syntax/tex.vim. 3487 3488I've included some support for various popular packages on my website: > 3489 3490 https://www.drchip.org/astronaut/vim/index.html#LATEXPKGS 3491< 3492The syntax files there go into your .../after/syntax/tex/ directory. 3493 3494 *tex-error* *g:tex_no_error* 3495 Tex: Excessive Error Highlighting? ~ 3496 3497The <tex.vim> supports lexical error checking of various sorts. Thus, 3498although the error checking is ofttimes very useful, it can indicate 3499errors where none actually are. If this proves to be a problem for you, 3500you may put in your vimrc the following statement: > 3501 let g:tex_no_error=1 3502and all error checking by <syntax/tex.vim> will be suppressed. 3503 3504 *tex-math* 3505 Tex: Need a new Math Group? ~ 3506 3507If you want to include a new math group in your LaTeX, the following 3508code shows you an example as to how you might do so: > 3509 call TexNewMathZone(sfx,mathzone,starform) 3510You'll want to provide the new math group with a unique suffix 3511(currently, A-L and V-Z are taken by <syntax/tex.vim> itself). 3512As an example, consider how eqnarray is set up by <syntax/tex.vim>: > 3513 call TexNewMathZone("D","eqnarray",1) 3514You'll need to change "mathzone" to the name of your new math group, 3515and then to the call to it in .vim/after/syntax/tex.vim. 3516The "starform" variable, if true, implies that your new math group 3517has a starred form (ie. eqnarray*). 3518 3519 *tex-style* *b:tex_stylish* 3520 Tex: Starting a New Style? ~ 3521 3522One may use "\makeatletter" in `*.tex` files, thereby making the use of "@" in 3523commands available. However, since the `*.tex` file doesn't have one of the 3524following suffices: sty cls clo dtx ltx, the syntax highlighting will flag 3525such use of @ as an error. To solve this: > 3526 3527 :let b:tex_stylish = 1 3528 :set ft=tex 3529 3530Putting "let g:tex_stylish=1" into your vimrc will make <syntax/tex.vim> 3531always accept such use of @. 3532 3533 *tex-cchar* *tex-cole* *tex-conceal* 3534 Tex: Taking Advantage of Conceal Mode~ 3535 3536If you have 'conceallevel' set to 2 and if your encoding is utf-8, then a 3537number of character sequences can be translated into appropriate utf-8 glyphs, 3538including various accented characters, Greek characters in MathZones, and 3539superscripts and subscripts in MathZones. Not all characters can be made into 3540superscripts or subscripts; the constraint is due to what utf-8 supports. 3541In fact, only a few characters are supported as subscripts. 3542 3543One way to use this is to have vertically split windows (see |CTRL-W_v|); one 3544with 'conceallevel' at 0 and the other at 2; and both using 'scrollbind'. 3545 3546 *g:tex_conceal* 3547 Tex: Selective Conceal Mode~ 3548 3549You may selectively use conceal mode by setting g:tex_conceal in your 3550vimrc. By default, g:tex_conceal is set to "admgs" to enable concealment 3551for the following sets of characters: > 3552 3553 a = accents/ligatures 3554 b = bold and italic 3555 d = delimiters 3556 m = math symbols 3557 g = Greek 3558 s = superscripts/subscripts 3559< 3560By leaving one or more of these out, the associated conceal-character 3561substitution will not be made. 3562 3563 *g:tex_isk* *g:tex_stylish* 3564 Tex: Controlling iskeyword~ 3565 3566Normally, LaTeX keywords support 0-9, a-z, A-z, and 192-255 only. Latex 3567keywords don't support the underscore - except when in `*.sty` files. The 3568syntax highlighting script handles this with the following logic: 3569 3570 * If g:tex_stylish exists and is 1 3571 then the file will be treated as a "sty" file, so the "_" 3572 will be allowed as part of keywords 3573 (regardless of g:tex_isk) 3574 * Else if the file's suffix is sty, cls, clo, dtx, or ltx, 3575 then the file will be treated as a "sty" file, so the "_" 3576 will be allowed as part of keywords 3577 (regardless of g:tex_isk) 3578 3579 * If g:tex_isk exists, then it will be used for the local 'iskeyword' 3580 * Else the local 'iskeyword' will be set to 48-57,a-z,A-Z,192-255 3581 3582 *tex-supersub* *g:tex_superscripts* *g:tex_subscripts* 3583 Tex: Fine Subscript and Superscript Control~ 3584 3585 See |tex-conceal| for how to enable concealed character replacement. 3586 3587 See |g:tex_conceal| for selectively concealing accents, bold/italic, 3588 math, Greek, and superscripts/subscripts. 3589 3590 One may exert fine control over which superscripts and subscripts one 3591 wants syntax-based concealment for (see |:syn-cchar|). Since not all 3592 fonts support all characters, one may override the 3593 concealed-replacement lists; by default these lists are given by: > 3594 3595 let g:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]" 3596 let g:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]" 3597< 3598 For example, I use Luxi Mono Bold; it doesn't support subscript 3599 characters for "hklmnpst", so I put > 3600 let g:tex_subscripts= "[0-9aeijoruvx,+-/().]" 3601< in ~/.config/nvim/ftplugin/tex/tex.vim in order to avoid having 3602 inscrutable utf-8 glyphs appear. 3603 3604 *tex-matchcheck* *g:tex_matchcheck* 3605 Tex: Match Check Control~ 3606 3607 Sometimes one actually wants mismatched parentheses, square braces, 3608 and or curly braces; for example, \text{(1,10]} is a range from but 3609 not including 1 to and including 10. This wish, of course, conflicts 3610 with the desire to provide delimiter mismatch detection. To 3611 accommodate these conflicting goals, syntax/tex.vim provides > 3612 g:tex_matchcheck = '[({[]' 3613< which is shown along with its default setting. So, if one doesn't 3614 want [] and () to be checked for mismatches, try using > 3615 let g:tex_matchcheck= '[{}]' 3616< If you don't want matching to occur inside bold and italicized 3617 regions, > 3618 let g:tex_excludematcher= 1 3619< will prevent the texMatcher group from being included in those 3620 regions. 3621 3622TF *ft-tf-syntax* 3623 3624There is one option for the tf syntax highlighting. 3625 3626For syncing, minlines defaults to 100. If you prefer another value, you can 3627set "tf_minlines" to the value you desire. Example: > 3628 3629 :let tf_minlines = your choice 3630< 3631TYPESCRIPT *ft-typescript-syntax* *ft-typescriptreact-syntax* 3632 3633There is one option to control the TypeScript syntax highlighting. 3634 3635 *g:typescript_host_keyword* 3636When this variable is set to 1, host-specific APIs such as `addEventListener` 3637are highlighted. To disable set it to zero in your .vimrc: > 3638 3639 let g:typescript_host_keyword = 0 3640< 3641The default value is 1. 3642 3643TYPST *ft-typst-syntax* 3644 3645 *g:typst_embedded_languages* 3646Typst files can embed syntax highlighting for other languages by setting the 3647|g:typst_embedded_languages| variable. This variable is a list of language 3648names whose syntax definitions will be included in Typst files. Example: > 3649 3650 let g:typst_embedded_languages = ['python', 'r'] 3651 3652VIM *ft-vim-syntax* *g:vimsyn_minlines* *g:vimsyn_maxlines* 3653 3654There is a trade-off between more accurate syntax highlighting versus screen 3655updating speed. To improve accuracy, you may wish to increase the 3656g:vimsyn_minlines variable. The g:vimsyn_maxlines variable may be used to 3657improve screen updating rates (see |:syn-sync| for more on this). > 3658 3659 g:vimsyn_minlines : used to set synchronization minlines 3660 g:vimsyn_maxlines : used to set synchronization maxlines 3661< 3662 (g:vim_minlines and g:vim_maxlines are deprecated variants of 3663 these two options) 3664 3665 *g:vimsyn_embed* 3666The g:vimsyn_embed option allows users to select what, if any, types of 3667embedded script highlighting they wish to have. > 3668 3669 g:vimsyn_embed == 0 : disable (don't embed any scripts) 3670 g:vimsyn_embed ==# 'lpPr' : support embedded Lua, Perl, Python and Ruby 3671< 3672By default, g:vimsyn_embed is unset, and embedded Lua scripts are supported. 3673 3674 *g:vimsyn_folding* 3675Some folding is now supported with when 'foldmethod' is set to "syntax": > 3676 3677 g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding 3678 g:vimsyn_folding =~# 'a' : fold augroups 3679 g:vimsyn_folding =~# 'f' : fold functions 3680 g:vimsyn_folding =~# 'h' : fold let heredocs 3681 g:vimsyn_folding =~# 'l' : fold Lua heredocs 3682 g:vimsyn_folding =~# 'p' : fold Perl heredocs 3683 g:vimsyn_folding =~# 'P' : fold Python heredocs 3684 g:vimsyn_folding =~# 'r' : fold Ruby heredocs 3685< 3686 3687By default, g:vimsyn_folding is unset. Concatenate the indicated characters 3688to support folding of multiple syntax constructs (e.g., 3689g:vimsyn_folding = "fh" will enable folding of both functions and heredocs). 3690 3691 *g:vimsyn_comment_strings* 3692By default, strings are highlighted inside comments. This may be disabled by 3693setting g:vimsyn_comment_strings to false. 3694 3695 *g:vimsyn_noerror* 3696Not all error highlighting that syntax/vim.vim does may be correct; Vim script 3697is a difficult language to highlight correctly. A way to suppress error 3698highlighting is to put the following line in your |vimrc|: > 3699 3700 let g:vimsyn_noerror = 1 3701< 3702 3703 3704WDL *wdl-syntax* 3705 3706The Workflow Description Language is a way to specify data processing 3707workflows with a human-readable and writeable syntax. This is used a lot in 3708bioinformatics. More info on the spec can be found here: 3709https://github.com/openwdl/wdl 3710 3711 3712XF86CONFIG *ft-xf86conf-syntax* 3713 3714The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both 3715variants are supported. Automatic detection is used, but is far from perfect. 3716You may need to specify the version manually. Set the variable 3717xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in 3718your vimrc. Example: > 3719 :let xf86conf_xfree86_version=3 3720When using a mix of versions, set the b:xf86conf_xfree86_version variable. 3721 3722Note that spaces and underscores in option names are not supported. Use 3723"SyncOnGreen" instead of "__s yn con gr_e_e_n" if you want the option name 3724highlighted. 3725 3726 3727XML *ft-xml-syntax* 3728 3729Xml namespaces are highlighted by default. This can be inhibited by 3730setting a global variable: > 3731 3732 :let g:xml_namespace_transparent=1 3733< 3734 *xml-folding* 3735The xml syntax file provides syntax |folding| (see |:syn-fold|) between 3736start and end tags. This can be turned on by > 3737 3738 :let g:xml_syntax_folding = 1 3739 :set foldmethod=syntax 3740 3741Note: Syntax folding might slow down syntax highlighting significantly, 3742especially for large files. 3743 3744 3745X Pixmaps (XPM) *ft-xpm-syntax* 3746 3747xpm.vim creates its syntax items dynamically based upon the contents of the 3748XPM file. Thus if you make changes e.g. in the color specification strings, 3749you have to source it again e.g. with ":set syn=xpm". 3750 3751To copy a pixel with one of the colors, yank a "pixel" with "yl" and insert it 3752somewhere else with "P". 3753 3754Do you want to draw with the mouse? Try the following: > 3755 :function! GetPixel() 3756 : let c = getline(".")[col(".") - 1] 3757 : echo c 3758 : exe "noremap <LeftMouse> <LeftMouse>r" .. c 3759 : exe "noremap <LeftDrag> <LeftMouse>r" .. c 3760 :endfunction 3761 :noremap <RightMouse> <LeftMouse>:call GetPixel()<CR> 3762 :set guicursor=n:hor20 " to see the color beneath the cursor 3763This turns the right button into a pipette and the left button into a pen. 3764It will work with XPM files that have one character per pixel only and you 3765must not click outside of the pixel strings, but feel free to improve it. 3766 3767It will look much better with a font in a quadratic cell size, e.g. for X: > 3768 :set guifont=-*-clean-medium-r-*-*-8-*-*-*-*-80-* 3769 3770 3771YAML *ft-yaml-syntax* 3772 3773 *g:yaml_schema* *b:yaml_schema* 3774A YAML schema is a combination of a set of tags and a mechanism for resolving 3775non-specific tags. For user this means that YAML parser may, depending on 3776plain scalar contents, treat plain scalar (which can actually be only string 3777and nothing else) as a value of the other type: null, boolean, floating-point, 3778integer. `g:yaml_schema` option determines according to which schema values 3779will be highlighted specially. Supported schemas are 3780 3781Schema Description ~ 3782failsafe No additional highlighting. 3783json Supports JSON-style numbers, booleans and null. 3784core Supports more number, boolean and null styles. 3785pyyaml In addition to core schema supports highlighting timestamps, 3786 but there are some differences in what is recognized as 3787 numbers and many additional boolean values not present in core 3788 schema. 3789 3790Default schema is `core`. 3791 3792Note that schemas are not actually limited to plain scalars, but this is the 3793only difference between schemas defined in YAML specification and the only 3794difference defined in the syntax file. 3795 3796 3797ZSH *ft-zsh-syntax* 3798 3799The syntax script for zsh allows for syntax-based folding: > 3800 3801 :let g:zsh_fold_enable = 1 3802 3803============================================================================== 38046. Defining a syntax *:syn-define* *E410* 3805 3806Vim understands three types of syntax items: 3807 38081. Keyword 3809 It can only contain keyword characters, according to the characters 3810 specified with |:syn-iskeyword| or the 'iskeyword' option. It cannot 3811 contain other syntax items. It will only match with a complete word (there 3812 are no keyword characters before or after the match). The keyword "if" 3813 would match in "if(a=b)", but not in "ifdef x", because "(" is not a 3814 keyword character and "d" is. 3815 38162. Match 3817 This is a match with a single regexp pattern. 3818 38193. Region 3820 This starts at a match of the "start" regexp pattern and ends with a match 3821 with the "end" regexp pattern. Any other text can appear in between. A 3822 "skip" regexp pattern can be used to avoid matching the "end" pattern. 3823 3824Several syntax ITEMs can be put into one syntax GROUP. For a syntax group 3825you can give highlighting attributes. For example, you could have an item 3826to define a `/* ... */` comment and another one that defines a "// ..." 3827comment, and put them both in the "Comment" group. You can then specify that 3828a "Comment" will be in bold font and have a blue color. You are free to make 3829one highlight group for one syntax item, or put all items into one group. 3830This depends on how you want to specify your highlighting attributes. Putting 3831each item in its own group results in having to specify the highlighting 3832for a lot of groups. 3833 3834Note that a syntax group and a highlight group are similar. For a highlight 3835group you will have given highlight attributes. These attributes will be used 3836for the syntax group with the same name. 3837 3838In case more than one item matches at the same position, the one that was 3839defined LAST wins. Thus you can override previously defined syntax items by 3840using an item that matches the same text. But a keyword always goes before a 3841match or region. And a keyword with matching case always goes before a 3842keyword with ignoring case. 3843 3844 3845PRIORITY *:syn-priority* 3846 3847When several syntax items may match, these rules are used: 3848 38491. When multiple Match or Region items start in the same position, the item 3850 defined last has priority. 38512. A Keyword has priority over Match and Region items. 38523. An item that starts in an earlier position has priority over items that 3853 start in later positions. 3854 3855 3856DEFINING CASE *:syn-case* *E390* 3857 3858:sy[ntax] case [match | ignore] 3859 This defines if the following ":syntax" commands will work with 3860 matching case, when using "match", or with ignoring case, when using 3861 "ignore". Note that any items before this are not affected, and all 3862 items until the next ":syntax case" command are affected. 3863 3864:sy[ntax] case 3865 Show either "syntax case match" or "syntax case ignore". 3866 3867 3868DEFINING FOLDLEVEL *:syn-foldlevel* 3869 3870:sy[ntax] foldlevel start 3871:sy[ntax] foldlevel minimum 3872 This defines how the foldlevel of a line is computed when using 3873 foldmethod=syntax (see |fold-syntax| and |:syn-fold|): 3874 3875 start: Use level of item containing start of line. 3876 minimum: Use lowest local-minimum level of items on line. 3877 3878 The default is "start". Use "minimum" to search a line horizontally 3879 for the lowest level contained on the line that is followed by a 3880 higher level. This produces more natural folds when syntax items 3881 may close and open horizontally within a line. 3882 3883:sy[ntax] foldlevel 3884 Show the current foldlevel method, either "syntax foldlevel start" or 3885 "syntax foldlevel minimum". 3886 3887SPELL CHECKING *:syn-spell* 3888 3889:sy[ntax] spell toplevel 3890:sy[ntax] spell notoplevel 3891:sy[ntax] spell default 3892 This defines where spell checking is to be done for text that is not 3893 in a syntax item: 3894 3895 toplevel: Text is spell checked. 3896 notoplevel: Text is not spell checked. 3897 default: When there is a @Spell cluster no spell checking. 3898 3899 For text in syntax items use the @Spell and @NoSpell clusters 3900 |spell-syntax|. When there is no @Spell and no @NoSpell cluster then 3901 spell checking is done for "default" and "toplevel". 3902 3903 To activate spell checking the 'spell' option must be set. 3904 3905:sy[ntax] spell 3906 Show the current syntax spell checking method, either "syntax spell 3907 toplevel", "syntax spell notoplevel" or "syntax spell default". 3908 3909 3910SYNTAX ISKEYWORD SETTING *:syn-iskeyword* 3911 3912:sy[ntax] iskeyword [clear | {option}] 3913 This defines the keyword characters. It's like the 'iskeyword' option 3914 for but only applies to syntax highlighting. 3915 3916 clear: Syntax specific iskeyword setting is disabled and the 3917 buffer-local 'iskeyword' setting is used. 3918 {option} Set the syntax 'iskeyword' option to a new value. 3919 3920 Example: > 3921 :syntax iskeyword @,48-57,192-255,$,_ 3922< 3923 This would set the syntax specific iskeyword option to include all 3924 alphabetic characters, plus the numeric characters, all accented 3925 characters and also includes the "_" and the "$". 3926 3927 If no argument is given, the current value will be output. 3928 3929 Setting this option influences what |/\k| matches in syntax patterns 3930 and also determines where |:syn-keyword| will be checked for a new 3931 match. 3932 3933 It is recommended when writing syntax files, to use this command to 3934 set the correct value for the specific syntax language and not change 3935 the 'iskeyword' option. 3936 3937DEFINING KEYWORDS *:syn-keyword* 3938 3939:sy[ntax] keyword {group-name} [{options}] {keyword} ... [{options}] 3940 3941 This defines a number of keywords. 3942 3943 {group-name} Is a syntax group name such as "Comment". 3944 [{options}] See |:syn-arguments| below. 3945 {keyword} ... Is a list of keywords which are part of this group. 3946 3947 Example: > 3948 :syntax keyword Type int long char 3949< 3950 The {options} can be given anywhere in the line. They will apply to 3951 all keywords given, also for options that come after a keyword. 3952 These examples do exactly the same: > 3953 :syntax keyword Type contained int long char 3954 :syntax keyword Type int long contained char 3955 :syntax keyword Type int long char contained 3956< *E789* *E890* 3957 When you have a keyword with an optional tail, like Ex commands in 3958 Vim, you can put the optional characters inside [], to define all the 3959 variations at once: > 3960 :syntax keyword vimCommand ab[breviate] n[ext] 3961< 3962 Don't forget that a keyword can only be recognized if all the 3963 characters are included in the 'iskeyword' option. If one character 3964 isn't, the keyword will never be recognized. 3965 Multi-byte characters can also be used. These do not have to be in 3966 'iskeyword'. 3967 See |:syn-iskeyword| for defining syntax specific iskeyword settings. 3968 3969 A keyword always has higher priority than a match or region, the 3970 keyword is used if more than one item matches. Keywords do not nest 3971 and a keyword can't contain anything else. 3972 3973 Note that when you have a keyword that is the same as an option (even 3974 one that isn't allowed here), you can not use it. Use a match 3975 instead. 3976 3977 The maximum length of a keyword is 80 characters. 3978 3979 The same keyword can be defined multiple times, when its containment 3980 differs. For example, you can define the keyword once not contained 3981 and use one highlight group, and once contained, and use a different 3982 highlight group. Example: > 3983 :syn keyword vimCommand tag 3984 :syn keyword vimSetting contained tag 3985< When finding "tag" outside of any syntax item, the "vimCommand" 3986 highlight group is used. When finding "tag" in a syntax item that 3987 contains "vimSetting", the "vimSetting" group is used. 3988 3989 3990DEFINING MATCHES *:syn-match* 3991 3992:sy[ntax] match {group-name} [{options}] 3993 [excludenl] 3994 [keepend] 3995 {pattern} 3996 [{options}] 3997 3998 This defines one match. 3999 4000 {group-name} A syntax group name such as "Comment". 4001 [{options}] See |:syn-arguments| below. 4002 [excludenl] Don't make a pattern with the end-of-line "$" 4003 extend a containing match or region. Must be 4004 given before the pattern. |:syn-excludenl| 4005 keepend Don't allow contained matches to go past a 4006 match with the end pattern. See 4007 |:syn-keepend|. 4008 {pattern} The search pattern that defines the match. 4009 See |:syn-pattern| below. 4010 Note that the pattern may match more than one 4011 line, which makes the match depend on where 4012 Vim starts searching for the pattern. You 4013 need to make sure syncing takes care of this. 4014 4015 Example (match a character constant): > 4016 :syntax match Character /'.'/hs=s+1,he=e-1 4017< 4018 4019DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end* 4020 *E398* *E399* 4021:sy[ntax] region {group-name} [{options}] 4022 [matchgroup={group-name}] 4023 [keepend] 4024 [extend] 4025 [excludenl] 4026 start={start-pattern} ... 4027 [skip={skip-pattern}] 4028 end={end-pattern} ... 4029 [{options}] 4030 4031 This defines one region. It may span several lines. 4032 4033 {group-name} A syntax group name such as "Comment". 4034 [{options}] See |:syn-arguments| below. 4035 [matchgroup={group-name}] The syntax group to use for the following 4036 start or end pattern matches only. Not used 4037 for the text in between the matched start and 4038 end patterns. Use NONE to reset to not using 4039 a different group for the start or end match. 4040 See |:syn-matchgroup|. 4041 keepend Don't allow contained matches to go past a 4042 match with the end pattern. See 4043 |:syn-keepend|. 4044 extend Override a "keepend" for an item this region 4045 is contained in. See |:syn-extend|. 4046 excludenl Don't make a pattern with the end-of-line "$" 4047 extend a containing match or item. Only 4048 useful for end patterns. Must be given before 4049 the patterns it applies to. |:syn-excludenl| 4050 start={start-pattern} The search pattern that defines the start of 4051 the region. See |:syn-pattern| below. 4052 skip={skip-pattern} The search pattern that defines text inside 4053 the region where not to look for the end 4054 pattern. See |:syn-pattern| below. 4055 end={end-pattern} The search pattern that defines the end of 4056 the region. See |:syn-pattern| below. 4057 4058 Example: > 4059 :syntax region String start=+"+ skip=+\\"+ end=+"+ 4060< 4061 The start/skip/end patterns and the options can be given in any order. 4062 There can be zero or one skip pattern. There must be one or more 4063 start and end patterns. This means that you can omit the skip 4064 pattern, but you must give at least one start and one end pattern. It 4065 is allowed to have white space before and after the equal sign 4066 (although it mostly looks better without white space). 4067 4068 When more than one start pattern is given, a match with one of these 4069 is sufficient. This means there is an OR relation between the start 4070 patterns. The last one that matches is used. The same is true for 4071 the end patterns. 4072 4073 The search for the end pattern starts right after the start pattern. 4074 Offsets are not used for this. This implies that the match for the 4075 end pattern will never overlap with the start pattern. 4076 4077 The skip and end pattern can match across line breaks, but since the 4078 search for the pattern can start in any line it often does not do what 4079 you want. The skip pattern doesn't avoid a match of an end pattern in 4080 the next line. Use single-line patterns to avoid trouble. 4081 4082 Note: The decision to start a region is only based on a matching start 4083 pattern. There is no check for a matching end pattern. This does NOT 4084 work: > 4085 :syn region First start="(" end=":" 4086 :syn region Second start="(" end=";" 4087< The Second always matches before the First (last defined pattern has 4088 higher priority). The Second region then continues until the next 4089 ';', no matter if there is a ':' before it. Using a match does work: > 4090 :syn match First "(\_.\{-}:" 4091 :syn match Second "(\_.\{-};" 4092< This pattern matches any character or line break with "\_." and 4093 repeats that with "\{-}" (repeat as few as possible). 4094 4095 *:syn-keepend* 4096 By default, a contained match can obscure a match for the end pattern. 4097 This is useful for nesting. For example, a region that starts with 4098 "{" and ends with "}", can contain another region. An encountered "}" 4099 will then end the contained region, but not the outer region: 4100 { starts outer "{}" region 4101 { starts contained "{}" region 4102 } ends contained "{}" region 4103 } ends outer "{} region 4104 If you don't want this, the "keepend" argument will make the matching 4105 of an end pattern of the outer region also end any contained item. 4106 This makes it impossible to nest the same region, but allows for 4107 contained items to highlight parts of the end pattern, without causing 4108 that to skip the match with the end pattern. Example: > 4109 :syn match vimComment +"[^"]\+$+ 4110 :syn region vimCommand start="set" end="$" contains=vimComment keepend 4111< The "keepend" makes the vimCommand always end at the end of the line, 4112 even though the contained vimComment includes a match with the <EOL>. 4113 4114 When "keepend" is not used, a match with an end pattern is retried 4115 after each contained match. When "keepend" is included, the first 4116 encountered match with an end pattern is used, truncating any 4117 contained matches. 4118 *:syn-extend* 4119 The "keepend" behavior can be changed by using the "extend" argument. 4120 When an item with "extend" is contained in an item that uses 4121 "keepend", the "keepend" is ignored and the containing region will be 4122 extended. 4123 This can be used to have some contained items extend a region while 4124 others don't. Example: > 4125 4126 :syn region htmlRef start=+<a>+ end=+</a>+ keepend contains=htmlItem,htmlScript 4127 :syn match htmlItem +<[^>]*>+ contained 4128 :syn region htmlScript start=+<script+ end=+</script[^>]*>+ contained extend 4129 4130< Here the htmlItem item does not make the htmlRef item continue 4131 further, it is only used to highlight the <> items. The htmlScript 4132 item does extend the htmlRef item. 4133 4134 Another example: > 4135 :syn region xmlFold start="<a>" end="</a>" fold transparent keepend extend 4136< This defines a region with "keepend", so that its end cannot be 4137 changed by contained items, like when the "</a>" is matched to 4138 highlight it differently. But when the xmlFold region is nested (it 4139 includes itself), the "extend" applies, so that the "</a>" of a nested 4140 region only ends that region, and not the one it is contained in. 4141 4142 *:syn-excludenl* 4143 When a pattern for a match or end pattern of a region includes a '$' 4144 to match the end-of-line, it will make a region item that it is 4145 contained in continue on the next line. For example, a match with 4146 "\\$" (backslash at the end of the line) can make a region continue 4147 that would normally stop at the end of the line. This is the default 4148 behavior. If this is not wanted, there are two ways to avoid it: 4149 1. Use "keepend" for the containing item. This will keep all 4150 contained matches from extending the match or region. It can be 4151 used when all contained items must not extend the containing item. 4152 2. Use "excludenl" in the contained item. This will keep that match 4153 from extending the containing match or region. It can be used if 4154 only some contained items must not extend the containing item. 4155 "excludenl" must be given before the pattern it applies to. 4156 4157 *:syn-matchgroup* 4158 "matchgroup" can be used to highlight the start and/or end pattern 4159 differently than the body of the region. Example: > 4160 :syntax region String matchgroup=Quote start=+"+ skip=+\\"+ end=+"+ 4161< This will highlight the quotes with the "Quote" group, and the text in 4162 between with the "String" group. 4163 The "matchgroup" is used for all start and end patterns that follow, 4164 until the next "matchgroup". Use "matchgroup=NONE" to go back to not 4165 using a matchgroup. 4166 4167 In a start or end pattern that is highlighted with "matchgroup" the 4168 contained items of the region are not used. This can be used to avoid 4169 that a contained item matches in the start or end pattern match. When 4170 using "transparent", this does not apply to a start or end pattern 4171 match that is highlighted with "matchgroup". 4172 4173 Here is an example, which highlights three levels of parentheses in 4174 different colors: > 4175 :sy region par1 matchgroup=par1 start=/(/ end=/)/ contains=par2 4176 :sy region par2 matchgroup=par2 start=/(/ end=/)/ contains=par3 contained 4177 :sy region par3 matchgroup=par3 start=/(/ end=/)/ contains=par1 contained 4178 :hi par1 ctermfg=red guifg=red 4179 :hi par2 ctermfg=blue guifg=blue 4180 :hi par3 ctermfg=darkgreen guifg=darkgreen 4181< 4182 *E849* 4183The maximum number of syntax groups is 19999. 4184 4185============================================================================== 41867. :syntax arguments *:syn-arguments* 4187 4188The :syntax commands that define syntax items take a number of arguments. 4189The common ones are explained here. The arguments may be given in any order 4190and may be mixed with patterns. 4191 4192Not all commands accept all arguments. This table shows which arguments 4193can not be used for all commands: 4194 *E395* 4195 contains oneline fold display extend concealends~ 4196:syntax keyword - - - - - - 4197:syntax match yes - yes yes yes - 4198:syntax region yes yes yes yes yes yes 4199 4200These arguments can be used for all three commands: 4201 conceal 4202 cchar 4203 contained 4204 containedin 4205 nextgroup 4206 transparent 4207 skipwhite 4208 skipnl 4209 skipempty 4210 4211conceal *conceal* *:syn-conceal* 4212 4213When the "conceal" argument is given, the item is marked as concealable. 4214Whether or not it is actually concealed depends on the value of the 4215'conceallevel' option. The 'concealcursor' option is used to decide whether 4216concealable items in the current line are displayed unconcealed to be able to 4217edit the line. 4218 4219Another way to conceal text is with |matchadd()|, but internally this works a 4220bit differently |syntax-vs-match|. 4221 4222concealends *:syn-concealends* 4223 4224When the "concealends" argument is given, the start and end matches of 4225the region, but not the contents of the region, are marked as concealable. 4226Whether or not they are actually concealed depends on the setting on the 4227'conceallevel' option. The ends of a region can only be concealed separately 4228in this way when they have their own highlighting via "matchgroup". The 4229|synconcealed()| function can be used to retrieve information about concealed 4230items. 4231 4232cchar *:syn-cchar* 4233 *E844* 4234The "cchar" argument defines the character shown in place of the item 4235when it is concealed (setting "cchar" only makes sense when the conceal 4236argument is given.) If "cchar" is not set then the default conceal 4237character defined in the 'listchars' option is used. The character cannot be 4238a control character such as Tab. Example: > 4239 :syntax match Entity "&" conceal cchar=& 4240See |hl-Conceal| for highlighting. 4241 4242contained *:syn-contained* 4243 4244When the "contained" argument is given, this item will not be recognized at 4245the top level, but only when it is mentioned in the "contains" field of 4246another match. Example: > 4247 :syntax keyword Todo TODO contained 4248 :syntax match Comment "//.*" contains=Todo 4249 4250 4251display *:syn-display* 4252 4253If the "display" argument is given, this item will be skipped when the 4254detected highlighting will not be displayed. This will speed up highlighting, 4255by skipping this item when only finding the syntax state for the text that is 4256to be displayed. 4257 4258Generally, you can use "display" for match and region items that meet these 4259conditions: 4260- The item does not continue past the end of a line. Example for C: A region 4261 for a "/*" comment can't contain "display", because it continues on the next 4262 line. 4263- The item does not contain items that continue past the end of the line or 4264 make it continue on the next line. 4265- The item does not change the size of any item it is contained in. Example 4266 for C: A match with "\\$" in a preprocessor match can't have "display", 4267 because it may make that preprocessor match shorter. 4268- The item does not allow other items to match that didn't match otherwise, 4269 and that item may extend the match too far. Example for C: A match for a 4270 "//" comment can't use "display", because a "/*" inside that comment would 4271 match then and start a comment which extends past the end of the line. 4272 4273Examples, for the C language, where "display" can be used: 4274- match with a number 4275- match with a label 4276 4277 4278transparent *:syn-transparent* 4279 4280If the "transparent" argument is given, this item will not be highlighted 4281itself, but will take the highlighting of the item it is contained in. This 4282is useful for syntax items that don't need any highlighting but are used 4283only to skip over a part of the text. 4284 4285The "contains=" argument is also inherited from the item it is contained in, 4286unless a "contains" argument is given for the transparent item itself. To 4287avoid that unwanted items are contained, use "contains=NONE". Example, which 4288highlights words in strings, but makes an exception for "vim": > 4289 :syn match myString /'[^']*'/ contains=myWord,myVim 4290 :syn match myWord /\<[a-z]*\>/ contained 4291 :syn match myVim /\<vim\>/ transparent contained contains=NONE 4292 :hi link myString String 4293 :hi link myWord Comment 4294Since the "myVim" match comes after "myWord" it is the preferred match (last 4295match in the same position overrules an earlier one). The "transparent" 4296argument makes the "myVim" match use the same highlighting as "myString". But 4297it does not contain anything. If the "contains=NONE" argument would be left 4298out, then "myVim" would use the contains argument from myString and allow 4299"myWord" to be contained, which will be highlighted as a Comment. This 4300happens because a contained match doesn't match inside itself in the same 4301position, thus the "myVim" match doesn't overrule the "myWord" match here. 4302 4303When you look at the colored text, it is like looking at layers of contained 4304items. The contained item is on top of the item it is contained in, thus you 4305see the contained item. When a contained item is transparent, you can look 4306through, thus you see the item it is contained in. In a picture: 4307 4308 look from here 4309 4310 | | | | | | 4311 V V V V V V 4312 4313 xxxx yyy more contained items 4314 .................... contained item (transparent) 4315 ============================= first item 4316 4317The 'x', 'y' and '=' represent a highlighted syntax item. The '.' represent a 4318transparent group. 4319 4320What you see is: 4321 4322 =======xxxx=======yyy======== 4323 4324Thus you look through the transparent "....". 4325 4326 4327oneline *:syn-oneline* 4328 4329The "oneline" argument indicates that the region does not cross a line 4330boundary. It must match completely in the current line. However, when the 4331region has a contained item that does cross a line boundary, it continues on 4332the next line anyway. A contained item can be used to recognize a line 4333continuation pattern. But the "end" pattern must still match in the first 4334line, otherwise the region doesn't even start. 4335 4336When the start pattern includes a "\n" to match an end-of-line, the end 4337pattern must be found in the same line as where the start pattern ends. The 4338end pattern may also include an end-of-line. Thus the "oneline" argument 4339means that the end of the start pattern and the start of the end pattern must 4340be within one line. This can't be changed by a skip pattern that matches a 4341line break. 4342 4343 4344fold *:syn-fold* 4345 4346The "fold" argument makes the fold level increase by one for this item. 4347Example: > 4348 :syn region myFold start="{" end="}" transparent fold 4349 :syn sync fromstart 4350 :set foldmethod=syntax 4351This will make each {} block form one fold. 4352 4353The fold will start on the line where the item starts, and end where the item 4354ends. If the start and end are within the same line, there is no fold. 4355The 'foldnestmax' option limits the nesting of syntax folds. 4356See |:syn-foldlevel| to control how the foldlevel of a line is computed 4357from its syntax items. 4358 4359 4360 *:syn-contains* *E405* *E406* *E407* *E408* *E409* 4361contains={group-name},... 4362 4363The "contains" argument is followed by a list of syntax group names. These 4364groups will be allowed to begin inside the item (they may extend past the 4365containing group's end). This allows for recursive nesting of matches and 4366regions. If there is no "contains" argument, no groups will be contained in 4367this item. The group names do not need to be defined before they can be used 4368here. 4369 4370contains=ALL 4371 If the only item in the contains list is "ALL", then all 4372 groups will be accepted inside the item. 4373 4374contains=ALLBUT,{group-name},... 4375 If the first item in the contains list is "ALLBUT", then all 4376 groups will be accepted inside the item, except the ones that 4377 are listed. Example: > 4378 :syntax region Block start="{" end="}" ... contains=ALLBUT,Function 4379 4380contains=TOP 4381 If the first item in the contains list is "TOP", then all 4382 groups will be accepted that don't have the "contained" 4383 argument. 4384contains=TOP,{group-name},... 4385 Like "TOP", but excluding the groups that are listed. 4386 4387contains=CONTAINED 4388 If the first item in the contains list is "CONTAINED", then 4389 all groups will be accepted that have the "contained" 4390 argument. 4391contains=CONTAINED,{group-name},... 4392 Like "CONTAINED", but excluding the groups that are 4393 listed. 4394 4395 4396The {group-name} in the "contains" list can be a pattern. All group names 4397that match the pattern will be included (or excluded, if "ALLBUT" is used). 4398The pattern cannot contain white space or a ','. Example: > 4399 ... contains=Comment.*,Keyw[0-3] 4400The matching will be done at moment the syntax command is executed. Groups 4401that are defined later will not be matched. Also, if the current syntax 4402command defines a new group, it is not matched. Be careful: When putting 4403syntax commands in a file you can't rely on groups NOT being defined, because 4404the file may have been sourced before, and ":syn clear" doesn't remove the 4405group names. 4406 4407The contained groups will also match in the start and end patterns of a 4408region. If this is not wanted, the "matchgroup" argument can be used 4409|:syn-matchgroup|. The "ms=" and "me=" offsets can be used to change the 4410region where contained items do match. Note that this may also limit the 4411area that is highlighted 4412 4413 4414containedin={group-name},... *:syn-containedin* 4415 4416The "containedin" argument is followed by a list of syntax group names. The 4417item will be allowed to begin inside these groups. This works as if the 4418containing item has a "contains=" argument that includes this item. 4419 4420Only the immediate containing item (the one at the top of the syntax stack) is 4421considered. Vim does not search other ancestors. If the immediate container 4422neither contains this item via |:syn-contains| nor is named in this item's 4423"containedin=", the match will not start even if some ancestor would allow it. 4424Note that a |:syn-transparent| region still enforces its own |:syn-contains| 4425list. 4426 4427The {group-name},... can be used just like for "contains", as explained above. 4428 4429This is useful when adding a syntax item afterwards. An item can be told to 4430be included inside an already existing item, without changing the definition 4431of that item. For example, to highlight a word in a C comment after loading 4432the C syntax: > 4433 :syn keyword myword HELP containedin=cComment contained 4434Note that "contained" is also used, to avoid that the item matches at the top 4435level. 4436 4437Matches for "containedin" are added to the other places where the item can 4438appear. A "contains" argument may also be added as usual. Don't forget that 4439keywords never contain another item, thus adding them to "containedin" won't 4440work. 4441See also: |:syn-contains|, |:syn-transparent|. 4442 4443 4444nextgroup={group-name},... *:syn-nextgroup* 4445 4446The "nextgroup" argument is followed by a list of syntax group names, 4447separated by commas (just like with "contains", so you can also use patterns). 4448 4449If the "nextgroup" argument is given, the mentioned syntax groups will be 4450tried for a match, after the match or region ends. If none of the groups have 4451a match, highlighting continues normally. If there is a match, this group 4452will be used, even when it is not mentioned in the "contains" field of the 4453current group. This is like giving the mentioned group priority over all 4454other groups. Example: > 4455 :syntax match ccFoobar "Foo.\{-}Bar" contains=ccFoo 4456 :syntax match ccFoo "Foo" contained nextgroup=ccFiller 4457 :syntax region ccFiller start="." matchgroup=ccBar end="Bar" contained 4458 4459This will highlight "Foo" and "Bar" differently, and only when there is a 4460"Bar" after "Foo". In the text line below, "f" shows where ccFoo is used for 4461highlighting, and "bbb" where ccBar is used. > 4462 4463 Foo asdfasd Bar asdf Foo asdf Bar asdf 4464 fff bbb fff bbb 4465 4466Note the use of ".\{-}" to skip as little as possible until the next Bar. 4467when `.*` would be used, the "asdf" in between "Bar" and "Foo" would be 4468highlighted according to the "ccFoobar" group, because the ccFooBar match 4469would include the first "Foo" and the last "Bar" in the line (see |pattern|). 4470 4471 4472skipwhite *:syn-skipwhite* 4473skipnl *:syn-skipnl* 4474skipempty *:syn-skipempty* 4475 4476These arguments are only used in combination with "nextgroup". They can be 4477used to allow the next group to match after skipping some text: 4478 skipwhite skip over space and tab characters 4479 skipnl skip over the end of a line 4480 skipempty skip over empty lines (implies a "skipnl") 4481 4482When "skipwhite" is present, the white space is only skipped if there is no 4483next group that matches the white space. 4484 4485When "skipnl" is present, the match with nextgroup may be found in the next 4486line. This only happens when the current item ends at the end of the current 4487line! When "skipnl" is not present, the nextgroup will only be found after 4488the current item in the same line. 4489 4490When skipping text while looking for a next group, the matches for other 4491groups are ignored. Only when no next group matches, other items are tried 4492for a match again. This means that matching a next group and skipping white 4493space and <EOL>s has a higher priority than other items. 4494 4495Example: > 4496 :syn match ifstart "\<if.*" nextgroup=ifline skipwhite skipempty 4497 :syn match ifline "[^ \t].*" nextgroup=ifline skipwhite skipempty contained 4498 :syn match ifline "endif" contained 4499Note that the `[^ \t].*` match matches all non-white text. Thus it would also 4500match "endif". Therefore the "endif" match is put last, so that it takes 4501precedence. 4502Note that this example doesn't work for nested "if"s. You need to add 4503"contains" arguments to make that work (omitted for simplicity of the 4504example). 4505 4506IMPLICIT CONCEAL *:syn-conceal-implicit* 4507 4508:sy[ntax] conceal [on|off] 4509 This defines if the following ":syntax" commands will define keywords, 4510 matches or regions with the "conceal" flag set. After ":syn conceal 4511 on", all subsequent ":syn keyword", ":syn match" or ":syn region" 4512 defined will have the "conceal" flag set implicitly. ":syn conceal 4513 off" returns to the normal state where the "conceal" flag must be 4514 given explicitly. 4515 4516:sy[ntax] conceal 4517 Show either "syntax conceal on" or "syntax conceal off". 4518 4519============================================================================== 45208. Syntax patterns *:syn-pattern* *E401* *E402* 4521 4522In the syntax commands, a pattern must be surrounded by two identical 4523characters. This is like it works for the ":s" command. The most common to 4524use is the double quote. But if the pattern contains a double quote, you can 4525use another character that is not used in the pattern. Examples: > 4526 :syntax region Comment start="/\*" end="\*/" 4527 :syntax region String start=+"+ end=+"+ skip=+\\"+ 4528 4529See |pattern| for the explanation of what a pattern is. Syntax patterns are 4530always interpreted like the 'magic' option is set, no matter what the actual 4531value of 'magic' is. And the patterns are interpreted like the 'l' flag is 4532not included in 'cpoptions'. This was done to make syntax files portable and 4533independent of the 'magic' setting. 4534 4535Try to avoid patterns that can match an empty string, such as "[a-z]*". 4536This slows down the highlighting a lot, because it matches everywhere. 4537 4538 *:syn-pattern-offset* 4539The pattern can be followed by a character offset. This can be used to 4540change the highlighted part, and to change the text area included in the 4541match or region (which only matters when trying to match other items). Both 4542are relative to the matched pattern. The character offset for a skip 4543pattern can be used to tell where to continue looking for an end pattern. 4544 4545The offset takes the form of "{what}={offset}" 4546The {what} can be one of seven strings: 4547 4548ms Match Start offset for the start of the matched text 4549me Match End offset for the end of the matched text 4550hs Highlight Start offset for where the highlighting starts 4551he Highlight End offset for where the highlighting ends 4552rs Region Start offset for where the body of a region starts 4553re Region End offset for where the body of a region ends 4554lc Leading Context offset past "leading context" of pattern 4555 4556The {offset} can be: 4557 4558s start of the matched pattern 4559s+{nr} start of the matched pattern plus {nr} chars to the right 4560s-{nr} start of the matched pattern plus {nr} chars to the left 4561e end of the matched pattern 4562e+{nr} end of the matched pattern plus {nr} chars to the right 4563e-{nr} end of the matched pattern plus {nr} chars to the left 4564{nr} (for "lc" only): start matching {nr} chars right of the start 4565 4566Examples: "ms=s+1", "hs=e-2", "lc=3". 4567 4568Although all offsets are accepted after any pattern, they are not always 4569meaningful. This table shows which offsets are actually used: 4570 4571 ms me hs he rs re lc ~ 4572match item yes yes yes yes - - yes 4573region item start yes - yes - yes - yes 4574region item skip - yes - - - - yes 4575region item end - yes - yes - yes yes 4576 4577Offsets can be concatenated, with a ',' in between. Example: > 4578 :syn match String /"[^"]*"/hs=s+1,he=e-1 4579< 4580 some "string" text 4581 ^^^^^^ highlighted 4582 4583Notes: 4584- There must be no white space between the pattern and the character 4585 offset(s). 4586- The highlighted area will never be outside of the matched text. 4587- A negative offset for an end pattern may not always work, because the end 4588 pattern may be detected when the highlighting should already have stopped. 4589- Before Vim 7.2 the offsets were counted in bytes instead of characters. 4590 This didn't work well for multibyte characters, so it was changed with the 4591 Vim 7.2 release. 4592- The start of a match cannot be in a line other than where the pattern 4593 matched. This doesn't work: "a\nb"ms=e. You can make the highlighting 4594 start in another line, this does work: "a\nb"hs=e. 4595 4596Example (match a comment but don't highlight the `/* and */`): >vim 4597 :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1 4598< > 4599 /* this is a comment */ 4600 ^^^^^^^^^^^^^^^^^^^ highlighted 4601< 4602A more complicated Example: >vim 4603 :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 4604< > 4605 abcfoostringbarabc 4606 mmmmmmmmmmm match 4607 sssrrreee highlight start/region/end ("Foo", "Exa" and "Bar") 4608< 4609Leading context *:syn-lc* *:syn-leading* *:syn-context* 4610 4611Note: This is an obsolete feature, only included for backwards compatibility 4612with previous Vim versions. It's now recommended to use the |/\@<=| construct 4613in the pattern. You can also often use |/\zs|. 4614 4615The "lc" offset specifies leading context -- a part of the pattern that must 4616be present, but is not considered part of the match. An offset of "lc=n" will 4617cause Vim to step back n columns before attempting the pattern match, allowing 4618characters which have already been matched in previous patterns to also be 4619used as leading context for this match. This can be used, for instance, to 4620specify that an "escaping" character must not precede the match: > 4621 4622 :syn match ZNoBackslash "[^\\]z"ms=s+1 4623 :syn match WNoBackslash "[^\\]w"lc=1 4624 :syn match Underline "_\+" 4625< 4626 ___zzzz ___wwww 4627 ^^^ ^^^ matches Underline 4628 ^ ^ matches ZNoBackslash 4629 ^^^^ matches WNoBackslash 4630 4631The "ms" offset is automatically set to the same value as the "lc" offset, 4632unless you set "ms" explicitly. 4633 4634 4635Multi-line patterns *:syn-multi-line* 4636 4637The patterns can include "\n" to match an end-of-line. Mostly this works as 4638expected, but there are a few exceptions. 4639 4640When using a start pattern with an offset, the start of the match is not 4641allowed to start in a following line. The highlighting can start in a 4642following line though. Using the "\zs" item also requires that the start of 4643the match doesn't move to another line. 4644 4645The skip pattern can include the "\n", but the search for an end pattern will 4646continue in the first character of the next line, also when that character is 4647matched by the skip pattern. This is because redrawing may start in any line 4648halfway in a region and there is no check if the skip pattern started in a 4649previous line. For example, if the skip pattern is "a\nb" and an end pattern 4650is "b", the end pattern does match in the second line of this: > 4651 x x a 4652 b x x 4653Generally this means that the skip pattern should not match any characters 4654after the "\n". 4655 4656 4657External matches *:syn-ext-match* 4658 4659These extra regular expression items are available in region patterns: 4660 4661 */\z(* */\z(\)* *E50* *E52* *E879* 4662 \z(\) Marks the sub-expression as "external", meaning that it can be 4663 accessed from another pattern match. Currently only usable in 4664 defining a syntax region start pattern. 4665 4666 */\z1* */\z2* */\z3* */\z4* */\z5* 4667 \z1 ... \z9 */\z6* */\z7* */\z8* */\z9* *E66* *E67* 4668 Matches the same string that was matched by the corresponding 4669 sub-expression in a previous start pattern match. 4670 4671Sometimes the start and end patterns of a region need to share a common 4672sub-expression. A common example is the "here" document in Perl and many Unix 4673shells. This effect can be achieved with the "\z" special regular expression 4674items, which marks a sub-expression as "external", in the sense that it can be 4675referenced from outside the pattern in which it is defined. The here-document 4676example, for instance, can be done like this: > 4677 :syn region hereDoc start="<<\z(\I\i*\)" end="^\z1$" 4678 4679As can be seen here, the \z actually does double duty. In the start pattern, 4680it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it 4681changes the \z1 back-reference into an external reference referring to the 4682first external sub-expression in the start pattern. External references can 4683also be used in skip patterns: > 4684 :syn region foo start="start \z(\I\i*\)" skip="not end \z1" end="end \z1" 4685 4686Note that normal and external sub-expressions are completely orthogonal and 4687indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied 4688to the string "aabb", then \1 will refer to "bb" and \z1 will refer to "aa". 4689Note also that external sub-expressions cannot be accessed as back-references 4690within the same pattern like normal sub-expressions. If you want to use one 4691sub-expression as both a normal and an external sub-expression, you can nest 4692the two, as in "\(\z(...\)\)". 4693 4694Note that only matches within a single line can be used. Multi-line matches 4695cannot be referred to. 4696 4697============================================================================== 46989. Syntax clusters *:syn-cluster* *E400* 4699 4700:sy[ntax] cluster {cluster-name} [contains={group-name},...] 4701 [add={group-name},...] 4702 [remove={group-name},...] 4703 4704This command allows you to cluster a list of syntax groups together under a 4705single name. 4706 4707 contains={group-name},... 4708 The cluster is set to the specified list of groups. 4709 add={group-name},... 4710 The specified groups are added to the cluster. 4711 remove={group-name},... 4712 The specified groups are removed from the cluster. 4713 4714A cluster so defined may be referred to in a contains=..., containedin=..., 4715nextgroup=..., add=... or remove=... list with a "@" prefix. You can also use 4716this notation to implicitly declare a cluster before specifying its contents. 4717 4718Example: > 4719 :syntax match Thing "# [^#]\+ #" contains=@ThingMembers 4720 :syntax cluster ThingMembers contains=ThingMember1,ThingMember2 4721 4722As the previous example suggests, modifications to a cluster are effectively 4723retroactive; the membership of the cluster is checked at the last minute, so 4724to speak: > 4725 :syntax keyword A aaa 4726 :syntax keyword B bbb 4727 :syntax cluster AandB contains=A 4728 :syntax match Stuff "( aaa bbb )" contains=@AandB 4729 :syntax cluster AandB add=B " now both keywords are matched in Stuff 4730 4731This also has implications for nested clusters: > 4732 :syntax keyword A aaa 4733 :syntax keyword B bbb 4734 :syntax cluster SmallGroup contains=B 4735 :syntax cluster BigGroup contains=A,@SmallGroup 4736 :syntax match Stuff "( aaa bbb )" contains=@BigGroup 4737 :syntax cluster BigGroup remove=B " no effect, since B isn't in BigGroup 4738 :syntax cluster SmallGroup remove=B " now bbb isn't matched within Stuff 4739< 4740 *E848* 4741The maximum number of clusters is 9767. 4742 4743============================================================================== 474410. Including syntax files *:syn-include* *E397* 4745 4746It is often useful for one language's syntax file to include a syntax file for 4747a related language. Depending on the exact relationship, this can be done in 4748two different ways: 4749 4750 - If top-level syntax items in the included syntax file are to be 4751 allowed at the top level in the including syntax, you can simply use 4752 the |:runtime| command: > 4753 4754 " In cpp.vim: 4755 :runtime! syntax/c.vim 4756 :unlet b:current_syntax 4757 4758< - If top-level syntax items in the included syntax file are to be 4759 contained within a region in the including syntax, you can use the 4760 ":syntax include" command: 4761 4762:sy[ntax] include [@{grouplist-name}] {file-name} 4763 4764 All syntax items declared in the included file will have the 4765 "contained" flag added. In addition, if a group list is specified, 4766 all top-level syntax items in the included file will be added to 4767 that list. > 4768 4769 " In perl.vim: 4770 :syntax include @Pod <script>:p:h/pod.vim 4771 :syntax region perlPOD start="^=head" end="^=cut" contains=@Pod 4772< 4773 When {file-name} is an absolute path (starts with "/", "c:", "$VAR" 4774 or "<script>") that file is sourced. When it is a relative path 4775 (e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'. 4776 All matching files are loaded. Using a relative path is 4777 recommended, because it allows a user to replace the included file 4778 with their own version, without replacing the file that does the 4779 ":syn include". 4780 4781 *E847* 4782The maximum number of includes is 999. 4783 4784============================================================================== 478511. Synchronizing *:syn-sync* *E403* *E404* 4786 4787Vim wants to be able to start redrawing in any position in the document. To 4788make this possible it needs to know the syntax state at the position where 4789redrawing starts. 4790 4791:sy[ntax] sync [ccomment [group-name] | minlines={N} | ...] 4792 4793There are four ways to synchronize: 47941. Always parse from the start of the file. 4795 |:syn-sync-first| 47962. Based on C-style comments. Vim understands how C-comments work and can 4797 figure out if the current line starts inside or outside a comment. 4798 |:syn-sync-second| 47993. Jumping back a certain number of lines and start parsing there. 4800 |:syn-sync-third| 48014. Searching backwards in the text for a pattern to sync on. 4802 |:syn-sync-fourth| 4803 4804 *:syn-sync-maxlines* *:syn-sync-minlines* 4805For the last three methods, the line range where the parsing can start is 4806limited by "minlines" and "maxlines". 4807 4808If the "minlines={N}" argument is given, the parsing always starts at least 4809that many lines backwards. This can be used if the parsing may take a few 4810lines before it's correct, or when it's not possible to use syncing. 4811 4812If the "maxlines={N}" argument is given, the number of lines that are searched 4813for a comment or syncing pattern is restricted to N lines backwards (after 4814adding "minlines"). This is useful if you have few things to sync on and a 4815slow machine. Example: > 4816 :syntax sync maxlines=500 ccomment 4817< 4818 *:syn-sync-linebreaks* 4819When using a pattern that matches multiple lines, a change in one line may 4820cause a pattern to no longer match in a previous line. This means has to 4821start above where the change was made. How many lines can be specified with 4822the "linebreaks" argument. For example, when a pattern may include one line 4823break use this: > 4824 :syntax sync linebreaks=1 4825The result is that redrawing always starts at least one line before where a 4826change was made. The default value for "linebreaks" is zero. Usually the 4827value for "minlines" is bigger than "linebreaks". 4828 4829 4830First syncing method: *:syn-sync-first* 4831> 4832 :syntax sync fromstart 4833 4834The file will be parsed from the start. This makes syntax highlighting 4835accurate, but can be slow for long files. Vim caches previously parsed text, 4836so that it's only slow when parsing the text for the first time. However, 4837when making changes some part of the text needs to be parsed again (worst 4838case: to the end of the file). 4839 4840Using "fromstart" is equivalent to using "minlines" with a very large number. 4841 4842 4843Second syncing method: *:syn-sync-second* *:syn-sync-ccomment* 4844 4845For the second method, only the "ccomment" argument needs to be given. 4846Example: > 4847 :syntax sync ccomment 4848 4849When Vim finds that the line where displaying starts is inside a C-style 4850comment, the last region syntax item with the group-name "Comment" will be 4851used. This requires that there is a region with the group-name "Comment"! 4852An alternate group name can be specified, for example: > 4853 :syntax sync ccomment javaComment 4854This means that the last item specified with "syn region javaComment" will be 4855used for the detected C comment region. This only works properly if that 4856region does have a start pattern "\/*" and an end pattern "*\/". 4857 4858The "maxlines" argument can be used to restrict the search to a number of 4859lines. The "minlines" argument can be used to at least start a number of 4860lines back (e.g., for when there is some construct that only takes a few 4861lines, but it hard to sync on). 4862 4863Note: Syncing on a C comment doesn't work properly when strings are used 4864that cross a line and contain a "*/". Since letting strings cross a line 4865is a bad programming habit (many compilers give a warning message), and the 4866chance of a "*/" appearing inside a comment is very small, this restriction 4867is hardly ever noticed. 4868 4869 4870Third syncing method: *:syn-sync-third* 4871 4872For the third method, only the "minlines={N}" argument needs to be given. 4873Vim will subtract {N} from the line number and start parsing there. This 4874means {N} extra lines need to be parsed, which makes this method a bit slower. 4875Example: > 4876 :syntax sync minlines=50 4877 4878"lines" is equivalent to "minlines" (used by older versions). 4879 4880 4881Fourth syncing method: *:syn-sync-fourth* 4882 4883The idea is to synchronize on the end of a few specific regions, called a 4884sync pattern. Only regions can cross lines, so when we find the end of some 4885region, we might be able to know in which syntax item we are. The search 4886starts in the line just above the one where redrawing starts. From there 4887the search continues backwards in the file. 4888 4889This works just like the non-syncing syntax items. You can use contained 4890matches, nextgroup, etc. But there are a few differences: 4891- Keywords cannot be used. 4892- The syntax items with the "sync" keyword form a completely separated group 4893 of syntax items. You can't mix syncing groups and non-syncing groups. 4894- The matching works backwards in the buffer (line by line), instead of 4895 forwards. 4896- A line continuation pattern can be given. It is used to decide which group 4897 of lines need to be searched like they were one line. This means that the 4898 search for a match with the specified items starts in the first of the 4899 consecutive lines that contain the continuation pattern. 4900- When using "nextgroup" or "contains", this only works within one line (or 4901 group of continued lines). 4902- When using a region, it must start and end in the same line (or group of 4903 continued lines). Otherwise the end is assumed to be at the end of the 4904 line (or group of continued lines). 4905- When a match with a sync pattern is found, the rest of the line (or group of 4906 continued lines) is searched for another match. The last match is used. 4907 This is used when a line can contain both the start and the end of a region 4908 (e.g., in a C-comment like `/* this */`, the last "*/" is used). 4909 4910There are two ways how a match with a sync pattern can be used: 49111. Parsing for highlighting starts where redrawing starts (and where the 4912 search for the sync pattern started). The syntax group that is expected 4913 to be valid there must be specified. This works well when the regions 4914 that cross lines cannot contain other regions. 49152. Parsing for highlighting continues just after the match. The syntax group 4916 that is expected to be present just after the match must be specified. 4917 This can be used when the previous method doesn't work well. It's much 4918 slower, because more text needs to be parsed. 4919Both types of sync patterns can be used at the same time. 4920 4921Besides the sync patterns, other matches and regions can be specified, to 4922avoid finding unwanted matches. 4923 4924[The reason that the sync patterns are given separately, is that mostly the 4925search for the sync point can be much simpler than figuring out the 4926highlighting. The reduced number of patterns means it will go (much) 4927faster.] 4928 4929 *syn-sync-grouphere* *E393* *E394* 4930 :syntax sync match {sync-group-name} grouphere {group-name} "pattern" ... 4931 4932 Define a match that is used for syncing. {group-name} is the 4933 name of a syntax group that follows just after the match. Parsing 4934 of the text for highlighting starts just after the match. A region 4935 must exist for this {group-name}. The first one defined will be used. 4936 "NONE" can be used for when there is no syntax group after the match. 4937 4938 *syn-sync-groupthere* 4939 :syntax sync match {sync-group-name} groupthere {group-name} "pattern" ... 4940 4941 Like "grouphere", but {group-name} is the name of a syntax group that 4942 is to be used at the start of the line where searching for the sync 4943 point started. The text between the match and the start of the sync 4944 pattern searching is assumed not to change the syntax highlighting. 4945 For example, in C you could search backwards for "/*" and "*/". If 4946 "/*" is found first, you know that you are inside a comment, so the 4947 "groupthere" is "cComment". If "*/" is found first, you know that you 4948 are not in a comment, so the "groupthere" is "NONE". (in practice 4949 it's a bit more complicated, because the "/*" and "*/" could appear 4950 inside a string. That's left as an exercise to the reader...). 4951 4952 :syntax sync match ... 4953 :syntax sync region ... 4954 4955 Without a "groupthere" argument. Define a region or match that is 4956 skipped while searching for a sync point. 4957 4958 *syn-sync-linecont* 4959 :syntax sync linecont {pattern} 4960 4961 When {pattern} matches in a line, it is considered to continue in 4962 the next line. This means that the search for a sync point will 4963 consider the lines to be concatenated. 4964 4965If the "maxlines={N}" argument is given too, the number of lines that are 4966searched for a match is restricted to N. This is useful if you have very 4967few things to sync on and a slow machine. Example: > 4968 :syntax sync maxlines=100 4969 4970You can clear all sync settings with: > 4971 :syntax sync clear 4972 4973You can clear specific sync patterns with: > 4974 :syntax sync clear {sync-group-name} ... 4975 4976============================================================================== 497712. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list* 4978 4979This command lists all the syntax items: > 4980 4981 :sy[ntax] [list] 4982 4983To show the syntax items for one syntax group: > 4984 4985 :sy[ntax] list {group-name} 4986 4987To list the syntax groups in one cluster: *E392* > 4988 4989 :sy[ntax] list @{cluster-name} 4990 4991See above for other arguments for the ":syntax" command. 4992 4993Note that the ":syntax" command can be abbreviated to ":sy", although ":syn" 4994is mostly used, because it looks better. 4995 4996============================================================================== 499713. Highlight command *:highlight* *:hi* *E28* *E411* *E415* 4998 4999Nvim uses a range of highlight groups which fall into two categories: Editor 5000interface and syntax highlighting. In rough order of importance, these are 5001- basic editor |highlight-groups| 5002- standard syntax |group-name|s (in addition, syntax files can define 5003 language-specific groups, which are prefixed with the language name) 5004- |diagnostic-highlights| 5005- |treesitter-highlight-groups| 5006- |lsp-semantic-highlight| groups 5007- |lsp-highlight| of symbols and references 5008 5009Where appropriate, highlight groups are linked by default to one of the more basic 5010groups, but colorschemes are expected to cover all of them. Under each tag, 5011the corresponding highlight groups are highlighted using the current 5012colorscheme. 5013 5014 *:colo* *:colorscheme* *E185* 5015:colo[rscheme] Output the name of the currently active color scheme. 5016 This is basically the same as > 5017 :echo g:colors_name 5018< In case g:colors_name has not been defined :colo will 5019 output "default". 5020 5021:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath' 5022 for the file "colors/{name}.{vim,lua}". The first one 5023 that is found is loaded. 5024 Note: "colors/{name}.vim" is tried first. 5025 Also searches all plugins in 'packpath', first below 5026 "start" and then under "opt". 5027 5028 Doesn't work recursively, thus you can't use 5029 ":colorscheme" in a color scheme script. 5030 5031 To customize a color scheme use another name, e.g. 5032 "~/.config/nvim/colors/mine.vim", and use `:runtime` to 5033 load the original color scheme: > 5034 runtime colors/evening.vim 5035 hi Statement ctermfg=Blue guifg=Blue 5036 5037< Before the color scheme will be loaded the 5038 |ColorSchemePre| autocommand event is triggered. 5039 After the color scheme has been loaded the 5040 |ColorScheme| autocommand event is triggered. 5041 For info about writing a color scheme file: > 5042 :edit $VIMRUNTIME/colors/README.txt 5043 5044:hi[ghlight] List all the current highlight groups that have 5045 attributes set. 5046 5047:hi[ghlight] {group-name} 5048 List one highlight group. 5049 5050 *highlight-clear* *:hi-clear* 5051:hi[ghlight] clear Reset all highlighting to the defaults. Removes all 5052 highlighting for groups added by the user. 5053 Uses the current value of 'background' to decide which 5054 default colors to use. 5055 If there was a default link, restore it. |:hi-link| 5056 5057:hi[ghlight] clear {group-name} 5058:hi[ghlight] {group-name} NONE 5059 Disable the highlighting for one highlight group. It 5060 is _not_ set back to the default colors. 5061 5062:hi[ghlight] [default] {group-name} {key}={arg} ... 5063 Add a highlight group, or change the highlighting for 5064 an existing group. 5065 See |highlight-args| for the {key}={arg} arguments. 5066 See |:highlight-default| for the optional [default] 5067 argument. 5068 5069Normally a highlight group is added once when starting up. This sets the 5070default values for the highlighting. After that, you can use additional 5071highlight commands to change the arguments that you want to set to non-default 5072values. The value "NONE" can be used to switch the value off or go back to 5073the default value. 5074 5075A simple way to change colors is with the |:colorscheme| command. This loads 5076a file with ":highlight" commands such as this: > 5077 5078 :hi Comment gui=bold 5079 5080Note that all settings that are not included remain the same, only the 5081specified field is used, and settings are merged with previous ones. So, the 5082result is like this single command has been used: > 5083 :hi Comment ctermfg=Cyan guifg=#80a0ff gui=bold 5084< 5085 *:highlight-verbose* 5086When listing a highlight group and 'verbose' is non-zero, the listing will 5087also tell where it was last set. Example: > 5088 :verbose hi Comment 5089< Comment xxx ctermfg=4 guifg=Blue ~ 5090 Last set from /home/mool/vim/vim7/runtime/syntax/syncolor.vim ~ 5091 5092When ":hi clear" is used then the script where this command is used will be 5093mentioned for the default values. See |:verbose-cmd| for more information. 5094 5095 *highlight-args* *E416* *E417* *E423* 5096There are two types of UIs for highlighting: 5097cterm terminal UI (|TUI|) 5098gui GUI or RGB-capable TUI ('termguicolors') 5099 5100For each type the highlighting can be given. This makes it possible to use 5101the same syntax file on all UIs. 5102 51031. TUI highlight arguments 5104 5105 *bold* *underline* *undercurl* 5106 *underdouble* *underdotted* 5107 *underdashed* *inverse* *italic* 5108 *standout* *strikethrough* *altfont* 5109 *dim* *blink* *hl-conceal* *overline* *nocombine* 5110cterm={attr-list} *attr-list* *highlight-cterm* *E418* 5111 attr-list is a comma-separated list (without spaces) of the 5112 following items (in any order): 5113 bold 5114 underline 5115 undercurl curly underline 5116 underdouble double underline 5117 underdotted dotted underline 5118 underdashed dashed underline 5119 strikethrough 5120 reverse 5121 inverse same as reverse 5122 italic 5123 standout 5124 altfont 5125 dim half-bright/faint text 5126 blink blinking text 5127 conceal concealed/hidden text 5128 overline overlined text 5129 nocombine override attributes instead of combining them 5130 NONE no attributes used (used to reset it) 5131 5132 Note that "bold" can be used here and by using a bold font. They 5133 have the same effect. 5134 "undercurl", "underdouble", "underdotted", and "underdashed" fall back 5135 to "underline" in a terminal that does not support them. The color is 5136 set using |guisp|. 5137 5138start={term-list} *highlight-start* *E422* 5139stop={term-list} *term-list* *highlight-stop* 5140 These lists of terminal codes can be used to get 5141 non-standard attributes on a terminal. 5142 5143 The escape sequence specified with the "start" argument 5144 is written before the characters in the highlighted 5145 area. It can be anything that you want to send to the 5146 terminal to highlight this area. The escape sequence 5147 specified with the "stop" argument is written after the 5148 highlighted area. This should undo the "start" argument. 5149 Otherwise the screen will look messed up. 5150 5151 {term-list} is a string with escape sequences. This is any string of 5152 characters, except that it can't start with "t_" and blanks are not 5153 allowed. The <> notation is recognized here, so you can use things 5154 like "<Esc>" and "<Space>". Example: 5155 start=<Esc>[27h;<Esc>[<Space>r; 5156 5157ctermfg={color-nr} *ctermfg* *E421* 5158ctermbg={color-nr} *ctermbg* 5159 The {color-nr} argument is a color number. Its range is zero to 5160 (not including) the number of |tui-colors| available. 5161 The actual color with this number depends on the type of terminal 5162 and its settings. Sometimes the color also depends on the settings of 5163 "cterm". For example, on some systems "cterm=bold ctermfg=3" gives 5164 another color, on others you just get color 3. 5165 5166 The following (case-insensitive) names are recognized: 5167 5168 *cterm-colors* 5169 NR-16 NR-8 COLOR NAME ~ 5170 0 0 Black 5171 1 4 DarkBlue 5172 2 2 DarkGreen 5173 3 6 DarkCyan 5174 4 1 DarkRed 5175 5 5 DarkMagenta 5176 6 3 Brown, DarkYellow 5177 7 7 LightGray, LightGrey, Gray, Grey 5178 8 0* DarkGray, DarkGrey 5179 9 4* Blue, LightBlue 5180 10 2* Green, LightGreen 5181 11 6* Cyan, LightCyan 5182 12 1* Red, LightRed 5183 13 5* Magenta, LightMagenta 5184 14 3* Yellow, LightYellow 5185 15 7* White 5186 5187 The number under "NR-16" is used for 16-color terminals ('t_Co' 5188 greater than or equal to 16). The number under "NR-8" is used for 5189 8-color terminals ('t_Co' less than 16). The "*" indicates that the 5190 bold attribute is set for ctermfg. In many 8-color terminals (e.g., 5191 "linux"), this causes the bright colors to appear. This doesn't work 5192 for background colors! Without the "*" the bold attribute is removed. 5193 If you want to set the bold attribute in a different way, put a 5194 "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument. Or use 5195 a number instead of a color name. 5196 5197 Note that for 16 color ansi style terminals (including xterms), the 5198 numbers in the NR-8 column is used. Here "*" means "add 8" so that 5199 Blue is 12, DarkGray is 8 etc. 5200 5201 Note that for some color terminals these names may result in the wrong 5202 colors! 5203 5204 You can also use "NONE" to remove the color. 5205 5206 *:hi-normal-cterm* 5207 When setting the "ctermfg" or "ctermbg" colors for the Normal group, 5208 these will become the colors used for the non-highlighted text. 5209 Example: > 5210 :highlight Normal ctermfg=grey ctermbg=darkblue 5211< When setting the "ctermbg" color for the Normal group, the 5212 'background' option will be adjusted automatically, under the 5213 condition that the color is recognized and 'background' was not set 5214 explicitly. This causes the highlight groups that depend on 5215 'background' to change! This means you should set the colors for 5216 Normal first, before setting other colors. 5217 When a color scheme is being used, changing 'background' causes it to 5218 be reloaded, which may reset all colors (including Normal). First 5219 delete the "g:colors_name" variable when you don't want this. 5220 5221 When you have set "ctermfg" or "ctermbg" for the Normal group, Vim 5222 needs to reset the color when exiting. This is done with the 5223 "orig_pair" |terminfo| entry. 5224 *E419* *E420* 5225 When Vim knows the normal foreground and background colors, "fg" and 5226 "bg" can be used as color names. This only works after setting the 5227 colors for the Normal group and for the MS-Windows console. Example, 5228 for reverse video: > 5229 :highlight Visual ctermfg=bg ctermbg=fg 5230< Note that the colors are used that are valid at the moment this 5231 command are given. If the Normal group colors are changed later, the 5232 "fg" and "bg" colors will not be adjusted. 5233 5234 52352. GUI highlight arguments 5236 5237gui={attr-list} *highlight-gui* 5238 These give the attributes to use in the GUI mode. 5239 See |attr-list| for a description. 5240 Note that "bold" can be used here and by using a bold font. They 5241 have the same effect. 5242 Note that the attributes are ignored for the "Normal" group. 5243 5244font={font-name} *highlight-font* 5245 font-name is the name of a font, as it is used on the system Vim 5246 runs on. For X11 this is a complicated name, for example: > 5247 font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1 5248< 5249 The font-name "NONE" can be used to revert to the default font. 5250 When setting the font for the "Normal" group, this becomes the default 5251 font (until the 'guifont' option is changed; the last one set is 5252 used). 5253 The following only works with Motif not with other GUIs: 5254 When setting the font for the "Menu" group, the menus will be changed. 5255 When setting the font for the "Tooltip" group, the tooltips will be 5256 changed. 5257 All fonts used, except for Menu and Tooltip, should be of the same 5258 character size as the default font! Otherwise redrawing problems will 5259 occur. 5260 To use a font name with an embedded space or other special character, 5261 put it in single quotes. The single quote cannot be used then. 5262 Example: > 5263 :hi comment font='Monospace 10' 5264 5265guifg={color-name} *guifg* 5266guibg={color-name} *guibg* 5267guisp={color-name} *guisp* 5268 These give the foreground (guifg), background (guibg) and special 5269 (guisp) color to use in the GUI. "guisp" is used for various 5270 underlines. 5271 There are a few special names: 5272 NONE no color (transparent) 5273 bg use normal background color 5274 background use normal background color 5275 fg use normal foreground color 5276 foreground use normal foreground color 5277 To use a color name with an embedded space or other special character, 5278 put it in single quotes. The single quote cannot be used then. 5279 Example: > 5280 :hi comment guifg='salmon pink' 5281< 5282 *gui-colors* 5283 Suggested color names (these are available on most systems): 5284 Red LightRed DarkRed 5285 Green LightGreen DarkGreen SeaGreen 5286 Blue LightBlue DarkBlue SlateBlue 5287 Cyan LightCyan DarkCyan 5288 Magenta LightMagenta DarkMagenta 5289 Yellow LightYellow Brown DarkYellow 5290 Gray LightGray DarkGray 5291 Black White 5292 Orange Purple Violet 5293 5294 Colors which define Nvim's default color scheme: 5295 NvimDarkBlue NvimLightBlue 5296 NvimDarkCyan NvimLightCyan 5297 NvimDarkGray1 NvimLightGray1 5298 NvimDarkGray2 NvimLightGray2 5299 NvimDarkGray3 NvimLightGray3 5300 NvimDarkGray4 NvimLightGray4 5301 NvimDarkGreen NvimLightGreen 5302 NvimDarkMagenta NvimLightMagenta 5303 NvimDarkRed NvimLightRed 5304 NvimDarkYellow NvimLightYellow 5305 5306 You can also specify a color by its RGB (red, green, blue) values. 5307 The format is "#rrggbb", where 5308 "rr" is the Red value 5309 "gg" is the Green value 5310 "bb" is the Blue value 5311 All values are hexadecimal, range from "00" to "ff". Examples: > 5312 :highlight Comment guifg=#11f0c3 guibg=#ff00ff 5313< 5314blend={integer} *highlight-blend* *opacity* 5315 Override the blend level for a highlight group within the popupmenu 5316 or floating windows. Only takes effect if 'pumblend' or 'winblend' 5317 is set for the menu or window. See the help at the respective option. 5318 5319 See also the "blend" flag of |nvim_buf_set_extmark()|. 5320 5321 *highlight-groups* *highlight-default* 5322These are the builtin highlighting groups. Note that the highlighting depends 5323on the value of 'background'. You can see the current settings with the 5324":highlight" command. 5325 *hl-ColorColumn* 5326ColorColumn Used for the columns set with 'colorcolumn'. 5327 *hl-Conceal* 5328Conceal Placeholder characters substituted for concealed 5329 text (see 'conceallevel'). 5330 *hl-CurSearch* 5331CurSearch Current match for the last search pattern (see 'hlsearch'). 5332 Note: This is correct after a search, but may get outdated if 5333 changes are made or the screen is redrawn. 5334 *hl-Cursor* *hl-lCursor* 5335Cursor Character under the cursor. 5336lCursor Character under the cursor when |language-mapping| 5337 is used (see 'guicursor'). 5338 *hl-CursorIM* 5339CursorIM Like Cursor, but used when in IME mode. *CursorIM* 5340 *hl-CursorColumn* 5341CursorColumn Screen-column at the cursor, when 'cursorcolumn' is set. 5342 *hl-CursorLine* 5343CursorLine Screen-line at the cursor, when 'cursorline' is set. 5344 Low-priority if foreground (ctermfg OR guifg) is not set. 5345 *hl-Directory* 5346Directory Directory names (and other special names in listings). 5347 *hl-DiffAdd* 5348DiffAdd Diff mode: Added line. |diff.txt| 5349 *hl-DiffChange* 5350DiffChange Diff mode: Changed line. |diff.txt| 5351 *hl-DiffDelete* 5352DiffDelete Diff mode: Deleted line. |diff.txt| 5353 *hl-DiffText* 5354DiffText Diff mode: Changed text within a changed line. |diff.txt| 5355 *hl-DiffTextAdd* 5356DiffTextAdd Diff mode: Added text within a changed line. Linked to 5357 |hl-DiffText| by default. |diff.txt| 5358 *hl-EndOfBuffer* 5359EndOfBuffer Filler lines (~) after the last line in the buffer. 5360 By default, this is highlighted like |hl-NonText|. 5361 *hl-TermCursor* 5362TermCursor Cursor in a focused terminal. 5363 *hl-OkMsg* 5364OkMsg Success messages. 5365 *hl-WarningMsg* 5366WarningMsg Warning messages. 5367 *hl-ErrorMsg* 5368ErrorMsg Error messages. 5369 *hl-StderrMsg* 5370StderrMsg Messages in stderr from shell commands. 5371 *hl-StdoutMsg* 5372StdoutMsg Messages in stdout from shell commands. 5373 *hl-WinSeparator* 5374WinSeparator Separators between window splits. 5375 *hl-Folded* 5376Folded Line used for closed folds. 5377 *hl-FoldColumn* 5378FoldColumn 'foldcolumn' 5379 *hl-SignColumn* 5380SignColumn Column where |signs| are displayed. 5381 *hl-IncSearch* 5382IncSearch 'incsearch' highlighting; also used for the text replaced with 5383 ":s///c". 5384 *hl-Substitute* 5385Substitute |:substitute| replacement text highlighting. 5386 *hl-LineNr* 5387LineNr Line number for ":number" and ":#" commands, and when 'number' 5388 or 'relativenumber' option is set. 5389 *hl-LineNrAbove* 5390LineNrAbove Line number for when the 'relativenumber' 5391 option is set, above the cursor line. 5392 *hl-LineNrBelow* 5393LineNrBelow Line number for when the 'relativenumber' 5394 option is set, below the cursor line. 5395 *hl-CursorLineNr* 5396CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' 5397 contains "number" or is "both", for the cursor line. 5398 *hl-CursorLineFold* 5399CursorLineFold Like FoldColumn when 'cursorline' is set for the cursor line. 5400 *hl-CursorLineSign* 5401CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line. 5402 *hl-MatchParen* 5403MatchParen Character under the cursor or just before it, if it 5404 is a paired bracket, and its match. |pi_paren.txt| 5405 *hl-MCursor* 5406MCursor |multicursor| cursor. 5407 *hl-MCursorVisual* 5408MCursorVisual |multicursor| Visual selection. 5409 *hl-ModeMsg* 5410ModeMsg 'showmode' message (e.g., "-- INSERT --"). 5411 *hl-MsgArea* 5412MsgArea Area for messages and command-line, see also 'cmdheight'. 5413 *hl-MsgSeparator* 5414MsgSeparator Separator for scrolled messages |msgsep|. 5415 *hl-MoreMsg* 5416MoreMsg |more-prompt| 5417 *hl-NonText* 5418NonText '@' at the end of the window, characters from 'showbreak' 5419 and other characters that do not really exist in the text 5420 (e.g., ">" displayed when a double-wide character doesn't 5421 fit at the end of the line). See also |hl-EndOfBuffer|. 5422 *hl-Normal* 5423Normal Normal text. 5424 *hl-NormalFloat* 5425NormalFloat Normal text in floating windows. 5426 *hl-FloatBorder* 5427FloatBorder Border of floating windows. 5428 *hl-FloatShadow* 5429FloatShadow Blended areas when border is "shadow". 5430 *hl-FloatShadowThrough* 5431FloatShadowThrough 5432 Shadow corners when border is "shadow". 5433 *hl-FloatTitle* 5434FloatTitle Title of floating windows. 5435 *hl-FloatFooter* 5436FloatFooter Footer of floating windows. 5437 *hl-NormalNC* 5438NormalNC Normal text in non-current windows. 5439 *hl-Pmenu* 5440Pmenu Popup menu: Normal item. 5441 *hl-PmenuSel* 5442PmenuSel Popup menu: Selected item. Combined with |hl-Pmenu|. 5443 *hl-PmenuKind* 5444PmenuKind Popup menu: Normal item "kind". 5445 *hl-PmenuKindSel* 5446PmenuKindSel Popup menu: Selected item "kind". 5447 *hl-PmenuExtra* 5448PmenuExtra Popup menu: Normal item "extra text". 5449 *hl-PmenuExtraSel* 5450PmenuExtraSel Popup menu: Selected item "extra text". 5451 *hl-PmenuSbar* 5452PmenuSbar Popup menu: Scrollbar. 5453 *hl-PmenuThumb* 5454PmenuThumb Popup menu: Thumb of the scrollbar. 5455 *hl-PmenuMatch* 5456PmenuMatch Popup menu: Matched text in normal item. Combined with 5457 |hl-Pmenu|. 5458 *hl-PmenuMatchSel* 5459PmenuMatchSel Popup menu: Matched text in selected item. Combined with 5460 |hl-PmenuMatch| and |hl-PmenuSel|. 5461 *hl-PmenuBorder* 5462PmenuBorder Popup menu: border of popup menu. 5463 *hl-PmenuShadow* 5464PmenuShadow Popup menu: blended areas when 'pumborder' is "shadow". 5465 *hl-PmenuShadowThrough* 5466PmenuShadowThrough 5467 Popup menu: shadow corners when 'pumborder' is "shadow". 5468 *hl-ComplMatchIns* 5469ComplMatchIns Matched text of the currently inserted completion. 5470 *hl-PreInsert* 5471PreInsert Text inserted when "preinsert" is in 'completeopt'. 5472 *hl-ComplHint* 5473ComplHint Virtual text of the currently selected completion. 5474 *hl-ComplHintMore* 5475ComplHintMore The additional information of the virtual text. 5476 *hl-Question* 5477Question |hit-enter| prompt and yes/no questions. 5478 *hl-QuickFixLine* 5479QuickFixLine Current |quickfix| item in the quickfix window. Combined with 5480 |hl-CursorLine| when the cursor is there. 5481 *hl-Search* 5482Search Last search pattern highlighting (see 'hlsearch'). 5483 Also used for similar items that need to stand out. 5484 *hl-SnippetTabstop* 5485SnippetTabstop Tabstops in snippets. |vim.snippet| 5486 *hl-SnippetTabstopActive* 5487SnippetTabstopActive 5488 The currently active tabstop. |vim.snippet| 5489 *hl-SpecialKey* 5490SpecialKey Unprintable characters: Text displayed differently from what 5491 it really is. But not 'listchars' whitespace. |hl-Whitespace| 5492 *hl-SpellBad* 5493SpellBad Word that is not recognized by the spellchecker. |spell| 5494 Combined with the highlighting used otherwise. 5495 *hl-SpellCap* 5496SpellCap Word that should start with a capital. |spell| 5497 Combined with the highlighting used otherwise. 5498 *hl-SpellLocal* 5499SpellLocal Word that is recognized by the spellchecker as one that is 5500 used in another region. |spell| 5501 Combined with the highlighting used otherwise. 5502 *hl-SpellRare* 5503SpellRare Word that is recognized by the spellchecker as one that is 5504 hardly ever used. |spell| 5505 Combined with the highlighting used otherwise. 5506 *hl-StatusLine* 5507StatusLine Status line of current window. 5508 *hl-StatusLineNC* 5509StatusLineNC Status lines of not-current windows. 5510 *hl-StatusLineTerm* 5511StatusLineTerm Status line of |terminal| window. 5512 *hl-StatusLineTermNC* 5513StatusLineTermNC 5514 Status line of non-current |terminal| windows. 5515 *hl-TabLine* 5516TabLine Tabpages line, not active tabpage label. 5517 *hl-TabLineFill* 5518TabLineFill Tabpages line, where there are no labels. 5519 *hl-TabLineSel* 5520TabLineSel Tabpages line, active tabpage label. 5521 *hl-Title* 5522Title Titles for output from ":set all", ":autocmd" etc. 5523 *hl-Visual* 5524Visual Visual mode selection. 5525 *hl-VisualNOS* 5526VisualNOS Visual mode selection when vim is "Not Owning the Selection". 5527 *hl-Whitespace* 5528Whitespace "nbsp", "space", "tab", "multispace", "lead" and "trail" 5529 in 'listchars'. 5530 *hl-WildMenu* 5531WildMenu Current match in 'wildmenu' completion. 5532 *hl-WinBar* 5533WinBar Window bar of current window. 5534 *hl-WinBarNC* 5535WinBarNC Window bar of not-current windows. 5536 5537 *hl-User1* *hl-User1..9* *hl-User9* 5538The 'statusline' syntax allows the use of 9 different highlights in the 5539statusline and ruler (via 'rulerformat'). The names are User1 to User9. 5540 5541For the GUI you can use the following groups to set the colors for the menu, 5542scrollbars and tooltips. They don't have defaults. This doesn't work for the 5543Win32 GUI. Only three highlight arguments have any effect here: font, guibg, 5544and guifg. 5545 5546 *hl-Menu* 5547Menu Current font, background and foreground colors of the menus. 5548 Also used for the toolbar. 5549 Applicable highlight arguments: font, guibg, guifg. 5550 5551 *hl-Scrollbar* 5552Scrollbar Current background and foreground of the main window's 5553 scrollbars. 5554 Applicable highlight arguments: guibg, guifg. 5555 5556 *hl-Tooltip* 5557Tooltip Current font, background and foreground of the tooltips. 5558 Applicable highlight arguments: font, guibg, guifg. 5559 5560============================================================================== 556114. Linking groups *:hi-link* *:highlight-link* *E412* *E413* 5562 5563When you want to use the same highlighting for several syntax groups, you 5564can do this more easily by linking the groups into one common highlight 5565group, and give the color attributes only for that group. 5566 5567To set a link: 5568 5569 :hi[ghlight][!] [default] link {from-group} {to-group} 5570 5571To remove a link: 5572 5573 :hi[ghlight][!] [default] link {from-group} NONE 5574 5575Notes: *E414* 5576- If the {from-group} and/or {to-group} doesn't exist, it is created. You 5577 don't get an error message for a non-existing group. 5578- As soon as you use a ":highlight" command for a linked group, the link is 5579 removed. 5580- If there are already highlight settings for the {from-group}, the link is 5581 not made, unless the '!' is given. For a ":highlight link" command in a 5582 sourced file, you don't get an error message. This can be used to skip 5583 links for groups that already have settings. 5584 5585 *:hi-default* *:highlight-default* 5586The [default] argument is used for setting the default highlighting for a 5587group. If highlighting has already been specified for the group the command 5588will be ignored. Also when there is an existing link. 5589 5590Using [default] is especially useful to overrule the highlighting of a 5591specific syntax file. For example, the C syntax file contains: > 5592 :highlight default link cComment Comment 5593If you like Question highlighting for C comments, put this in your vimrc file: > 5594 :highlight link cComment Question 5595Without the "default" in the C syntax file, the highlighting would be 5596overruled when the syntax file is loaded. 5597 5598To have a link survive `:highlight clear`, which is useful if you have 5599highlighting for a specific filetype and you want to keep it when selecting 5600another color scheme, put a command like this in the 5601"after/syntax/{filetype}.vim" file: > 5602 highlight! default link cComment Question 5603 5604============================================================================== 560515. Cleaning up *:syn-clear* *E391* 5606 5607If you want to clear the syntax stuff for the current buffer, you can use this 5608command: > 5609 :syntax clear 5610 5611This command should be used when you want to switch off syntax highlighting, 5612or when you want to switch to using another syntax. It's normally not needed 5613in a syntax file itself, because syntax is cleared by the autocommands that 5614load the syntax file. 5615The command also deletes the "b:current_syntax" variable, since no syntax is 5616loaded after this command. 5617 5618To clean up specific syntax groups for the current buffer: > 5619 :syntax clear {group-name} ... 5620This removes all patterns and keywords for {group-name}. 5621 5622To clean up specific syntax group lists for the current buffer: > 5623 :syntax clear @{grouplist-name} ... 5624This sets {grouplist-name}'s contents to an empty list. 5625 5626 *:syntax-off* *:syn-off* 5627If you want to disable syntax highlighting for all buffers, you need to remove 5628the autocommands that load the syntax files: > 5629 :syntax off 5630 5631What this command actually does, is executing the command > 5632 :source $VIMRUNTIME/syntax/nosyntax.vim 5633See the "nosyntax.vim" file for details. Note that for this to work 5634$VIMRUNTIME must be valid. See |$VIMRUNTIME|. 5635 5636 *:syntax-reset* *:syn-reset* 5637If you have changed the colors and messed them up, use this command to get the 5638defaults back: > 5639 5640 :syntax reset 5641 5642It is a bit of a wrong name, since it does not reset any syntax items, it only 5643affects the highlighting. 5644 5645Note that the syntax colors that you set in your vimrc file will also be reset 5646back to their Vim default. 5647Note that if you are using a color scheme, the colors defined by the color 5648scheme for syntax highlighting will be lost. 5649 5650Note that when a color scheme is used, there might be some confusion whether 5651your defined colors are to be used or the colors from the scheme. This 5652depends on the color scheme file. See |:colorscheme|. 5653 5654============================================================================== 565516. Highlighting tags *tag-highlight* 5656 5657If you want to highlight all the tags in your file, you can use the following 5658mappings. 5659 5660 <F11> -- Generate tags.vim file, and highlight tags. 5661 <F12> -- Just highlight tags based on existing tags.vim file. 5662> 5663 :map <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12> 5664 :map <F12> :so tags.vim<CR> 5665 5666WARNING: The longer the tags file, the slower this will be, and the more 5667memory Vim will consume. 5668 5669Only highlighting typedefs, unions and structs can be done too. For this you 5670must use Universal Ctags (https://ctags.io) or Exuberant ctags. 5671 5672Put these lines in your Makefile: > 5673 5674 # Make a highlight file for types. Requires Universal/Exuberant ctags and awk 5675 types: types.vim 5676 types.vim: *.[ch] 5677 ctags --c-kinds=gstu -o- *.[ch] |\ 5678 awk 'BEGIN{printf("syntax keyword Type\t")}\ 5679 {printf("%s ", $$1)}END{print ""}' > $@ 5680 5681And put these lines in your vimrc: > 5682 5683 " load the types.vim highlighting file, if it exists 5684 autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') .. '/types.vim' 5685 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname) 5686 autocmd BufRead,BufNewFile *.[ch] exe 'so ' .. fname 5687 autocmd BufRead,BufNewFile *.[ch] endif 5688 5689============================================================================== 569017. Color xterms *xterm-color* *color-xterm* 5691 5692 *colortest.vim* 5693To test your color setup, a file has been included in the Vim distribution. 5694To use it, execute this command: > 5695 :runtime syntax/colortest.vim 5696 5697Nvim uses 256-color and |true-color| terminal capabilities wherever possible. 5698 5699============================================================================== 570018. When syntax is slow *:synti* *:syntime* 5701 5702This is aimed at authors of a syntax file. 5703 5704If your syntax causes redrawing to be slow, here are a few hints on making it 5705faster. To see slowness switch on some features that usually interfere, such 5706as 'relativenumber' and |folding|. 5707 5708To find out what patterns are consuming the most time, get an overview with 5709this sequence: > 5710 :syntime on 5711 [ redraw the text at least once with CTRL-L ] 5712 :syntime report 5713 5714This will display a list of syntax patterns that were used, sorted by the time 5715it took to match them against the text. 5716 5717:synti[me] on Start measuring syntax times. This will add some 5718 overhead to compute the time spent on syntax pattern 5719 matching. 5720 5721:synti[me] off Stop measuring syntax times. 5722 5723:synti[me] clear Set all the counters to zero, restart measuring. 5724 5725:synti[me] report Show the syntax items used since ":syntime on" in the 5726 current window. Use a wider display to see more of 5727 the output. 5728 5729 The list is sorted by total time. The columns are: 5730 TOTAL Total time in seconds spent on 5731 matching this pattern. 5732 COUNT Number of times the pattern was used. 5733 MATCH Number of times the pattern actually 5734 matched 5735 SLOWEST The longest time for one try. 5736 AVERAGE The average time for one try. 5737 NAME Name of the syntax item. Note that 5738 this is not unique. 5739 PATTERN The pattern being used. 5740 5741Pattern matching gets slow when it has to try many alternatives. Try to 5742include as much literal text as possible to reduce the number of ways a 5743pattern does NOT match. 5744 5745When using the "\@<=" and "\@<!" items, add a maximum size to avoid trying at 5746all positions in the current and previous line. For example, if the item is 5747literal text specify the size of that text (in bytes): 5748 5749"<\@<=span" Matches "span" in "<span". This tries matching with "<" in 5750 many places. 5751"<\@1<=span" Matches the same, but only tries one byte before "span". 5752 5753 5754 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: