home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim53os2.zip / vim-5.3 / doc / syntax.txt < prev    next >
Text File  |  1998-08-30  |  75KB  |  1,790 lines

  1. *syntax.txt*    For Vim version 5.3.  Last modification: 1998 Aug 23
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Syntax highlighting        *syntax* *syntax-highlighting* *coloring*
  8.  
  9. Syntax highlighting enables the possibility to show parts of the text in
  10. another font or color.  Those parts can be specific keywords or text
  11. matching a pattern.  Vim doesn't parse the whole file (to keep it fast), so
  12. the highlighting has its limitations.  Lexical highlighting might be a
  13. better name, but everybody calls it syntax highlighting, so we'll stick with
  14. that.
  15.  
  16. Vim supports syntax highlighting on all terminals.  But since most ordinary
  17. terminals have very limited highlighting possibilities, it works best in the
  18. GUI version, gvim.
  19.  
  20. 1.  Quick start            |:syn-qstart|
  21. 2.  Syntax files        |:syn-files|
  22. 3.  Syntax file remarks        |:syn-file-remarks|
  23. 4.  Defining a syntax        |:syn-define|
  24. 5.  :syntax arguments        |:syn-arguments|
  25. 6.  Syntax patterns        |:syn-pattern|
  26. 7.  Syntax clusters        |:syn-cluster|
  27. 8.  Including syntax files    |:syn-include|
  28. 9.  Synchronizing        |:syn-sync|
  29. 10. Listing syntax items    |:syntax|
  30. 11. Highlight command        |:highlight|
  31. 12. Linking groups        |:highlight-link|
  32. 13. Cleaning up            |:syn-clear|
  33. 14. Highlighting tags        |tag-highlight|
  34. 15. Color xterms        |xterm-color|
  35.  
  36. {Vi does not have any of these commands}
  37.  
  38. The syntax highlighting is not available when the |+syntax| feature has been
  39. disabled at compile time.
  40.  
  41. ==============================================================================
  42. 1. Quick start                        *:syn-qstart*
  43.  
  44.                             *:syn-on*
  45. For a large number of common languages syntax files have been included.  To
  46. start using them, type this command:
  47. >  :syntax on
  48.  
  49. This will enable automatic syntax highlighting.  The type of highlighting will
  50. be selected using the file name extension, and sometimes using the first line
  51. of the file.
  52.  
  53. Include this command in your .vimrc if you always want syntax highlighting, or
  54. put it in your .gvimrc if you only want it in the GUI.  If you don't want it
  55. for B&W terminals, but you do want it for color terminals, put this in your
  56. .vimrc:
  57. >  if &t_Co > 1
  58. >    syntax on
  59. >  endif
  60.  
  61. What this command actually does, is executing the command
  62. >  source $VIM/syntax/syntax.vim
  63. If the VIM environment variable is not set, Vim will try to find
  64. the path in another way (see |$VIM|).  Normally this will work just fine.  If
  65. it doesn't, try setting the VIM environment variable to the directory where
  66. the Vim stuff is located.  For example, if your syntax files are in the
  67. "/usr/vim/5.0/syntax" directory, set $VIM to "/usr/vim/5.0".  You must do this
  68. in the shell, before starting Vim.
  69.  
  70.                             *:syn-default-override*
  71. You can override the default highlight settings, by issuing ":highlight"
  72. commands after sourcing "syntax.vim".  For example:
  73. >  syntax on
  74. >  highlight Constant gui=NONE guibg=grey95
  75.  
  76. This will change the GUI highlighting for the "Constant" group.  See
  77. |:highlight| about how to specify highlighting attributes.
  78.  
  79. If you are running in the GUI, you can get white text on a black background
  80. with:
  81. >  highlight Normal guibg=Black guifg=White
  82.  
  83. If you have a black background, use these commands to get better colors (see
  84. 'background'):
  85. >  set background=dark
  86. >  syntax on
  87.  
  88. NOTE: The syntax files on MS-DOS and Windows have lines that end in <CR><NL>.
  89. The files for Unix end in <NL>.  This means you should use the right type of
  90. file for your system.  Although on MS-DOS and Windows the right format is
  91. automatically selected if the 'fileformats' option is not empty.
  92.  
  93. NOTE: When using reverse video ("gvim -fg white -bg black"), the default value
  94. of 'background' will not be set until the GUI window is opened, which is after
  95. reading the .gvimrc.  This will cause the wrong default highlighting to be
  96. used.  To set the default value of 'background' before switching on
  97. highlighting, include the ":gui" command in the .gvimrc:
  98.  
  99. >  :gui        " open window and set default for 'background'
  100. >  :syntax on    " start highlighting, use 'background' to set colors
  101.  
  102.  
  103. To switch off the syntax highlighting:            *:syn-off*
  104. >  :syntax off
  105.  
  106. You can toggle the syntax on/off with this command
  107. >  :if has("syntax_items") | syntax off | else | syntax on | endif
  108.  
  109. To put this into a mapping, you can use:
  110. >  map <F7> :if has("syntax_items") <Bar> syntax off <Bar> else <Bar> syntax on <Bar> endif <CR>
  111. [using the |<>| notation, type this literally]
  112.  
  113. ==============================================================================
  114. 2. Syntax files                        *:syn-files*
  115.  
  116. The syntax and highlighting commands for one language are normally stored in
  117. a syntax file.  The name convention is: "{name}.vim".  Where {name} is the
  118. name of the language, or an abbreviation (to fit the name in 8.3 characters,
  119. which is always done, in case the file will be used on a DOS filesystem).
  120. Examples:
  121.     c.vim        perl.vim    java.vim    html.vim
  122.     cpp.vim        sh.vim        csh.vim
  123.  
  124. The syntax file can contain any Ex commands, just like a vimrc file.  But
  125. the idea is that only commands for a specific language are included.  When a
  126. language is a superset of another language, it may include the other one,
  127. for example, the cpp.vim file could include the c.vim file:
  128. >  :so $VIM/syntax/c.vim
  129.  
  130. The .vim files are normally loaded with an autocommand.  For example:
  131. >  :au BufNewFile,BufReadPost *.c,*.h source $VIM/syntax/c.vim
  132. >  :au BufNewFile,BufReadPost *.cpp source $VIM/syntax/cpp.vim
  133.  
  134.  
  135. MAKING YOUR OWN SYNTAX FILES                *mysyntaxfile*
  136.  
  137. When you create your own syntax files, and you want to have these
  138. automatically used with ":syntax on", do this:
  139.  
  140. 1. Create a file that contains the autocommands to load your syntax file when
  141.    the right file name or extension is detected.  To prevent loading two
  142.    syntax files (when the extension is used twice), first delete other
  143.    autocommands for the same extension.  You can also include ":highlight"
  144.    commands in this file, which override the normal highlighting (because the
  145.    file is sourced after setting the normal highlighting).  Example:
  146. >    augroup syntax
  147. >    au! BufNewFile,BufReadPost *.bat
  148. >    au  BufNewFile,BufReadPost *.bat  so ~/vim/batch.vim
  149. >    augroup END
  150. >    highlight Comment gui=bold
  151.    Let's assume you write this file in "~/vim/mysyntax.vim".
  152.  
  153. 2. In your .vimrc, set the "mysyntaxfile" variable to the file you just
  154.    created.  For example:
  155. >  :let mysyntaxfile = "~/vim/mysyntax.vim"
  156.    Put this before ":syntax on"!
  157.  
  158. 3. If your file type can only be detected by inspecting the contents of the
  159.    file, create another file for doing this.  See $VIM/syntax/scripts.vim for
  160.    examples.  Let's assume you write this file in "~/vim/myscripts.vim".
  161.    Then set the "myscriptsfile" variable to this file name.  Example:
  162. >  :let myscriptsfile = "~/vim/myscripts.vim"
  163.    Note that this file is only used when no syntax file was loaded by the
  164.    autocommands, if the file type has not been detected by the file name or
  165.    extension.
  166.  
  167. Note that "mysyntaxfile" is sourced AFTER defining the default autocommands
  168. for the supplied syntax files, so you can override these with your own files.
  169. The "myscriptsfile" is loaded before the default checks for syntax files,
  170. which also means that your rules override the supplied rules.
  171.  
  172.  
  173. NAMING CONVENTIONS
  174.                             *group-name*
  175. To be able to allow each user to pick his favorite set of colors, there need
  176. to be preferred names for highlight groups that are common for many languages.
  177. These are the ones that are suggested to be used:
  178.  
  179.     *Comment    any comment
  180.  
  181.     *Constant    any constant
  182.      String        a string constant: "this is a string"
  183.      Character    a character constant: 'c', '\n'
  184.      Number        a number constant: 234, 0xff
  185.      Boolean    a boolean constant: TRUE, false
  186.      Float        a floating point constant: 2.3e10
  187.  
  188.     *Identifier    any variable name
  189.      Function    function name (also: methods for classes)
  190.  
  191.     *Statement    any statement
  192.      Conditional    if, then, else, endif, switch, etc.
  193.      Repeat        for, do, while, etc.
  194.      Label        case, default, etc.
  195.      Operator    "sizeof", "+", "*", etc.
  196.      Keyword    any other keyword
  197.      Exception    try, catch, throw
  198.  
  199.     *PreProc    generic Preprocessor
  200.      Include    preprocessor #include
  201.      Define        preprocessor #define
  202.      Macro        same as Define
  203.      PreCondit    preprocessor #if, #else, #endif, etc.
  204.  
  205.     *Type        int, long, char, etc.
  206.      StorageClass    static, register, volatile, etc.
  207.      Structure    struct, union, enum, etc.
  208.      Typedef    A typedef
  209.  
  210.     *Special    any special symbol
  211.      SpecialChar    special character in a constant
  212.      Tag        you can use CTRL-] on this
  213.      Delimiter    character that needs attention
  214.      SpecialComment    special things inside a comment
  215.      Debug        debugging statements
  216.  
  217.     *Ignore        left blank, hidden
  218.  
  219.     *Error        any erroneous construct
  220.  
  221.     *Todo        anything that needs extra attention
  222.  
  223. The ones marked with * are the preferred groups, the other are minor groups.
  224. For the preferred groups, the "syntax.vim" file contains default highlighting.
  225. The minor groups are linked to the preferred groups, so they get the same
  226. highlighting.  You can override these defaults by giving ":highlight" commands
  227. after sourcing the "syntax.vim" file.
  228.  
  229. Note that highlight group names are not case sensitive.  "String" and "string"
  230. can be used for the same group.
  231.  
  232. The following names are reserved and cannot be used as a group name:
  233.     NONE   ALL   ALLBUT   contains   contained
  234.  
  235. ==============================================================================
  236. 3. Syntax file remarks                    *:syn-file-remarks*
  237.  
  238.                         *b:current_syntax-variable*
  239. The name of the syntax that has been loaded is stored in the
  240. "b:current_syntax" variable.  You can use this if you want to load other
  241. settings, depending on which syntax is active.  Example:
  242. >  :au BufReadPost * if b:current_syntax == "csh"
  243. >  :au BufReadPost *   do-some-things
  244. >  :au BufReadPost * endif
  245.  
  246.  
  247. 2HTML                        *2html.vim* *convert-to-HTML*
  248.  
  249. This is not a syntax file itself, but a script that converts the current
  250. window into HTML.  A new window is opened, in which the HTML file is built.
  251.     Warning: This is slow!
  252. The resulting file can be written where you want it.  You can then view it
  253. with any HTML viewer, such as Netscape.  The colors should be exactly the same
  254. as you see them in Vim.
  255. Remarks:
  256. - This only works in the GUI version.
  257. - In older browsers the background colors will not be shown.
  258. - From Netscape you can also print the file (in color)!
  259. - When 'tabstop' is not 8, the amount of white space will be wrong.
  260.  
  261.  
  262. Assembly                        *asmselect.vim*
  263.  
  264. There are many types of assembly languages that all use the same file name
  265. extensions.  Therefore you will have to select the type yourself, or add a
  266. line in the assembly file that Vim will recognize.
  267.  
  268. The most flexible is to add a line in your assembly file containing:
  269. >    asmsyntax=nasm
  270. Replace "nasm" with the name of the real assembly syntax.  This line must be
  271. one of the first five lines in the file.
  272.  
  273. The syntax type can always be overruled for a specific buffer by setting the
  274. b:asmsyntax variable:
  275. >    let b:asmsyntax=nasm
  276.  
  277. If b:asmsyntax is not set, either automatically or by hand, then the value of
  278. the global variable asmsyntax is used.  This can be seen as a default assembly
  279. language:
  280. >    let asmsyntax=nasm
  281.  
  282. As a last resort, if nothing is defined, the "asm" syntax is used.
  283.  
  284.  
  285. C                            *c.vim*
  286.  
  287. Most C highlighting is fixed.  There is one optional feature: highlighting
  288. strings and numbers inside a comment.  It can be enabled by adding this line
  289. to your vimrc:
  290. >  let c_comment_strings=1
  291. To disable it again, use this:
  292. >  unlet c_comment_strings
  293.  
  294. If you notice highlighting errors while scrolling backwards, which are fixed
  295. when redrawing with CTRL-L, try setting the "c_minlines" internal variable
  296. to a larger number:
  297. >  let c_minlines = 50
  298. This will make the syntax synchronisation start 50 lines before the first
  299. displayed line.  The default value is 10.  The disadvantage of using a larger
  300. number is that redrawing can become slow.
  301.  
  302. If you would like to flag trailing white space, and spaces before a Tab as
  303. errors:
  304. >  let c_space_errors = 1
  305.  
  306.  
  307. COBOL                            *cobol.vim*
  308.  
  309. COBOL highlighting for legacy code has different needs than fresh development.
  310. This is due both to differences in what is being done (maintenance versus
  311. development) as well as other factors.  To enable legacy code highlighting,
  312. add this line to you .vimrc:
  313. >  let cobol_legacy_code=1
  314. To disable it again, use this:
  315. >  unlet cobol_legacy_code
  316.  
  317.  
  318. EIFFEL                            *eiffel.vim*
  319.  
  320. While Eiffel is not case-sensitive, its style guidelines are, and the
  321. syntax highlighting file encourages their use. This also allows to
  322. highlight class names differently. If you want to disable case-sensitive
  323. highlighting, add the following line to your startup file:
  324.  
  325. >  let eiffel_ignore_case=1
  326.  
  327. Case still matters for class names and TODO marks in comments.
  328.  
  329. Conversely, for even stricter checks, add the following line too:
  330.  
  331. >  let eiffel_pedantic=1
  332.  
  333. Currently, this will only catch improper capitalization for the five
  334. predefined words "Current", "Void", "Result", "Precursor", and "NONE",
  335. to warn against their accidental use as feature or class names.
  336.  
  337. If instead you want to use the lower-case version of "Current", "Void",
  338. "Result", and "Precursor", you can use
  339.  
  340. >  let eiffel_lower_case_predef=1
  341.  
  342. instead of completely turning case-sensitive highlighting off.
  343.  
  344. Finally, some vendors support hexadecimal constants. To handle them, add
  345.  
  346. >  let eiffel_hex_constants=1
  347.  
  348. to your startup file.
  349.  
  350.                             *fvwm.vim*
  351. FVWM CONFIGURATION FILES
  352.  
  353. Put
  354. >      let is_fvwm1 = 1
  355. in your vimrc for more specific Fvwm1 syntax, or
  356. >      let is_fvwm2 = 1
  357. if you're using Fvwm2.
  358.  
  359.  
  360. HTML                            *html.vim*
  361.  
  362. The coloring scheme for tags in the HTML file works as follows.
  363.  
  364. The  <> of opening tags are colored differently than the </> of a closing tag.
  365. This is on purpose! For opening tags the 'Function' color is used, while for
  366. closing tags the 'Type' color is used (See syntax.vim to check how those are
  367. defined for you)
  368.  
  369. Known tag names are colored the same way as statements in C.  Unknown tag
  370. names are colored with the same color as the <> or </> respectively which
  371. makes it easy to spot errors
  372.  
  373. Note that the same is true for argument (or attribute) names. Known attribute
  374. names are colored differently than unknown ones.
  375.  
  376. Some HTML tags are used to change the rendering of text. The following tags
  377. are recognized by the html.vim syntax coloring file and change the way normal
  378. text is shown: <B> <I> <U> <EM> <STRONG> (<EM> is used as an alias for <I>,
  379. while <STRONG> as an alias for <B>), <H1> - <H6>, <HEAD>, <TITLE> and <A>, but
  380. only if used as a link that is, it must include a href as in
  381. <A href="somfile.html">).
  382.  
  383. If you want to change how such text is rendered, you must redefine the
  384. following syntax groups:
  385.  
  386.     - htmlBold
  387.     - htmlBoldUnderline
  388.     - htmlBoldUnderlineItalic
  389.     - htmlUnderline
  390.     - htmlUnderlineItalic
  391.     - htmlItalic
  392.     - htmlLink for links
  393.     - htmlTitle for titles
  394.     - htmlH1 - htmlH6 for headings
  395.  
  396. To make this redefinition work you must redefine them all with the exception
  397. of the last two (htmlTitle and htmlH[1-6], which are optional) and define the
  398. following variable in your vimrc (this is due to the order in which the files
  399. are read during initialization)
  400. >   let html_my_rendering=1
  401.  
  402. If you'd like to see an example download mysyntax.vim at
  403. http://www.fleiner.com/vim/mysyntax.vim
  404.  
  405. You can also disable this rendering by adding the following line to your
  406. vimrc file:
  407. >   let html_no_rendering=1
  408.  
  409. HTML comments are rather special (see an HTML reference document for the
  410. details), and the syntax coloring scheme will highlight all errors.
  411. However, if you prefer to use the wrong style (starts with <!-- and
  412. ends with -->) you can define
  413. >   let html_wrong_comments=1
  414.  
  415. JavaScript embedded inside HTML documents is highlighted as 'Special'
  416. with statements, comments, strings and so on colored as in standard
  417. programming languages. Note that only JavaScript is currently supported,
  418. no other scripting language has been added yet.
  419.  
  420. Embedded and inlined cascading style sheets (CSS) are highlighted too.
  421.  
  422.  
  423. JAVA                            *java.vim*
  424.  
  425. The java.vim syntax highlighting file offers several options:
  426.  
  427. In Java 1.0.2 it was never possible to have braces inside parens, so this was
  428. flagged as an error.  Since Java 1.1 this is possible (with anonymous
  429. classes), and therefore is no longer marked as an error. If you prefer the old
  430. way, put the following line into your vim startup file:
  431. >  let java_mark_braces_in_parens_as_errors=1
  432.  
  433. Function names are not highlighted, as the way to find functions depends on
  434. how you write java code.  To enable it anyway put the following line in your
  435. startup file:
  436. >  let java_highlight_functions=1
  437. This will only work if you either use two spaces for indentation or tabs.  If
  438. you use another indentation style but would still want function declarations
  439. to be highlighted create your own definitions by changing the definitions in
  440. java.vim or by creating your own java.vim which includes the original one and
  441. then adds the code to highlight functions.
  442.  
  443. In java 1.1 the functions System.out.println() and System.err.println() should
  444. only be used for debugging. Therefor it is possible to highlight debugging
  445. statements differently. To do this you must add the following definition in
  446. your startup file:
  447. >  let java_highlight_debug=1
  448. The result will be that those statements are highlighted as 'Special'
  449. characters. If you prefer to have them highlighted differently you must define
  450. new highlightings for the following groups.:
  451.     Debug, DebugSpecial, DebugString, DebugBoolean, DebugType
  452. which are used for the statement itself, special characters used in debug
  453. strings, strings, boolean constants and types (this, super) respectively. I
  454. have opted to chose another background for those statements.
  455.  
  456. In order to help you to write code that can be easely ported between
  457. java and C++, all C++ keywords are marked as error in a java program.
  458. However, if you use them regularly, you may want to define the following
  459. variable in your .vimrc file:
  460. >  let java_allow_cpp_keywords=1
  461.  
  462. Javadoc is a program that takes special comments out of java program files and
  463. creates HTML pages. The standard configuration will highlight this HTML code
  464. similarly to HTML files (see |html.vim|). You can even add javascript
  465. and CSS inside this code (see below). There are four differences however:
  466.   1. The title (all characters up to the first '.' which is followed by
  467.      some white space or up to the first '@') is colored differently (to change
  468.      the color change the group CommentTitle).
  469.   2. The text is colored as 'Comment'.
  470.   3. HTML comments are colored as 'Special'
  471.   4. The special javadoc tags (@see, @param, ...) are highlighted as specials
  472.      and the argument (for @see, @param, @exception) as Function.
  473. To turn this feature off add the following line to your startup file:
  474. >  let java_ignore_javadoc=1
  475.  
  476. If you use the special javadoc comment highlighting described above you
  477. can also turn on special highlighting for javascript and embedded CSS
  478. (stylesheets). This makes only sense if you actually have javadoc comments
  479. that include either javascript or emdedded CSS. The options to use are
  480. >  let java_javascript=1
  481. >  let java_css=1
  482.  
  483. If you notice highlighting errors while scrolling backwards, which are fixed
  484. when redrawing with CTRL-L, try setting the "java_minlines" internal variable
  485. to a larger number:
  486. >  let java_minlines = 50
  487. This will make the syntax synchronisation start 50 lines before the first
  488. displayed line.  The default value is 10.  The disadvantage of using a larger
  489. number is that redrawing can become slow.
  490.  
  491.  
  492. LACE                            *lace.vim*
  493.  
  494. Lace (Language for Assembly of Classes in Eiffel) is case insensitive, but the
  495. style guide lines are not.  If you prefer case insensitive highlighting, just
  496. define the vim variable 'lace_case_insensitive' in your startup file:
  497. >  let lace_case_insensitive=1
  498.  
  499.  
  500. LEX                            *lex.vim*
  501.  
  502. Lex uses brute-force synchronizing as the "^%%$" section delimiter
  503. gives no clue as to what section follows.  Consequently, the value for
  504. >syn sync minlines=300
  505. may be changed by the user if s/he is experiencing synchronization
  506. difficulties (such as may happen with large <*.lex> files).
  507.  
  508.  
  509. MAPLE                            *maple.vim*
  510.  
  511. Maple V, by Waterloo Maple Inc, supports symbolic algebra.  The language
  512. supports many packages of functions which are selectively loaded by the user.
  513. The standard set of packages' functions as supplied in Maple V release 4 may be
  514. highlighted at the user's discretion.  Users may place in their <.vimrc> file:
  515.  
  516. >  let mvpkg_all= 1
  517.  
  518. to get all package functions highlighted, or users may select any subset by
  519. choosing a variable/package from the table below and setting that variable to
  520. 1, also in their <.vimrc> file (prior to sourcing $VIM/syntax/syntax.vim).
  521.  
  522. >    Table of Maple V Package Function Selectors
  523. >  mv_DEtools     mv_genfunc    mv_networks    mv_process
  524. >  mv_Galois     mv_geometry    mv_numapprox    mv_simplex
  525. >  mv_GaussInt     mv_grobner    mv_numtheory    mv_stats
  526. >  mv_LREtools     mv_group    mv_orthopoly    mv_student
  527. >  mv_combinat     mv_inttrans    mv_padic    mv_sumtools
  528. >  mv_combstruct mv_liesymm    mv_plots    mv_tensor
  529. >  mv_difforms     mv_linalg    mv_plottools    mv_totorder
  530. >  mv_finance     mv_logic    mv_powseries
  531.  
  532.  
  533. PERL                                                    *perl.vim*
  534.  
  535. There are a number of possible options to the perl syntax highlighting.
  536.  
  537. The first option will handle package references (the 'PkgName::' in
  538. '$PkgName::VarName') separate from normal variables.
  539.  
  540. > let perl_want_scope_in_variables = 1
  541.  
  542. If you want complex things like '@{${"foo"}}' to be parsed set the variable
  543.  
  544. > let perl_extended_vars = 1
  545.  
  546. This makes the matches being coloured like strings. By default this will be
  547. highlighted in the default colour.
  548.  
  549. > let perl_highlight_matches = 1
  550.  
  551. Below you can set the maximum distance VIM should look for starting points for
  552. its attempts in syntax highlighting. This should only fail in in very rare
  553. circumstances.
  554.  
  555. > let perl_sync_dist = 100
  556.  
  557. The perl.vim file is under construction because there are a number of errors
  558. in there. Please let me know any problems you encounter. See the syntax file
  559. for the mail address.
  560.  
  561.  
  562. REXX                            *rexx.vim*
  563.  
  564. If you notice highlighting errors while scrolling backwards, which are fixed
  565. when redrawing with CTRL-L, try setting the "rexx_minlines" internal variable
  566. to a larger number:
  567. >  let rexx_minlines = 50
  568. This will make the syntax synchronisation start 50 lines before the first
  569. displayed line.  The default value is 10.  The disadvantage of using a larger
  570. number is that redrawing can become slow.
  571.  
  572.  
  573. SH                            *sh.vim*
  574.  
  575. This covers the "normal" Unix sh, bash and the korn shell.  If you're working
  576. on a system where bash is called sh, you will benefit to define the vim
  577. variable 'bash_is_sh' in your '.vimrc' file:
  578. >  let bash_is_sh = 1
  579.  
  580. To choose between the two ways to treat single-quotes inside a pair of
  581. double-quotes, I have introduced a Vim variable "highlight_balanced_quotes".
  582. By default (ie by not declaring this variable) single quotes can be used
  583. inside double quotes, and are not highlighted.  If you prefer balanced single
  584. quotes as I do you just make the statement in your .vimrc file:
  585. >  let highlight_balanced_quotes = 1
  586.  
  587. Similar I have introduced another vim variable "highlight_function_name" to be
  588. used to enable/disable highlighting of the function-name in function
  589. declaration.  Default is not to highlight the function name.  If you want to
  590. highlight functions names, include this in your .vimrc file:
  591. >  let highlight_function_name = 1
  592.  
  593. If you notice highlighting errors while scrolling backwards, which are fixed
  594. when redrawing with CTRL-L, try setting the "sh_minlines" internal variable
  595. to a larger number:
  596. >  let sh_minlines = 200
  597. This will make the syntax synchronisation start 200 lines before the first
  598. displayed line.  The default value is 100.  The disadvantage of using a larger
  599. number is that redrawing can become slow.
  600.  
  601. If you don't have much to synchronize on, displaying can be very slow.  To
  602. reduce this, the "sh_maxlines" internal variable can be set:
  603. >  let sh_maxlines = 100
  604. The default is to use the double of "sh_minlines".  Set it to a smaller number
  605. to speed up displaying.  The disadvantage is that highlight errors may appear.
  606.  
  607.  
  608. TEX                            *tex.vim*
  609.  
  610. The <tex.vim> highlighting supports TeX, LaTeX, and some AmsTeX.  The
  611. highlighting supports three primary zones: normal, texZone, and texMathZone.
  612. Although a considerable effort has been made to have these zones terminate
  613. properly, zones delineated by $..$ and $$..$$ cannot be synchronized as
  614. there's no difference between start and end patterns.  Consequently, a
  615. special "TeX comment" has been provided
  616. > %stopzone
  617. which will forcibly terminate the highlighting of either a texZone or a
  618. texMathZone.
  619.  
  620. If you have a slow computer, you may wish to reduce the values for
  621. > syn sync maxlines=200
  622. > syn sync minlines=50
  623. (especially the latter).  If your computer is fast, you may wish to
  624. increase them.  This primarily affects synchronizing (ie. just what group,
  625. if any, is the text at the top of the screen supposed to be in?).
  626.  
  627.  
  628. X Pixmaps (XPM)                        *xpm.vim*
  629.  
  630. xpm.vim creates its syntax items dynamically based upon the contents of the
  631. XPM file.  Thus if you make changes e.g. in the color specification strings,
  632. you have to source it again e.g. with ":syntax off|syntax on".
  633.  
  634. To copy a pixel with one of the colors, yank a "pixel" with "yl" and insert it
  635. somewhere else with "P".
  636.  
  637. Do you want to draw with the mouse?  A simple first attempt:
  638.    noremap <RightMouse> <LeftMouse>"xyl
  639.    noremap <LeftMouse>  <LeftMouse>x"xP
  640.    noremap <LeftDrag>   <LeftMouse>x"xP
  641.    set guicursor=n:hor20          " to see the color beneath the cursor
  642. This turns the right button into a pipette and the left button into a pen.
  643. It will work with XPM files that have one character per pixel only and you
  644. must not click outside of the pixel strings, but feel free to improve it.
  645.  
  646. It will look much better with a font in a quadratic cell size.
  647.  
  648. ==============================================================================
  649. 4. Defining a syntax                    *:syn-define*
  650.  
  651. Vim understands three types of syntax items:
  652. 1. A keyword.  It can only contain keyword characters, according to the
  653.    'iskeyword' option.  It cannot contain other syntax items.  It will only
  654.    be recognized when it is a complete match (there are no keyword
  655.    characters before or after the match).  "if" would match in "if(a=b)",
  656.    but not in "ifdef x".
  657. 2. A match.  This is a match with a single regexp pattern.  It must be within
  658.    one line.
  659. 3. A region.  This starts at a match of the start regexp pattern and
  660.    ends with a match with the end regexp pattern.  A skip regexp pattern can
  661.    be used to avoid matching the end pattern.
  662.  
  663. Several syntax ITEMs can be put into one syntax GROUP.  For a syntax group
  664. you can give highlighting attributes.  For example, you could have an item
  665. to define a "/* .. */" comment and another one that defines a "// .." comment,
  666. and put them both in the "Comment" group.  You can then specify that a
  667. "Comment" will be in bold font and have a blue color.  You are free to make
  668. one highlight group for one syntax item, or put all items into one group.
  669. This depends on how you want to specify your highlighting attributes.  Putting
  670. each item in its own group results in having to specify the highlighting
  671. for a lot of groups.
  672.  
  673. Note that a syntax group and a highlight group are similar.  For a highlight
  674. group you will have given highlight attributes.  These attributes will be used
  675. for the syntax group with the same name.
  676.  
  677. In case more than one item matches at the same position, the one that was
  678. defined LAST wins.  Thus you can override previously defined syntax items by
  679. using an item that matches the same text.  But a keyword always goes before a
  680. match or region.  And a keyword with matching case always goes before a
  681. keyword with ignoring case.
  682.  
  683.  
  684. DEFINING CASE                        *:syn-case*
  685.  
  686. :sy[ntax] case [match|ignore]
  687.     This defines if the following ":syntax" commands will work with
  688.     matching case, when using "match", or with ignoring case, when using
  689.     "ignore".  Note that any items before this are not affected, and all
  690.     items until the next ":syntax case" command are affected.
  691.  
  692.  
  693. DEFINING KEYWORDS                    *:syn-keyword*
  694.  
  695. :sy[ntax] keyword {group-name} [{options}] {keyword} .. [{options}]
  696.  
  697.     This defines a number of keywords.
  698.  
  699.     {group-name}    Is a syntax group name such as "Comment".
  700.     [{options}]    See |:syn-arguments| below.
  701.     {keyword} ..    Is a list of keywords which are part of this group.
  702.  
  703.     Example:
  704. >  :syntax keyword   Type   int long char
  705.  
  706.     The {options} can be given anywhere in the line.  They will apply to
  707.     all keywords given, also for options that come after a keyword.
  708.     These examples do exactly the same:
  709. >  :syntax keyword   Type   contained int long char
  710. >  :syntax keyword   Type   int long contained char
  711. >  :syntax keyword   Type   int long char contained
  712.  
  713.     When you have a keyword with an optional tail, like Ex commands in
  714.     Vim, you can put the optional characters inside [], to define all the
  715.     variations at once:
  716. >  :syntax keyword   VimCommand   ab[breviate] n[ext]
  717.  
  718.     A keyword always has higher priority than a match or region, the
  719.     keyword is used if more than one item matches.  Keywords do not nest
  720.     and a keyword can't contain anything else.
  721.  
  722.     Note that when you have a keyword that is the same as an option (even
  723.     one that isn't allowed here), you can not use it.  Use a match
  724.     instead.
  725.  
  726.     The maximum length of a keyword is 80 characters.
  727.  
  728.     The same keyword can be defined multiple times, when its containment
  729.     differs.  For example, you can define the keyword once not contained
  730.     and use one highlight group, and once contained, and use a different
  731.     highlight group. Example:
  732. >  :syn keyword vimCommand tag
  733. >  :syn keyword vimSetting contained tag
  734.     When finding "tag" outside of any syntax item, the "vimCommand"
  735.     highlight group is used.  When finding "tag" in a syntax item that
  736.     contains "vimSetting", the "vimSetting" group is used.
  737.  
  738.  
  739. DEFINING MATCHES                    *:syn-match*
  740.  
  741. :sy[ntax] match {group-name} [{options}] {pattern} [{options}]
  742.  
  743.     This defines one match.
  744.  
  745.     {group-name}        A syntax group name such as "Comment".
  746.     [{options}]        See |:syn-arguments| below.
  747.     {pattern}        The search pattern that defines the match.
  748.                 See |:syn-pattern| below.
  749.  
  750.     Example (match a character constant):
  751. >  :syntax match Character /'.'/s+1e-1
  752.  
  753.  
  754. DEFINING REGIONS    *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
  755.  
  756. :sy[ntax] region {group-name} [{options}]
  757.         [matchgroup={group_name}]
  758.         [keepend]
  759.         start={start_pattern} ..
  760.         [skip={skip_pattern}]
  761.         end={end_pattern} ..
  762.         [{options}]
  763.  
  764.     This defines one region.  It may span several lines.
  765.  
  766.     {group-name}        A syntax group name such as "Comment".
  767.     [{options}]        See |:syn-arguments| below.
  768.     [matchgroup={group-name}]  The syntax group to use for the following
  769.                 start or end pattern matches only.  Not used
  770.                 for the text in between the matched start and
  771.                 end patterns.  Use NONE to reset to not using
  772.                 a different group for the start or end match.
  773.                 See |:syn-matchgroup|.
  774.     keepend            Don't allow contained matches to go past a
  775.                 match with the end pattern.  See
  776.                 |:syn-keepend|.
  777.     start={start_pattern}    The search pattern that defines the start of
  778.                 the region.  See |:syn-pattern| below.
  779.     skip={skip_pattern}    The search pattern that defines text inside
  780.                 the region where not to look for the end
  781.                 pattern.  See |:syn-pattern| below.
  782.     end={end_pattern}    The search pattern that defines the end of
  783.                 the region.  See |:syn-pattern| below.
  784.  
  785.     Example:
  786. >  :syntax region String   start=+"+  skip=+\\"+  end=+"+
  787.  
  788.     The start/skip/end patterns and the options can be given in any order.
  789.     There can be zero or one skip pattern.  There must be one or more
  790.     start and end patterns.  This means that you can omit the skip
  791.     pattern, but you must give at least one start and one end pattern.  It
  792.     is allowed to have white space before and after the equal sign
  793.     (although it mostly looks better without white space).
  794.  
  795.     When more than one start pattern is given, a match with one of these
  796.     is sufficient.  This means there is an OR relation between the start
  797.     patterns.  The first one that matches is used.  The same is true for
  798.     the end patterns.
  799.  
  800.     The search for the end pattern starts at the start of the region.
  801.     This implies that it can also match inside the start pattern!
  802.  
  803.     Note: The decision to start a region is only based on a matching start
  804.     pattern.  There is no check for a matching end pattern.  This does NOT
  805.     work:
  806.         :syn region First  start="("  end="."
  807.         :syn region Second start="("  end=";"
  808.     The Second always matches before the First (last defined pattern has
  809.     higher priority).  The Second region then continues until the next
  810.     ';', no matter if there is a '.' before it.
  811.  
  812.                             *:syn-keepend*
  813.     By default, a contained match can obscure a match for the end pattern.
  814.     This is useful for nesting.  For example, a region that starts with
  815.     "{" and ends with "}", can contain another region.  An encountered "}"
  816.     will then end the contained region, but not the outer region:
  817.         {        starts outer "{}" region
  818.         {    starts contained "{}" region
  819.         }    ends contained "{}" region
  820.         }        ends outer "{} region
  821.     If you don't want this, the "keepend" argument will make the matching
  822.     of an end pattern of the outer region also end any contained item.
  823.     This makes it impossible to nest the same region, but allows for
  824.     contained items to highlight parts of the end pattern, without causing
  825.     that to skip the match with the end pattern.  Example:
  826. >  :syn match  VimComment +"[^"]\+$+
  827. >  :syn region VimCommand start="set" end="$" contains=VimComment keepend
  828.     The "keepend" makes the VimCommand always end at the end of the line,
  829.     even though the contained VimComment includes a match with the <EOL>.
  830.  
  831.     When "keepend" is not used, a match with an end pattern is retried
  832.     after each contained match.  When "keepend" is included, the first
  833.     encountered match with an end pattern is used, truncating any
  834.     contained matches.
  835.  
  836.                             *:syn-matchgroup*
  837.     "matchgroup" can be used to highlight the start and/or end pattern
  838.     differently than the body of the region.  Example:
  839. >  :syntax region String matchgroup=Quote start=+"+  skip=+\\"+  end=+"+
  840.     This will highlight the quotes with the "Quote" group, and the text in
  841.     between with the "String" group.
  842.     The "matchgroup" is used for all start and end patterns that follow,
  843.     until the next "matchgroup".  Use "matchgroup=NONE" to go back to not
  844.     using a matchgroup.
  845.  
  846.     It is not possible to have a contained match in a start or end pattern
  847.     that is highlighted with "matchgroup".
  848.     When using "transparent", it does not apply to a start or end pattern
  849.     that is highlighted with "matchgroup".
  850.  
  851. ==============================================================================
  852. 5. :syntax arguments                    *:syn-arguments*
  853.  
  854. The :syntax commands that define syntax items take a number of arguments.
  855. The common ones are explained here.  The arguments may be given in any order
  856. and may be mixed with patterns.
  857.  
  858. Not all commands accept all arguments.  This table shows which arguments
  859. can be used for each command:
  860.  
  861.          contained  nextgroup  skip*   transparent  contains  oneline ~
  862. :syntax keyword        yes           yes    yes       yes       -     -
  863. :syntax match        yes           yes    yes       yes          yes     -
  864. :syntax region        yes           yes    yes       yes          yes    yes
  865.  
  866.  
  867. contained                        *:syn-contained*
  868.  
  869. When the "contained" argument is given, this item will not be recognized at
  870. the top level, but only when it is mentioned in the "contains" field of
  871. another match.  Example:
  872. >   :syntax keyword Todo    TODO    contained
  873. >   :syntax match   Comment "//.*"  contains=Todo
  874.  
  875.  
  876. transparent                        *:syn-transparent*
  877.  
  878. If the "transparent" argument is given, this item will not be highlighted
  879. itself, but will take the highlighting of the item it is contained in.  This
  880. is useful for syntax items that don't need any highlighting but are used
  881. only to skip over a part of the text.  The same groups as the item it is
  882. contained in are used, unless a "contains" argument is given too.
  883.  
  884.  
  885. oneline                            *:syn-oneline*
  886.  
  887. The "oneline" argument indicates that the region does not cross a line
  888. boundary.  It must match completely in the current line.  However, when the
  889. region has a contained item that does cross a line boundary, it continues on
  890. the next line anyway.  A contained item can be used to recognize a line
  891. continuation pattern.
  892.  
  893.  
  894. contains={groupname},..                    *:syn-contains*
  895.  
  896. The "contains" argument is followed by a list of syntax group names.  These
  897. groups will be allowed to begin inside the item (they may extend past the
  898. containing group's end).  This allows for recursive nesting of matches and
  899. regions.  If there is no "contains" argument, no groups will be contained in
  900. this item.  The group names do not need to be defined before they can be used
  901. here.
  902.  
  903. contains=ALL
  904.         If the only item in the contains list is "ALL", then all
  905.         groups will be accepted inside the item.
  906.  
  907. contains=ALLBUT,{group-name},..
  908.         If the first item in the contains list is "ALLBUT", then all
  909.         groups will be accepted inside the item, except the ones that
  910.         are listed, and the "contained" items.  Example:
  911. >  :syntax region Block start="{" end="}" ... contains=ALLBUT,Function
  912.  
  913. The {group-name} in the "contains" list can be a pattern.  All group names
  914. that match the pattern will be included (or excluded, if "ALLBUT" is used).
  915. The pattern cannot contain white space or a ','.  Example:
  916. >  ... contains=Comment.*,Keyw[0-3]
  917. The matching will be done at moment the syntax command is executed.  Groups
  918. that are defined later, will not be matched.  But be careful: When putting
  919. syntax commands in a file you can't rely on groups NOT being defined, because
  920. the file may have been sourced before, and "syn clear" doesn't remove the
  921. group names.
  922.  
  923.  
  924. nextgroup={groupname},..                *:syn-nextgroup*
  925.  
  926. The "nextgroup" argument is followed by a list of syntax group names,
  927. separated by commas (just like with "contains", so you can also use patterns).
  928.  
  929. If the "nextgroup" argument is given, the mentioned syntax groups will be
  930. tried for a match, after the match or region ends.  If none of the groups have
  931. a match, highlighting continues normally.  If there is a match, this group
  932. will used, even when it is not mentioned in the "contains" field of the
  933. current group.  This is like giving the mentioned group priority over all
  934. other groups.  Example:
  935. >   :syntax match  ccFoobar  "Foo.\{-}Bar"  contains=ccFoo
  936. >   :syntax match  ccFoo     "Foo"        contained nextgroup=ccFiller
  937. >   :syntax region ccFiller  start="."  matchgroup=ccBar  end="Bar"  contained
  938.  
  939. This will highlight "Foo" and "Bar" differently, and only when there is a
  940. "Bar" after "Foo".  In the text line below, "f" shows where ccFoo is used for
  941. highlighting, and "bbb" where ccBar is used.
  942.  
  943. >   Foo asdfasd Bar asdf Foo asdf Bar asdf
  944. >   fff        bbb      fff      bbb
  945.  
  946. Note the use of ".\{-}" to skip as little as possible until the next Bar.
  947. when ".*" would be used, the "asdf" in between "Bar" and "Foo" would be
  948. highlighted according to the "ccFoobar" group, because the ccFooBar match
  949. would include the first "Foo" and the last "Bar" in the line (see |pattern|).
  950.  
  951.  
  952. skipwhite                        *:syn-skipwhite*
  953. skipnl                            *:syn-skipnl*
  954. skipempty                        *:syn-skipempty*
  955.  
  956. These arguments are only used in combination with "nextgroup".  They can be
  957. used to allow the next group to match after skipping some text:
  958.     skipwhite    skip over space and Tab characters
  959.     skipnl        skip over the end of a line
  960.     skipempty    skip over empty lines (implies a "skipnl")
  961.  
  962. When "skipwhite" is present, the white space is only skipped if there is no
  963. next group that matches the white space.
  964.  
  965. When "skipnl" is present, the match with nextgroup may be found in the next
  966. line.  This only happens when the current item ends at the end of the current
  967. line!  When "skipnl" is not present, the nextgroup will only be found after
  968. the current item in the same line.
  969.  
  970. When skipping text while looking for a next group, the matches for other
  971. groups are ignored.  Only when no next group matches, other items are tried
  972. for a match again.  This means that matching a next group and skipping white
  973. space and <EOL>s has a higher priority than other items.
  974.  
  975. Example:
  976. >  syn match ifstart "if.*"     nextgroup=ifline skipwhite skipempty
  977. >  syn match ifline  "endif"    contained
  978. >  syn match ifline  "[^ \t].*" nextgroup=ifline skipwhite skipempty contained
  979. Note that the last match, which matches any non-white text, is put last,
  980. otherwise the "endif" of the indent would never match, because the "[^ \t].*"
  981. would match first.
  982. Note that this example doesn't work for nested "if"s.  You need to add
  983. "contains" arguments to make that work (omitted for simplicity of the
  984. example).
  985.  
  986. ==============================================================================
  987. 6. Syntax patterns                    *:syn-pattern*
  988.  
  989. In the syntax commands, a pattern must be surrounded by two identical
  990. characters.  This is like it works for the ":s" command.  The most common to
  991. use is the double quote.  But if the pattern contains a double quote, you can
  992. use another character that is not used in the pattern.  Examples:
  993. >  :syntax region Comment  start="/\*"  end="\*/"
  994. >  :syntax region String   start=+"+    end=+"+   skip=+\\"+
  995.  
  996. See |pattern| for the explanation of what a pattern is.  Syntax patterns are
  997. always interpreted like the 'magic' options is set, no matter what the actual
  998. value of 'magic' is.  And the patterns are interpreted like the 'l' flag is
  999. not included in 'cpoptions'.  This was done to make syntax files portable and
  1000. independent of 'compatible' and 'magic' settings.
  1001.  
  1002. Try to avoid patterns that can match an empty string, such as "[a-z]*".
  1003. This slows down the highlighting a lot, because it matches everywhere.
  1004.  
  1005. The pattern can be followed by a character offset.  This can be used to
  1006. change the highlighted part, and to change the text area included in the
  1007. match or region (which only matters when trying to match other items).  Both
  1008. are relative to the matched pattern.  The character offset for a skip
  1009. pattern can be used to tell where to continue looking for an end pattern.
  1010.  
  1011. The offset takes the form of "{what}={offset}"
  1012. The {what} can be one of seven strings:
  1013.  
  1014. ms    Match Start    offset for the start of the matched text
  1015. me    Match End    offset for the end of the matched text
  1016. hs    Highlight Start    offset for where the highlighting starts
  1017. he    Highlight End    offset for where the highlighting ends
  1018. rs    Region Start    offset for where the body of a region starts
  1019. re    Region End    offset for where the body of a region ends
  1020. lc    Leading Context    offset past "leading context" of pattern
  1021.  
  1022. The {offset} can be:
  1023.  
  1024. s    start of the matched pattern
  1025. s+{nr}    start of the matched pattern plus {nr} chars to the right
  1026. s-{nr}    start of the matched pattern plus {nr} chars to the left
  1027. e    end of the matched pattern
  1028. e+{nr}    end of the matched pattern plus {nr} chars to the right
  1029. e-{nr}    end of the matched pattern plus {nr} chars to the left
  1030. {nr}    (for "lc" only): start matching {nr} chars to the left
  1031.  
  1032. Examples: "ms=s+1", "hs=e-2", "lc=3".
  1033.  
  1034. Although all offsets are accepted after any pattern, they are not always
  1035. meaningful.  This table shows which offsets are actually used:
  1036.  
  1037.             ms   me   hs   he   rs   re      lc ~
  1038. match item        yes  yes  yes  yes  -    -    yes
  1039. region item start   yes  -    yes  -    yes  -    yes
  1040. region item skip    -    yes  -    -    -    -    -
  1041. region item end     -    yes  -    yes  -    yes  -
  1042.  
  1043. Offsets can be concatenated, with a ',' in between.  Example:
  1044. >  syn match String  /".*"/hs=s+1,he=e-1
  1045.  
  1046.     some "string" text
  1047.       ^^^^^^        highlighted
  1048.  
  1049. Notes:
  1050. - There must be no white space between the pattern and the character
  1051.   offset(s).
  1052. - The highlighted area will never be outside of the matched text.
  1053. - A negative offset for an end pattern may not always work, because the end
  1054.   pattern may be detected when the highlighting should already have stopped.
  1055.  
  1056. Example (match a comment but don't highlight the /* and */):
  1057. >  :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1
  1058.  
  1059.     /* this is a comment */
  1060.       ^^^^^^^^^^^^^^^^^^^     highlighted
  1061.  
  1062. A more complicated Example:
  1063. >  :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
  1064.  
  1065.      abcfoostringbarabc
  1066.         mmmmmmmmmmm        match
  1067.           ssrrrreee        highlight start/region/end ("Foo", "Exa" and "Bar")
  1068.  
  1069. Leading context            *:syn-lc* *:syn-leading* *:syn-context*
  1070.  
  1071. The "lc" offset specifies leading context -- a part of the pattern that must
  1072. be present, but is not considered part of the match.  An offset of "lc=n" will
  1073. cause Vim to step back n columns before attempting the pattern match, allowing
  1074. characters which have already been matched in previous patterns to also be
  1075. used as leading context for this match.  This can be used, for instance, to
  1076. specify that an "escaping" character must not precede the match:
  1077.  
  1078. >  :syn match ZNoBackslash "[^\\]z"ms=s+1
  1079. >  :syn match WNoBackslash "[^\\]w"lc=1
  1080. >  :syn match Underline "_\+"
  1081.  
  1082.       ___zzzz ___wwww
  1083.       ^^^     ^^^      matches Underline
  1084.           ^ ^      matches ZNoBackslash
  1085.              ^^^^ matches WNoBackslash
  1086.  
  1087. The "ms" offset is automatically set to the same value as the "lc" offset,
  1088. unless you set "ms" explicitly.
  1089.  
  1090. ==============================================================================
  1091. 7. Syntax clusters                    *:syn-cluster*
  1092.  
  1093. :sy[ntax] cluster {cluster-name} [contains={group-name}..]
  1094.                  [add={group-name}..]
  1095.                  [remove={group-name}..]
  1096.  
  1097. This command allows you to cluster a list of syntax groups together under a
  1098. single name.
  1099.  
  1100.     contains={group-name}..
  1101.         The cluster is set to the specified list of groups.
  1102.     add={group-name}..
  1103.         The specified groups are added to the cluster.
  1104.     remove={group-name}..
  1105.         The specified groups are removed from the cluster.
  1106.  
  1107. A cluster so defined may be referred to in a contains=.., nextgroup=.., add=..
  1108. or remove=.. list with a "@" prefix.  You can also use this notation to
  1109. implicitly declare a cluster before specifying its contents.
  1110.  
  1111. Example:
  1112. >   :syntax match Thing "# [^#]\+ #" contains=@ThingMembers
  1113. >   :syntax cluster ThingMembers contains=ThingMember1,ThingMember2
  1114.  
  1115. As the previous example suggests, modifications to a cluster are effectively
  1116. retroactive; the membership of the cluster is checked at the last minute, so
  1117. to speak:
  1118. >   :syntax keyword A aaa
  1119. >   :syntax cluster AandB contains=A
  1120. >   :syntax match Stuff "( aaa bbb )" contains=@AandB
  1121. >   :syntax cluster AandB add=B    " now both keywords are matched in Stuff
  1122.  
  1123. This also has implications for nested clusters:
  1124. >   :syntax keyword A aaa
  1125. >   :syntax keyword B bbb
  1126. >   :syntax cluster SmallGroup contains=B
  1127. >   :syntax cluster BigGroup contains=A,@SmallGroup
  1128. >   :syntax match Stuff "( aaa bbb )" contains=@BigGroup
  1129. >   :syntax cluster BigGroup remove=B    " no effect, since B isn't in BigGroup
  1130. >   :syntax cluster SmallGroup remove=B  " now bbb isn't matched within Stuff
  1131.  
  1132. ==============================================================================
  1133. 8. Including syntax files                *:syn-include*
  1134.  
  1135. It is often useful for one language's syntax file to include a syntax file for
  1136. a related language.  Depending on the exact relationship, this can be done in
  1137. two different ways:
  1138.  
  1139.     - If top-level syntax items in the included syntax file are to be
  1140.       allowed at the top level in the including syntax, you can simply use
  1141.       the |:source| command:
  1142.  
  1143. >  " In cpp.vim:
  1144. >  :source <sfile>:p:h/c.vim
  1145.  
  1146.     - If top-level syntax items in the included syntax file are to be
  1147.       contained within a region in the including syntax, you can use the
  1148.       ":syntax include" command:
  1149.  
  1150. :sy[ntax] include [@{grouplist-name}] {file-name}
  1151.  
  1152.       All syntax items declared in the included file will have the
  1153.       "contained" flag added.  In addition, if a group list is specified,
  1154.       all top-level syntax items in the included file will be added to
  1155.       that list.
  1156.  
  1157. >   " In perl.vim:
  1158. >   :syntax include @Pod <sfile>:p:h/pod.vim
  1159. >   :syntax region perlPOD start="^=head" end="^=cut" contains=@Pod
  1160.  
  1161. ==============================================================================
  1162. 9. Synchronizing                    *:syn-sync*
  1163.  
  1164. Vim wants to be able to start redrawing in any position in the document.  To
  1165. make this possible it needs to know the syntax item at the position where
  1166. redrawing starts.
  1167.  
  1168. :sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
  1169.  
  1170. There are three ways to synchronize:
  1171. 1. Based on C-style comments.  Vim understands how C-comments work and can
  1172.    figure out if the current line starts inside or outside a comment.
  1173. 2. Jumping back a certain number of lines and start parsing there.
  1174. 3. Searching backwards in the text for a pattern to sync on.
  1175.  
  1176. For all three methods, the line range where the parsing can start is limited
  1177. by "minlines" and "maxlines".
  1178.  
  1179. If the "minlines={N}" argument is given, the parsing always starts at least
  1180. that many lines backwards.  This can be used if the parsing may take a few
  1181. lines before it's correct, or when it's not possible to use syncing.
  1182.  
  1183. If the "maxlines={N}" argument is given, the number of lines that are searched
  1184. for a comment or syncing pattern is restricted to N lines backwards (after
  1185. adding "minlines".  This is useful if you have few things to sync on and a
  1186. slow machine.  Example:
  1187. >  :syntax sync ccomment maxlines=500
  1188.  
  1189.  
  1190. First syncing method:
  1191.  
  1192. For the first method, only the "ccomment" argument needs to be given.
  1193. Example:
  1194. >  :syntax sync ccomment
  1195.  
  1196. When Vim finds that the line where displaying starts is inside a C-style
  1197. comment, the first region syntax item with the group-name "Comment" will be
  1198. used.  This requires that there is a region with the group-name "Comment"!
  1199. An alternate group name can be specified, for example:
  1200. >  :syntax sync ccomment javaComment
  1201.  
  1202. The "maxlines" argument can be used to restrict the search to a number of
  1203. lines.  The "minlines" argument can be used to at least start a number of
  1204. lines back (e.g., for when there is some construct that only takes a few
  1205. lines, but it hard to sync on).
  1206.  
  1207. Note: Syncing on a C comment doesn't work properly when strings are used
  1208. that cross a line and contain a "*/".  Since letting strings cross a line
  1209. is a bad programming habit (many compilers give a warning message), and the
  1210. chance of a "*/" appearing inside a comment is very small, this restriction
  1211. is hardly ever noticed.
  1212.  
  1213.  
  1214. Second syncing method:
  1215.  
  1216. For the second method, only the "lines={N}" argument needs to be given.  Vim
  1217. will subtract {N} from the line number and start parsing there.  This means
  1218. {N} extra lines need to be parsed, which makes this method a bit slower.
  1219. Example:
  1220. >  :syntax sync lines=50
  1221.  
  1222. "lines" and "minlines" are equivalent.
  1223.  
  1224.  
  1225. Third syncing method:
  1226.  
  1227. The idea is to synchronize on the end of a few specific regions, called a
  1228. sync pattern.  Only regions can cross lines, so when we find the end of some
  1229. region, we might be able to know in which syntax item we are.  The search
  1230. starts in the line just above the one where redrawing starts.  From there
  1231. the search continues backwards in the file.
  1232.  
  1233. This works just like the non-syncing syntax ltems.  You can use contained
  1234. matches, nextgroup, etc.  But there are a few differences:
  1235. - Keywords cannot be used.
  1236. - The syntax items with the "sync" keyword form a completely separated group
  1237.   of syntax items.  You can't mix syncing groups and non-syncing groups.
  1238. - The matching works backwards in the buffer (line by line), instead of
  1239.   forwards.
  1240. - A line continuation pattern can be given.  It is used to decide which group
  1241.   of lines need to be searched like they were one line.  This means that the
  1242.   search for a match with the specified items starts in the first of the
  1243.   consecutive that contain the continuation pattern.
  1244. - When using "nextgroup" or "contains", this only works within one line (or
  1245.   group of continuated lines).
  1246. - When a match with a sync pattern is found, the rest of the line (or group of
  1247.   continuated lines) is searched for another match.  The last match is used.
  1248.   This is used when a line can contain both the start end the end of a region
  1249.   (e.g., in a C-comment like /* this */, the last "*/" is used).
  1250.  
  1251. There are two ways how a match with a sync pattern can be used:
  1252. 1. Parsing for highlighting starts where redrawing starts (and where the
  1253.    search for the sync pattern started).  The syntax group that is expected
  1254.    to be valid there must be specified.  This works well when the regions
  1255.    that cross lines cannot contain other regions.
  1256. 2. Parsing for highlighting continues just after the match.  The syntax group
  1257.    that is expected to be present just after the match must be specified.
  1258.    This can be used when the previous method doesn't work well.  It's much
  1259.    slower, because more text needs to be parsed.
  1260. Both types of sync patterns can be used at the same time.
  1261.  
  1262. Besides the sync patterns, other matches and regions can be specified, to
  1263. avoid finding unwanted matches.
  1264.  
  1265. [The reason that the sync patterns are given separately, is that mostly the
  1266. search for the sync point can be much simpler than figuring out the
  1267. highlighting.  The reduced number of patterns means it will go (much)
  1268. faster.]
  1269.  
  1270.                         *syn-sync-grouphere*
  1271.     :syntax sync match {sync-group-name} grouphere {group-name} "pattern" ..
  1272.  
  1273.     Define a match that is used for syncing.  {group-name} is the
  1274.     name of a syntax group that follows just after the match.  Parsing
  1275.     of the text for highlighting starts just after the match.  A region
  1276.     must exist for this {group-name}.  The first one defined will be used.
  1277.     "NONE" can be used for when there is no syntax group after the match.
  1278.  
  1279.                         *syn-sync-groupthere*
  1280.     :syntax sync match {sync-group-name} groupthere {group-name} "pattern" ..
  1281.  
  1282.     Like "grouphere", but {group-name} is the name of a syntax group that
  1283.     is to be used at the start of the line where searching for the sync
  1284.     point started.  The text between the match and the start of the sync
  1285.     pattern searching is assumed not to change the syntax highlighting.
  1286.     For example, in C you could search backwards for "/*" and "*/".  If
  1287.     "/*" is found first, you know that you are inside a comment, so the
  1288.     "groupthere" is "cComment".  If "*/" is found first, you know that you
  1289.     are not in a comment, so the "groupthere" is "NONE".  (in practice
  1290.     it's a bit more complicated, because the "/*" and "*/" could appear
  1291.     inside a string.  That's left as an exercise to the reader...).
  1292.  
  1293.     :syntax sync match ..
  1294.     :syntax sync region ..
  1295.  
  1296.     Without a "groupthere" argument.  Define a region or match that is
  1297.     skipped while searching for a sync point.
  1298.  
  1299.     :syntax sync linecont {pattern}
  1300.  
  1301.     When {pattern} matches in a line, it is considered to continue in
  1302.     the next line.  This means that the search for a sync point will
  1303.     consider the lines to be concatenated.
  1304.  
  1305. If the "maxlines={N}" argument is given too, the number of lines that are
  1306. searched for a match is restricted to N.  This is useful if you have very
  1307. few things to sync on and a slow machine.  Example:
  1308. >  :syntax sync maxlines=100
  1309.  
  1310. You can clear all sync settings with:
  1311. >  :syntax sync clear
  1312.  
  1313. You can clear specific sync patterns with:
  1314. >  :syntax sync clear {sync-group-name} ..
  1315.  
  1316. ==============================================================================
  1317. 10. Listing syntax items                *:syntax* *:sy* *:syn*
  1318.  
  1319. This commands lists all the syntax items:
  1320.  
  1321.     :sy[ntax] [list]
  1322.  
  1323. To show the syntax items for one syntax group:
  1324.  
  1325.     :sy[ntax] list {group-name}
  1326.  
  1327. To list the syntax groups in one group list:
  1328.  
  1329.     :sy[ntax] list @{grouplist-name}
  1330.  
  1331. See above for other arguments for the ":syntax" command.
  1332.  
  1333. Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
  1334. is mostly used, because it looks better.
  1335.  
  1336. ==============================================================================
  1337. 11. Highlight command                    *:highlight*
  1338.  
  1339. There are two types of highlight groups:
  1340. - The ones used for specific languages.  For these the name starts with the
  1341.   name of the language.  Many of these don't have any attributes, but are
  1342.   linked to a group of the second type.
  1343. - The ones used for all languages.  These are also used for the 'highlight'
  1344.   option.
  1345.  
  1346. :hi[ghlight]        List all the current highlight groups that have
  1347.             attributes set.
  1348.  
  1349. :hi[ghlight] {group-name}
  1350.             List one highlight group.
  1351.  
  1352. :hi[ghlight] clear {group-name}
  1353. :hi[ghlight] {group-name} NONE
  1354.             Disable the highlighting for one highlight group.
  1355.  
  1356. :hi[ghlight] {group-name} {key}={arg} ..
  1357.             Add a highlight group, or change the highlighting for
  1358.             an existing group.  See below for the arguments
  1359.             |highlight-args|.
  1360.  
  1361. Normally a highlight group is added once, in the *.vim file.  This sets
  1362. the default values for the highlighting.  After that, you can use additional
  1363. highlight commands to change the arguments that you want to set to
  1364. non-default values.  The value "NONE" can be used to switch the value off or
  1365. go back to the default value.
  1366.  
  1367. Example.  The syntax.vim file contains this line:
  1368. >  hi Comment    term=bold ctermfg=Cyan guifg=#80a0ff
  1369.  
  1370. You can change this by giving another ":highlight: command:
  1371. >  hi Comment    gui=bold
  1372.  
  1373. Note that all settings that are not included remain the same, only the
  1374. specified field is used, and settings are merged with previous ones.  So, the
  1375. result is like this single command has been used:
  1376. >  hi Comment    term=bold ctermfg=Cyan guifg=#80a0ff gui=bold
  1377.  
  1378.                         *highlight-args*
  1379. There are three types of terminals for highlighting:
  1380. term    a normal terminal (vt100, xterm)
  1381. cterm    a color terminal (MS-DOS console, color-xterm, these have the "Co"
  1382.     termcap entry)
  1383. gui    the GUI
  1384.  
  1385. For each type the highlighting can be given.  This makes it possible to use
  1386. the same syntax file on all terminals, and use the optimal highlighting.
  1387.  
  1388. 1. highlight arguments for normal terminals
  1389.  
  1390. term={attr-list}                *attr-list* *highlight-term*
  1391.     attr-list is a comma separated list (without spaces) of the
  1392.     following items (in any order):
  1393.         bold
  1394.         underline
  1395.         reverse
  1396.         inverse        same as reverse
  1397.         italic
  1398.         standout
  1399.         NONE        no attributes used (used to reset it)
  1400.  
  1401.     Note that "bold" can be used here and by using a bold font.  They
  1402.     have the same effect.
  1403.  
  1404. start={term-list}                *highlight-start*
  1405. stop={term-list}                *term-list* *highlight-stop*
  1406.     These lists of terminal codes can be used to get
  1407.     non-standard attributes on a terminal.
  1408.  
  1409.     The escape sequence specified with the "start" argument
  1410.     is written before the characters in the highlighted
  1411.     area.  It can be anything that you want to send to the
  1412.     terminal to highlight this area.  The escape sequence
  1413.     specified with the "stop" argument is written after the
  1414.     highlighted area.  This should undo the "start" argument.
  1415.     Otherwise the screen will look messed up.
  1416.  
  1417.     The {term-list} can have two forms:
  1418.  
  1419.     1. A string with escape sequences.
  1420.        This is any string of characters, except that it can't start with
  1421.        "t_" and blanks are not allowed.  The <> notation is recognized
  1422.        here, so you can use things like "<Esc>" and "<Space>".  Example:
  1423.         start=<Esc>[27h;<Esc>[<Space>r;
  1424.  
  1425.     2. A list of terminal codes.
  1426.        Each terminal code has the form "t_xx", where "xx" is the name of
  1427.        the termcap entry.  The codes have to be separated with commas.
  1428.        White space is not allowed.  Example:
  1429.         start=t_C1,t_BL
  1430.        The terminal codes must exist for this to work.
  1431.  
  1432.  
  1433. 2. highlight arguments for color terminals
  1434.  
  1435. cterm={attr-list}                    *highlight-cterm*
  1436.     See above for the description of {attr-list} |attr-list|.
  1437.     The "cterm" argument is likely to be different from "term", when
  1438.     colors are used.  For example, in a normal terminal comments could
  1439.     be underlined, in a color terminal they can be made Blue.
  1440.     Note: Many terminals (e.g., DOS console) can't mix these attributes
  1441.     with coloring.  Use only one of "cterm=" OR "ctermfg=" OR "ctermbg=".
  1442.  
  1443. ctermfg={color-nr}                    *highlight-ctermfg*
  1444. ctermbg={color-nr}                    *highlight-ctermbg*
  1445.     The {color-nr} argument is a color number.  Its range is zero to
  1446.     (not including) the number given by the termcap entry "Co".
  1447.     The actual color with this number depends on the type of terminal
  1448.     and its settings.  Sometimes the color also depends on the settings of
  1449.     "cterm".  For example, on some systems "cterm=bold ctermfg=3" gives
  1450.     another color, on others you just get color 3.
  1451.  
  1452.     For an xterm this depends on your resources, and is a bit
  1453.     unpredictable.  See your xterm documentation for the defaults.  The
  1454.     colors for a color-xterm can be changed from the .Xdefaults file.
  1455.     Unfortunately this means that it's not possible to get the same colors
  1456.     for each user.  See |xterm-color| for info about color xterms.
  1457.  
  1458.     The MSDOS standard colors are fixed (in a console window), so these
  1459.     have been used for the names.  But the meaning of color names in X11
  1460.     are fixed, so these color settings have been used, to make the
  1461.     highlighting settings portable (complicated, isn't it?).  The
  1462.     following names are recognized, with the color number used:
  1463.  
  1464.         NR-16   NR-8    COLOR NAME ~
  1465.                             *cterm-colors*
  1466.         0        0        Black
  1467.         1        4        DarkBlue
  1468.         2       2        DarkGreen
  1469.         3       6        DarkCyan
  1470.         4       1        DarkRed
  1471.         5       5        DarkMagenta
  1472.         6       3        Brown
  1473.         7       7        LightGray, LightGrey, Gray, Grey
  1474.         8        0*        DarkGray, DarkGrey
  1475.         9        4*        Blue, LightBlue
  1476.         10        2*        Green, LightGreen
  1477.         11        6*        Cyan, LightCyan
  1478.         12        1*        Red, LightRed
  1479.         13        5*        Magenta, LightMagenta
  1480.         14        3*        Yellow
  1481.         15        7*        White
  1482.  
  1483.     The number under "NR-16" is used for 16-color terminals ('t_Co'
  1484.     greater than or equal to 16).  The number under "NR-8" is used for
  1485.     8-color terminals ('t_Co' less than 16).  The '*' indicates that the
  1486.     bold attribute is set for ctermfg.  In many 8-color terminals (e.g.,
  1487.     "linux"), this causes the bright colors to appear.  This doesn't work
  1488.     for background colors!  Without the '*' the bold attribute is removed.
  1489.     If you want to set the bold attribute in a different way, put a
  1490.     "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument.  Or use
  1491.     a number instead of a color name.
  1492.  
  1493.     The case of the color names is ignored.
  1494.  
  1495.     Note that for some color terminals these names may result in the wrong
  1496.     colors!
  1497.  
  1498.     When setting the "ctermfg" or "ctermbg" colors for the Normal group,
  1499.     these will become the colors used for the non-highlighted text.
  1500.     When setting the "ctermbg" color for the Normal group, the
  1501.     'background' option will be adjusted automatically.  This causes the
  1502.     highlight groups that depend on 'background' to change!  This means
  1503.     you should set the colors for Normal first, before setting other
  1504.     colors.
  1505.  
  1506.     When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
  1507.     needs to reset the color when exiting.  This is done with the "op"
  1508.     termcap entry |t_op|.  If this doesn't work correctly, try setting the
  1509.     't_op' option in your .vimrc.
  1510.  
  1511.  
  1512. 3. highlight arguments for the GUI
  1513.  
  1514. gui={attr-list}                        *highlight-gui*
  1515.     These give the attributes to use in the GUI mode.
  1516.     See |attr-list| for a description.
  1517.     Note that "bold" can be used here and by using a bold font.  They
  1518.     have the same effect.
  1519.  
  1520. font={font-name}                    *highlight-font*
  1521.     font-name is the name of a font, as it is used on the system Vim
  1522.     runs on.  For X11 this is a complicated name, for example:
  1523. >  font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
  1524.  
  1525.     The font-name "NONE" can be used to revert to the default font.
  1526.     When setting the font for the "Normal" group, this becomes the default
  1527.     font (until the 'guifont' option is changed; the last one set is
  1528.     used).  All fonts used should be of the same character size as the
  1529.     default font!  Otherwise redrawing problems will occur.
  1530.     Setting the font does not work for the "Menu" group.
  1531.  
  1532. guifg={color-name}                    *highlight-guifg*
  1533. guibg={color-name}                    *highlight-guibg*
  1534.     These give the foreground (guifg) and background (guibg) color to
  1535.     use in the GUI.  There are a few special names:
  1536.         NONE        no color (transparant)
  1537.         bg        use normal background color
  1538.         background    use normal background color
  1539.         fg        use normal foreground color
  1540.         foreground    use normal foreground color
  1541.     To use a color name with an embedded space or other special character,
  1542.     put it in single quotes.  The single quote cannot be used then.
  1543.     Example:
  1544. >        :hi comment guifg='salmon pink'
  1545.  
  1546.                             *gui-colors*
  1547.     Suggested color names (these are available on most systems):
  1548.         Red        LightRed    DarkRed
  1549.         Green    LightGreen    DarkGreen    SeaGreen
  1550.         Blue    LightBlue    DarkBlue    SlateBlue
  1551.         Cyan    LightCyan    DarkCyan
  1552.         Magenta    LightMagenta    DarkMagenta
  1553.         Yellow    LightYellow    Brown
  1554.         Gray    LightGray    DarkGray
  1555.         Black    White
  1556.         Orange    Purple        Violet
  1557.  
  1558.     In the Win32 GUI version, additional system colors are available.  See
  1559.     |win32-colors|.
  1560.  
  1561.     You can also specify a color by its Red, Green and Blue values.
  1562.     The format is "#rrggbb", where
  1563.         "rr"    is the Red value
  1564.         "bb"    is the Blue value
  1565.         "gg"    is the Green value
  1566.     All values are hexadecimal, range from "00" to "ff".  Examples:
  1567. >  :highlight Comment guifg=#11f0c3 guibg=#ff00ff
  1568.  
  1569.                     *highlight-groups* *highlight-default*
  1570. These are the default highlighting groups.  These groups are used by the
  1571. 'highlight' option default.  Note that the highlighting depends on the value
  1572. of 'background'.  You can see the current settings with the ":highlight"
  1573. command.
  1574.                             *hl-Cursor*
  1575. Cursor        the character under the cursor
  1576.                             *hl-Directory*
  1577. Directory    directory names (and other special names in listings)
  1578.                             *hl-ErrorMsg*
  1579. ErrorMsg    error messages
  1580.                             *hl-IncSearch*
  1581. IncSearch    'incsearch' highlighting
  1582.                             *hl-ModeMsg*
  1583. ModeMsg        'showmode' message (e.g., "-- INSERT --")
  1584.                             *hl-MoreMsg*
  1585. MoreMsg        |more-prompt|
  1586.                             *hl-NonText*
  1587. NonText        '~' and '@' at the end of the window and characters from
  1588.         'showbreak'
  1589.                             *hl-Question*
  1590. Question    |hit-return| prompt and yes/no questions
  1591.                             *hl-SpecialKey*
  1592. SpecialKey    Meta and special keys listed with ":map"
  1593.                             *hl-StatusLine*
  1594. StatusLine    status line of current window
  1595.                             *hl-StatusLineNC*
  1596. StatusLineNC    status lines of not-current windows
  1597.                             *hl-Title*
  1598. Title        titles for output from ":set all", ":autocmd" etc.
  1599.                             *hl-Visual*
  1600. Visual        Visual mode selection
  1601.                             *hl-WarningMsg*
  1602. WarningMsg    warning messages
  1603.                             *hl-LineNr*
  1604. LineNr        line number for ":number" and ":#" commands, and when 'number'
  1605.         option is set.
  1606.                             *hl-Normal*
  1607. Normal        normal text
  1608.                             *hl-Search*
  1609. Search        last search pattern highlighting (see 'hlsearch')
  1610.  
  1611.  
  1612. For the GUI you can use these groups to set the colors for the menu and
  1613. scrollbars.  They don't have defaults.  This doesn't work for the Win32 GUI.
  1614.     Menu                            *hl-Menu*
  1615.     Scrollbar                            *hl-Scrollbar*
  1616.  
  1617. ==============================================================================
  1618. 12. Linking groups                    *:highlight-link*
  1619.  
  1620. When you want to use the same highlighting for several syntax groups, you
  1621. can do this more easily by linking the groups into one common highlight
  1622. group, and give the color attributes only for that group.
  1623.  
  1624.     :hi[ghlight][!] link {from-group} {to-group}
  1625.  
  1626. Notes:
  1627. - If the {from-group} and/or {to-group} doesn't exist, it is created.  You
  1628.   don't get an error message for a non-existing group.
  1629. - If the {to-group} is "NONE", the link is removed from the {from-group}.
  1630. - As soon as you use a ":highlight" command for a linked group, the link is
  1631.   removed.
  1632. - If there are already highlight settings for the {from-group}, the link is
  1633.   not made, unless the '!' is given.  For a ":highlight link" command in a
  1634.   sourced file, you don't get an error message.  This can be used to skip
  1635.   links for groups that already have settings.
  1636.  
  1637. ==============================================================================
  1638. 13. Cleaning up                        *:syn-clear*
  1639.  
  1640. If you want to clear the syntax stuff for the current buffer, you can use this
  1641. command:
  1642. >  :syntax clear
  1643.  
  1644. This command should be used when you want to switch off syntax highlighting,
  1645. or when you want to switch to using another syntax.  It's a good idea to
  1646. include this command at the beginning of a syntax file.
  1647.  
  1648. If you want to disable syntax highlighting for all buffers, you need to remove
  1649. the autocommands that load the syntax files:
  1650. >  :syntax off
  1651.  
  1652. What this command actually does, is executing the command
  1653. >  source $VIM/syntax/nosyntax.vim
  1654. See the "nosyntax.vim" file for details.  Note that for this to work $VIM must
  1655. be valid.  See |$VIM|.
  1656.  
  1657. To clean up specific syntax groups for the current buffer:
  1658. >  :syntax clear {group-name} ..
  1659. This removes all patterns and keywords for {group-name}.
  1660.  
  1661. To clean up specific syntax group lists for the current buffer:
  1662. >  :syntax clear @{grouplist-name} ..
  1663. This sets {grouplist-name}'s contents to an empty list.
  1664.  
  1665. ==============================================================================
  1666. 14. Highlighting tags                    *tag-highlight*
  1667.  
  1668. If you want to highlight all the tags in your file, you can use the following
  1669. mappings.
  1670.  
  1671.     <F11>    -- Generate tags.vim file, and highlight tags.
  1672.     <F12>    -- Just highlight tags based on existing tags.vim file.
  1673.  
  1674. >  map <F11>  :sp tags<CR>:%s/^\([^    :]*:\)\=\([^    ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
  1675. >  map <F12>  :so tags.vim<CR>
  1676.  
  1677. WARNING: The longer the tags file, the slower this will be, and the more
  1678. memory Vim will consume.
  1679.  
  1680. Only highlighting typedefs, unions and structs can be done too.  For this you
  1681. must use Exuberant ctags (included with Vim).
  1682.  
  1683. Put these lines in your Makefile:
  1684.  
  1685. # Make a highlight file for types.  Requires Exuberant ctags and awk
  1686. types: types.vim
  1687. types.vim: *.[ch]
  1688.     ctags -i=gstuS -o- *.[ch] |\
  1689.         awk 'BEGIN{printf("syntax keyword Type\t")}\
  1690.             {printf("%s ", $$1)}END{print ""}' > $@
  1691.  
  1692. And put these lines in your .vimrc:
  1693.  
  1694. >  " load the types.vim highlighting file, if it exists
  1695. >  autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
  1696. >  autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
  1697. >  autocmd BufRead,BufNewFile *.[ch]   exe 'so ' . fname
  1698. >  autocmd BufRead,BufNewFile *.[ch] endif
  1699.  
  1700. ==============================================================================
  1701. 15. Color xterms                *xterm-color* *color-xterm*
  1702.  
  1703. Most color xterms have only eight colors.  They should work with these
  1704. lines in your .vimrc:
  1705. >  :if has("terminfo")
  1706. >  :  set t_Co=8
  1707. >  :  set t_Sf=<Esc>[3%p1%dm
  1708. >  :  set t_Sb=<Esc>[4%p1%dm
  1709. >  :else
  1710. >  :  set t_Co=8
  1711. >  :  set t_Sf=<Esc>[3%dm
  1712. >  :  set t_Sb=<Esc>[4%dm
  1713. >  :endif
  1714.     [<Esc> is a real escape, type CTRL-V <Esc>]
  1715.  
  1716. You might want to put these lines in an ":if" that checks the name of your
  1717. terminal, for example:
  1718. >  :if &term =~ "xterm"
  1719.    put above lines here
  1720. >  :endif
  1721.  
  1722. Note: Do these settings BEFORE doing ":syntax on".  Otherwise the colors may
  1723. be wrong.
  1724.                             *xiterm* *rxvt*
  1725. The above settings have been mentioned to work for xiterm and rxvt too.
  1726.  
  1727. To test your color setup, a file has been included in the Vim distribution.
  1728. To use it, execute these commands:
  1729. >  :e $VIM/syntax/colortest.vim
  1730. >  :so %
  1731.  
  1732. Some versions of xterm (and other terminals, like the linux console) can
  1733. output lighter foreground colors, even though the number of colors is defined
  1734. at 8.  Therefore Vim sets the "cterm=bold" attribute for light foreground
  1735. colors, when 't_Co' is 8.
  1736.  
  1737. To get 16 colors, get the newest xterm version (which should be included with
  1738. Xfree86 3.3).  You can also find the latest version at:
  1739.     http://www.clark.net/pub/dickey/xterm
  1740. You probably have to enable 16 colors when running configure:
  1741.     ./configure --disable-bold-color
  1742. If you only get 8 colors, check the xterm compilation settings.
  1743.  
  1744. This xterm should work with these lines in your .vimrc:
  1745. >  :if has("terminfo")
  1746. >  :  set t_Co=16
  1747. >  :  set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
  1748. >  :  set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
  1749. >  :else
  1750. >  :  set t_Co=16
  1751. >  :  set t_Sf=<Esc>[3%dm
  1752. >  :  set t_Sb=<Esc>[4%dm
  1753. >  :endif
  1754.     [<Esc> is a real escape, type CTRL-V <Esc>]
  1755.  
  1756. Without |+terminfo|, Vim will recognize these settings, and automatically
  1757. translate cterm colors of 8 and above to "<Esc>[9%dm" and "<Esc>[10%dm".
  1758.  
  1759. Or just set the TERM environment variable to "xterm-16color" and try if that
  1760. works.
  1761.  
  1762. You probably want to use these X resouces (put them in your ~/.Xdefaults file):
  1763.     XTerm*color0:            #000000
  1764.     XTerm*color1:            #c00000
  1765.     XTerm*color2:            #008000
  1766.     XTerm*color3:            #808000
  1767.     XTerm*color4:            #0000c0
  1768.     XTerm*color5:            #c000c0
  1769.     XTerm*color6:            #008080
  1770.     XTerm*color7:            #c0c0c0
  1771.     XTerm*color8:            #808080
  1772.     XTerm*color9:            #ff6060
  1773.     XTerm*color10:            #00ff00
  1774.     XTerm*color11:            #ffff00
  1775.     XTerm*color12:            #8080ff
  1776.     XTerm*color13:            #ff40ff
  1777.     XTerm*color14:            #00ffff
  1778.     XTerm*color15:            #ffffff
  1779.     Xterm*cursorColor:        Black
  1780.  
  1781. [Note: The cursorColor is required to work around a bug, which changes the
  1782. cursor color to the color of the last drawn text.  This has been fixed by a
  1783. newer version of xterm, but not everybody is it using yet.]
  1784.  
  1785. To get these right away, reload the .Xdefaults file to the X Option database
  1786. Manager (you only need to do this when you just changed the .Xdefaults file):
  1787. >  xrdb -merge ~/.Xdefaults
  1788.  
  1789.  vim:tw=78:ts=8:sw=4
  1790.