blob: cd06f1683c7ce50fa047f8cd57032d0b368370d9 [file] [log] [blame]
Bram Moolenaarfff2bee2010-05-15 13:56:02 +02001*syntax.txt* For Vim version 7.3a. Last change: 2010 May 14
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Syntax highlighting *syntax* *syntax-highlighting* *coloring*
8
9Syntax highlighting enables Vim to show parts of the text in another font or
10color. Those parts can be specific keywords or text matching a pattern. Vim
11doesn't parse the whole file (to keep it fast), so the highlighting has its
12limitations. Lexical highlighting might be a better name, but since everybody
13calls it syntax highlighting we'll stick with that.
14
15Vim supports syntax highlighting on all terminals. But since most ordinary
16terminals have very limited highlighting possibilities, it works best in the
17GUI version, gvim.
18
19In the User Manual:
20|usr_06.txt| introduces syntax highlighting.
21|usr_44.txt| introduces writing a syntax file.
22
231. Quick start |:syn-qstart|
242. Syntax files |:syn-files|
253. Syntax loading procedure |syntax-loading|
264. Syntax file remarks |:syn-file-remarks|
275. Defining a syntax |:syn-define|
286. :syntax arguments |:syn-arguments|
297. Syntax patterns |:syn-pattern|
308. Syntax clusters |:syn-cluster|
319. Including syntax files |:syn-include|
3210. Synchronizing |:syn-sync|
3311. Listing syntax items |:syntax|
3412. Highlight command |:highlight|
3513. Linking groups |:highlight-link|
3614. Cleaning up |:syn-clear|
3715. Highlighting tags |tag-highlight|
Bram Moolenaar860cae12010-06-05 23:22:07 +02003816. Window-local syntax |:ownsyntax|
3917. Color xterms |xterm-color|
Bram Moolenaar071d4272004-06-13 20:20:40 +000040
41{Vi does not have any of these commands}
42
43Syntax highlighting is not available when the |+syntax| feature has been
44disabled at compile time.
45
46==============================================================================
471. Quick start *:syn-qstart*
48
49 *:syn-enable* *:syntax-enable*
50This command switches on syntax highlighting: >
51
52 :syntax enable
53
54What this command actually does is to execute the command >
55 :source $VIMRUNTIME/syntax/syntax.vim
56
57If the VIM environment variable is not set, Vim will try to find
58the path in another way (see |$VIMRUNTIME|). Usually this works just
59fine. If it doesn't, try setting the VIM environment variable to the
60directory where the Vim stuff is located. For example, if your syntax files
61are in the "/usr/vim/vim50/syntax" directory, set $VIMRUNTIME to
62"/usr/vim/vim50". You must do this in the shell, before starting Vim.
63
64 *:syn-on* *:syntax-on*
65The ":syntax enable" command will keep your current color settings. This
66allows using ":highlight" commands to set your preferred colors before or
67after using this command. If you want Vim to overrule your settings with the
68defaults, use: >
69 :syntax on
70<
71 *:hi-normal* *:highlight-normal*
72If you are running in the GUI, you can get white text on a black background
73with: >
74 :highlight Normal guibg=Black guifg=White
75For a color terminal see |:hi-normal-cterm|.
76For setting up your own colors syntax highlighting see |syncolor|.
77
78NOTE: The syntax files on MS-DOS and Windows have lines that end in <CR><NL>.
79The files for Unix end in <NL>. This means you should use the right type of
80file for your system. Although on MS-DOS and Windows the right format is
81automatically selected if the 'fileformats' option is not empty.
82
83NOTE: When using reverse video ("gvim -fg white -bg black"), the default value
84of 'background' will not be set until the GUI window is opened, which is after
Bram Moolenaar910f66f2006-04-05 20:41:53 +000085reading the |gvimrc|. This will cause the wrong default highlighting to be
Bram Moolenaar071d4272004-06-13 20:20:40 +000086used. To set the default value of 'background' before switching on
Bram Moolenaar910f66f2006-04-05 20:41:53 +000087highlighting, include the ":gui" command in the |gvimrc|: >
Bram Moolenaar071d4272004-06-13 20:20:40 +000088
89 :gui " open window and set default for 'background'
90 :syntax on " start highlighting, use 'background' to set colors
91
Bram Moolenaar910f66f2006-04-05 20:41:53 +000092NOTE: Using ":gui" in the |gvimrc| means that "gvim -f" won't start in the
Bram Moolenaar071d4272004-06-13 20:20:40 +000093foreground! Use ":gui -f" then.
94
95
96You can toggle the syntax on/off with this command >
97 :if exists("syntax_on") | syntax off | else | syntax enable | endif
98
99To put this into a mapping, you can use: >
100 :map <F7> :if exists("syntax_on") <Bar>
101 \ syntax off <Bar>
102 \ else <Bar>
103 \ syntax enable <Bar>
104 \ endif <CR>
105[using the |<>| notation, type this literally]
106
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000107Details:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108The ":syntax" commands are implemented by sourcing a file. To see exactly how
109this works, look in the file:
110 command file ~
111 :syntax enable $VIMRUNTIME/syntax/syntax.vim
112 :syntax on $VIMRUNTIME/syntax/syntax.vim
113 :syntax manual $VIMRUNTIME/syntax/manual.vim
114 :syntax off $VIMRUNTIME/syntax/nosyntax.vim
115Also see |syntax-loading|.
116
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100117NOTE: If displaying long lines is slow and switching off syntax highlighting
118makes it fast, consider setting the 'synmaxcol' option to a lower value.
119
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120==============================================================================
1212. Syntax files *:syn-files*
122
123The syntax and highlighting commands for one language are normally stored in
124a syntax file. The name convention is: "{name}.vim". Where {name} is the
125name of the language, or an abbreviation (to fit the name in 8.3 characters,
126a requirement in case the file is used on a DOS filesystem).
127Examples:
128 c.vim perl.vim java.vim html.vim
129 cpp.vim sh.vim csh.vim
130
131The syntax file can contain any Ex commands, just like a vimrc file. But
132the idea is that only commands for a specific language are included. When a
133language is a superset of another language, it may include the other one,
134for example, the cpp.vim file could include the c.vim file: >
135 :so $VIMRUNTIME/syntax/c.vim
136
137The .vim files are normally loaded with an autocommand. For example: >
138 :au Syntax c runtime! syntax/c.vim
139 :au Syntax cpp runtime! syntax/cpp.vim
140These commands are normally in the file $VIMRUNTIME/syntax/synload.vim.
141
142
143MAKING YOUR OWN SYNTAX FILES *mysyntaxfile*
144
145When you create your own syntax files, and you want to have Vim use these
146automatically with ":syntax enable", do this:
147
1481. Create your user runtime directory. You would normally use the first item
149 of the 'runtimepath' option. Example for Unix: >
150 mkdir ~/.vim
151
1522. Create a directory in there called "syntax". For Unix: >
153 mkdir ~/.vim/syntax
154
1553. Write the Vim syntax file. Or download one from the internet. Then write
156 it in your syntax directory. For example, for the "mine" syntax: >
157 :w ~/.vim/syntax/mine.vim
158
159Now you can start using your syntax file manually: >
160 :set syntax=mine
161You don't have to exit Vim to use this.
162
163If you also want Vim to detect the type of file, see |new-filetype|.
164
165If you are setting up a system with many users and you don't want each user
166to add the same syntax file, you can use another directory from 'runtimepath'.
167
168
169ADDING TO AN EXISTING SYNTAX FILE *mysyntaxfile-add*
170
171If you are mostly satisfied with an existing syntax file, but would like to
172add a few items or change the highlighting, follow these steps:
173
1741. Create your user directory from 'runtimepath', see above.
175
1762. Create a directory in there called "after/syntax". For Unix: >
177 mkdir ~/.vim/after
178 mkdir ~/.vim/after/syntax
179
1803. Write a Vim script that contains the commands you want to use. For
181 example, to change the colors for the C syntax: >
182 highlight cComment ctermfg=Green guifg=Green
183
1844. Write that file in the "after/syntax" directory. Use the name of the
185 syntax, with ".vim" added. For our C syntax: >
186 :w ~/.vim/after/syntax/c.vim
187
188That's it. The next time you edit a C file the Comment color will be
189different. You don't even have to restart Vim.
190
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000191If you have multiple files, you can use the filetype as the directory name.
192All the "*.vim" files in this directory will be used, for example:
193 ~/.vim/after/syntax/c/one.vim
194 ~/.vim/after/syntax/c/two.vim
195
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196
197REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
198
199If you don't like a distributed syntax file, or you have downloaded a new
200version, follow the same steps as for |mysyntaxfile| above. Just make sure
201that you write the syntax file in a directory that is early in 'runtimepath'.
202Vim will only load the first syntax file found.
203
204
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100205NAMING CONVENTIONS *group-name* *{group-name}* *E669* *W18*
206
207A syntax group name is to be used for syntax items that match the same kind of
208thing. These are then linked to a highlight group that specifies the color.
209A syntax group name doesn't specify any color or attributes itself.
210
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211The name for a highlight or syntax group must consist of ASCII letters, digits
212and the underscore. As a regexp: "[a-zA-Z0-9_]*"
213
214To be able to allow each user to pick his favorite set of colors, there must
215be preferred names for highlight groups that are common for many languages.
216These are the suggested group names (if syntax highlighting works properly
217you can see the actual color, except for "Ignore"):
218
219 *Comment any comment
220
221 *Constant any constant
222 String a string constant: "this is a string"
223 Character a character constant: 'c', '\n'
224 Number a number constant: 234, 0xff
225 Boolean a boolean constant: TRUE, false
226 Float a floating point constant: 2.3e10
227
228 *Identifier any variable name
229 Function function name (also: methods for classes)
230
231 *Statement any statement
232 Conditional if, then, else, endif, switch, etc.
233 Repeat for, do, while, etc.
234 Label case, default, etc.
235 Operator "sizeof", "+", "*", etc.
236 Keyword any other keyword
237 Exception try, catch, throw
238
239 *PreProc generic Preprocessor
240 Include preprocessor #include
241 Define preprocessor #define
242 Macro same as Define
243 PreCondit preprocessor #if, #else, #endif, etc.
244
245 *Type int, long, char, etc.
246 StorageClass static, register, volatile, etc.
247 Structure struct, union, enum, etc.
248 Typedef A typedef
249
250 *Special any special symbol
251 SpecialChar special character in a constant
252 Tag you can use CTRL-] on this
253 Delimiter character that needs attention
254 SpecialComment special things inside a comment
255 Debug debugging statements
256
257 *Underlined text that stands out, HTML links
258
259 *Ignore left blank, hidden
260
261 *Error any erroneous construct
262
263 *Todo anything that needs extra attention; mostly the
264 keywords TODO FIXME and XXX
265
266The names marked with * are the preferred groups; the others are minor groups.
267For the preferred groups, the "syntax.vim" file contains default highlighting.
268The minor groups are linked to the preferred groups, so they get the same
269highlighting. You can override these defaults by using ":highlight" commands
270after sourcing the "syntax.vim" file.
271
272Note that highlight group names are not case sensitive. "String" and "string"
273can be used for the same group.
274
275The following names are reserved and cannot be used as a group name:
276 NONE ALL ALLBUT contains contained
277
278==============================================================================
2793. Syntax loading procedure *syntax-loading*
280
281This explains the details that happen when the command ":syntax enable" is
282issued. When Vim initializes itself, it finds out where the runtime files are
283located. This is used here as the variable |$VIMRUNTIME|.
284
285":syntax enable" and ":syntax on" do the following:
286
287 Source $VIMRUNTIME/syntax/syntax.vim
288 |
289 +- Clear out any old syntax by sourcing $VIMRUNTIME/syntax/nosyntax.vim
290 |
291 +- Source first syntax/synload.vim in 'runtimepath'
292 | |
293 | +- Setup the colors for syntax highlighting. If a color scheme is
294 | | defined it is loaded again with ":colors {name}". Otherwise
295 | | ":runtime! syntax/syncolor.vim" is used. ":syntax on" overrules
296 | | existing colors, ":syntax enable" only sets groups that weren't
297 | | set yet.
298 | |
299 | +- Set up syntax autocmds to load the appropriate syntax file when
300 | | the 'syntax' option is set. *synload-1*
301 | |
302 | +- Source the user's optional file, from the |mysyntaxfile| variable.
303 | This is for backwards compatibility with Vim 5.x only. *synload-2*
304 |
305 +- Do ":filetype on", which does ":runtime! filetype.vim". It loads any
306 | filetype.vim files found. It should always Source
307 | $VIMRUNTIME/filetype.vim, which does the following.
308 | |
309 | +- Install autocmds based on suffix to set the 'filetype' option
310 | | This is where the connection between file name and file type is
311 | | made for known file types. *synload-3*
312 | |
313 | +- Source the user's optional file, from the *myfiletypefile*
314 | | variable. This is for backwards compatibility with Vim 5.x only.
315 | | *synload-4*
316 | |
317 | +- Install one autocommand which sources scripts.vim when no file
318 | | type was detected yet. *synload-5*
319 | |
320 | +- Source $VIMRUNTIME/menu.vim, to setup the Syntax menu. |menu.vim|
321 |
322 +- Install a FileType autocommand to set the 'syntax' option when a file
323 | type has been detected. *synload-6*
324 |
325 +- Execute syntax autocommands to start syntax highlighting for each
326 already loaded buffer.
327
328
329Upon loading a file, Vim finds the relevant syntax file as follows:
330
331 Loading the file triggers the BufReadPost autocommands.
332 |
333 +- If there is a match with one of the autocommands from |synload-3|
334 | (known file types) or |synload-4| (user's file types), the 'filetype'
335 | option is set to the file type.
336 |
337 +- The autocommand at |synload-5| is triggered. If the file type was not
338 | found yet, then scripts.vim is searched for in 'runtimepath'. This
339 | should always load $VIMRUNTIME/scripts.vim, which does the following.
340 | |
341 | +- Source the user's optional file, from the *myscriptsfile*
342 | | variable. This is for backwards compatibility with Vim 5.x only.
343 | |
344 | +- If the file type is still unknown, check the contents of the file,
345 | again with checks like "getline(1) =~ pattern" as to whether the
346 | file type can be recognized, and set 'filetype'.
347 |
348 +- When the file type was determined and 'filetype' was set, this
349 | triggers the FileType autocommand |synload-6| above. It sets
350 | 'syntax' to the determined file type.
351 |
352 +- When the 'syntax' option was set above, this triggers an autocommand
353 | from |synload-1| (and |synload-2|). This find the main syntax file in
354 | 'runtimepath', with this command:
355 | runtime! syntax/<name>.vim
356 |
357 +- Any other user installed FileType or Syntax autocommands are
358 triggered. This can be used to change the highlighting for a specific
359 syntax.
360
361==============================================================================
3624. Syntax file remarks *:syn-file-remarks*
363
364 *b:current_syntax-variable*
365Vim stores the name of the syntax that has been loaded in the
366"b:current_syntax" variable. You can use this if you want to load other
367settings, depending on which syntax is active. Example: >
368 :au BufReadPost * if b:current_syntax == "csh"
369 :au BufReadPost * do-some-things
370 :au BufReadPost * endif
371
372
3732HTML *2html.vim* *convert-to-HTML*
374
375This is not a syntax file itself, but a script that converts the current
376window into HTML. Vim opens a new window in which it builds the HTML file.
377
378You are not supposed to set the 'filetype' or 'syntax' option to "2html"!
379Source the script to convert the current file: >
380
381 :runtime! syntax/2html.vim
382<
383Warning: This is slow!
384 *:TOhtml*
385Or use the ":TOhtml" user command. It is defined in a standard plugin.
386":TOhtml" also works with a range and in a Visual area: >
387
388 :10,40TOhtml
389
Bram Moolenaarb02cbe32010-07-11 22:38:52 +0200390":TOhtml" has another special feature: if the window is in diff mode, it will
391generate HTML that shows all the related windows. This can be disabled by
392setting the g:diff_one_file variable: >
393
394 let g:diff_one_file = 1
395
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100396After you save the resulting file, you can view it with any browser. The
397colors should be exactly the same as you see them in Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000398
399To restrict the conversion to a range of lines set "html_start_line" and
400"html_end_line" to the first and last line to be converted. Example, using
401the last set Visual area: >
402
403 :let html_start_line = line("'<")
404 :let html_end_line = line("'>")
405
406The lines are numbered according to 'number' option and the Number
407highlighting. You can force lines to be numbered in the HTML output by
408setting "html_number_lines" to non-zero value: >
409 :let html_number_lines = 1
410Force to omit the line numbers by using a zero value: >
411 :let html_number_lines = 0
412Go back to the default to use 'number' by deleting the variable: >
413 :unlet html_number_lines
414
415By default, HTML optimized for old browsers is generated. If you prefer using
416cascading style sheets (CSS1) for the attributes (resulting in considerably
417shorter and valid HTML 4 file), use: >
418 :let html_use_css = 1
419
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100420Closed folds are put in the HTML as they are displayed. If you don't want
421this, use the |zR| command before invoking 2html, or use: >
422 :let html_ignore_folding = 1
423
424You may want to generate HTML that includes all the data within the folds, and
425allow the user to view the folded data similar to how they would in Vim. To
426generate this dynamic fold information, use: >
427 :let html_dynamic_folds = 1
428
429Using html_dynamic_folds will imply html_use_css, because it would be far too
430difficult to do it for old browsers. However, html_ignore_folding overrides
431html_dynamic_folds.
432
433Using html_dynamic_folds will default to generating a foldcolumn in the html
434similar to Vim's foldcolumn, that will use javascript to open and close the
435folds in the HTML document. The width of this foldcolumn starts at the current
436setting of |'foldcolumn'| but grows to fit the greatest foldlevel in your
437document. If you do not want to show a foldcolumn at all, use: >
438 :let html_no_foldcolumn = 1
439
440Using this option, there will be no foldcolumn available to open the folds in
441the HTML. For this reason, another option is provided: html_hover_unfold.
442Enabling this option will use CSS 2.0 to allow a user to open a fold by
443hovering the mouse pointer over it. Note that old browsers (notably Internet
444Explorer 6) will not support this feature. Browser-specific markup for IE6 is
445included to fall back to the normal CSS1 code so that the folds show up
446correctly for this browser, but they will not be openable without a
447foldcolumn. Note that using html_hover_unfold will allow modern browsers with
448disabled javascript to view closed folds. To use this option, use: >
449 :let html_hover_unfold = 1
450
451Setting html_no_foldcolumn with html_dynamic_folds will automatically set
452html_hover_unfold, because otherwise the folds wouldn't be dynamic.
453
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454By default "<pre>" and "</pre>" is used around the text. This makes it show
455up as you see it in Vim, but without wrapping. If you prefer wrapping, at the
456risk of making some things look a bit different, use: >
457 :let html_no_pre = 1
458This will use <br> at the end of each line and use "&nbsp;" for repeated
459spaces.
460
461The current value of 'encoding' is used to specify the charset of the HTML
462file. This only works for those values of 'encoding' that have an equivalent
463HTML charset name. To overrule this set g:html_use_encoding to the name of
464the charset to be used: >
465 :let html_use_encoding = "foobar"
466To omit the line that specifies the charset, set g:html_use_encoding to an
467empty string: >
468 :let html_use_encoding = ""
469To go back to the automatic mechanism, delete the g:html_use_encoding
470variable: >
471 :unlet html_use_encoding
472<
Bram Moolenaar47136d72004-10-12 20:02:24 +0000473For diff mode a sequence of more than 3 filler lines is displayed as three
474lines with the middle line mentioning the total number of inserted lines. If
475you prefer to see all the inserted lines use: >
476 :let html_whole_filler = 1
477And to go back to displaying up to three lines again: >
478 :unlet html_whole_filler
Bram Moolenaar488c6512005-08-11 20:09:58 +0000479<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000480 *convert-to-XML* *convert-to-XHTML*
481An alternative is to have the script generate XHTML (XML compliant HTML). To
482do this set the "use_xhtml" variable: >
483 :let use_xhtml = 1
484To disable it again delete the variable: >
485 :unlet use_xhtml
486The generated XHTML file can be used in DocBook XML documents. See:
487 http://people.mech.kuleuven.ac.be/~pissaris/howto/src2db.html
488
489Remarks:
490- This only works in a version with GUI support. If the GUI is not actually
491 running (possible for X11) it still works, but not very well (the colors
492 may be wrong).
493- Older browsers will not show the background colors.
494- From most browsers you can also print the file (in color)!
495
496Here is an example how to run the script over all .c and .h files from a
497Unix shell: >
498 for f in *.[ch]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done
499<
500
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000501ABEL *abel.vim* *ft-abel-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000502
503ABEL highlighting provides some user-defined options. To enable them, assign
504any value to the respective variable. Example: >
505 :let abel_obsolete_ok=1
506To disable them use ":unlet". Example: >
507 :unlet abel_obsolete_ok
508
509Variable Highlight ~
510abel_obsolete_ok obsolete keywords are statements, not errors
511abel_cpp_comments_illegal do not interpret '//' as inline comment leader
512
513
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000514ADA
Bram Moolenaar071d4272004-06-13 20:20:40 +0000515
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000516See |ft-ada-syntax|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000517
518
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000519ANT *ant.vim* *ft-ant-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520
521The ant syntax file provides syntax highlighting for javascript and python
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000522by default. Syntax highlighting for other script languages can be installed
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523by the function AntSyntaxScript(), which takes the tag name as first argument
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000524and the script syntax file name as second argument. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525
526 :call AntSyntaxScript('perl', 'perl.vim')
527
528will install syntax perl highlighting for the following ant code >
529
530 <script language = 'perl'><![CDATA[
531 # everything inside is highlighted as perl
532 ]]></script>
533
534See |mysyntaxfile-add| for installing script languages permanently.
535
536
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000537APACHE *apache.vim* *ft-apache-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538
539The apache syntax file provides syntax highlighting depending on Apache HTTP
540server version, by default for 1.3.x. Set "apache_version" to Apache version
541(as a string) to get highlighting for another version. Example: >
542
543 :let apache_version = "2.0"
544<
545
546 *asm.vim* *asmh8300.vim* *nasm.vim* *masm.vim* *asm68k*
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000547ASSEMBLY *ft-asm-syntax* *ft-asmh8300-syntax* *ft-nasm-syntax*
548 *ft-masm-syntax* *ft-asm68k-syntax* *fasm.vim*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549
550Files matching "*.i" could be Progress or Assembly. If the automatic detection
551doesn't work for you, or you don't edit Progress at all, use this in your
552startup vimrc: >
553 :let filetype_i = "asm"
554Replace "asm" with the type of assembly you use.
555
556There are many types of assembly languages that all use the same file name
557extensions. Therefore you will have to select the type yourself, or add a
558line in the assembly file that Vim will recognize. Currently these syntax
559files are included:
560 asm GNU assembly (the default)
561 asm68k Motorola 680x0 assembly
562 asmh8300 Hitachi H-8300 version of GNU assembly
563 ia64 Intel Itanium 64
564 fasm Flat assembly (http://flatassembler.net)
565 masm Microsoft assembly (probably works for any 80x86)
566 nasm Netwide assembly
567 tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and
568 MMX)
569 pic PIC assembly (currently for PIC16F84)
570
571The most flexible is to add a line in your assembly file containing: >
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100572 asmsyntax=nasm
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573Replace "nasm" with the name of the real assembly syntax. This line must be
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100574one of the first five lines in the file. No non-white text must be
575immediately before or after this text.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576
577The syntax type can always be overruled for a specific buffer by setting the
578b:asmsyntax variable: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000579 :let b:asmsyntax = "nasm"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580
581If b:asmsyntax is not set, either automatically or by hand, then the value of
582the global variable asmsyntax is used. This can be seen as a default assembly
583language: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000584 :let asmsyntax = "nasm"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000585
586As a last resort, if nothing is defined, the "asm" syntax is used.
587
588
589Netwide assembler (nasm.vim) optional highlighting ~
590
591To enable a feature: >
592 :let {variable}=1|set syntax=nasm
593To disable a feature: >
594 :unlet {variable} |set syntax=nasm
595
596Variable Highlight ~
597nasm_loose_syntax unofficial parser allowed syntax not as Error
598 (parser dependent; not recommended)
599nasm_ctx_outside_macro contexts outside macro not as Error
600nasm_no_warn potentially risky syntax not as ToDo
601
602
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000603ASPPERL and ASPVBS *ft-aspperl-syntax* *ft-aspvbs-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000604
605*.asp and *.asa files could be either Perl or Visual Basic script. Since it's
606hard to detect this you can set two global variables to tell Vim what you are
607using. For Perl script use: >
608 :let g:filetype_asa = "aspperl"
609 :let g:filetype_asp = "aspperl"
610For Visual Basic use: >
611 :let g:filetype_asa = "aspvbs"
612 :let g:filetype_asp = "aspvbs"
613
614
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000615BAAN *baan.vim* *baan-syntax*
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000616
617The baan.vim gives syntax support for BaanC of release BaanIV upto SSA ERP LN
618for both 3 GL and 4 GL programming. Large number of standard defines/constants
619are supported.
620
621Some special violation of coding standards will be signalled when one specify
622in ones |.vimrc|: >
623 let baan_code_stds=1
624
625*baan-folding*
626
627Syntax folding can be enabled at various levels through the variables
628mentioned below (Set those in your |.vimrc|). The more complex folding on
629source blocks and SQL can be CPU intensive.
630
631To allow any folding and enable folding at function level use: >
632 let baan_fold=1
633Folding can be enabled at source block level as if, while, for ,... The
634indentation preceding the begin/end keywords has to match (spaces are not
635considered equal to a tab). >
636 let baan_fold_block=1
637Folding can be enabled for embedded SQL blocks as SELECT, SELECTDO,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000638SELECTEMPTY, ... The indentation preceding the begin/end keywords has to
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000639match (spaces are not considered equal to a tab). >
640 let baan_fold_sql=1
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000641Note: Block folding can result in many small folds. It is suggested to |:set|
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000642the options 'foldminlines' and 'foldnestmax' in |.vimrc| or use |:setlocal| in
643.../after/syntax/baan.vim (see |after-directory|). Eg: >
644 set foldminlines=5
645 set foldnestmax=6
646
647
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000648BASIC *basic.vim* *vb.vim* *ft-basic-syntax* *ft-vb-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000649
650Both Visual Basic and "normal" basic use the extension ".bas". To detect
651which one should be used, Vim checks for the string "VB_Name" in the first
652five lines of the file. If it is not found, filetype will be "basic",
653otherwise "vb". Files with the ".frm" extension will always be seen as Visual
654Basic.
655
656
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000657C *c.vim* *ft-c-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658
659A few things in C highlighting are optional. To enable them assign any value
660to the respective variable. Example: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000661 :let c_comment_strings = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662To disable them use ":unlet". Example: >
663 :unlet c_comment_strings
664
665Variable Highlight ~
666c_gnu GNU gcc specific items
667c_comment_strings strings and numbers inside a comment
668c_space_errors trailing white space and spaces before a <Tab>
669c_no_trail_space_error ... but no trailing spaces
670c_no_tab_space_error ... but no spaces before a <Tab>
671c_no_bracket_error don't highlight {}; inside [] as errors
Bram Moolenaar677ee682005-01-27 14:41:15 +0000672c_no_curly_error don't highlight {}; inside [] and () as errors;
673 except { and } in first column
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000674c_curly_error highlight a missing }; this forces syncing from the
675 start of the file, can be slow
Bram Moolenaar071d4272004-06-13 20:20:40 +0000676c_no_ansi don't do standard ANSI types and constants
677c_ansi_typedefs ... but do standard ANSI types
678c_ansi_constants ... but do standard ANSI constants
679c_no_utf don't highlight \u and \U in strings
680c_syntax_for_h use C syntax for *.h files, instead of C++
681c_no_if0 don't highlight "#if 0" blocks as comments
682c_no_cformat don't highlight %-formats in strings
683c_no_c99 don't highlight C99 standard items
684
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000685When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will
686become a fold. If you don't want comments to become a fold use: >
687 :let c_no_comment_fold = 1
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000688"#if 0" blocks are also folded, unless: >
689 :let c_no_if0_fold = 1
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000690
Bram Moolenaar071d4272004-06-13 20:20:40 +0000691If you notice highlighting errors while scrolling backwards, which are fixed
692when redrawing with CTRL-L, try setting the "c_minlines" internal variable
693to a larger number: >
694 :let c_minlines = 100
695This will make the syntax synchronization start 100 lines before the first
696displayed line. The default value is 50 (15 when c_no_if0 is set). The
697disadvantage of using a larger number is that redrawing can become slow.
698
699When using the "#if 0" / "#endif" comment highlighting, notice that this only
700works when the "#if 0" is within "c_minlines" from the top of the window. If
701you have a long "#if 0" construct it will not be highlighted correctly.
702
703To match extra items in comments, use the cCommentGroup cluster.
704Example: >
705 :au Syntax c call MyCadd()
706 :function MyCadd()
707 : syn keyword cMyItem contained Ni
708 : syn cluster cCommentGroup add=cMyItem
709 : hi link cMyItem Title
710 :endfun
711
712ANSI constants will be highlighted with the "cConstant" group. This includes
713"NULL", "SIG_IGN" and others. But not "TRUE", for example, because this is
714not in the ANSI standard. If you find this confusing, remove the cConstant
715highlighting: >
716 :hi link cConstant NONE
717
718If you see '{' and '}' highlighted as an error where they are OK, reset the
719highlighting for cErrInParen and cErrInBracket.
720
721If you want to use folding in your C files, you can add these lines in a file
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200722in the "after" directory in 'runtimepath'. For Unix this would be
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723~/.vim/after/syntax/c.vim. >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000724 syn sync fromstart
725 set foldmethod=syntax
726
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000727CH *ch.vim* *ft-ch-syntax*
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000728
729C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon
730the C syntax file. See |c.vim| for all the settings that are available for C.
731
732By setting a variable you can tell Vim to use Ch syntax for *.h files, instead
733of C or C++: >
734 :let ch_syntax_for_h = 1
735
Bram Moolenaar071d4272004-06-13 20:20:40 +0000736
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000737CHILL *chill.vim* *ft-chill-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000738
739Chill syntax highlighting is similar to C. See |c.vim| for all the settings
740that are available. Additionally there is:
741
Bram Moolenaar071d4272004-06-13 20:20:40 +0000742chill_space_errors like c_space_errors
743chill_comment_string like c_comment_strings
744chill_minlines like c_minlines
745
746
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000747CHANGELOG *changelog.vim* *ft-changelog-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000748
749ChangeLog supports highlighting spaces at the start of a line.
750If you do not like this, add following line to your .vimrc: >
751 let g:changelog_spacing_errors = 0
752This works the next time you edit a changelog file. You can also use
753"b:changelog_spacing_errors" to set this per buffer (before loading the syntax
754file).
755
756You can change the highlighting used, e.g., to flag the spaces as an error: >
757 :hi link ChangelogError Error
758Or to avoid the highlighting: >
759 :hi link ChangelogError NONE
760This works immediately.
761
762
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000763COBOL *cobol.vim* *ft-cobol-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764
765COBOL highlighting has different needs for legacy code than it does for fresh
766development. This is due to differences in what is being done (maintenance
767versus development) and other factors. To enable legacy code highlighting,
768add this line to your .vimrc: >
769 :let cobol_legacy_code = 1
770To disable it again, use this: >
771 :unlet cobol_legacy_code
772
773
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000774COLD FUSION *coldfusion.vim* *ft-coldfusion-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000776The ColdFusion has its own version of HTML comments. To turn on ColdFusion
Bram Moolenaar071d4272004-06-13 20:20:40 +0000777comment highlighting, add the following line to your startup file: >
778
779 :let html_wrong_comments = 1
780
781The ColdFusion syntax file is based on the HTML syntax file.
782
783
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000784CSH *csh.vim* *ft-csh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000785
786This covers the shell named "csh". Note that on some systems tcsh is actually
787used.
788
789Detecting whether a file is csh or tcsh is notoriously hard. Some systems
790symlink /bin/csh to /bin/tcsh, making it almost impossible to distinguish
791between csh and tcsh. In case VIM guesses wrong you can set the
792"filetype_csh" variable. For using csh: >
793
794 :let filetype_csh = "csh"
795
796For using tcsh: >
797
798 :let filetype_csh = "tcsh"
799
800Any script with a tcsh extension or a standard tcsh filename (.tcshrc,
801tcsh.tcshrc, tcsh.login) will have filetype tcsh. All other tcsh/csh scripts
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000802will be classified as tcsh, UNLESS the "filetype_csh" variable exists. If the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000803"filetype_csh" variable exists, the filetype will be set to the value of the
804variable.
805
806
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000807CYNLIB *cynlib.vim* *ft-cynlib-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000808
809Cynlib files are C++ files that use the Cynlib class library to enable
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000810hardware modelling and simulation using C++. Typically Cynlib files have a .cc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000811or a .cpp extension, which makes it very difficult to distinguish them from a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000812normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000813line to your .vimrc file: >
814
815 :let cynlib_cyntax_for_cc=1
816
817Similarly for cpp files (this extension is only usually used in Windows) >
818
819 :let cynlib_cyntax_for_cpp=1
820
821To disable these again, use this: >
822
823 :unlet cynlib_cyntax_for_cc
824 :unlet cynlib_cyntax_for_cpp
825<
826
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000827CWEB *cweb.vim* *ft-cweb-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000828
829Files matching "*.w" could be Progress or cweb. If the automatic detection
830doesn't work for you, or you don't edit Progress at all, use this in your
831startup vimrc: >
832 :let filetype_w = "cweb"
833
834
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000835DESKTOP *desktop.vim* *ft-desktop-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000836
837Primary goal of this syntax file is to highlight .desktop and .directory files
Bram Moolenaara17d4c12010-05-30 18:30:36 +0200838according to freedesktop.org standard:
839http://standards.freedesktop.org/desktop-entry-spec/latest/
Bram Moolenaar071d4272004-06-13 20:20:40 +0000840But actually almost none implements this standard fully. Thus it will
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000841highlight all Unix ini files. But you can force strict highlighting according
Bram Moolenaar071d4272004-06-13 20:20:40 +0000842to standard by placing this in your vimrc file: >
843 :let enforce_freedesktop_standard = 1
844
845
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000846DIRCOLORS *dircolors.vim* *ft-dircolors-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000847
848The dircolors utility highlighting definition has one option. It exists to
849provide compatibility with the Slackware GNU/Linux distributions version of
850the command. It adds a few keywords that are generally ignored by most
851versions. On Slackware systems, however, the utility accepts the keywords and
852uses them for processing. To enable the Slackware keywords add the following
853line to your startup file: >
854 let dircolors_is_slackware = 1
855
856
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000857DOCBOOK *docbk.vim* *ft-docbk-syntax* *docbook*
858DOCBOOK XML *docbkxml.vim* *ft-docbkxml-syntax*
859DOCBOOK SGML *docbksgml.vim* *ft-docbksgml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000860
861There are two types of DocBook files: SGML and XML. To specify what type you
862are using the "b:docbk_type" variable should be set. Vim does this for you
863automatically if it can recognize the type. When Vim can't guess it the type
864defaults to XML.
865You can set the type manually: >
866 :let docbk_type = "sgml"
867or: >
868 :let docbk_type = "xml"
869You need to do this before loading the syntax file, which is complicated.
870Simpler is setting the filetype to "docbkxml" or "docbksgml": >
871 :set filetype=docbksgml
872or: >
873 :set filetype=docbkxml
874
875
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000876DOSBATCH *dosbatch.vim* *ft-dosbatch-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000877
878There is one option with highlighting DOS batch files. This covers new
879extensions to the Command Interpreter introduced with Windows 2000 and
880is controlled by the variable dosbatch_cmdextversion. For Windows NT
881this should have the value 1, and for Windows 2000 it should be 2.
882Select the version you want with the following line: >
883
Bram Moolenaar8299df92004-07-10 09:47:34 +0000884 :let dosbatch_cmdextversion = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000885
886If this variable is not defined it defaults to a value of 2 to support
887Windows 2000.
888
Bram Moolenaar8299df92004-07-10 09:47:34 +0000889A second option covers whether *.btm files should be detected as type
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000890"dosbatch" (MS-DOS batch files) or type "btm" (4DOS batch files). The latter
891is used by default. You may select the former with the following line: >
Bram Moolenaar8299df92004-07-10 09:47:34 +0000892
893 :let g:dosbatch_syntax_for_btm = 1
894
895If this variable is undefined or zero, btm syntax is selected.
896
897
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000898DOXYGEN *doxygen.vim* *doxygen-syntax*
899
900Doxygen generates code documentation using a special documentation format
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000901(similar to Javadoc). This syntax script adds doxygen highlighting to c, cpp,
902idl and php files, and should also work with java.
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000903
Bram Moolenaar25394022007-05-10 19:06:20 +0000904There are a few of ways to turn on doxygen formatting. It can be done
905explicitly or in a modeline by appending '.doxygen' to the syntax of the file.
906Example: >
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000907 :set syntax=c.doxygen
908or >
909 // vim:syntax=c.doxygen
910
Bram Moolenaar25394022007-05-10 19:06:20 +0000911It can also be done automatically for c, cpp and idl files by setting the
912global or buffer-local variable load_doxygen_syntax. This is done by adding
913the following to your .vimrc. >
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000914 :let g:load_doxygen_syntax=1
915
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200916There are a couple of variables that have an effect on syntax highlighting, and
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000917are to do with non-standard highlighting options.
918
919Variable Default Effect ~
920g:doxygen_enhanced_color
921g:doxygen_enhanced_colour 0 Use non-standard highlighting for
922 doxygen comments.
923
924doxygen_my_rendering 0 Disable rendering of HTML bold, italic
925 and html_my_rendering underline.
926
927doxygen_javadoc_autobrief 1 Set to 0 to disable javadoc autobrief
928 colour highlighting.
929
930doxygen_end_punctuation '[.]' Set to regexp match for the ending
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000931 punctuation of brief
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000932
933There are also some hilight groups worth mentioning as they can be useful in
934configuration.
935
936Highlight Effect ~
937doxygenErrorComment The colour of an end-comment when missing
938 punctuation in a code, verbatim or dot section
939doxygenLinkError The colour of an end-comment when missing the
940 \endlink from a \link section.
941
Bram Moolenaar071d4272004-06-13 20:20:40 +0000942
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000943DTD *dtd.vim* *ft-dtd-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000944
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000945The DTD syntax highlighting is case sensitive by default. To disable
Bram Moolenaar071d4272004-06-13 20:20:40 +0000946case-sensitive highlighting, add the following line to your startup file: >
947
948 :let dtd_ignore_case=1
949
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000950The DTD syntax file will highlight unknown tags as errors. If
Bram Moolenaar071d4272004-06-13 20:20:40 +0000951this is annoying, it can be turned off by setting: >
952
953 :let dtd_no_tag_errors=1
954
955before sourcing the dtd.vim syntax file.
956Parameter entity names are highlighted in the definition using the
957'Type' highlighting group and 'Comment' for punctuation and '%'.
958Parameter entity instances are highlighted using the 'Constant'
959highlighting group and the 'Type' highlighting group for the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000960delimiters % and ;. This can be turned off by setting: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961
962 :let dtd_no_param_entities=1
963
964The DTD syntax file is also included by xml.vim to highlight included dtd's.
965
966
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000967EIFFEL *eiffel.vim* *ft-eiffel-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000968
969While Eiffel is not case-sensitive, its style guidelines are, and the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000970syntax highlighting file encourages their use. This also allows to
971highlight class names differently. If you want to disable case-sensitive
Bram Moolenaar071d4272004-06-13 20:20:40 +0000972highlighting, add the following line to your startup file: >
973
974 :let eiffel_ignore_case=1
975
976Case still matters for class names and TODO marks in comments.
977
978Conversely, for even stricter checks, add one of the following lines: >
979
980 :let eiffel_strict=1
981 :let eiffel_pedantic=1
982
983Setting eiffel_strict will only catch improper capitalization for the
984five predefined words "Current", "Void", "Result", "Precursor", and
985"NONE", to warn against their accidental use as feature or class names.
986
987Setting eiffel_pedantic will enforce adherence to the Eiffel style
988guidelines fairly rigorously (like arbitrary mixes of upper- and
989lowercase letters as well as outdated ways to capitalize keywords).
990
991If you want to use the lower-case version of "Current", "Void",
992"Result", and "Precursor", you can use >
993
994 :let eiffel_lower_case_predef=1
995
996instead of completely turning case-sensitive highlighting off.
997
998Support for ISE's proposed new creation syntax that is already
999experimentally handled by some compilers can be enabled by: >
1000
1001 :let eiffel_ise=1
1002
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001003Finally, some vendors support hexadecimal constants. To handle them, add >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001004
1005 :let eiffel_hex_constants=1
1006
1007to your startup file.
1008
1009
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001010ERLANG *erlang.vim* *ft-erlang-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001011
1012The erlang highlighting supports Erlang (ERicsson LANGuage).
1013Erlang is case sensitive and default extension is ".erl".
1014
1015If you want to disable keywords highlighting, put in your .vimrc: >
1016 :let erlang_keywords = 1
1017If you want to disable built-in-functions highlighting, put in your
1018.vimrc file: >
1019 :let erlang_functions = 1
1020If you want to disable special characters highlighting, put in
1021your .vimrc: >
1022 :let erlang_characters = 1
1023
1024
Bram Moolenaard68071d2006-05-02 22:08:30 +00001025FLEXWIKI *flexwiki.vim* *ft-flexwiki-syntax*
1026
1027FlexWiki is an ASP.NET-based wiki package available at http://www.flexwiki.com
1028
1029Syntax highlighting is available for the most common elements of FlexWiki
1030syntax. The associated ftplugin script sets some buffer-local options to make
1031editing FlexWiki pages more convenient. FlexWiki considers a newline as the
1032start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length),
1033'wrap' (wrap long lines instead of using horizontal scrolling), 'linebreak'
1034(to wrap at a character in 'breakat' instead of at the last char on screen),
1035and so on. It also includes some keymaps that are disabled by default.
1036
1037If you want to enable the keymaps that make "j" and "k" and the cursor keys
1038move up and down by display lines, add this to your .vimrc: >
1039 :let flexwiki_maps = 1
1040
1041
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001042FORM *form.vim* *ft-form-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043
1044The coloring scheme for syntax elements in the FORM file uses the default
1045modes Conditional, Number, Statement, Comment, PreProc, Type, and String,
Bram Moolenaardd2a0d82007-05-12 15:07:00 +00001046following the language specifications in 'Symbolic Manipulation with FORM' by
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047J.A.M. Vermaseren, CAN, Netherlands, 1991.
1048
1049If you want include your own changes to the default colors, you have to
1050redefine the following syntax groups:
1051
1052 - formConditional
1053 - formNumber
1054 - formStatement
1055 - formHeaderStatement
1056 - formComment
1057 - formPreProc
1058 - formDirective
1059 - formType
1060 - formString
1061
1062Note that the form.vim syntax file implements FORM preprocessor commands and
1063directives per default in the same syntax group.
1064
1065A predefined enhanced color mode for FORM is available to distinguish between
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001066header statements and statements in the body of a FORM program. To activate
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067this mode define the following variable in your vimrc file >
1068
1069 :let form_enhanced_color=1
1070
1071The enhanced mode also takes advantage of additional color features for a dark
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001072gvim display. Here, statements are colored LightYellow instead of Yellow, and
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073conditionals are LightBlue for better distinction.
1074
1075
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001076FORTRAN *fortran.vim* *ft-fortran-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077
1078Default highlighting and dialect ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001079Highlighting appropriate for f95 (Fortran 95) is used by default. This choice
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080should be appropriate for most users most of the time because Fortran 95 is a
1081superset of Fortran 90 and almost a superset of Fortran 77.
1082
1083Fortran source code form ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001084Fortran 9x code can be in either fixed or free source form. Note that the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085syntax highlighting will not be correct if the form is incorrectly set.
1086
1087When you create a new fortran file, the syntax script assumes fixed source
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001088form. If you always use free source form, then >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 :let fortran_free_source=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001090in your .vimrc prior to the :syntax on command. If you always use fixed source
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091form, then >
1092 :let fortran_fixed_source=1
1093in your .vimrc prior to the :syntax on command.
1094
1095If the form of the source code depends upon the file extension, then it is
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001096most convenient to set fortran_free_source in a ftplugin file. For more
1097information on ftplugin files, see |ftplugin|. For example, if all your
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098fortran files with an .f90 extension are written in free source form and the
1099rest in fixed source form, add the following code to your ftplugin file >
1100 let s:extfname = expand("%:e")
1101 if s:extfname ==? "f90"
1102 let fortran_free_source=1
1103 unlet! fortran_fixed_source
1104 else
1105 let fortran_fixed_source=1
1106 unlet! fortran_free_source
1107 endif
1108Note that this will work only if the "filetype plugin indent on" command
1109precedes the "syntax on" command in your .vimrc file.
1110
1111When you edit an existing fortran file, the syntax script will assume free
1112source form if the fortran_free_source variable has been set, and assumes
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001113fixed source form if the fortran_fixed_source variable has been set. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114neither of these variables have been set, the syntax script attempts to
1115determine which source form has been used by examining the first five columns
Bram Moolenaar910f66f2006-04-05 20:41:53 +00001116of the first 250 lines of your file. If no signs of free source form are
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001117detected, then the file is assumed to be in fixed source form. The algorithm
1118should work in the vast majority of cases. In some cases, such as a file that
Bram Moolenaar910f66f2006-04-05 20:41:53 +00001119begins with 250 or more full-line comments, the script may incorrectly decide
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001120that the fortran code is in fixed form. If that happens, just add a
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121non-comment statement beginning anywhere in the first five columns of the
1122first twenty five lines, save (:w) and then reload (:e!) the file.
1123
1124Tabs in fortran files ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001125Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
Bram Moolenaar071d4272004-06-13 20:20:40 +00001126fixed format fortran source code which requires fixed column boundaries.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001127Therefore, tabs are marked as errors. Nevertheless, some programmers like
1128using tabs. If your fortran files contain tabs, then you should set the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129variable fortran_have_tabs in your .vimrc with a command such as >
1130 :let fortran_have_tabs=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001131placed prior to the :syntax on command. Unfortunately, the use of tabs will
Bram Moolenaar071d4272004-06-13 20:20:40 +00001132mean that the syntax file will not be able to detect incorrect margins.
1133
1134Syntax folding of fortran files ~
1135If you wish to use foldmethod=syntax, then you must first set the variable
1136fortran_fold with a command such as >
1137 :let fortran_fold=1
1138to instruct the syntax script to define fold regions for program units, that
1139is main programs starting with a program statement, subroutines, function
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001140subprograms, block data subprograms, interface blocks, and modules. If you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141also set the variable fortran_fold_conditionals with a command such as >
1142 :let fortran_fold_conditionals=1
1143then fold regions will also be defined for do loops, if blocks, and select
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001144case constructs. If you also set the variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145fortran_fold_multilinecomments with a command such as >
1146 :let fortran_fold_multilinecomments=1
1147then fold regions will also be defined for three or more consecutive comment
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001148lines. Note that defining fold regions can be slow for large files.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149
1150If fortran_fold, and possibly fortran_fold_conditionals and/or
1151fortran_fold_multilinecomments, have been set, then vim will fold your file if
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001152you set foldmethod=syntax. Comments or blank lines placed between two program
Bram Moolenaar071d4272004-06-13 20:20:40 +00001153units are not folded because they are seen as not belonging to any program
1154unit.
1155
1156More precise fortran syntax ~
1157If you set the variable fortran_more_precise with a command such as >
1158 :let fortran_more_precise=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001159then the syntax coloring will be more precise but slower. In particular,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160statement labels used in do, goto and arithmetic if statements will be
1161recognized, as will construct names at the end of a do, if, select or forall
1162construct.
1163
1164Non-default fortran dialects ~
1165The syntax script supports five Fortran dialects: f95, f90, f77, the Lahey
1166subset elf90, and the Imagine1 subset F.
1167
1168If you use f77 with extensions, even common ones like do/enddo loops, do/while
1169loops and free source form that are supported by most f77 compilers including
1170g77 (GNU Fortran), then you will probably find the default highlighting
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001171satisfactory. However, if you use strict f77 with no extensions, not even free
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172source form or the MIL STD 1753 extensions, then the advantages of setting the
1173dialect to f77 are that names such as SUM are recognized as user variable
1174names and not highlighted as f9x intrinsic functions, that obsolete constructs
1175such as ASSIGN statements are not highlighted as todo items, and that fixed
1176source form will be assumed.
1177
1178If you use elf90 or F, the advantage of setting the dialect appropriately is
1179that f90 features excluded from these dialects will be highlighted as todo
1180items and that free source form will be assumed as required for these
1181dialects.
1182
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001183The dialect can be selected by setting the variable fortran_dialect. The
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184permissible values of fortran_dialect are case-sensitive and must be "f95",
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001185"f90", "f77", "elf" or "F". Invalid values of fortran_dialect are ignored.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001186
1187If all your fortran files use the same dialect, set fortran_dialect in your
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001188.vimrc prior to your syntax on statement. If the dialect depends upon the file
1189extension, then it is most convenient to set it in a ftplugin file. For more
1190information on ftplugin files, see |ftplugin|. For example, if all your
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191fortran files with an .f90 extension are written in the elf subset, your
1192ftplugin file should contain the code >
1193 let s:extfname = expand("%:e")
1194 if s:extfname ==? "f90"
1195 let fortran_dialect="elf"
1196 else
1197 unlet! fortran_dialect
1198 endif
1199Note that this will work only if the "filetype plugin indent on" command
1200precedes the "syntax on" command in your .vimrc file.
1201
1202Finer control is necessary if the file extension does not uniquely identify
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001203the dialect. You can override the default dialect, on a file-by-file basis, by
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204including a comment with the directive "fortran_dialect=xx" (where xx=f77 or
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001205elf or F or f90 or f95) in one of the first three lines in your file. For
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206example, your older .f files may be written in extended f77 but your newer
1207ones may be F codes, and you would identify the latter by including in the
1208first three lines of those files a Fortran comment of the form >
1209 ! fortran_dialect=F
1210F overrides elf if both directives are present.
1211
1212Limitations ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001213Parenthesis checking does not catch too few closing parentheses. Hollerith
1214strings are not recognized. Some keywords may be highlighted incorrectly
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215because Fortran90 has no reserved words.
1216
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001217For further information related to fortran, see |ft-fortran-indent| and
1218|ft-fortran-plugin|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001219
1220
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001221FVWM CONFIGURATION FILES *fvwm.vim* *ft-fvwm-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222
1223In order for Vim to recognize Fvwm configuration files that do not match
1224the patterns *fvwmrc* or *fvwm2rc* , you must put additional patterns
1225appropriate to your system in your myfiletypes.vim file. For these
1226patterns, you must set the variable "b:fvwm_version" to the major version
1227number of Fvwm, and the 'filetype' option to fvwm.
1228
1229For example, to make Vim identify all files in /etc/X11/fvwm2/
1230as Fvwm2 configuration files, add the following: >
1231
1232 :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 |
1233 \ set filetype=fvwm
1234
1235If you'd like Vim to highlight all valid color names, tell it where to
1236find the color database (rgb.txt) on your system. Do this by setting
1237"rgb_file" to its location. Assuming your color database is located
1238in /usr/X11/lib/X11/, you should add the line >
1239
1240 :let rgb_file = "/usr/X11/lib/X11/rgb.txt"
1241
1242to your .vimrc file.
1243
1244
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001245GSP *gsp.vim* *ft-gsp-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001246
1247The default coloring style for GSP pages is defined by |html.vim|, and
1248the coloring for java code (within java tags or inline between backticks)
1249is defined by |java.vim|. The following HTML groups defined in |html.vim|
1250are redefined to incorporate and highlight inline java code:
1251
1252 htmlString
1253 htmlValue
1254 htmlEndTag
1255 htmlTag
1256 htmlTagN
1257
1258Highlighting should look fine most of the places where you'd see inline
1259java code, but in some special cases it may not. To add another HTML
1260group where you will have inline java code where it does not highlight
1261correctly, just copy the line you want from |html.vim| and add gspJava
1262to the contains clause.
1263
1264The backticks for inline java are highlighted according to the htmlError
1265group to make them easier to see.
1266
1267
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001268GROFF *groff.vim* *ft-groff-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269
1270The groff syntax file is a wrapper for |nroff.vim|, see the notes
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001271under that heading for examples of use and configuration. The purpose
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272of this wrapper is to set up groff syntax extensions by setting the
1273filetype from a |modeline| or in a personal filetype definitions file
1274(see |filetype.txt|).
1275
1276
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001277HASKELL *haskell.vim* *lhaskell.vim* *ft-haskell-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278
1279The Haskell syntax files support plain Haskell code as well as literate
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001280Haskell code, the latter in both Bird style and TeX style. The Haskell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281syntax highlighting will also highlight C preprocessor directives.
1282
1283If you want to highlight delimiter characters (useful if you have a
1284light-coloured background), add to your .vimrc: >
1285 :let hs_highlight_delimiters = 1
1286To treat True and False as keywords as opposed to ordinary identifiers,
1287add: >
1288 :let hs_highlight_boolean = 1
1289To also treat the names of primitive types as keywords: >
1290 :let hs_highlight_types = 1
1291And to treat the names of even more relatively common types as keywords: >
1292 :let hs_highlight_more_types = 1
1293If you want to highlight the names of debugging functions, put in
1294your .vimrc: >
1295 :let hs_highlight_debug = 1
1296
1297The Haskell syntax highlighting also highlights C preprocessor
1298directives, and flags lines that start with # but are not valid
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001299directives as erroneous. This interferes with Haskell's syntax for
1300operators, as they may start with #. If you want to highlight those
Bram Moolenaar071d4272004-06-13 20:20:40 +00001301as operators as opposed to errors, put in your .vimrc: >
1302 :let hs_allow_hash_operator = 1
1303
1304The syntax highlighting for literate Haskell code will try to
1305automatically guess whether your literate Haskell code contains
1306TeX markup or not, and correspondingly highlight TeX constructs
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001307or nothing at all. You can override this globally by putting
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308in your .vimrc >
1309 :let lhs_markup = none
1310for no highlighting at all, or >
1311 :let lhs_markup = tex
1312to force the highlighting to always try to highlight TeX markup.
1313For more flexibility, you may also use buffer local versions of
1314this variable, so e.g. >
1315 :let b:lhs_markup = tex
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001316will force TeX highlighting for a particular buffer. It has to be
Bram Moolenaar071d4272004-06-13 20:20:40 +00001317set before turning syntax highlighting on for the buffer or
1318loading a file.
1319
1320
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001321HTML *html.vim* *ft-html-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001322
1323The coloring scheme for tags in the HTML file works as follows.
1324
1325The <> of opening tags are colored differently than the </> of a closing tag.
1326This is on purpose! For opening tags the 'Function' color is used, while for
1327closing tags the 'Type' color is used (See syntax.vim to check how those are
1328defined for you)
1329
1330Known tag names are colored the same way as statements in C. Unknown tag
1331names are colored with the same color as the <> or </> respectively which
1332makes it easy to spot errors
1333
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001334Note that the same is true for argument (or attribute) names. Known attribute
Bram Moolenaar071d4272004-06-13 20:20:40 +00001335names are colored differently than unknown ones.
1336
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001337Some HTML tags are used to change the rendering of text. The following tags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338are recognized by the html.vim syntax coloring file and change the way normal
1339text is shown: <B> <I> <U> <EM> <STRONG> (<EM> is used as an alias for <I>,
1340while <STRONG> as an alias for <B>), <H1> - <H6>, <HEAD>, <TITLE> and <A>, but
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001341only if used as a link (that is, it must include a href as in
Bram Moolenaar25394022007-05-10 19:06:20 +00001342<A href="somefile.html">).
Bram Moolenaar071d4272004-06-13 20:20:40 +00001343
1344If you want to change how such text is rendered, you must redefine the
1345following syntax groups:
1346
1347 - htmlBold
1348 - htmlBoldUnderline
1349 - htmlBoldUnderlineItalic
1350 - htmlUnderline
1351 - htmlUnderlineItalic
1352 - htmlItalic
1353 - htmlTitle for titles
1354 - htmlH1 - htmlH6 for headings
1355
1356To make this redefinition work you must redefine them all with the exception
1357of the last two (htmlTitle and htmlH[1-6], which are optional) and define the
1358following variable in your vimrc (this is due to the order in which the files
1359are read during initialization) >
1360 :let html_my_rendering=1
1361
1362If you'd like to see an example download mysyntax.vim at
1363http://www.fleiner.com/vim/download.html
1364
1365You can also disable this rendering by adding the following line to your
1366vimrc file: >
1367 :let html_no_rendering=1
1368
1369HTML comments are rather special (see an HTML reference document for the
1370details), and the syntax coloring scheme will highlight all errors.
1371However, if you prefer to use the wrong style (starts with <!-- and
1372ends with --!>) you can define >
1373 :let html_wrong_comments=1
1374
1375JavaScript and Visual Basic embedded inside HTML documents are highlighted as
1376'Special' with statements, comments, strings and so on colored as in standard
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001377programming languages. Note that only JavaScript and Visual Basic are currently
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378supported, no other scripting language has been added yet.
1379
1380Embedded and inlined cascading style sheets (CSS) are highlighted too.
1381
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001382There are several html preprocessor languages out there. html.vim has been
1383written such that it should be trivial to include it. To do so add the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001384following two lines to the syntax coloring file for that language
1385(the example comes from the asp.vim file):
1386
1387 runtime! syntax/html.vim
1388 syn cluster htmlPreproc add=asp
1389
1390Now you just need to make sure that you add all regions that contain
1391the preprocessor language to the cluster htmlPreproc.
1392
1393
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001394HTML/OS (by Aestiva) *htmlos.vim* *ft-htmlos-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001395
1396The coloring scheme for HTML/OS works as follows:
1397
1398Functions and variable names are the same color by default, because VIM
1399doesn't specify different colors for Functions and Identifiers. To change
1400this (which is recommended if you want function names to be recognizable in a
1401different color) you need to add the following line to either your ~/.vimrc: >
1402 :hi Function term=underline cterm=bold ctermfg=LightGray
1403
1404Of course, the ctermfg can be a different color if you choose.
1405
1406Another issues that HTML/OS runs into is that there is no special filetype to
1407signify that it is a file with HTML/OS coding. You can change this by opening
1408a file and turning on HTML/OS syntax by doing the following: >
1409 :set syntax=htmlos
1410
1411Lastly, it should be noted that the opening and closing characters to begin a
1412block of HTML/OS code can either be << or [[ and >> or ]], respectively.
1413
1414
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001415IA64 *ia64.vim* *intel-itanium* *ft-ia64-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001416
1417Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
1418how to recognize this filetype.
1419
1420To have *.inc files be recognized as IA64, add this to your .vimrc file: >
1421 :let g:filetype_inc = "ia64"
1422
1423
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001424INFORM *inform.vim* *ft-inform-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001425
1426Inform highlighting includes symbols provided by the Inform Library, as
1427most programs make extensive use of it. If do not wish Library symbols
1428to be highlighted add this to your vim startup: >
1429 :let inform_highlight_simple=1
1430
1431By default it is assumed that Inform programs are Z-machine targeted,
1432and highlights Z-machine assembly language symbols appropriately. If
1433you intend your program to be targeted to a Glulx/Glk environment you
1434need to add this to your startup sequence: >
1435 :let inform_highlight_glulx=1
1436
1437This will highlight Glulx opcodes instead, and also adds glk() to the
1438set of highlighted system functions.
1439
1440The Inform compiler will flag certain obsolete keywords as errors when
1441it encounters them. These keywords are normally highlighted as errors
1442by Vim. To prevent such error highlighting, you must add this to your
1443startup sequence: >
1444 :let inform_suppress_obsolete=1
1445
1446By default, the language features highlighted conform to Compiler
1447version 6.30 and Library version 6.11. If you are using an older
1448Inform development environment, you may with to add this to your
1449startup sequence: >
1450 :let inform_highlight_old=1
1451
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001452IDL *idl.vim* *idl-syntax*
1453
1454IDL (Interface Definition Language) files are used to define RPC calls. In
1455Microsoft land, this is also used for defining COM interfaces and calls.
1456
1457IDL's structure is simple enough to permit a full grammar based approach to
1458rather than using a few heuristics. The result is large and somewhat
Bram Moolenaar25394022007-05-10 19:06:20 +00001459repetitive but seems to work.
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001460
1461There are some Microsoft extensions to idl files that are here. Some of them
1462are disabled by defining idl_no_ms_extensions.
1463
1464The more complex of the extensions are disabled by defining idl_no_extensions.
1465
1466Variable Effect ~
1467
1468idl_no_ms_extensions Disable some of the Microsoft specific
1469 extensions
1470idl_no_extensions Disable complex extensions
1471idlsyntax_showerror Show IDL errors (can be rather intrusive, but
1472 quite helpful)
1473idlsyntax_showerror_soft Use softer colours by default for errors
1474
Bram Moolenaar071d4272004-06-13 20:20:40 +00001475
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001476JAVA *java.vim* *ft-java-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001477
1478The java.vim syntax highlighting file offers several options:
1479
1480In Java 1.0.2 it was never possible to have braces inside parens, so this was
1481flagged as an error. Since Java 1.1 this is possible (with anonymous
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001482classes), and therefore is no longer marked as an error. If you prefer the old
Bram Moolenaar071d4272004-06-13 20:20:40 +00001483way, put the following line into your vim startup file: >
1484 :let java_mark_braces_in_parens_as_errors=1
1485
1486All identifiers in java.lang.* are always visible in all classes. To
1487highlight them use: >
1488 :let java_highlight_java_lang_ids=1
1489
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001490You can also highlight identifiers of most standard Java packages if you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001491download the javaid.vim script at http://www.fleiner.com/vim/download.html.
1492If you prefer to only highlight identifiers of a certain package, say java.io
1493use the following: >
1494 :let java_highlight_java_io=1
1495Check the javaid.vim file for a list of all the packages that are supported.
1496
1497Function names are not highlighted, as the way to find functions depends on
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001498how you write Java code. The syntax file knows two possible ways to highlight
Bram Moolenaar071d4272004-06-13 20:20:40 +00001499functions:
1500
1501If you write function declarations that are always indented by either
1502a tab, 8 spaces or 2 spaces you may want to set >
1503 :let java_highlight_functions="indent"
1504However, if you follow the Java guidelines about how functions and classes are
1505supposed to be named (with respect to upper and lowercase), use >
1506 :let java_highlight_functions="style"
1507If both options do not work for you, but you would still want function
1508declarations to be highlighted create your own definitions by changing the
1509definitions in java.vim or by creating your own java.vim which includes the
1510original one and then adds the code to highlight functions.
1511
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001512In Java 1.1 the functions System.out.println() and System.err.println() should
Bram Moolenaared203462004-06-16 11:19:22 +00001513only be used for debugging. Therefore it is possible to highlight debugging
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001514statements differently. To do this you must add the following definition in
Bram Moolenaar071d4272004-06-13 20:20:40 +00001515your startup file: >
1516 :let java_highlight_debug=1
1517The result will be that those statements are highlighted as 'Special'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001518characters. If you prefer to have them highlighted differently you must define
Bram Moolenaar071d4272004-06-13 20:20:40 +00001519new highlightings for the following groups.:
1520 Debug, DebugSpecial, DebugString, DebugBoolean, DebugType
1521which are used for the statement itself, special characters used in debug
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001522strings, strings, boolean constants and types (this, super) respectively. I
Bram Moolenaar071d4272004-06-13 20:20:40 +00001523have opted to chose another background for those statements.
1524
Bram Moolenaar8c8de832008-06-24 22:58:06 +00001525In order to help you write code that can be easily ported between Java and
1526C++, all C++ keywords can be marked as an error in a Java program. To
1527have this add this line in your .vimrc file: >
1528 :let java_allow_cpp_keywords = 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001529
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001530Javadoc is a program that takes special comments out of Java program files and
1531creates HTML pages. The standard configuration will highlight this HTML code
1532similarly to HTML files (see |html.vim|). You can even add Javascript
1533and CSS inside this code (see below). There are four differences however:
Bram Moolenaar071d4272004-06-13 20:20:40 +00001534 1. The title (all characters up to the first '.' which is followed by
1535 some white space or up to the first '@') is colored differently (to change
1536 the color change the group CommentTitle).
1537 2. The text is colored as 'Comment'.
1538 3. HTML comments are colored as 'Special'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001539 4. The special Javadoc tags (@see, @param, ...) are highlighted as specials
Bram Moolenaar071d4272004-06-13 20:20:40 +00001540 and the argument (for @see, @param, @exception) as Function.
1541To turn this feature off add the following line to your startup file: >
1542 :let java_ignore_javadoc=1
1543
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001544If you use the special Javadoc comment highlighting described above you
1545can also turn on special highlighting for Javascript, visual basic
1546scripts and embedded CSS (stylesheets). This makes only sense if you
1547actually have Javadoc comments that include either Javascript or embedded
1548CSS. The options to use are >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001549 :let java_javascript=1
1550 :let java_css=1
1551 :let java_vb=1
1552
1553In order to highlight nested parens with different colors define colors
1554for javaParen, javaParen1 and javaParen2, for example with >
1555 :hi link javaParen Comment
1556or >
1557 :hi javaParen ctermfg=blue guifg=#0000ff
1558
1559If you notice highlighting errors while scrolling backwards, which are fixed
1560when redrawing with CTRL-L, try setting the "java_minlines" internal variable
1561to a larger number: >
1562 :let java_minlines = 50
1563This will make the syntax synchronization start 50 lines before the first
1564displayed line. The default value is 10. The disadvantage of using a larger
1565number is that redrawing can become slow.
1566
1567
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001568LACE *lace.vim* *ft-lace-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001569
1570Lace (Language for Assembly of Classes in Eiffel) is case insensitive, but the
1571style guide lines are not. If you prefer case insensitive highlighting, just
1572define the vim variable 'lace_case_insensitive' in your startup file: >
1573 :let lace_case_insensitive=1
1574
1575
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001576LEX *lex.vim* *ft-lex-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001577
1578Lex uses brute-force synchronizing as the "^%%$" section delimiter
1579gives no clue as to what section follows. Consequently, the value for >
1580 :syn sync minlines=300
1581may be changed by the user if s/he is experiencing synchronization
1582difficulties (such as may happen with large lex files).
1583
1584
Bram Moolenaara5fac542005-10-12 20:58:49 +00001585LISP *lisp.vim* *ft-lisp-syntax*
1586
1587The lisp syntax highlighting provides two options: >
1588
1589 g:lisp_instring : if it exists, then "(...)" strings are highlighted
1590 as if the contents of the string were lisp.
1591 Useful for AutoLisp.
1592 g:lisp_rainbow : if it exists and is nonzero, then differing levels
1593 of parenthesization will receive different
1594 highlighting.
1595<
1596The g:lisp_rainbow option provides 10 levels of individual colorization for
1597the parentheses and backquoted parentheses. Because of the quantity of
1598colorization levels, unlike non-rainbow highlighting, the rainbow mode
1599specifies its highlighting using ctermfg and guifg, thereby bypassing the
1600usual colorscheme control using standard highlighting groups. The actual
1601highlighting used depends on the dark/bright setting (see |'bg'|).
1602
1603
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001604LITE *lite.vim* *ft-lite-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001605
1606There are two options for the lite syntax highlighting.
1607
1608If you like SQL syntax highlighting inside Strings, use this: >
1609
1610 :let lite_sql_query = 1
1611
1612For syncing, minlines defaults to 100. If you prefer another value, you can
1613set "lite_minlines" to the value you desire. Example: >
1614
1615 :let lite_minlines = 200
1616
1617
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001618LPC *lpc.vim* *ft-lpc-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001619
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001620LPC stands for a simple, memory-efficient language: Lars Pensj| C. The
Bram Moolenaar071d4272004-06-13 20:20:40 +00001621file name of LPC is usually *.c. Recognizing these files as LPC would bother
1622users writing only C programs. If you want to use LPC syntax in Vim, you
1623should set a variable in your .vimrc file: >
1624
1625 :let lpc_syntax_for_c = 1
1626
1627If it doesn't work properly for some particular C or LPC files, use a
1628modeline. For a LPC file:
1629
1630 // vim:set ft=lpc:
1631
1632For a C file that is recognized as LPC:
1633
1634 // vim:set ft=c:
1635
1636If you don't want to set the variable, use the modeline in EVERY LPC file.
1637
1638There are several implementations for LPC, we intend to support most widely
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001639used ones. Here the default LPC syntax is for MudOS series, for MudOS v22
Bram Moolenaar071d4272004-06-13 20:20:40 +00001640and before, you should turn off the sensible modifiers, and this will also
1641asserts the new efuns after v22 to be invalid, don't set this variable when
1642you are using the latest version of MudOS: >
1643
1644 :let lpc_pre_v22 = 1
1645
1646For LpMud 3.2 series of LPC: >
1647
1648 :let lpc_compat_32 = 1
1649
1650For LPC4 series of LPC: >
1651
1652 :let lpc_use_lpc4_syntax = 1
1653
1654For uLPC series of LPC:
1655uLPC has been developed to Pike, so you should use Pike syntax
1656instead, and the name of your source file should be *.pike
1657
1658
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001659LUA *lua.vim* *ft-lua-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001660
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001661This syntax file may be used for Lua 4.0, Lua 5.0 or Lua 5.1 (the latter is
1662the default). You can select one of these versions using the global variables
1663lua_version and lua_subversion. For example, to activate Lua
16644.0 syntax highlighting, use this command: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001665
1666 :let lua_version = 4
1667
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001668If you are using Lua 5.0, use these commands: >
1669
1670 :let lua_version = 5
1671 :let lua_subversion = 0
1672
1673To restore highlighting for Lua 5.1: >
1674
1675 :let lua_version = 5
1676 :let lua_subversion = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001677
1678
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001679MAIL *mail.vim* *ft-mail.vim*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001680
1681Vim highlights all the standard elements of an email (headers, signatures,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001682quoted text and URLs / email addresses). In keeping with standard conventions,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001683signatures begin in a line containing only "--" followed optionally by
1684whitespaces and end with a newline.
1685
1686Vim treats lines beginning with ']', '}', '|', '>' or a word followed by '>'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001687as quoted text. However Vim highlights headers and signatures in quoted text
Bram Moolenaar071d4272004-06-13 20:20:40 +00001688only if the text is quoted with '>' (optionally followed by one space).
1689
1690By default mail.vim synchronises syntax to 100 lines before the first
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001691displayed line. If you have a slow machine, and generally deal with emails
Bram Moolenaar071d4272004-06-13 20:20:40 +00001692with short headers, you can change this to a smaller value: >
1693
1694 :let mail_minlines = 30
1695
1696
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001697MAKE *make.vim* *ft-make-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001698
1699In makefiles, commands are usually highlighted to make it easy for you to spot
1700errors. However, this may be too much coloring for you. You can turn this
1701feature off by using: >
1702
1703 :let make_no_commands = 1
1704
1705
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001706MAPLE *maple.vim* *ft-maple-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001707
1708Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
1709supports many packages of functions which are selectively loaded by the user.
1710The standard set of packages' functions as supplied in Maple V release 4 may be
1711highlighted at the user's discretion. Users may place in their .vimrc file: >
1712
1713 :let mvpkg_all= 1
1714
1715to get all package functions highlighted, or users may select any subset by
1716choosing a variable/package from the table below and setting that variable to
17171, also in their .vimrc file (prior to sourcing
1718$VIMRUNTIME/syntax/syntax.vim).
1719
1720 Table of Maple V Package Function Selectors >
1721 mv_DEtools mv_genfunc mv_networks mv_process
1722 mv_Galois mv_geometry mv_numapprox mv_simplex
1723 mv_GaussInt mv_grobner mv_numtheory mv_stats
1724 mv_LREtools mv_group mv_orthopoly mv_student
1725 mv_combinat mv_inttrans mv_padic mv_sumtools
1726 mv_combstruct mv_liesymm mv_plots mv_tensor
1727 mv_difforms mv_linalg mv_plottools mv_totorder
1728 mv_finance mv_logic mv_powseries
1729
1730
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001731MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +00001732
1733Empty *.m files will automatically be presumed to be Matlab files unless you
1734have the following in your .vimrc: >
1735
1736 let filetype_m = "mma"
1737
1738
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001739MOO *moo.vim* *ft-moo-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001740
1741If you use C-style comments inside expressions and find it mangles your
1742highlighting, you may want to use extended (slow!) matches for C-style
1743comments: >
1744
1745 :let moo_extended_cstyle_comments = 1
1746
1747To disable highlighting of pronoun substitution patterns inside strings: >
1748
1749 :let moo_no_pronoun_sub = 1
1750
1751To disable highlighting of the regular expression operator '%|', and matching
1752'%(' and '%)' inside strings: >
1753
1754 :let moo_no_regexp = 1
1755
1756Unmatched double quotes can be recognized and highlighted as errors: >
1757
1758 :let moo_unmatched_quotes = 1
1759
1760To highlight builtin properties (.name, .location, .programmer etc.): >
1761
1762 :let moo_builtin_properties = 1
1763
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001764Unknown builtin functions can be recognized and highlighted as errors. If you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001765use this option, add your own extensions to the mooKnownBuiltinFunction group.
1766To enable this option: >
1767
1768 :let moo_unknown_builtin_functions = 1
1769
1770An example of adding sprintf() to the list of known builtin functions: >
1771
1772 :syn keyword mooKnownBuiltinFunction sprintf contained
1773
1774
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001775MSQL *msql.vim* *ft-msql-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776
1777There are two options for the msql syntax highlighting.
1778
1779If you like SQL syntax highlighting inside Strings, use this: >
1780
1781 :let msql_sql_query = 1
1782
1783For syncing, minlines defaults to 100. If you prefer another value, you can
1784set "msql_minlines" to the value you desire. Example: >
1785
1786 :let msql_minlines = 200
1787
1788
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001789NCF *ncf.vim* *ft-ncf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790
1791There is one option for NCF syntax highlighting.
1792
1793If you want to have unrecognized (by ncf.vim) statements highlighted as
1794errors, use this: >
1795
1796 :let ncf_highlight_unknowns = 1
1797
1798If you don't want to highlight these errors, leave it unset.
1799
1800
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001801NROFF *nroff.vim* *ft-nroff-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802
1803The nroff syntax file works with AT&T n/troff out of the box. You need to
1804activate the GNU groff extra features included in the syntax file before you
1805can use them.
1806
1807For example, Linux and BSD distributions use groff as their default text
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001808processing package. In order to activate the extra syntax highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +00001809features for groff, add the following option to your start-up files: >
1810
1811 :let b:nroff_is_groff = 1
1812
1813Groff is different from the old AT&T n/troff that you may still find in
1814Solaris. Groff macro and request names can be longer than 2 characters and
1815there are extensions to the language primitives. For example, in AT&T troff
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001816you access the year as a 2-digit number with the request \(yr. In groff you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817can use the same request, recognized for compatibility, or you can use groff's
1818native syntax, \[yr]. Furthermore, you can use a 4-digit year directly:
1819\[year]. Macro requests can be longer than 2 characters, for example, GNU mm
1820accepts the requests ".VERBON" and ".VERBOFF" for creating verbatim
1821environments.
1822
1823In order to obtain the best formatted output g/troff can give you, you should
1824follow a few simple rules about spacing and punctuation.
1825
18261. Do not leave empty spaces at the end of lines.
1827
18282. Leave one space and one space only after an end-of-sentence period,
1829 exclamation mark, etc.
1830
18313. For reasons stated below, it is best to follow all period marks with a
1832 carriage return.
1833
1834The reason behind these unusual tips is that g/n/troff have a line breaking
1835algorithm that can be easily upset if you don't follow the rules given above.
1836
1837Unlike TeX, troff fills text line-by-line, not paragraph-by-paragraph and,
1838furthermore, it does not have a concept of glue or stretch, all horizontal and
1839vertical space input will be output as is.
1840
1841Therefore, you should be careful about not using more space between sentences
1842than you intend to have in your final document. For this reason, the common
1843practice is to insert a carriage return immediately after all punctuation
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001844marks. If you want to have "even" text in your final processed output, you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845need to maintaining regular spacing in the input text. To mark both trailing
1846spaces and two or more spaces after a punctuation as an error, use: >
1847
1848 :let nroff_space_errors = 1
1849
1850Another technique to detect extra spacing and other errors that will interfere
1851with the correct typesetting of your file, is to define an eye-catching
1852highlighting definition for the syntax groups "nroffDefinition" and
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001853"nroffDefSpecial" in your configuration files. For example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001854
1855 hi def nroffDefinition term=italic cterm=italic gui=reverse
1856 hi def nroffDefSpecial term=italic,bold cterm=italic,bold
1857 \ gui=reverse,bold
1858
1859If you want to navigate preprocessor entries in your source file as easily as
1860with section markers, you can activate the following option in your .vimrc
1861file: >
1862
1863 let b:preprocs_as_sections = 1
1864
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00001865As well, the syntax file adds an extra paragraph marker for the extended
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866paragraph macro (.XP) in the ms package.
1867
1868Finally, there is a |groff.vim| syntax file that can be used for enabling
1869groff syntax highlighting either on a file basis or globally by default.
1870
1871
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001872OCAML *ocaml.vim* *ft-ocaml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873
1874The OCaml syntax file handles files having the following prefixes: .ml,
1875.mli, .mll and .mly. By setting the following variable >
1876
1877 :let ocaml_revised = 1
1878
1879you can switch from standard OCaml-syntax to revised syntax as supported
1880by the camlp4 preprocessor. Setting the variable >
1881
1882 :let ocaml_noend_error = 1
1883
1884prevents highlighting of "end" as error, which is useful when sources
1885contain very long structures that Vim does not synchronize anymore.
1886
1887
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001888PAPP *papp.vim* *ft-papp-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889
1890The PApp syntax file handles .papp files and, to a lesser extend, .pxml
1891and .pxsl files which are all a mixture of perl/xml/html/other using xml
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001892as the top-level file format. By default everything inside phtml or pxml
1893sections is treated as a string with embedded preprocessor commands. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894you set the variable: >
1895
1896 :let papp_include_html=1
1897
1898in your startup file it will try to syntax-hilight html code inside phtml
1899sections, but this is relatively slow and much too colourful to be able to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001900edit sensibly. ;)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001901
1902The newest version of the papp.vim syntax file can usually be found at
1903http://papp.plan9.de.
1904
1905
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001906PASCAL *pascal.vim* *ft-pascal-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907
1908Files matching "*.p" could be Progress or Pascal. If the automatic detection
1909doesn't work for you, or you don't edit Progress at all, use this in your
1910startup vimrc: >
1911
1912 :let filetype_p = "pascal"
1913
1914The Pascal syntax file has been extended to take into account some extensions
1915provided by Turbo Pascal, Free Pascal Compiler and GNU Pascal Compiler.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001916Delphi keywords are also supported. By default, Turbo Pascal 7.0 features are
Bram Moolenaar071d4272004-06-13 20:20:40 +00001917enabled. If you prefer to stick with the standard Pascal keywords, add the
1918following line to your startup file: >
1919
1920 :let pascal_traditional=1
1921
1922To switch on Delphi specific constructions (such as one-line comments,
1923keywords, etc): >
1924
1925 :let pascal_delphi=1
1926
1927
1928The option pascal_symbol_operator controls whether symbol operators such as +,
1929*, .., etc. are displayed using the Operator color or not. To colorize symbol
1930operators, add the following line to your startup file: >
1931
1932 :let pascal_symbol_operator=1
1933
1934Some functions are highlighted by default. To switch it off: >
1935
1936 :let pascal_no_functions=1
1937
Bram Moolenaar996343d2010-07-04 22:20:21 +02001938Furthermore, there are specific variables for some compilers. Besides
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939pascal_delphi, there are pascal_gpc and pascal_fpc. Default extensions try to
1940match Turbo Pascal. >
1941
1942 :let pascal_gpc=1
1943
1944or >
1945
1946 :let pascal_fpc=1
1947
1948To ensure that strings are defined on a single line, you can define the
1949pascal_one_line_string variable. >
1950
1951 :let pascal_one_line_string=1
1952
1953If you dislike <Tab> chars, you can set the pascal_no_tabs variable. Tabs
1954will be highlighted as Error. >
1955
1956 :let pascal_no_tabs=1
1957
1958
1959
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001960PERL *perl.vim* *ft-perl-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001961
1962There are a number of possible options to the perl syntax highlighting.
1963
1964If you use POD files or POD segments, you might: >
1965
1966 :let perl_include_pod = 1
1967
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001968The reduce the complexity of parsing (and increase performance) you can switch
1969off two elements in the parsing of variable names and contents. >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001970
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001971To handle package references in variable and function names not differently
1972from the rest of the name (like 'PkgName::' in '$PkgName::VarName'): >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001973
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001974 :let perl_no_scope_in_variables = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001976(In Vim 6.x it was the other way around: "perl_want_scope_in_variables"
1977enabled it.)
1978
1979If you do not want complex things like '@{${"foo"}}' to be parsed: >
1980
1981 :let perl_no_extended_vars = 1
1982
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +00001983(In Vim 6.x it was the other way around: "perl_extended_vars" enabled it.)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001984
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001985The coloring strings can be changed. By default strings and qq friends will be
1986highlighted like the first line. If you set the variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00001987perl_string_as_statement, it will be highlighted as in the second line.
1988
1989 "hello world!"; qq|hello world|;
1990 ^^^^^^^^^^^^^^NN^^^^^^^^^^^^^^^N (unlet perl_string_as_statement)
1991 S^^^^^^^^^^^^SNNSSS^^^^^^^^^^^SN (let perl_string_as_statement)
1992
1993(^ = perlString, S = perlStatement, N = None at all)
1994
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001995The syncing has 3 options. The first two switch off some triggering of
Bram Moolenaar071d4272004-06-13 20:20:40 +00001996synchronization and should only be needed in case it fails to work properly.
1997If while scrolling all of a sudden the whole screen changes color completely
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001998then you should try and switch off one of those. Let me know if you can figure
Bram Moolenaar071d4272004-06-13 20:20:40 +00001999out the line that causes the mistake.
2000
2001One triggers on "^\s*sub\s*" and the other on "^[$@%]" more or less. >
2002
2003 :let perl_no_sync_on_sub
2004 :let perl_no_sync_on_global_var
2005
2006Below you can set the maximum distance VIM should look for starting points for
2007its attempts in syntax highlighting. >
2008
2009 :let perl_sync_dist = 100
2010
2011If you want to use folding with perl, set perl_fold: >
2012
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002013 :let perl_fold = 1
2014
2015If you want to fold blocks in if statements, etc. as well set the following: >
2016
2017 :let perl_fold_blocks = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00002019To avoid folding packages or subs when perl_fold is let, let the appropriate
2020variable(s): >
2021
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002022 :unlet perl_nofold_packages
2023 :unlet perl_nofold_subs
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00002024
2025
Bram Moolenaar071d4272004-06-13 20:20:40 +00002026
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002027PHP3 and PHP4 *php.vim* *php3.vim* *ft-php-syntax* *ft-php3-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002028
2029[note: previously this was called "php3", but since it now also supports php4
2030it has been renamed to "php"]
2031
2032There are the following options for the php syntax highlighting.
2033
2034If you like SQL syntax highlighting inside Strings: >
2035
2036 let php_sql_query = 1
2037
2038For highlighting the Baselib methods: >
2039
2040 let php_baselib = 1
2041
2042Enable HTML syntax highlighting inside strings: >
2043
2044 let php_htmlInStrings = 1
2045
2046Using the old colorstyle: >
2047
2048 let php_oldStyle = 1
2049
2050Enable highlighting ASP-style short tags: >
2051
2052 let php_asp_tags = 1
2053
2054Disable short tags: >
2055
2056 let php_noShortTags = 1
2057
2058For highlighting parent error ] or ): >
2059
2060 let php_parent_error_close = 1
2061
2062For skipping an php end tag, if there exists an open ( or [ without a closing
2063one: >
2064
2065 let php_parent_error_open = 1
2066
2067Enable folding for classes and functions: >
2068
2069 let php_folding = 1
2070
2071Selecting syncing method: >
2072
2073 let php_sync_method = x
2074
2075x = -1 to sync by search (default),
2076x > 0 to sync at least x lines backwards,
2077x = 0 to sync from start.
2078
2079
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00002080PLAINTEX *plaintex.vim* *ft-plaintex-syntax*
2081
2082TeX is a typesetting language, and plaintex is the file type for the "plain"
2083variant of TeX. If you never want your *.tex files recognized as plain TeX,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002084see |ft-tex-plugin|.
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00002085
2086This syntax file has the option >
2087
2088 let g:plaintex_delimiters = 1
2089
2090if you want to highlight brackets "[]" and braces "{}".
2091
2092
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002093PPWIZARD *ppwiz.vim* *ft-ppwiz-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002094
2095PPWizard is a preprocessor for HTML and OS/2 INF files
2096
2097This syntax file has the options:
2098
2099- ppwiz_highlight_defs : determines highlighting mode for PPWizard's
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002100 definitions. Possible values are
Bram Moolenaar071d4272004-06-13 20:20:40 +00002101
2102 ppwiz_highlight_defs = 1 : PPWizard #define statements retain the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002103 colors of their contents (e.g. PPWizard macros and variables)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002104
2105 ppwiz_highlight_defs = 2 : preprocessor #define and #evaluate
2106 statements are shown in a single color with the exception of line
2107 continuation symbols
2108
2109 The default setting for ppwiz_highlight_defs is 1.
2110
2111- ppwiz_with_html : If the value is 1 (the default), highlight literal
2112 HTML code; if 0, treat HTML code like ordinary text.
2113
2114
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002115PHTML *phtml.vim* *ft-phtml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002116
2117There are two options for the phtml syntax highlighting.
2118
2119If you like SQL syntax highlighting inside Strings, use this: >
2120
2121 :let phtml_sql_query = 1
2122
2123For syncing, minlines defaults to 100. If you prefer another value, you can
2124set "phtml_minlines" to the value you desire. Example: >
2125
2126 :let phtml_minlines = 200
2127
2128
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002129POSTSCRIPT *postscr.vim* *ft-postscr-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130
2131There are several options when it comes to highlighting PostScript.
2132
2133First which version of the PostScript language to highlight. There are
2134currently three defined language versions, or levels. Level 1 is the original
2135and base version, and includes all extensions prior to the release of level 2.
2136Level 2 is the most common version around, and includes its own set of
2137extensions prior to the release of level 3. Level 3 is currently the highest
2138level supported. You select which level of the PostScript language you want
2139highlighted by defining the postscr_level variable as follows: >
2140
2141 :let postscr_level=2
2142
2143If this variable is not defined it defaults to 2 (level 2) since this is
2144the most prevalent version currently.
2145
2146Note, not all PS interpreters will support all language features for a
2147particular language level. In particular the %!PS-Adobe-3.0 at the start of
2148PS files does NOT mean the PostScript present is level 3 PostScript!
2149
2150If you are working with Display PostScript, you can include highlighting of
2151Display PS language features by defining the postscr_display variable as
2152follows: >
2153
2154 :let postscr_display=1
2155
2156If you are working with Ghostscript, you can include highlighting of
2157Ghostscript specific language features by defining the variable
2158postscr_ghostscript as follows: >
2159
2160 :let postscr_ghostscript=1
2161
2162PostScript is a large language, with many predefined elements. While it
2163useful to have all these elements highlighted, on slower machines this can
2164cause Vim to slow down. In an attempt to be machine friendly font names and
2165character encodings are not highlighted by default. Unless you are working
2166explicitly with either of these this should be ok. If you want them to be
2167highlighted you should set one or both of the following variables: >
2168
2169 :let postscr_fonts=1
2170 :let postscr_encodings=1
2171
2172There is a stylistic option to the highlighting of and, or, and not. In
2173PostScript the function of these operators depends on the types of their
2174operands - if the operands are booleans then they are the logical operators,
2175if they are integers then they are binary operators. As binary and logical
2176operators can be highlighted differently they have to be highlighted one way
2177or the other. By default they are treated as logical operators. They can be
2178highlighted as binary operators by defining the variable
2179postscr_andornot_binary as follows: >
2180
2181 :let postscr_andornot_binary=1
2182<
2183
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002184 *ptcap.vim* *ft-printcap-syntax*
2185PRINTCAP + TERMCAP *ft-ptcap-syntax* *ft-termcap-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002186
2187This syntax file applies to the printcap and termcap databases.
2188
2189In order for Vim to recognize printcap/termcap files that do not match
2190the patterns *printcap*, or *termcap*, you must put additional patterns
2191appropriate to your system in your |myfiletypefile| file. For these
2192patterns, you must set the variable "b:ptcap_type" to either "print" or
2193"term", and then the 'filetype' option to ptcap.
2194
2195For example, to make Vim identify all files in /etc/termcaps/ as termcap
2196files, add the following: >
2197
2198 :au BufNewFile,BufRead /etc/termcaps/* let b:ptcap_type = "term" |
2199 \ set filetype=ptcap
2200
2201If you notice highlighting errors while scrolling backwards, which
2202are fixed when redrawing with CTRL-L, try setting the "ptcap_minlines"
2203internal variable to a larger number: >
2204
2205 :let ptcap_minlines = 50
2206
2207(The default is 20 lines.)
2208
2209
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002210PROGRESS *progress.vim* *ft-progress-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002211
2212Files matching "*.w" could be Progress or cweb. If the automatic detection
2213doesn't work for you, or you don't edit cweb at all, use this in your
2214startup vimrc: >
2215 :let filetype_w = "progress"
2216The same happens for "*.i", which could be assembly, and "*.p", which could be
2217Pascal. Use this if you don't use assembly and Pascal: >
2218 :let filetype_i = "progress"
2219 :let filetype_p = "progress"
2220
2221
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002222PYTHON *python.vim* *ft-python-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223
2224There are four options to control Python syntax highlighting.
2225
2226For highlighted numbers: >
2227 :let python_highlight_numbers = 1
2228
2229For highlighted builtin functions: >
2230 :let python_highlight_builtins = 1
2231
2232For highlighted standard exceptions: >
2233 :let python_highlight_exceptions = 1
2234
2235For highlighted trailing whitespace and mix of spaces and tabs:
2236 :let python_highlight_space_errors = 1
2237
2238If you want all possible Python highlighting (the same as setting the
2239preceding three options): >
2240 :let python_highlight_all = 1
2241
2242
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002243QUAKE *quake.vim* *ft-quake-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244
2245The Quake syntax definition should work for most any FPS (First Person
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002246Shooter) based on one of the Quake engines. However, the command names vary
Bram Moolenaar071d4272004-06-13 20:20:40 +00002247a bit between the three games (Quake, Quake 2, and Quake 3 Arena) so the
2248syntax definition checks for the existence of three global variables to allow
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002249users to specify what commands are legal in their files. The three variables
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250can be set for the following effects:
2251
2252set to highlight commands only available in Quake: >
2253 :let quake_is_quake1 = 1
2254
2255set to highlight commands only available in Quake 2: >
2256 :let quake_is_quake2 = 1
2257
2258set to highlight commands only available in Quake 3 Arena: >
2259 :let quake_is_quake3 = 1
2260
2261Any combination of these three variables is legal, but might highlight more
2262commands than are actually available to you by the game.
2263
2264
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002265READLINE *readline.vim* *ft-readline-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002266
2267The readline library is primarily used by the BASH shell, which adds quite a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002268few commands and options to the ones already available. To highlight these
Bram Moolenaar071d4272004-06-13 20:20:40 +00002269items as well you can add the following to your |vimrc| or just type it in the
2270command line before loading a file with the readline syntax: >
2271 let readline_has_bash = 1
2272
2273This will add highlighting for the commands that BASH (version 2.05a and
2274later, and part earlier) adds.
2275
2276
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002277REXX *rexx.vim* *ft-rexx-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002278
2279If you notice highlighting errors while scrolling backwards, which are fixed
2280when redrawing with CTRL-L, try setting the "rexx_minlines" internal variable
2281to a larger number: >
2282 :let rexx_minlines = 50
2283This will make the syntax synchronization start 50 lines before the first
2284displayed line. The default value is 10. The disadvantage of using a larger
2285number is that redrawing can become slow.
2286
2287
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002288RUBY *ruby.vim* *ft-ruby-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002289
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002290There are a number of options to the Ruby syntax highlighting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291
2292By default, the "end" keyword is colorized according to the opening statement
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002293of the block it closes. While useful, this feature can be expensive; if you
Bram Moolenaar071d4272004-06-13 20:20:40 +00002294experience slow redrawing (or you are on a terminal with poor color support)
2295you may want to turn it off by defining the "ruby_no_expensive" variable: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002296
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297 :let ruby_no_expensive = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002298<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299In this case the same color will be used for all control keywords.
2300
2301If you do want this feature enabled, but notice highlighting errors while
2302scrolling backwards, which are fixed when redrawing with CTRL-L, try setting
2303the "ruby_minlines" variable to a value larger than 50: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002304
Bram Moolenaar071d4272004-06-13 20:20:40 +00002305 :let ruby_minlines = 100
Bram Moolenaar25394022007-05-10 19:06:20 +00002306<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002307Ideally, this value should be a number of lines large enough to embrace your
2308largest class or module.
2309
Bram Moolenaar25394022007-05-10 19:06:20 +00002310Highlighting of special identifiers can be disabled by removing the
2311rubyIdentifier highlighting: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002312
Bram Moolenaar25394022007-05-10 19:06:20 +00002313 :hi link rubyIdentifier NONE
2314<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002315This will prevent highlighting of special identifiers like "ConstantName",
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002316"$global_var", "@@class_var", "@instance_var", "| block_param |", and
2317":symbol".
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002319Significant methods of Kernel, Module and Object are highlighted by default.
2320This can be disabled by defining "ruby_no_special_methods": >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002322 :let ruby_no_special_methods = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002323<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002324This will prevent highlighting of important methods such as "require", "attr",
2325"private", "raise" and "proc".
2326
Bram Moolenaar25394022007-05-10 19:06:20 +00002327Ruby operators can be highlighted. This is enabled by defining
2328"ruby_operators": >
2329
2330 :let ruby_operators = 1
2331<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002332Whitespace errors can be highlighted by defining "ruby_space_errors": >
2333
2334 :let ruby_space_errors = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002335<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002336This will highlight trailing whitespace and tabs preceded by a space character
2337as errors. This can be refined by defining "ruby_no_trail_space_error" and
2338"ruby_no_tab_space_error" which will ignore trailing whitespace and tabs after
2339spaces respectively.
2340
2341Folding can be enabled by defining "ruby_fold": >
2342
2343 :let ruby_fold = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002344<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002345This will set the 'foldmethod' option to "syntax" and allow folding of
2346classes, modules, methods, code blocks, heredocs and comments.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002347
Bram Moolenaar25394022007-05-10 19:06:20 +00002348Folding of multiline comments can be disabled by defining
2349"ruby_no_comment_fold": >
2350
2351 :let ruby_no_comment_fold = 1
2352<
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002353
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002354SCHEME *scheme.vim* *ft-scheme-syntax*
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002355
2356By default only R5RS keywords are highlighted and properly indented.
2357
2358MzScheme-specific stuff will be used if b:is_mzscheme or g:is_mzscheme
2359variables are defined.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002360
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002361Also scheme.vim supports keywords of the Chicken Scheme->C compiler. Define
2362b:is_chicken or g:is_chicken, if you need them.
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002363
2364
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002365SDL *sdl.vim* *ft-sdl-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002366
2367The SDL highlighting probably misses a few keywords, but SDL has so many
2368of them it's almost impossibly to cope.
2369
2370The new standard, SDL-2000, specifies that all identifiers are
2371case-sensitive (which was not so before), and that all keywords can be
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002372used either completely lowercase or completely uppercase. To have the
Bram Moolenaar071d4272004-06-13 20:20:40 +00002373highlighting reflect this, you can set the following variable: >
2374 :let sdl_2000=1
2375
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002376This also sets many new keywords. If you want to disable the old
Bram Moolenaar071d4272004-06-13 20:20:40 +00002377keywords, which is probably a good idea, use: >
2378 :let SDL_no_96=1
2379
2380
2381The indentation is probably also incomplete, but right now I am very
2382satisfied with it for my own projects.
2383
2384
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002385SED *sed.vim* *ft-sed-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386
2387To make tabs stand out from regular blanks (accomplished by using Todo
2388highlighting on the tabs), define "highlight_sedtabs" by putting >
2389
2390 :let highlight_sedtabs = 1
2391
2392in the vimrc file. (This special highlighting only applies for tabs
2393inside search patterns, replacement texts, addresses or text included
2394by an Append/Change/Insert command.) If you enable this option, it is
2395also a good idea to set the tab width to one character; by doing that,
2396you can easily count the number of tabs in a string.
2397
2398Bugs:
2399
2400 The transform command (y) is treated exactly like the substitute
2401 command. This means that, as far as this syntax file is concerned,
2402 transform accepts the same flags as substitute, which is wrong.
2403 (Transform accepts no flags.) I tolerate this bug because the
2404 involved commands need very complex treatment (95 patterns, one for
2405 each plausible pattern delimiter).
2406
2407
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002408SGML *sgml.vim* *ft-sgml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409
2410The coloring scheme for tags in the SGML file works as follows.
2411
2412The <> of opening tags are colored differently than the </> of a closing tag.
2413This is on purpose! For opening tags the 'Function' color is used, while for
2414closing tags the 'Type' color is used (See syntax.vim to check how those are
2415defined for you)
2416
2417Known tag names are colored the same way as statements in C. Unknown tag
2418names are not colored which makes it easy to spot errors.
2419
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002420Note that the same is true for argument (or attribute) names. Known attribute
Bram Moolenaar071d4272004-06-13 20:20:40 +00002421names are colored differently than unknown ones.
2422
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002423Some SGML tags are used to change the rendering of text. The following tags
Bram Moolenaar071d4272004-06-13 20:20:40 +00002424are recognized by the sgml.vim syntax coloring file and change the way normal
2425text is shown: <varname> <emphasis> <command> <function> <literal>
2426<replaceable> <ulink> and <link>.
2427
2428If you want to change how such text is rendered, you must redefine the
2429following syntax groups:
2430
2431 - sgmlBold
2432 - sgmlBoldItalic
2433 - sgmlUnderline
2434 - sgmlItalic
2435 - sgmlLink for links
2436
2437To make this redefinition work you must redefine them all and define the
2438following variable in your vimrc (this is due to the order in which the files
2439are read during initialization) >
2440 let sgml_my_rendering=1
2441
2442You can also disable this rendering by adding the following line to your
2443vimrc file: >
2444 let sgml_no_rendering=1
2445
2446(Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>)
2447
2448
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002449SH *sh.vim* *ft-sh-syntax* *ft-bash-syntax* *ft-ksh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002451This covers the "normal" Unix (Bourne) sh, bash and the Korn shell.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452
2453Vim attempts to determine which shell type is in use by specifying that
2454various filenames are of specific types: >
2455
2456 ksh : .kshrc* *.ksh
2457 bash: .bashrc* bashrc bash.bashrc .bash_profile* *.bash
2458<
2459If none of these cases pertain, then the first line of the file is examined
2460(ex. /bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype,
2461then that shelltype is used. However some files (ex. .profile) are known to
2462be shell files but the type is not apparent. Furthermore, on many systems
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002463sh is symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002464
2465One may specify a global default by instantiating one of the following three
2466variables in your <.vimrc>:
2467
2468 ksh: >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002469 let g:is_kornshell = 1
2470< posix: (using this is the same as setting is_kornshell to 1) >
2471 let g:is_posix = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002472< bash: >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002473 let g:is_bash = 1
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002474< sh: (default) Bourne shell >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002475 let g:is_sh = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002476
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002477If there's no "#! ..." line, and the user hasn't availed himself/herself of a
2478default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002479the Bourne shell syntax. No need to quote RFCs or market penetration
2480statistics in error reports, please -- just select the default version of the
2481sh your system uses in your <.vimrc>.
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002482
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002483The syntax/sh.vim file provides several levels of syntax-based folding: >
2484
2485 let g:sh_fold_enabled= 0 (default, no syntax folding)
2486 let g:sh_fold_enabled= 1 (enable function folding)
2487 let g:sh_fold_enabled= 2 (enable heredoc folding)
2488 let g:sh_fold_enabled= 4 (enable if/do/for folding)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489>
2490then various syntax items (HereDocuments and function bodies) become
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002491syntax-foldable (see |:syn-fold|). You also may add these together
2492to get multiple types of folding: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002493
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002494 let g:sh_fold_enabled= 3 (enables function and heredoc folding)
2495
2496If you notice highlighting errors while scrolling backwards which are fixed
2497when one redraws with CTRL-L, try setting the "sh_minlines" internal variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00002498to a larger number. Example: >
2499
2500 let sh_minlines = 500
2501
2502This will make syntax synchronization start 500 lines before the first
2503displayed line. The default value is 200. The disadvantage of using a larger
2504number is that redrawing can become slow.
2505
2506If you don't have much to synchronize on, displaying can be very slow. To
2507reduce this, the "sh_maxlines" internal variable can be set. Example: >
2508
2509 let sh_maxlines = 100
2510<
2511The default is to use the twice sh_minlines. Set it to a smaller number to
2512speed up displaying. The disadvantage is that highlight errors may appear.
2513
2514
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002515SPEEDUP (AspenTech plant simulator) *spup.vim* *ft-spup-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516
2517The Speedup syntax file has some options:
2518
2519- strict_subsections : If this variable is defined, only keywords for
2520 sections and subsections will be highlighted as statements but not
2521 other keywords (like WITHIN in the OPERATION section).
2522
2523- highlight_types : Definition of this variable causes stream types
2524 like temperature or pressure to be highlighted as Type, not as a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002525 plain Identifier. Included are the types that are usually found in
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526 the DECLARE section; if you defined own types, you have to include
2527 them in the syntax file.
2528
2529- oneline_comments : this value ranges from 1 to 3 and determines the
2530 highlighting of # style comments.
2531
2532 oneline_comments = 1 : allow normal Speedup code after an even
2533 number of #s.
2534
2535 oneline_comments = 2 : show code starting with the second # as
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002536 error. This is the default setting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537
2538 oneline_comments = 3 : show the whole line as error if it contains
2539 more than one #.
2540
2541Since especially OPERATION sections tend to become very large due to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002542PRESETting variables, syncing may be critical. If your computer is
Bram Moolenaar071d4272004-06-13 20:20:40 +00002543fast enough, you can increase minlines and/or maxlines near the end of
2544the syntax file.
2545
2546
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002547SQL *sql.vim* *ft-sql-syntax*
2548 *sqlinformix.vim* *ft-sqlinformix-syntax*
Bram Moolenaar1056d982006-03-09 22:37:52 +00002549 *sqlanywhere.vim* *ft-sqlanywhere-syntax*
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002550
Bram Moolenaar1056d982006-03-09 22:37:52 +00002551While there is an ANSI standard for SQL, most database engines add their own
2552custom extensions. Vim currently supports the Oracle and Informix dialects of
2553SQL. Vim assumes "*.sql" files are Oracle SQL by default.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002554
Bram Moolenaar1056d982006-03-09 22:37:52 +00002555Vim currently has SQL support for a variety of different vendors via syntax
2556scripts. You can change Vim's default from Oracle to any of the current SQL
2557supported types. You can also easily alter the SQL dialect being used on a
2558buffer by buffer basis.
2559
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002560For more detailed instructions see |ft_sql.txt|.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002561
2562
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002563TCSH *tcsh.vim* *ft-tcsh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002564
2565This covers the shell named "tcsh". It is a superset of csh. See |csh.vim|
2566for how the filetype is detected.
2567
2568Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002569is set. If you want VIM to assume that no backslash quote constructs exist add
Bram Moolenaar071d4272004-06-13 20:20:40 +00002570this line to your .vimrc: >
2571
2572 :let tcsh_backslash_quote = 0
2573
2574If you notice highlighting errors while scrolling backwards, which are fixed
2575when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable
2576to a larger number: >
2577
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01002578 :let tcsh_minlines = 1000
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01002580This will make the syntax synchronization start 1000 lines before the first
2581displayed line. If you set "tcsh_minlines" to "fromstart", then
2582synchronization is done from the start of the file. The default value for
2583tcsh_minlines is 100. The disadvantage of using a larger number is that
2584redrawing can become slow.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585
2586
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002587TEX *tex.vim* *ft-tex-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002588
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002589 *tex-folding*
Bram Moolenaar488c6512005-08-11 20:09:58 +00002590Want Syntax Folding? ~
2591
2592As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
2593sections, subsections, etc are supported. Put >
2594 let g:tex_fold_enabled=1
2595in your <.vimrc>, and :set fdm=syntax. I suggest doing the latter via a
2596modeline at the end of your LaTeX file: >
2597 % vim: fdm=syntax
2598<
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002599 *tex-nospell*
2600Don't Want Spell Checking In Comments? ~
2601
2602Some folks like to include things like source code in comments and so would
2603prefer that spell checking be disabled in comments in LaTeX files. To do
2604this, put the following in your <.vimrc>: >
2605 let g:tex_comment_nospell= 1
2606<
2607 *tex-runon*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002608Run-on Comments/Math? ~
2609
Bram Moolenaar488c6512005-08-11 20:09:58 +00002610The <syntax/tex.vim> highlighting supports TeX, LaTeX, and some AmsTeX. The
2611highlighting supports three primary zones/regions: normal, texZone, and
2612texMathZone. Although considerable effort has been made to have these zones
2613terminate properly, zones delineated by $..$ and $$..$$ cannot be synchronized
2614as there's no difference between start and end patterns. Consequently, a
Bram Moolenaar071d4272004-06-13 20:20:40 +00002615special "TeX comment" has been provided >
2616 %stopzone
2617which will forcibly terminate the highlighting of either a texZone or a
2618texMathZone.
2619
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002620 *tex-slow*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002621Slow Syntax Highlighting? ~
2622
2623If you have a slow computer, you may wish to reduce the values for >
2624 :syn sync maxlines=200
2625 :syn sync minlines=50
2626(especially the latter). If your computer is fast, you may wish to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002627increase them. This primarily affects synchronizing (i.e. just what group,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002628if any, is the text at the top of the screen supposed to be in?).
2629
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002630 *tex-morecommands* *tex-package*
2631Want To Highlight More Commands? ~
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002632
2633LaTeX is a programmable language, and so there are thousands of packages full
2634of specialized LaTeX commands, syntax, and fonts. If you're using such a
2635package you'll often wish that the distributed syntax/tex.vim would support
2636it. However, clearly this is impractical. So please consider using the
2637techniques in |mysyntaxfile-add| to extend or modify the highlighting provided
2638by syntax/tex.vim.
2639
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002640 *tex-error*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641Excessive Error Highlighting? ~
2642
2643The <tex.vim> supports lexical error checking of various sorts. Thus,
2644although the error checking is ofttimes very useful, it can indicate
2645errors where none actually are. If this proves to be a problem for you,
2646you may put in your <.vimrc> the following statement: >
2647 let tex_no_error=1
Bram Moolenaar488c6512005-08-11 20:09:58 +00002648and all error checking by <syntax/tex.vim> will be suppressed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002649
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002650 *tex-math*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651Need a new Math Group? ~
2652
2653If you want to include a new math group in your LaTeX, the following
2654code shows you an example as to how you might do so: >
Bram Moolenaar488c6512005-08-11 20:09:58 +00002655 call TexNewMathZone(sfx,mathzone,starform)
2656You'll want to provide the new math group with a unique suffix
2657(currently, A-L and V-Z are taken by <syntax/tex.vim> itself).
2658As an example, consider how eqnarray is set up by <syntax/tex.vim>: >
2659 call TexNewMathZone("D","eqnarray",1)
2660You'll need to change "mathzone" to the name of your new math group,
2661and then to the call to it in .vim/after/syntax/tex.vim.
2662The "starform" variable, if true, implies that your new math group
2663has a starred form (ie. eqnarray*).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002665 *tex-style*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666Starting a New Style? ~
2667
2668One may use "\makeatletter" in *.tex files, thereby making the use of "@" in
2669commands available. However, since the *.tex file doesn't have one of the
2670following suffices: sty cls clo dtx ltx, the syntax highlighting will flag
2671such use of @ as an error. To solve this: >
2672
2673 :let b:tex_stylish = 1
2674 :set ft=tex
2675
2676Putting "let g:tex_stylish=1" into your <.vimrc> will make <syntax/tex.vim>
2677always accept such use of @.
2678
2679
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002680TF *tf.vim* *ft-tf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681
2682There is one option for the tf syntax highlighting.
2683
2684For syncing, minlines defaults to 100. If you prefer another value, you can
2685set "tf_minlines" to the value you desire. Example: >
2686
2687 :let tf_minlines = your choice
2688
2689
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002690VIM *vim.vim* *ft-vim-syntax*
2691 *g:vimsyn_minlines* *g:vimsyn_maxlines*
Bram Moolenaar996343d2010-07-04 22:20:21 +02002692There is a trade-off between more accurate syntax highlighting versus screen
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002693updating speed. To improve accuracy, you may wish to increase the
2694g:vimsyn_minlines variable. The g:vimsyn_maxlines variable may be used to
2695improve screen updating rates (see |:syn-sync| for more on this). >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002697 g:vimsyn_minlines : used to set synchronization minlines
2698 g:vimsyn_maxlines : used to set synchronization maxlines
2699<
2700 (g:vim_minlines and g:vim_maxlines are deprecated variants of
2701 these two options)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002703 *g:vimsyn_embed*
2704The g:vimsyn_embed option allows users to select what, if any, types of
2705embedded script highlighting they wish to have. >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002706
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002707 g:vimsyn_embed == 0 : don't embed any scripts
2708 g:vimsyn_embed =~ 'm' : embed mzscheme (but only if vim supports it)
2709 g:vimsyn_embed =~ 'p' : embed perl (but only if vim supports it)
2710 g:vimsyn_embed =~ 'P' : embed python (but only if vim supports it)
2711 g:vimsyn_embed =~ 'r' : embed ruby (but only if vim supports it)
2712 g:vimsyn_embed =~ 't' : embed tcl (but only if vim supports it)
2713<
2714By default, g:vimsyn_embed is "mpPr"; ie. syntax/vim.vim will support
2715highlighting mzscheme, perl, python, and ruby by default. Vim's has("tcl")
2716test appears to hang vim when tcl is not truly available. Thus, by default,
2717tcl is not supported for embedding (but those of you who like tcl embedded in
2718their vim syntax highlighting can simply include it in the g:vimembedscript
2719option).
2720 *g:vimsyn_folding*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002721
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002722Some folding is now supported with syntax/vim.vim: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002723
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002724 g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding
2725 g:vimsyn_folding =~ 'a' : augroups
2726 g:vimsyn_folding =~ 'f' : fold functions
2727 g:vimsyn_folding =~ 'm' : fold mzscheme script
2728 g:vimsyn_folding =~ 'p' : fold perl script
2729 g:vimsyn_folding =~ 'P' : fold python script
2730 g:vimsyn_folding =~ 'r' : fold ruby script
2731 g:vimsyn_folding =~ 't' : fold tcl script
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002733 *g:vimsyn_noerror*
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002734Not all error highlighting that syntax/vim.vim does may be correct; VimL is a
2735difficult language to highlight correctly. A way to suppress error
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002736highlighting is to put the following line in your |vimrc|: >
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002737
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002738 let g:vimsyn_noerror = 1
2739<
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002740
Bram Moolenaar071d4272004-06-13 20:20:40 +00002741
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002742XF86CONFIG *xf86conf.vim* *ft-xf86conf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743
2744The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both
2745variants are supported. Automatic detection is used, but is far from perfect.
2746You may need to specify the version manually. Set the variable
2747xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
2748your .vimrc. Example: >
2749 :let xf86conf_xfree86_version=3
2750When using a mix of versions, set the b:xf86conf_xfree86_version variable.
2751
2752Note that spaces and underscores in option names are not supported. Use
2753"SyncOnGreen" instead of "__s yn con gr_e_e_n" if you want the option name
2754highlighted.
2755
2756
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002757XML *xml.vim* *ft-xml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002758
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002759Xml namespaces are highlighted by default. This can be inhibited by
Bram Moolenaar071d4272004-06-13 20:20:40 +00002760setting a global variable: >
2761
2762 :let g:xml_namespace_transparent=1
2763<
2764 *xml-folding*
2765The xml syntax file provides syntax |folding| (see |:syn-fold|) between
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002766start and end tags. This can be turned on by >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767
2768 :let g:xml_syntax_folding = 1
2769 :set foldmethod=syntax
2770
2771Note: syntax folding might slow down syntax highlighting significantly,
2772especially for large files.
2773
2774
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002775X Pixmaps (XPM) *xpm.vim* *ft-xpm-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002776
2777xpm.vim creates its syntax items dynamically based upon the contents of the
2778XPM file. Thus if you make changes e.g. in the color specification strings,
2779you have to source it again e.g. with ":set syn=xpm".
2780
2781To copy a pixel with one of the colors, yank a "pixel" with "yl" and insert it
2782somewhere else with "P".
2783
2784Do you want to draw with the mouse? Try the following: >
2785 :function! GetPixel()
Bram Moolenaar61660ea2006-04-07 21:40:07 +00002786 : let c = getline(".")[col(".") - 1]
Bram Moolenaar071d4272004-06-13 20:20:40 +00002787 : echo c
2788 : exe "noremap <LeftMouse> <LeftMouse>r".c
2789 : exe "noremap <LeftDrag> <LeftMouse>r".c
2790 :endfunction
2791 :noremap <RightMouse> <LeftMouse>:call GetPixel()<CR>
2792 :set guicursor=n:hor20 " to see the color beneath the cursor
2793This turns the right button into a pipette and the left button into a pen.
2794It will work with XPM files that have one character per pixel only and you
2795must not click outside of the pixel strings, but feel free to improve it.
2796
2797It will look much better with a font in a quadratic cell size, e.g. for X: >
2798 :set guifont=-*-clean-medium-r-*-*-8-*-*-*-*-80-*
2799
2800==============================================================================
28015. Defining a syntax *:syn-define* *E410*
2802
2803Vim understands three types of syntax items:
2804
Bram Moolenaarce0842a2005-07-18 21:58:11 +000028051. Keyword
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 It can only contain keyword characters, according to the 'iskeyword'
2807 option. It cannot contain other syntax items. It will only match with a
2808 complete word (there are no keyword characters before or after the match).
2809 The keyword "if" would match in "if(a=b)", but not in "ifdef x", because
2810 "(" is not a keyword character and "d" is.
2811
Bram Moolenaarce0842a2005-07-18 21:58:11 +000028122. Match
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813 This is a match with a single regexp pattern.
2814
Bram Moolenaarce0842a2005-07-18 21:58:11 +000028153. Region
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816 This starts at a match of the "start" regexp pattern and ends with a match
2817 with the "end" regexp pattern. Any other text can appear in between. A
2818 "skip" regexp pattern can be used to avoid matching the "end" pattern.
2819
2820Several syntax ITEMs can be put into one syntax GROUP. For a syntax group
2821you can give highlighting attributes. For example, you could have an item
2822to define a "/* .. */" comment and another one that defines a "// .." comment,
2823and put them both in the "Comment" group. You can then specify that a
2824"Comment" will be in bold font and have a blue color. You are free to make
2825one highlight group for one syntax item, or put all items into one group.
2826This depends on how you want to specify your highlighting attributes. Putting
2827each item in its own group results in having to specify the highlighting
2828for a lot of groups.
2829
2830Note that a syntax group and a highlight group are similar. For a highlight
2831group you will have given highlight attributes. These attributes will be used
2832for the syntax group with the same name.
2833
2834In case more than one item matches at the same position, the one that was
2835defined LAST wins. Thus you can override previously defined syntax items by
2836using an item that matches the same text. But a keyword always goes before a
2837match or region. And a keyword with matching case always goes before a
2838keyword with ignoring case.
2839
2840
2841PRIORITY *:syn-priority*
2842
2843When several syntax items may match, these rules are used:
2844
28451. When multiple Match or Region items start in the same position, the item
2846 defined last has priority.
28472. A Keyword has priority over Match and Region items.
28483. An item that starts in an earlier position has priority over items that
2849 start in later positions.
2850
2851
2852DEFINING CASE *:syn-case* *E390*
2853
Bram Moolenaarce0842a2005-07-18 21:58:11 +00002854:sy[ntax] case [match | ignore]
Bram Moolenaar071d4272004-06-13 20:20:40 +00002855 This defines if the following ":syntax" commands will work with
2856 matching case, when using "match", or with ignoring case, when using
2857 "ignore". Note that any items before this are not affected, and all
2858 items until the next ":syntax case" command are affected.
2859
2860
Bram Moolenaarce0842a2005-07-18 21:58:11 +00002861SPELL CHECKING *:syn-spell*
2862
2863:sy[ntax] spell [toplevel | notoplevel | default]
2864 This defines where spell checking is to be done for text that is not
2865 in a syntax item:
2866
2867 toplevel: Text is spell checked.
2868 notoplevel: Text is not spell checked.
2869 default: When there is a @Spell cluster no spell checking.
2870
2871 For text in syntax items use the @Spell and @NoSpell clusters
2872 |spell-syntax|. When there is no @Spell and no @NoSpell cluster then
2873 spell checking is done for "default" and "toplevel".
2874
2875 To activate spell checking the 'spell' option must be set.
2876
2877
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878DEFINING KEYWORDS *:syn-keyword*
2879
2880:sy[ntax] keyword {group-name} [{options}] {keyword} .. [{options}]
2881
2882 This defines a number of keywords.
2883
2884 {group-name} Is a syntax group name such as "Comment".
2885 [{options}] See |:syn-arguments| below.
2886 {keyword} .. Is a list of keywords which are part of this group.
2887
2888 Example: >
2889 :syntax keyword Type int long char
2890<
2891 The {options} can be given anywhere in the line. They will apply to
2892 all keywords given, also for options that come after a keyword.
2893 These examples do exactly the same: >
2894 :syntax keyword Type contained int long char
2895 :syntax keyword Type int long contained char
2896 :syntax keyword Type int long char contained
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00002897< *E789*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898 When you have a keyword with an optional tail, like Ex commands in
2899 Vim, you can put the optional characters inside [], to define all the
2900 variations at once: >
2901 :syntax keyword vimCommand ab[breviate] n[ext]
2902<
2903 Don't forget that a keyword can only be recognized if all the
2904 characters are included in the 'iskeyword' option. If one character
2905 isn't, the keyword will never be recognized.
2906 Multi-byte characters can also be used. These do not have to be in
2907 'iskeyword'.
2908
2909 A keyword always has higher priority than a match or region, the
2910 keyword is used if more than one item matches. Keywords do not nest
2911 and a keyword can't contain anything else.
2912
2913 Note that when you have a keyword that is the same as an option (even
2914 one that isn't allowed here), you can not use it. Use a match
2915 instead.
2916
2917 The maximum length of a keyword is 80 characters.
2918
2919 The same keyword can be defined multiple times, when its containment
2920 differs. For example, you can define the keyword once not contained
2921 and use one highlight group, and once contained, and use a different
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002922 highlight group. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002923 :syn keyword vimCommand tag
2924 :syn keyword vimSetting contained tag
2925< When finding "tag" outside of any syntax item, the "vimCommand"
2926 highlight group is used. When finding "tag" in a syntax item that
2927 contains "vimSetting", the "vimSetting" group is used.
2928
2929
2930DEFINING MATCHES *:syn-match*
2931
2932:sy[ntax] match {group-name} [{options}] [excludenl] {pattern} [{options}]
2933
2934 This defines one match.
2935
2936 {group-name} A syntax group name such as "Comment".
2937 [{options}] See |:syn-arguments| below.
2938 [excludenl] Don't make a pattern with the end-of-line "$"
2939 extend a containing match or region. Must be
2940 given before the pattern. |:syn-excludenl|
2941 {pattern} The search pattern that defines the match.
2942 See |:syn-pattern| below.
2943 Note that the pattern may match more than one
2944 line, which makes the match depend on where
2945 Vim starts searching for the pattern. You
2946 need to make sure syncing takes care of this.
2947
2948 Example (match a character constant): >
2949 :syntax match Character /'.'/hs=s+1,he=e-1
2950<
2951
2952DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
2953 *E398* *E399*
2954:sy[ntax] region {group-name} [{options}]
2955 [matchgroup={group-name}]
2956 [keepend]
2957 [extend]
2958 [excludenl]
2959 start={start_pattern} ..
2960 [skip={skip_pattern}]
2961 end={end_pattern} ..
2962 [{options}]
2963
2964 This defines one region. It may span several lines.
2965
2966 {group-name} A syntax group name such as "Comment".
2967 [{options}] See |:syn-arguments| below.
2968 [matchgroup={group-name}] The syntax group to use for the following
2969 start or end pattern matches only. Not used
2970 for the text in between the matched start and
2971 end patterns. Use NONE to reset to not using
2972 a different group for the start or end match.
2973 See |:syn-matchgroup|.
2974 keepend Don't allow contained matches to go past a
2975 match with the end pattern. See
2976 |:syn-keepend|.
2977 extend Override a "keepend" for an item this region
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002978 is contained in. See |:syn-extend|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002979 excludenl Don't make a pattern with the end-of-line "$"
2980 extend a containing match or item. Only
2981 useful for end patterns. Must be given before
2982 the patterns it applies to. |:syn-excludenl|
2983 start={start_pattern} The search pattern that defines the start of
2984 the region. See |:syn-pattern| below.
2985 skip={skip_pattern} The search pattern that defines text inside
2986 the region where not to look for the end
2987 pattern. See |:syn-pattern| below.
2988 end={end_pattern} The search pattern that defines the end of
2989 the region. See |:syn-pattern| below.
2990
2991 Example: >
2992 :syntax region String start=+"+ skip=+\\"+ end=+"+
2993<
2994 The start/skip/end patterns and the options can be given in any order.
2995 There can be zero or one skip pattern. There must be one or more
2996 start and end patterns. This means that you can omit the skip
2997 pattern, but you must give at least one start and one end pattern. It
2998 is allowed to have white space before and after the equal sign
2999 (although it mostly looks better without white space).
3000
3001 When more than one start pattern is given, a match with one of these
3002 is sufficient. This means there is an OR relation between the start
3003 patterns. The last one that matches is used. The same is true for
3004 the end patterns.
3005
3006 The search for the end pattern starts right after the start pattern.
3007 Offsets are not used for this. This implies that the match for the
3008 end pattern will never overlap with the start pattern.
3009
3010 The skip and end pattern can match across line breaks, but since the
3011 search for the pattern can start in any line it often does not do what
3012 you want. The skip pattern doesn't avoid a match of an end pattern in
3013 the next line. Use single-line patterns to avoid trouble.
3014
3015 Note: The decision to start a region is only based on a matching start
3016 pattern. There is no check for a matching end pattern. This does NOT
3017 work: >
3018 :syn region First start="(" end=":"
3019 :syn region Second start="(" end=";"
3020< The Second always matches before the First (last defined pattern has
3021 higher priority). The Second region then continues until the next
3022 ';', no matter if there is a ':' before it. Using a match does work: >
3023 :syn match First "(\_.\{-}:"
3024 :syn match Second "(\_.\{-};"
3025< This pattern matches any character or line break with "\_." and
3026 repeats that with "\{-}" (repeat as few as possible).
3027
3028 *:syn-keepend*
3029 By default, a contained match can obscure a match for the end pattern.
3030 This is useful for nesting. For example, a region that starts with
3031 "{" and ends with "}", can contain another region. An encountered "}"
3032 will then end the contained region, but not the outer region:
3033 { starts outer "{}" region
3034 { starts contained "{}" region
3035 } ends contained "{}" region
3036 } ends outer "{} region
3037 If you don't want this, the "keepend" argument will make the matching
3038 of an end pattern of the outer region also end any contained item.
3039 This makes it impossible to nest the same region, but allows for
3040 contained items to highlight parts of the end pattern, without causing
3041 that to skip the match with the end pattern. Example: >
3042 :syn match vimComment +"[^"]\+$+
3043 :syn region vimCommand start="set" end="$" contains=vimComment keepend
3044< The "keepend" makes the vimCommand always end at the end of the line,
3045 even though the contained vimComment includes a match with the <EOL>.
3046
3047 When "keepend" is not used, a match with an end pattern is retried
3048 after each contained match. When "keepend" is included, the first
3049 encountered match with an end pattern is used, truncating any
3050 contained matches.
3051 *:syn-extend*
3052 The "keepend" behavior can be changed by using the "extend" argument.
3053 When an item with "extend" is contained in an item that uses
3054 "keepend", the "keepend" is ignored and the containing region will be
3055 extended.
3056 This can be used to have some contained items extend a region while
3057 others don't. Example: >
3058
3059 :syn region htmlRef start=+<a>+ end=+</a>+ keepend contains=htmlItem,htmlScript
3060 :syn match htmlItem +<[^>]*>+ contained
3061 :syn region htmlScript start=+<script+ end=+</script[^>]*>+ contained extend
3062
3063< Here the htmlItem item does not make the htmlRef item continue
3064 further, it is only used to highlight the <> items. The htmlScript
3065 item does extend the htmlRef item.
3066
3067 Another example: >
3068 :syn region xmlFold start="<a>" end="</a>" fold transparent keepend extend
3069< This defines a region with "keepend", so that its end cannot be
3070 changed by contained items, like when the "</a>" is matched to
3071 highlight it differently. But when the xmlFold region is nested (it
3072 includes itself), the "extend" applies, so that the "</a>" of a nested
3073 region only ends that region, and not the one it is contained in.
3074
3075 *:syn-excludenl*
3076 When a pattern for a match or end pattern of a region includes a '$'
3077 to match the end-of-line, it will make a region item that it is
3078 contained in continue on the next line. For example, a match with
3079 "\\$" (backslash at the end of the line) can make a region continue
3080 that would normally stop at the end of the line. This is the default
3081 behavior. If this is not wanted, there are two ways to avoid it:
3082 1. Use "keepend" for the containing item. This will keep all
3083 contained matches from extending the match or region. It can be
3084 used when all contained items must not extend the containing item.
3085 2. Use "excludenl" in the contained item. This will keep that match
3086 from extending the containing match or region. It can be used if
3087 only some contained items must not extend the containing item.
3088 "excludenl" must be given before the pattern it applies to.
3089
3090 *:syn-matchgroup*
3091 "matchgroup" can be used to highlight the start and/or end pattern
3092 differently than the body of the region. Example: >
3093 :syntax region String matchgroup=Quote start=+"+ skip=+\\"+ end=+"+
3094< This will highlight the quotes with the "Quote" group, and the text in
3095 between with the "String" group.
3096 The "matchgroup" is used for all start and end patterns that follow,
3097 until the next "matchgroup". Use "matchgroup=NONE" to go back to not
3098 using a matchgroup.
3099
3100 In a start or end pattern that is highlighted with "matchgroup" the
3101 contained items of the region are not used. This can be used to avoid
3102 that a contained item matches in the start or end pattern match. When
3103 using "transparent", this does not apply to a start or end pattern
3104 match that is highlighted with "matchgroup".
3105
3106 Here is an example, which highlights three levels of parentheses in
3107 different colors: >
3108 :sy region par1 matchgroup=par1 start=/(/ end=/)/ contains=par2
3109 :sy region par2 matchgroup=par2 start=/(/ end=/)/ contains=par3 contained
3110 :sy region par3 matchgroup=par3 start=/(/ end=/)/ contains=par1 contained
3111 :hi par1 ctermfg=red guifg=red
3112 :hi par2 ctermfg=blue guifg=blue
3113 :hi par3 ctermfg=darkgreen guifg=darkgreen
3114
3115==============================================================================
31166. :syntax arguments *:syn-arguments*
3117
3118The :syntax commands that define syntax items take a number of arguments.
3119The common ones are explained here. The arguments may be given in any order
3120and may be mixed with patterns.
3121
3122Not all commands accept all arguments. This table shows which arguments
3123can not be used for all commands:
3124 *E395* *E396*
Bram Moolenaar860cae12010-06-05 23:22:07 +02003125 contains oneline fold display extend concealends~
3126:syntax keyword - - - - - -
3127:syntax match yes - yes yes yes -
3128:syntax region yes yes yes yes yes yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00003129
3130These arguments can be used for all three commands:
Bram Moolenaar860cae12010-06-05 23:22:07 +02003131 conceal
3132 cchar
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133 contained
3134 containedin
3135 nextgroup
3136 transparent
3137 skipwhite
3138 skipnl
3139 skipempty
3140
Bram Moolenaar860cae12010-06-05 23:22:07 +02003141conceal *conceal* *:syn-conceal*
3142
3143When the "conceal" argument is given, the item is marked as concealable.
Bram Moolenaar370df582010-06-22 05:16:38 +02003144Whether or not it is actually concealed depends on the value of the
3145'conceallevel' option. If 'modifiable' option is on, concealable items
3146in the current line are always displayed unconcealed to be able to edit
3147the line.
Bram Moolenaar860cae12010-06-05 23:22:07 +02003148
3149concealends *:syn-concealends*
3150
3151When the "concealends" argument is given, the start and end matches of
3152the region, but not the contents of the region, are marked as concealable.
3153Whether or not they are actually concealed depends on the setting on the
3154'conceallevel' option. The ends of a region can only be concealed separately
3155in this way when they have their own highlighting via "matchgroup"
3156
3157cchar *:syn-cchar*
3158
3159The "cchar" argument defines the character shown in place of the item
3160when it is concealed (setting "cchar" only makes sense when the conceal
3161argument is given.) If "cchar" is not set then the default conceal
3162character defined in the 'listchars' option is used. Example: >
3163 :syntax match Entity "&amp;" conceal cchar=&
Bram Moolenaar9028b102010-07-11 16:58:51 +02003164See |hl-Conceal| for highlighting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165
3166contained *:syn-contained*
3167
3168When the "contained" argument is given, this item will not be recognized at
3169the top level, but only when it is mentioned in the "contains" field of
3170another match. Example: >
3171 :syntax keyword Todo TODO contained
3172 :syntax match Comment "//.*" contains=Todo
3173
3174
3175display *:syn-display*
3176
3177If the "display" argument is given, this item will be skipped when the
3178detected highlighting will not be displayed. This will speed up highlighting,
3179by skipping this item when only finding the syntax state for the text that is
3180to be displayed.
3181
3182Generally, you can use "display" for match and region items that meet these
3183conditions:
3184- The item does not continue past the end of a line. Example for C: A region
3185 for a "/*" comment can't contain "display", because it continues on the next
3186 line.
3187- The item does not contain items that continue past the end of the line or
3188 make it continue on the next line.
3189- The item does not change the size of any item it is contained in. Example
3190 for C: A match with "\\$" in a preprocessor match can't have "display",
3191 because it may make that preprocessor match shorter.
3192- The item does not allow other items to match that didn't match otherwise,
3193 and that item may extend the match too far. Example for C: A match for a
3194 "//" comment can't use "display", because a "/*" inside that comment would
3195 match then and start a comment which extends past the end of the line.
3196
3197Examples, for the C language, where "display" can be used:
3198- match with a number
3199- match with a label
3200
3201
3202transparent *:syn-transparent*
3203
3204If the "transparent" argument is given, this item will not be highlighted
3205itself, but will take the highlighting of the item it is contained in. This
3206is useful for syntax items that don't need any highlighting but are used
3207only to skip over a part of the text.
3208
3209The "contains=" argument is also inherited from the item it is contained in,
3210unless a "contains" argument is given for the transparent item itself. To
3211avoid that unwanted items are contained, use "contains=NONE". Example, which
3212highlights words in strings, but makes an exception for "vim": >
3213 :syn match myString /'[^']*'/ contains=myWord,myVim
3214 :syn match myWord /\<[a-z]*\>/ contained
3215 :syn match myVim /\<vim\>/ transparent contained contains=NONE
3216 :hi link myString String
3217 :hi link myWord Comment
3218Since the "myVim" match comes after "myWord" it is the preferred match (last
3219match in the same position overrules an earlier one). The "transparent"
3220argument makes the "myVim" match use the same highlighting as "myString". But
3221it does not contain anything. If the "contains=NONE" argument would be left
3222out, then "myVim" would use the contains argument from myString and allow
3223"myWord" to be contained, which will be highlighted as a Constant. This
3224happens because a contained match doesn't match inside itself in the same
3225position, thus the "myVim" match doesn't overrule the "myWord" match here.
3226
3227When you look at the colored text, it is like looking at layers of contained
3228items. The contained item is on top of the item it is contained in, thus you
3229see the contained item. When a contained item is transparent, you can look
3230through, thus you see the item it is contained in. In a picture:
3231
3232 look from here
3233
3234 | | | | | |
3235 V V V V V V
3236
3237 xxxx yyy more contained items
3238 .................... contained item (transparent)
3239 ============================= first item
3240
3241The 'x', 'y' and '=' represent a highlighted syntax item. The '.' represent a
3242transparent group.
3243
3244What you see is:
3245
3246 =======xxxx=======yyy========
3247
3248Thus you look through the transparent "....".
3249
3250
3251oneline *:syn-oneline*
3252
3253The "oneline" argument indicates that the region does not cross a line
3254boundary. It must match completely in the current line. However, when the
3255region has a contained item that does cross a line boundary, it continues on
3256the next line anyway. A contained item can be used to recognize a line
3257continuation pattern. But the "end" pattern must still match in the first
3258line, otherwise the region doesn't even start.
3259
3260When the start pattern includes a "\n" to match an end-of-line, the end
3261pattern must be found in the same line as where the start pattern ends. The
3262end pattern may also include an end-of-line. Thus the "oneline" argument
3263means that the end of the start pattern and the start of the end pattern must
3264be within one line. This can't be changed by a skip pattern that matches a
3265line break.
3266
3267
3268fold *:syn-fold*
3269
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003270The "fold" argument makes the fold level increase by one for this item.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003271Example: >
3272 :syn region myFold start="{" end="}" transparent fold
3273 :syn sync fromstart
3274 :set foldmethod=syntax
3275This will make each {} block form one fold.
3276
3277The fold will start on the line where the item starts, and end where the item
3278ends. If the start and end are within the same line, there is no fold.
3279The 'foldnestmax' option limits the nesting of syntax folds.
3280{not available when Vim was compiled without |+folding| feature}
3281
3282
3283 *:syn-contains* *E405* *E406* *E407* *E408* *E409*
3284contains={groupname},..
3285
3286The "contains" argument is followed by a list of syntax group names. These
3287groups will be allowed to begin inside the item (they may extend past the
3288containing group's end). This allows for recursive nesting of matches and
3289regions. If there is no "contains" argument, no groups will be contained in
3290this item. The group names do not need to be defined before they can be used
3291here.
3292
3293contains=ALL
3294 If the only item in the contains list is "ALL", then all
3295 groups will be accepted inside the item.
3296
3297contains=ALLBUT,{group-name},..
3298 If the first item in the contains list is "ALLBUT", then all
3299 groups will be accepted inside the item, except the ones that
3300 are listed. Example: >
3301 :syntax region Block start="{" end="}" ... contains=ALLBUT,Function
3302
3303contains=TOP
3304 If the first item in the contains list is "TOP", then all
3305 groups will be accepted that don't have the "contained"
3306 argument.
3307contains=TOP,{group-name},..
3308 Like "TOP", but excluding the groups that are listed.
3309
3310contains=CONTAINED
3311 If the first item in the contains list is "CONTAINED", then
3312 all groups will be accepted that have the "contained"
3313 argument.
3314contains=CONTAINED,{group-name},..
3315 Like "CONTAINED", but excluding the groups that are
3316 listed.
3317
3318
3319The {group-name} in the "contains" list can be a pattern. All group names
3320that match the pattern will be included (or excluded, if "ALLBUT" is used).
3321The pattern cannot contain white space or a ','. Example: >
3322 ... contains=Comment.*,Keyw[0-3]
3323The matching will be done at moment the syntax command is executed. Groups
3324that are defined later will not be matched. Also, if the current syntax
3325command defines a new group, it is not matched. Be careful: When putting
3326syntax commands in a file you can't rely on groups NOT being defined, because
3327the file may have been sourced before, and ":syn clear" doesn't remove the
3328group names.
3329
3330The contained groups will also match in the start and end patterns of a
3331region. If this is not wanted, the "matchgroup" argument can be used
3332|:syn-matchgroup|. The "ms=" and "me=" offsets can be used to change the
3333region where contained items do match. Note that this may also limit the
3334area that is highlighted
3335
3336
3337containedin={groupname}... *:syn-containedin*
3338
3339The "containedin" argument is followed by a list of syntax group names. The
3340item will be allowed to begin inside these groups. This works as if the
3341containing item has a "contains=" argument that includes this item.
3342
3343The {groupname}... can be used just like for "contains", as explained above.
3344
3345This is useful when adding a syntax item afterwards. An item can be told to
3346be included inside an already existing item, without changing the definition
3347of that item. For example, to highlight a word in a C comment after loading
3348the C syntax: >
3349 :syn keyword myword HELP containedin=cComment contained
3350Note that "contained" is also used, to avoid that the item matches at the top
3351level.
3352
3353Matches for "containedin" are added to the other places where the item can
3354appear. A "contains" argument may also be added as usual. Don't forget that
3355keywords never contain another item, thus adding them to "containedin" won't
3356work.
3357
3358
3359nextgroup={groupname},.. *:syn-nextgroup*
3360
3361The "nextgroup" argument is followed by a list of syntax group names,
3362separated by commas (just like with "contains", so you can also use patterns).
3363
3364If the "nextgroup" argument is given, the mentioned syntax groups will be
3365tried for a match, after the match or region ends. If none of the groups have
3366a match, highlighting continues normally. If there is a match, this group
3367will be used, even when it is not mentioned in the "contains" field of the
3368current group. This is like giving the mentioned group priority over all
3369other groups. Example: >
3370 :syntax match ccFoobar "Foo.\{-}Bar" contains=ccFoo
3371 :syntax match ccFoo "Foo" contained nextgroup=ccFiller
3372 :syntax region ccFiller start="." matchgroup=ccBar end="Bar" contained
3373
3374This will highlight "Foo" and "Bar" differently, and only when there is a
3375"Bar" after "Foo". In the text line below, "f" shows where ccFoo is used for
3376highlighting, and "bbb" where ccBar is used. >
3377
3378 Foo asdfasd Bar asdf Foo asdf Bar asdf
3379 fff bbb fff bbb
3380
3381Note the use of ".\{-}" to skip as little as possible until the next Bar.
3382when ".*" would be used, the "asdf" in between "Bar" and "Foo" would be
3383highlighted according to the "ccFoobar" group, because the ccFooBar match
3384would include the first "Foo" and the last "Bar" in the line (see |pattern|).
3385
3386
3387skipwhite *:syn-skipwhite*
3388skipnl *:syn-skipnl*
3389skipempty *:syn-skipempty*
3390
3391These arguments are only used in combination with "nextgroup". They can be
3392used to allow the next group to match after skipping some text:
Bram Moolenaardd2a0d82007-05-12 15:07:00 +00003393 skipwhite skip over space and tab characters
Bram Moolenaar071d4272004-06-13 20:20:40 +00003394 skipnl skip over the end of a line
3395 skipempty skip over empty lines (implies a "skipnl")
3396
3397When "skipwhite" is present, the white space is only skipped if there is no
3398next group that matches the white space.
3399
3400When "skipnl" is present, the match with nextgroup may be found in the next
3401line. This only happens when the current item ends at the end of the current
3402line! When "skipnl" is not present, the nextgroup will only be found after
3403the current item in the same line.
3404
3405When skipping text while looking for a next group, the matches for other
3406groups are ignored. Only when no next group matches, other items are tried
3407for a match again. This means that matching a next group and skipping white
3408space and <EOL>s has a higher priority than other items.
3409
3410Example: >
3411 :syn match ifstart "\<if.*" nextgroup=ifline skipwhite skipempty
3412 :syn match ifline "[^ \t].*" nextgroup=ifline skipwhite skipempty contained
3413 :syn match ifline "endif" contained
3414Note that the "[^ \t].*" match matches all non-white text. Thus it would also
3415match "endif". Therefore the "endif" match is put last, so that it takes
3416precedence.
3417Note that this example doesn't work for nested "if"s. You need to add
3418"contains" arguments to make that work (omitted for simplicity of the
3419example).
3420
Bram Moolenaar860cae12010-06-05 23:22:07 +02003421IMPLICIT CONCEAL *:syn-conceal-implicit*
3422
3423:sy[ntax] conceal [on|off]
3424 This defines if the following ":syntax" commands will define keywords,
3425 matches or regions with the "conceal" flag set. After ":syn conceal
3426 on", all subsequent ":syn keyword", ":syn match" or ":syn region"
3427 defined will have the "conceal" flag set implicitly. ":syn conceal
3428 off" returns to the normal state where the "conceal" flag must be
3429 given explicitly.
3430
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431==============================================================================
34327. Syntax patterns *:syn-pattern* *E401* *E402*
3433
3434In the syntax commands, a pattern must be surrounded by two identical
3435characters. This is like it works for the ":s" command. The most common to
3436use is the double quote. But if the pattern contains a double quote, you can
3437use another character that is not used in the pattern. Examples: >
3438 :syntax region Comment start="/\*" end="\*/"
3439 :syntax region String start=+"+ end=+"+ skip=+\\"+
3440
3441See |pattern| for the explanation of what a pattern is. Syntax patterns are
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003442always interpreted like the 'magic' option is set, no matter what the actual
Bram Moolenaar071d4272004-06-13 20:20:40 +00003443value of 'magic' is. And the patterns are interpreted like the 'l' flag is
3444not included in 'cpoptions'. This was done to make syntax files portable and
3445independent of 'compatible' and 'magic' settings.
3446
3447Try to avoid patterns that can match an empty string, such as "[a-z]*".
3448This slows down the highlighting a lot, because it matches everywhere.
3449
3450 *:syn-pattern-offset*
3451The pattern can be followed by a character offset. This can be used to
3452change the highlighted part, and to change the text area included in the
3453match or region (which only matters when trying to match other items). Both
3454are relative to the matched pattern. The character offset for a skip
3455pattern can be used to tell where to continue looking for an end pattern.
3456
3457The offset takes the form of "{what}={offset}"
3458The {what} can be one of seven strings:
3459
3460ms Match Start offset for the start of the matched text
3461me Match End offset for the end of the matched text
3462hs Highlight Start offset for where the highlighting starts
3463he Highlight End offset for where the highlighting ends
3464rs Region Start offset for where the body of a region starts
3465re Region End offset for where the body of a region ends
3466lc Leading Context offset past "leading context" of pattern
3467
3468The {offset} can be:
3469
3470s start of the matched pattern
3471s+{nr} start of the matched pattern plus {nr} chars to the right
3472s-{nr} start of the matched pattern plus {nr} chars to the left
3473e end of the matched pattern
3474e+{nr} end of the matched pattern plus {nr} chars to the right
3475e-{nr} end of the matched pattern plus {nr} chars to the left
3476{nr} (for "lc" only): start matching {nr} chars to the left
3477
3478Examples: "ms=s+1", "hs=e-2", "lc=3".
3479
3480Although all offsets are accepted after any pattern, they are not always
3481meaningful. This table shows which offsets are actually used:
3482
3483 ms me hs he rs re lc ~
3484match item yes yes yes yes - - yes
3485region item start yes - yes - yes - yes
3486region item skip - yes - - - - yes
3487region item end - yes - yes - yes yes
3488
3489Offsets can be concatenated, with a ',' in between. Example: >
3490 :syn match String /"[^"]*"/hs=s+1,he=e-1
3491<
3492 some "string" text
3493 ^^^^^^ highlighted
3494
3495Notes:
3496- There must be no white space between the pattern and the character
3497 offset(s).
3498- The highlighted area will never be outside of the matched text.
3499- A negative offset for an end pattern may not always work, because the end
3500 pattern may be detected when the highlighting should already have stopped.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003501- Before Vim 7.2 the offsets were counted in bytes instead of characters.
3502 This didn't work well for multi-byte characters, so it was changed with the
3503 Vim 7.2 release.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003504- The start of a match cannot be in a line other than where the pattern
3505 matched. This doesn't work: "a\nb"ms=e. You can make the highlighting
3506 start in another line, this does work: "a\nb"hs=e.
3507
3508Example (match a comment but don't highlight the /* and */): >
3509 :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1
3510<
3511 /* this is a comment */
3512 ^^^^^^^^^^^^^^^^^^^ highlighted
3513
3514A more complicated Example: >
3515 :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
3516<
3517 abcfoostringbarabc
3518 mmmmmmmmmmm match
Bram Moolenaar4770d092006-01-12 23:22:24 +00003519 sssrrreee highlight start/region/end ("Foo", "Exa" and "Bar")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003520
3521Leading context *:syn-lc* *:syn-leading* *:syn-context*
3522
3523Note: This is an obsolete feature, only included for backwards compatibility
3524with previous Vim versions. It's now recommended to use the |/\@<=| construct
3525in the pattern.
3526
3527The "lc" offset specifies leading context -- a part of the pattern that must
3528be present, but is not considered part of the match. An offset of "lc=n" will
3529cause Vim to step back n columns before attempting the pattern match, allowing
3530characters which have already been matched in previous patterns to also be
3531used as leading context for this match. This can be used, for instance, to
3532specify that an "escaping" character must not precede the match: >
3533
3534 :syn match ZNoBackslash "[^\\]z"ms=s+1
3535 :syn match WNoBackslash "[^\\]w"lc=1
3536 :syn match Underline "_\+"
3537<
3538 ___zzzz ___wwww
3539 ^^^ ^^^ matches Underline
3540 ^ ^ matches ZNoBackslash
3541 ^^^^ matches WNoBackslash
3542
3543The "ms" offset is automatically set to the same value as the "lc" offset,
3544unless you set "ms" explicitly.
3545
3546
3547Multi-line patterns *:syn-multi-line*
3548
3549The patterns can include "\n" to match an end-of-line. Mostly this works as
3550expected, but there are a few exceptions.
3551
3552When using a start pattern with an offset, the start of the match is not
3553allowed to start in a following line. The highlighting can start in a
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003554following line though. Using the "\zs" item also requires that the start of
3555the match doesn't move to another line.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003556
3557The skip pattern can include the "\n", but the search for an end pattern will
3558continue in the first character of the next line, also when that character is
3559matched by the skip pattern. This is because redrawing may start in any line
3560halfway a region and there is no check if the skip pattern started in a
3561previous line. For example, if the skip pattern is "a\nb" and an end pattern
3562is "b", the end pattern does match in the second line of this: >
3563 x x a
3564 b x x
3565Generally this means that the skip pattern should not match any characters
3566after the "\n".
3567
3568
3569External matches *:syn-ext-match*
3570
3571These extra regular expression items are available in region patterns:
3572
3573 */\z(* */\z(\)* *E50* *E52*
3574 \z(\) Marks the sub-expression as "external", meaning that it is can
3575 be accessed from another pattern match. Currently only usable
3576 in defining a syntax region start pattern.
3577
3578 */\z1* */\z2* */\z3* */\z4* */\z5*
3579 \z1 ... \z9 */\z6* */\z7* */\z8* */\z9* *E66* *E67*
3580 Matches the same string that was matched by the corresponding
3581 sub-expression in a previous start pattern match.
3582
3583Sometimes the start and end patterns of a region need to share a common
3584sub-expression. A common example is the "here" document in Perl and many Unix
3585shells. This effect can be achieved with the "\z" special regular expression
3586items, which marks a sub-expression as "external", in the sense that it can be
3587referenced from outside the pattern in which it is defined. The here-document
3588example, for instance, can be done like this: >
3589 :syn region hereDoc start="<<\z(\I\i*\)" end="^\z1$"
3590
3591As can be seen here, the \z actually does double duty. In the start pattern,
3592it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it
3593changes the \1 back-reference into an external reference referring to the
3594first external sub-expression in the start pattern. External references can
3595also be used in skip patterns: >
3596 :syn region foo start="start \(\I\i*\)" skip="not end \z1" end="end \z1"
3597
3598Note that normal and external sub-expressions are completely orthogonal and
3599indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied
3600to the string "aabb", then \1 will refer to "bb" and \z1 will refer to "aa".
3601Note also that external sub-expressions cannot be accessed as back-references
3602within the same pattern like normal sub-expressions. If you want to use one
3603sub-expression as both a normal and an external sub-expression, you can nest
3604the two, as in "\(\z(...\)\)".
3605
3606Note that only matches within a single line can be used. Multi-line matches
3607cannot be referred to.
3608
3609==============================================================================
36108. Syntax clusters *:syn-cluster* *E400*
3611
3612:sy[ntax] cluster {cluster-name} [contains={group-name}..]
3613 [add={group-name}..]
3614 [remove={group-name}..]
3615
3616This command allows you to cluster a list of syntax groups together under a
3617single name.
3618
3619 contains={group-name}..
3620 The cluster is set to the specified list of groups.
3621 add={group-name}..
3622 The specified groups are added to the cluster.
3623 remove={group-name}..
3624 The specified groups are removed from the cluster.
3625
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003626A cluster so defined may be referred to in a contains=.., containedin=..,
3627nextgroup=.., add=.. or remove=.. list with a "@" prefix. You can also use
3628this notation to implicitly declare a cluster before specifying its contents.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003629
3630Example: >
3631 :syntax match Thing "# [^#]\+ #" contains=@ThingMembers
3632 :syntax cluster ThingMembers contains=ThingMember1,ThingMember2
3633
3634As the previous example suggests, modifications to a cluster are effectively
3635retroactive; the membership of the cluster is checked at the last minute, so
3636to speak: >
3637 :syntax keyword A aaa
3638 :syntax keyword B bbb
3639 :syntax cluster AandB contains=A
3640 :syntax match Stuff "( aaa bbb )" contains=@AandB
3641 :syntax cluster AandB add=B " now both keywords are matched in Stuff
3642
3643This also has implications for nested clusters: >
3644 :syntax keyword A aaa
3645 :syntax keyword B bbb
3646 :syntax cluster SmallGroup contains=B
3647 :syntax cluster BigGroup contains=A,@SmallGroup
3648 :syntax match Stuff "( aaa bbb )" contains=@BigGroup
3649 :syntax cluster BigGroup remove=B " no effect, since B isn't in BigGroup
3650 :syntax cluster SmallGroup remove=B " now bbb isn't matched within Stuff
3651
3652==============================================================================
36539. Including syntax files *:syn-include* *E397*
3654
3655It is often useful for one language's syntax file to include a syntax file for
3656a related language. Depending on the exact relationship, this can be done in
3657two different ways:
3658
3659 - If top-level syntax items in the included syntax file are to be
3660 allowed at the top level in the including syntax, you can simply use
3661 the |:runtime| command: >
3662
3663 " In cpp.vim:
3664 :runtime! syntax/c.vim
3665 :unlet b:current_syntax
3666
3667< - If top-level syntax items in the included syntax file are to be
3668 contained within a region in the including syntax, you can use the
3669 ":syntax include" command:
3670
3671:sy[ntax] include [@{grouplist-name}] {file-name}
3672
3673 All syntax items declared in the included file will have the
3674 "contained" flag added. In addition, if a group list is specified,
3675 all top-level syntax items in the included file will be added to
3676 that list. >
3677
3678 " In perl.vim:
3679 :syntax include @Pod <sfile>:p:h/pod.vim
3680 :syntax region perlPOD start="^=head" end="^=cut" contains=@Pod
3681<
3682 When {file-name} is an absolute path (starts with "/", "c:", "$VAR"
3683 or "<sfile>") that file is sourced. When it is a relative path
3684 (e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'.
3685 All matching files are loaded. Using a relative path is
3686 recommended, because it allows a user to replace the included file
3687 with his own version, without replacing the file that does the ":syn
3688 include".
3689
3690==============================================================================
369110. Synchronizing *:syn-sync* *E403* *E404*
3692
3693Vim wants to be able to start redrawing in any position in the document. To
3694make this possible it needs to know the syntax state at the position where
3695redrawing starts.
3696
3697:sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
3698
3699There are four ways to synchronize:
37001. Always parse from the start of the file.
3701 |:syn-sync-first|
37022. Based on C-style comments. Vim understands how C-comments work and can
3703 figure out if the current line starts inside or outside a comment.
3704 |:syn-sync-second|
37053. Jumping back a certain number of lines and start parsing there.
3706 |:syn-sync-third|
37074. Searching backwards in the text for a pattern to sync on.
3708 |:syn-sync-fourth|
3709
3710 *:syn-sync-maxlines* *:syn-sync-minlines*
3711For the last three methods, the line range where the parsing can start is
3712limited by "minlines" and "maxlines".
3713
3714If the "minlines={N}" argument is given, the parsing always starts at least
3715that many lines backwards. This can be used if the parsing may take a few
3716lines before it's correct, or when it's not possible to use syncing.
3717
3718If the "maxlines={N}" argument is given, the number of lines that are searched
3719for a comment or syncing pattern is restricted to N lines backwards (after
3720adding "minlines"). This is useful if you have few things to sync on and a
3721slow machine. Example: >
3722 :syntax sync ccomment maxlines=500
3723<
3724 *:syn-sync-linebreaks*
3725When using a pattern that matches multiple lines, a change in one line may
3726cause a pattern to no longer match in a previous line. This means has to
3727start above where the change was made. How many lines can be specified with
3728the "linebreaks" argument. For example, when a pattern may include one line
3729break use this: >
3730 :syntax sync linebreaks=1
3731The result is that redrawing always starts at least one line before where a
3732change was made. The default value for "linebreaks" is zero. Usually the
3733value for "minlines" is bigger than "linebreaks".
3734
3735
3736First syncing method: *:syn-sync-first*
3737>
3738 :syntax sync fromstart
3739
3740The file will be parsed from the start. This makes syntax highlighting
3741accurate, but can be slow for long files. Vim caches previously parsed text,
3742so that it's only slow when parsing the text for the first time. However,
3743when making changes some part of the next needs to be parsed again (worst
3744case: to the end of the file).
3745
3746Using "fromstart" is equivalent to using "minlines" with a very large number.
3747
3748
3749Second syncing method: *:syn-sync-second* *:syn-sync-ccomment*
3750
3751For the second method, only the "ccomment" argument needs to be given.
3752Example: >
3753 :syntax sync ccomment
3754
3755When Vim finds that the line where displaying starts is inside a C-style
3756comment, the last region syntax item with the group-name "Comment" will be
3757used. This requires that there is a region with the group-name "Comment"!
3758An alternate group name can be specified, for example: >
3759 :syntax sync ccomment javaComment
3760This means that the last item specified with "syn region javaComment" will be
3761used for the detected C comment region. This only works properly if that
3762region does have a start pattern "\/*" and an end pattern "*\/".
3763
3764The "maxlines" argument can be used to restrict the search to a number of
3765lines. The "minlines" argument can be used to at least start a number of
3766lines back (e.g., for when there is some construct that only takes a few
3767lines, but it hard to sync on).
3768
3769Note: Syncing on a C comment doesn't work properly when strings are used
3770that cross a line and contain a "*/". Since letting strings cross a line
3771is a bad programming habit (many compilers give a warning message), and the
3772chance of a "*/" appearing inside a comment is very small, this restriction
3773is hardly ever noticed.
3774
3775
3776Third syncing method: *:syn-sync-third*
3777
3778For the third method, only the "minlines={N}" argument needs to be given.
3779Vim will subtract {N} from the line number and start parsing there. This
3780means {N} extra lines need to be parsed, which makes this method a bit slower.
3781Example: >
3782 :syntax sync minlines=50
3783
3784"lines" is equivalent to "minlines" (used by older versions).
3785
3786
3787Fourth syncing method: *:syn-sync-fourth*
3788
3789The idea is to synchronize on the end of a few specific regions, called a
3790sync pattern. Only regions can cross lines, so when we find the end of some
3791region, we might be able to know in which syntax item we are. The search
3792starts in the line just above the one where redrawing starts. From there
3793the search continues backwards in the file.
3794
3795This works just like the non-syncing syntax items. You can use contained
3796matches, nextgroup, etc. But there are a few differences:
3797- Keywords cannot be used.
3798- The syntax items with the "sync" keyword form a completely separated group
3799 of syntax items. You can't mix syncing groups and non-syncing groups.
3800- The matching works backwards in the buffer (line by line), instead of
3801 forwards.
3802- A line continuation pattern can be given. It is used to decide which group
3803 of lines need to be searched like they were one line. This means that the
3804 search for a match with the specified items starts in the first of the
3805 consecutive that contain the continuation pattern.
3806- When using "nextgroup" or "contains", this only works within one line (or
3807 group of continued lines).
3808- When using a region, it must start and end in the same line (or group of
3809 continued lines). Otherwise the end is assumed to be at the end of the
3810 line (or group of continued lines).
3811- When a match with a sync pattern is found, the rest of the line (or group of
3812 continued lines) is searched for another match. The last match is used.
3813 This is used when a line can contain both the start end the end of a region
3814 (e.g., in a C-comment like /* this */, the last "*/" is used).
3815
3816There are two ways how a match with a sync pattern can be used:
38171. Parsing for highlighting starts where redrawing starts (and where the
3818 search for the sync pattern started). The syntax group that is expected
3819 to be valid there must be specified. This works well when the regions
3820 that cross lines cannot contain other regions.
38212. Parsing for highlighting continues just after the match. The syntax group
3822 that is expected to be present just after the match must be specified.
3823 This can be used when the previous method doesn't work well. It's much
3824 slower, because more text needs to be parsed.
3825Both types of sync patterns can be used at the same time.
3826
3827Besides the sync patterns, other matches and regions can be specified, to
3828avoid finding unwanted matches.
3829
3830[The reason that the sync patterns are given separately, is that mostly the
3831search for the sync point can be much simpler than figuring out the
3832highlighting. The reduced number of patterns means it will go (much)
3833faster.]
3834
3835 *syn-sync-grouphere* *E393* *E394*
3836 :syntax sync match {sync-group-name} grouphere {group-name} "pattern" ..
3837
3838 Define a match that is used for syncing. {group-name} is the
3839 name of a syntax group that follows just after the match. Parsing
3840 of the text for highlighting starts just after the match. A region
3841 must exist for this {group-name}. The first one defined will be used.
3842 "NONE" can be used for when there is no syntax group after the match.
3843
3844 *syn-sync-groupthere*
3845 :syntax sync match {sync-group-name} groupthere {group-name} "pattern" ..
3846
3847 Like "grouphere", but {group-name} is the name of a syntax group that
3848 is to be used at the start of the line where searching for the sync
3849 point started. The text between the match and the start of the sync
3850 pattern searching is assumed not to change the syntax highlighting.
3851 For example, in C you could search backwards for "/*" and "*/". If
3852 "/*" is found first, you know that you are inside a comment, so the
3853 "groupthere" is "cComment". If "*/" is found first, you know that you
3854 are not in a comment, so the "groupthere" is "NONE". (in practice
3855 it's a bit more complicated, because the "/*" and "*/" could appear
3856 inside a string. That's left as an exercise to the reader...).
3857
3858 :syntax sync match ..
3859 :syntax sync region ..
3860
3861 Without a "groupthere" argument. Define a region or match that is
3862 skipped while searching for a sync point.
3863
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00003864 *syn-sync-linecont*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003865 :syntax sync linecont {pattern}
3866
3867 When {pattern} matches in a line, it is considered to continue in
3868 the next line. This means that the search for a sync point will
3869 consider the lines to be concatenated.
3870
3871If the "maxlines={N}" argument is given too, the number of lines that are
3872searched for a match is restricted to N. This is useful if you have very
3873few things to sync on and a slow machine. Example: >
3874 :syntax sync maxlines=100
3875
3876You can clear all sync settings with: >
3877 :syntax sync clear
3878
3879You can clear specific sync patterns with: >
3880 :syntax sync clear {sync-group-name} ..
3881
3882==============================================================================
388311. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
3884
Bram Moolenaar482aaeb2005-09-29 18:26:07 +00003885This command lists all the syntax items: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00003886
3887 :sy[ntax] [list]
3888
3889To show the syntax items for one syntax group: >
3890
3891 :sy[ntax] list {group-name}
3892
3893To list the syntax groups in one cluster: *E392* >
3894
3895 :sy[ntax] list @{cluster-name}
3896
3897See above for other arguments for the ":syntax" command.
3898
3899Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
3900is mostly used, because it looks better.
3901
3902==============================================================================
390312. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
3904
3905There are three types of highlight groups:
3906- The ones used for specific languages. For these the name starts with the
3907 name of the language. Many of these don't have any attributes, but are
3908 linked to a group of the second type.
3909- The ones used for all syntax languages.
3910- The ones used for the 'highlight' option.
3911 *hitest.vim*
3912You can see all the groups currently active with this command: >
3913 :so $VIMRUNTIME/syntax/hitest.vim
3914This will open a new window containing all highlight group names, displayed
3915in their own color.
3916
3917 *:colo* *:colorscheme* *E185*
Bram Moolenaar00a927d2010-05-14 23:24:24 +02003918:colo[rscheme] Output the name of the currently active color scheme.
3919 This is basically the same as >
3920 :echo g:colors_name
3921< In case g:colors_name has not been defined :colo will
3922 output "default". When compiled without the |+eval|
3923 feature it will output "unknown".
3924
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
3926 for the file "colors/{name}.vim. The first one that
3927 is found is loaded.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003928 To see the name of the currently active color scheme: >
Bram Moolenaar00a927d2010-05-14 23:24:24 +02003929 :colo
3930< The name is also stored in the g:colors_name variable.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003931 Doesn't work recursively, thus you can't use
Bram Moolenaar071d4272004-06-13 20:20:40 +00003932 ":colorscheme" in a color scheme script.
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00003933 After the color scheme has been loaded the
3934 |ColorScheme| autocommand event is triggered.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00003935 For info about writing a colorscheme file: >
3936 :edit $VIMRUNTIME/colors/README.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +00003937
3938:hi[ghlight] List all the current highlight groups that have
3939 attributes set.
3940
3941:hi[ghlight] {group-name}
3942 List one highlight group.
3943
3944:hi[ghlight] clear Reset all highlighting to the defaults. Removes all
3945 highlighting for groups added by the user!
3946 Uses the current value of 'background' to decide which
3947 default colors to use.
3948
3949:hi[ghlight] clear {group-name}
3950:hi[ghlight] {group-name} NONE
3951 Disable the highlighting for one highlight group. It
3952 is _not_ set back to the default colors.
3953
3954:hi[ghlight] [default] {group-name} {key}={arg} ..
3955 Add a highlight group, or change the highlighting for
3956 an existing group.
3957 See |highlight-args| for the {key}={arg} arguments.
3958 See |:highlight-default| for the optional [default]
3959 argument.
3960
3961Normally a highlight group is added once when starting up. This sets the
3962default values for the highlighting. After that, you can use additional
3963highlight commands to change the arguments that you want to set to non-default
3964values. The value "NONE" can be used to switch the value off or go back to
3965the default value.
3966
3967A simple way to change colors is with the |:colorscheme| command. This loads
3968a file with ":highlight" commands such as this: >
3969
3970 :hi Comment gui=bold
3971
3972Note that all settings that are not included remain the same, only the
3973specified field is used, and settings are merged with previous ones. So, the
3974result is like this single command has been used: >
3975 :hi Comment term=bold ctermfg=Cyan guifg=#80a0ff gui=bold
3976<
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00003977 *:highlight-verbose*
Bram Moolenaar661b1822005-07-28 22:36:45 +00003978When listing a highlight group and 'verbose' is non-zero, the listing will
3979also tell where it was last set. Example: >
3980 :verbose hi Comment
3981< Comment xxx term=bold ctermfg=4 guifg=Blue ~
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00003982 Last set from /home/mool/vim/vim7/runtime/syntax/syncolor.vim ~
Bram Moolenaar661b1822005-07-28 22:36:45 +00003983
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00003984When ":hi clear" is used then the script where this command is used will be
3985mentioned for the default values. See |:verbose-cmd| for more information.
Bram Moolenaar661b1822005-07-28 22:36:45 +00003986
Bram Moolenaar071d4272004-06-13 20:20:40 +00003987 *highlight-args* *E416* *E417* *E423*
3988There are three types of terminals for highlighting:
3989term a normal terminal (vt100, xterm)
3990cterm a color terminal (MS-DOS console, color-xterm, these have the "Co"
3991 termcap entry)
3992gui the GUI
3993
3994For each type the highlighting can be given. This makes it possible to use
3995the same syntax file on all terminals, and use the optimal highlighting.
3996
39971. highlight arguments for normal terminals
3998
Bram Moolenaar75c50c42005-06-04 22:06:24 +00003999 *bold* *underline* *undercurl*
4000 *inverse* *italic* *standout*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004001term={attr-list} *attr-list* *highlight-term* *E418*
4002 attr-list is a comma separated list (without spaces) of the
4003 following items (in any order):
4004 bold
4005 underline
Bram Moolenaar5409c052005-03-18 20:27:04 +00004006 undercurl not always available
Bram Moolenaar071d4272004-06-13 20:20:40 +00004007 reverse
4008 inverse same as reverse
4009 italic
4010 standout
4011 NONE no attributes used (used to reset it)
4012
4013 Note that "bold" can be used here and by using a bold font. They
4014 have the same effect.
Bram Moolenaar5409c052005-03-18 20:27:04 +00004015 "undercurl" is a curly underline. When "undercurl" is not possible
4016 then "underline" is used. In general "undercurl" is only available in
Bram Moolenaar910f66f2006-04-05 20:41:53 +00004017 the GUI. The color is set with |highlight-guisp|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004018
4019start={term-list} *highlight-start* *E422*
4020stop={term-list} *term-list* *highlight-stop*
4021 These lists of terminal codes can be used to get
4022 non-standard attributes on a terminal.
4023
4024 The escape sequence specified with the "start" argument
4025 is written before the characters in the highlighted
4026 area. It can be anything that you want to send to the
4027 terminal to highlight this area. The escape sequence
4028 specified with the "stop" argument is written after the
4029 highlighted area. This should undo the "start" argument.
4030 Otherwise the screen will look messed up.
4031
4032 The {term-list} can have two forms:
4033
4034 1. A string with escape sequences.
4035 This is any string of characters, except that it can't start with
4036 "t_" and blanks are not allowed. The <> notation is recognized
4037 here, so you can use things like "<Esc>" and "<Space>". Example:
4038 start=<Esc>[27h;<Esc>[<Space>r;
4039
4040 2. A list of terminal codes.
4041 Each terminal code has the form "t_xx", where "xx" is the name of
4042 the termcap entry. The codes have to be separated with commas.
4043 White space is not allowed. Example:
4044 start=t_C1,t_BL
4045 The terminal codes must exist for this to work.
4046
4047
40482. highlight arguments for color terminals
4049
4050cterm={attr-list} *highlight-cterm*
4051 See above for the description of {attr-list} |attr-list|.
4052 The "cterm" argument is likely to be different from "term", when
4053 colors are used. For example, in a normal terminal comments could
4054 be underlined, in a color terminal they can be made Blue.
4055 Note: Many terminals (e.g., DOS console) can't mix these attributes
4056 with coloring. Use only one of "cterm=" OR "ctermfg=" OR "ctermbg=".
4057
4058ctermfg={color-nr} *highlight-ctermfg* *E421*
4059ctermbg={color-nr} *highlight-ctermbg*
4060 The {color-nr} argument is a color number. Its range is zero to
4061 (not including) the number given by the termcap entry "Co".
4062 The actual color with this number depends on the type of terminal
4063 and its settings. Sometimes the color also depends on the settings of
4064 "cterm". For example, on some systems "cterm=bold ctermfg=3" gives
4065 another color, on others you just get color 3.
4066
4067 For an xterm this depends on your resources, and is a bit
4068 unpredictable. See your xterm documentation for the defaults. The
4069 colors for a color-xterm can be changed from the .Xdefaults file.
4070 Unfortunately this means that it's not possible to get the same colors
4071 for each user. See |xterm-color| for info about color xterms.
4072
4073 The MSDOS standard colors are fixed (in a console window), so these
4074 have been used for the names. But the meaning of color names in X11
4075 are fixed, so these color settings have been used, to make the
4076 highlighting settings portable (complicated, isn't it?). The
4077 following names are recognized, with the color number used:
4078
4079 *cterm-colors*
4080 NR-16 NR-8 COLOR NAME ~
4081 0 0 Black
4082 1 4 DarkBlue
4083 2 2 DarkGreen
4084 3 6 DarkCyan
4085 4 1 DarkRed
4086 5 5 DarkMagenta
4087 6 3 Brown, DarkYellow
4088 7 7 LightGray, LightGrey, Gray, Grey
4089 8 0* DarkGray, DarkGrey
4090 9 4* Blue, LightBlue
4091 10 2* Green, LightGreen
4092 11 6* Cyan, LightCyan
4093 12 1* Red, LightRed
4094 13 5* Magenta, LightMagenta
4095 14 3* Yellow, LightYellow
4096 15 7* White
4097
4098 The number under "NR-16" is used for 16-color terminals ('t_Co'
4099 greater than or equal to 16). The number under "NR-8" is used for
4100 8-color terminals ('t_Co' less than 16). The '*' indicates that the
4101 bold attribute is set for ctermfg. In many 8-color terminals (e.g.,
4102 "linux"), this causes the bright colors to appear. This doesn't work
4103 for background colors! Without the '*' the bold attribute is removed.
4104 If you want to set the bold attribute in a different way, put a
4105 "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument. Or use
4106 a number instead of a color name.
4107
4108 The case of the color names is ignored.
4109 Note that for 16 color ansi style terminals (including xterms), the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004110 numbers in the NR-8 column is used. Here '*' means 'add 8' so that Blue
Bram Moolenaar071d4272004-06-13 20:20:40 +00004111 is 12, DarkGray is 8 etc.
4112
4113 Note that for some color terminals these names may result in the wrong
4114 colors!
4115
4116 *:hi-normal-cterm*
4117 When setting the "ctermfg" or "ctermbg" colors for the Normal group,
4118 these will become the colors used for the non-highlighted text.
4119 Example: >
4120 :highlight Normal ctermfg=grey ctermbg=darkblue
4121< When setting the "ctermbg" color for the Normal group, the
4122 'background' option will be adjusted automatically. This causes the
4123 highlight groups that depend on 'background' to change! This means
4124 you should set the colors for Normal first, before setting other
4125 colors.
4126 When a colorscheme is being used, changing 'background' causes it to
4127 be reloaded, which may reset all colors (including Normal). First
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01004128 delete the "g:colors_name" variable when you don't want this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129
4130 When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
4131 needs to reset the color when exiting. This is done with the "op"
4132 termcap entry |t_op|. If this doesn't work correctly, try setting the
4133 't_op' option in your .vimrc.
4134 *E419* *E420*
4135 When Vim knows the normal foreground and background colors, "fg" and
4136 "bg" can be used as color names. This only works after setting the
4137 colors for the Normal group and for the MS-DOS console. Example, for
4138 reverse video: >
4139 :highlight Visual ctermfg=bg ctermbg=fg
4140< Note that the colors are used that are valid at the moment this
4141 command are given. If the Normal group colors are changed later, the
4142 "fg" and "bg" colors will not be adjusted.
4143
4144
41453. highlight arguments for the GUI
4146
4147gui={attr-list} *highlight-gui*
4148 These give the attributes to use in the GUI mode.
4149 See |attr-list| for a description.
4150 Note that "bold" can be used here and by using a bold font. They
4151 have the same effect.
4152 Note that the attributes are ignored for the "Normal" group.
4153
4154font={font-name} *highlight-font*
4155 font-name is the name of a font, as it is used on the system Vim
4156 runs on. For X11 this is a complicated name, for example: >
4157 font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
4158<
4159 The font-name "NONE" can be used to revert to the default font.
4160 When setting the font for the "Normal" group, this becomes the default
4161 font (until the 'guifont' option is changed; the last one set is
4162 used).
4163 The following only works with Motif and Athena, not with other GUIs:
4164 When setting the font for the "Menu" group, the menus will be changed.
4165 When setting the font for the "Tooltip" group, the tooltips will be
4166 changed.
4167 All fonts used, except for Menu and Tooltip, should be of the same
4168 character size as the default font! Otherwise redrawing problems will
4169 occur.
4170
4171guifg={color-name} *highlight-guifg*
4172guibg={color-name} *highlight-guibg*
Bram Moolenaar5409c052005-03-18 20:27:04 +00004173guisp={color-name} *highlight-guisp*
4174 These give the foreground (guifg), background (guibg) and special
Bram Moolenaar7df351e2006-01-23 22:30:28 +00004175 (guisp) color to use in the GUI. "guisp" is used for undercurl.
4176 There are a few special names:
Bram Moolenaar071d4272004-06-13 20:20:40 +00004177 NONE no color (transparent)
4178 bg use normal background color
4179 background use normal background color
4180 fg use normal foreground color
4181 foreground use normal foreground color
4182 To use a color name with an embedded space or other special character,
4183 put it in single quotes. The single quote cannot be used then.
4184 Example: >
4185 :hi comment guifg='salmon pink'
4186<
4187 *gui-colors*
4188 Suggested color names (these are available on most systems):
4189 Red LightRed DarkRed
4190 Green LightGreen DarkGreen SeaGreen
4191 Blue LightBlue DarkBlue SlateBlue
4192 Cyan LightCyan DarkCyan
4193 Magenta LightMagenta DarkMagenta
4194 Yellow LightYellow Brown DarkYellow
4195 Gray LightGray DarkGray
4196 Black White
4197 Orange Purple Violet
4198
4199 In the Win32 GUI version, additional system colors are available. See
4200 |win32-colors|.
4201
4202 You can also specify a color by its Red, Green and Blue values.
4203 The format is "#rrggbb", where
4204 "rr" is the Red value
Bram Moolenaar071d4272004-06-13 20:20:40 +00004205 "gg" is the Green value
Bram Moolenaar5409c052005-03-18 20:27:04 +00004206 "bb" is the Blue value
Bram Moolenaar071d4272004-06-13 20:20:40 +00004207 All values are hexadecimal, range from "00" to "ff". Examples: >
4208 :highlight Comment guifg=#11f0c3 guibg=#ff00ff
4209<
4210 *highlight-groups* *highlight-default*
4211These are the default highlighting groups. These groups are used by the
4212'highlight' option default. Note that the highlighting depends on the value
4213of 'background'. You can see the current settings with the ":highlight"
4214command.
Bram Moolenaar860cae12010-06-05 23:22:07 +02004215 *hl-Conceal*
4216Conceal placeholder characters substituted for concealed
4217 text (see 'conceallevel')
Bram Moolenaar071d4272004-06-13 20:20:40 +00004218 *hl-Cursor*
4219Cursor the character under the cursor
4220 *hl-CursorIM*
4221CursorIM like Cursor, but used when in IME mode |CursorIM|
Bram Moolenaar5316eee2006-03-12 22:11:10 +00004222 *hl-CursorColumn*
4223CursorColumn the screen column that the cursor is in when 'cursorcolumn' is
4224 set
4225 *hl-CursorLine*
4226CursorLine the screen line that the cursor is in when 'cursorline' is
4227 set
Bram Moolenaar071d4272004-06-13 20:20:40 +00004228 *hl-Directory*
4229Directory directory names (and other special names in listings)
4230 *hl-DiffAdd*
4231DiffAdd diff mode: Added line |diff.txt|
4232 *hl-DiffChange*
4233DiffChange diff mode: Changed line |diff.txt|
4234 *hl-DiffDelete*
4235DiffDelete diff mode: Deleted line |diff.txt|
4236 *hl-DiffText*
4237DiffText diff mode: Changed text within a changed line |diff.txt|
4238 *hl-ErrorMsg*
4239ErrorMsg error messages on the command line
4240 *hl-VertSplit*
4241VertSplit the column separating vertically split windows
4242 *hl-Folded*
4243Folded line used for closed folds
4244 *hl-FoldColumn*
4245FoldColumn 'foldcolumn'
4246 *hl-SignColumn*
4247SignColumn column where |signs| are displayed
4248 *hl-IncSearch*
4249IncSearch 'incsearch' highlighting; also used for the text replaced with
4250 ":s///c"
4251 *hl-LineNr*
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00004252LineNr Line number for ":number" and ":#" commands, and when 'number'
Bram Moolenaar64486672010-05-16 15:46:46 +02004253 or 'relativenumber' option is set.
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00004254 *hl-MatchParen*
4255MatchParen The character under the cursor or just before it, if it
4256 is a paired bracket, and its match. |pi_paren.txt|
4257
Bram Moolenaar071d4272004-06-13 20:20:40 +00004258 *hl-ModeMsg*
4259ModeMsg 'showmode' message (e.g., "-- INSERT --")
4260 *hl-MoreMsg*
4261MoreMsg |more-prompt|
4262 *hl-NonText*
4263NonText '~' and '@' at the end of the window, characters from
4264 'showbreak' and other characters that do not really exist in
4265 the text (e.g., ">" displayed when a double-wide character
4266 doesn't fit at the end of the line).
4267 *hl-Normal*
4268Normal normal text
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00004269 *hl-Pmenu*
4270Pmenu Popup menu: normal item.
4271 *hl-PmenuSel*
4272PmenuSel Popup menu: selected item.
4273 *hl-PmenuSbar*
4274PmenuSbar Popup menu: scrollbar.
4275 *hl-PmenuThumb*
4276PmenuThumb Popup menu: Thumb of the scrollbar.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004277 *hl-Question*
4278Question |hit-enter| prompt and yes/no questions
4279 *hl-Search*
4280Search Last search pattern highlighting (see 'hlsearch').
4281 Also used for highlighting the current line in the quickfix
4282 window and similar items that need to stand out.
4283 *hl-SpecialKey*
4284SpecialKey Meta and special keys listed with ":map", also for text used
4285 to show unprintable characters in the text, 'listchars'.
4286 Generally: text that is displayed differently from what it
4287 really is.
Bram Moolenaar217ad922005-03-20 22:37:15 +00004288 *hl-SpellBad*
4289SpellBad Word that is not recognized by the spellchecker. |spell|
4290 This will be combined with the highlighting used otherwise.
Bram Moolenaar53180ce2005-07-05 21:48:14 +00004291 *hl-SpellCap*
4292SpellCap Word that should start with a capital. |spell|
4293 This will be combined with the highlighting used otherwise.
Bram Moolenaar217ad922005-03-20 22:37:15 +00004294 *hl-SpellLocal*
4295SpellLocal Word that is recognized by the spellchecker as one that is
4296 used in another region. |spell|
4297 This will be combined with the highlighting used otherwise.
4298 *hl-SpellRare*
4299SpellRare Word that is recognized by the spellchecker as one that is
4300 hardly ever used. |spell|
4301 This will be combined with the highlighting used otherwise.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004302 *hl-StatusLine*
4303StatusLine status line of current window
4304 *hl-StatusLineNC*
4305StatusLineNC status lines of not-current windows
4306 Note: if this is equal to "StatusLine" Vim will use "^^^" in
4307 the status line of the current window.
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004308 *hl-TabLine*
4309TabLine tab pages line, not active tab page label
4310 *hl-TabLineFill*
4311TabLineFill tab pages line, where there are no labels
4312 *hl-TabLineSel*
4313TabLineSel tab pages line, active tab page label
Bram Moolenaar071d4272004-06-13 20:20:40 +00004314 *hl-Title*
4315Title titles for output from ":set all", ":autocmd" etc.
4316 *hl-Visual*
4317Visual Visual mode selection
4318 *hl-VisualNOS*
4319VisualNOS Visual mode selection when vim is "Not Owning the Selection".
4320 Only X11 Gui's |gui-x11| and |xterm-clipboard| supports this.
4321 *hl-WarningMsg*
4322WarningMsg warning messages
4323 *hl-WildMenu*
4324WildMenu current match in 'wildmenu' completion
4325
Bram Moolenaarf75a9632005-09-13 21:20:47 +00004326 *hl-User1* *hl-User1..9* *hl-User9*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004327The 'statusline' syntax allows the use of 9 different highlights in the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004328statusline and ruler (via 'rulerformat'). The names are User1 to User9.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004329
Bram Moolenaar8c8de832008-06-24 22:58:06 +00004330For the GUI you can use the following groups to set the colors for the menu,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004331scrollbars and tooltips. They don't have defaults. This doesn't work for the
4332Win32 GUI. Only three highlight arguments have any effect here: font, guibg,
4333and guifg.
4334
4335 *hl-Menu*
4336Menu Current font, background and foreground colors of the menus.
4337 Also used for the toolbar.
4338 Applicable highlight arguments: font, guibg, guifg.
4339
4340 NOTE: For Motif and Athena the font argument actually
4341 specifies a fontset at all times, no matter if 'guifontset' is
4342 empty, and as such it is tied to the current |:language| when
4343 set.
4344
4345 *hl-Scrollbar*
4346Scrollbar Current background and foreground of the main window's
4347 scrollbars.
4348 Applicable highlight arguments: guibg, guifg.
4349
4350 *hl-Tooltip*
4351Tooltip Current font, background and foreground of the tooltips.
4352 Applicable highlight arguments: font, guibg, guifg.
4353
4354 NOTE: For Motif and Athena the font argument actually
4355 specifies a fontset at all times, no matter if 'guifontset' is
4356 empty, and as such it is tied to the current |:language| when
4357 set.
4358
4359==============================================================================
436013. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
4361
4362When you want to use the same highlighting for several syntax groups, you
4363can do this more easily by linking the groups into one common highlight
4364group, and give the color attributes only for that group.
4365
4366To set a link:
4367
4368 :hi[ghlight][!] [default] link {from-group} {to-group}
4369
4370To remove a link:
4371
4372 :hi[ghlight][!] [default] link {from-group} NONE
4373
4374Notes: *E414*
4375- If the {from-group} and/or {to-group} doesn't exist, it is created. You
4376 don't get an error message for a non-existing group.
4377- As soon as you use a ":highlight" command for a linked group, the link is
4378 removed.
4379- If there are already highlight settings for the {from-group}, the link is
4380 not made, unless the '!' is given. For a ":highlight link" command in a
4381 sourced file, you don't get an error message. This can be used to skip
4382 links for groups that already have settings.
4383
4384 *:hi-default* *:highlight-default*
4385The [default] argument is used for setting the default highlighting for a
4386group. If highlighting has already been specified for the group the command
4387will be ignored. Also when there is an existing link.
4388
4389Using [default] is especially useful to overrule the highlighting of a
4390specific syntax file. For example, the C syntax file contains: >
4391 :highlight default link cComment Comment
4392If you like Question highlighting for C comments, put this in your vimrc file: >
4393 :highlight link cComment Question
4394Without the "default" in the C syntax file, the highlighting would be
4395overruled when the syntax file is loaded.
4396
4397==============================================================================
439814. Cleaning up *:syn-clear* *E391*
4399
4400If you want to clear the syntax stuff for the current buffer, you can use this
4401command: >
4402 :syntax clear
4403
4404This command should be used when you want to switch off syntax highlighting,
4405or when you want to switch to using another syntax. It's normally not needed
4406in a syntax file itself, because syntax is cleared by the autocommands that
4407load the syntax file.
4408The command also deletes the "b:current_syntax" variable, since no syntax is
4409loaded after this command.
4410
4411If you want to disable syntax highlighting for all buffers, you need to remove
4412the autocommands that load the syntax files: >
4413 :syntax off
4414
4415What this command actually does, is executing the command >
4416 :source $VIMRUNTIME/syntax/nosyntax.vim
4417See the "nosyntax.vim" file for details. Note that for this to work
4418$VIMRUNTIME must be valid. See |$VIMRUNTIME|.
4419
4420To clean up specific syntax groups for the current buffer: >
4421 :syntax clear {group-name} ..
4422This removes all patterns and keywords for {group-name}.
4423
4424To clean up specific syntax group lists for the current buffer: >
4425 :syntax clear @{grouplist-name} ..
4426This sets {grouplist-name}'s contents to an empty list.
4427
4428 *:syntax-reset* *:syn-reset*
4429If you have changed the colors and messed them up, use this command to get the
4430defaults back: >
4431
4432 :syntax reset
4433
4434This doesn't change the colors for the 'highlight' option.
4435
4436Note that the syntax colors that you set in your vimrc file will also be reset
4437back to their Vim default.
4438Note that if you are using a color scheme, the colors defined by the color
4439scheme for syntax highlighting will be lost.
4440
4441What this actually does is: >
4442
4443 let g:syntax_cmd = "reset"
4444 runtime! syntax/syncolor.vim
4445
4446Note that this uses the 'runtimepath' option.
4447
4448 *syncolor*
4449If you want to use different colors for syntax highlighting, you can add a Vim
4450script file to set these colors. Put this file in a directory in
4451'runtimepath' which comes after $VIMRUNTIME, so that your settings overrule
4452the default colors. This way these colors will be used after the ":syntax
4453reset" command.
4454
4455For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: >
4456
4457 if &background == "light"
4458 highlight comment ctermfg=darkgreen guifg=darkgreen
4459 else
4460 highlight comment ctermfg=green guifg=green
4461 endif
4462
Bram Moolenaarc0197e22004-09-13 20:26:32 +00004463 *E679*
4464Do make sure this syncolor.vim script does not use a "syntax on", set the
4465'background' option or uses a "colorscheme" command, because it results in an
4466endless loop.
4467
Bram Moolenaar071d4272004-06-13 20:20:40 +00004468Note that when a color scheme is used, there might be some confusion whether
4469your defined colors are to be used or the colors from the scheme. This
4470depends on the color scheme file. See |:colorscheme|.
4471
4472 *syntax_cmd*
4473The "syntax_cmd" variable is set to one of these values when the
4474syntax/syncolor.vim files are loaded:
4475 "on" ":syntax on" command. Highlight colors are overruled but
4476 links are kept
4477 "enable" ":syntax enable" command. Only define colors for groups that
4478 don't have highlighting yet. Use ":syntax default".
4479 "reset" ":syntax reset" command or loading a color scheme. Define all
4480 the colors.
4481 "skip" Don't define colors. Used to skip the default settings when a
4482 syncolor.vim file earlier in 'runtimepath' has already set
4483 them.
4484
4485==============================================================================
448615. Highlighting tags *tag-highlight*
4487
4488If you want to highlight all the tags in your file, you can use the following
4489mappings.
4490
4491 <F11> -- Generate tags.vim file, and highlight tags.
4492 <F12> -- Just highlight tags based on existing tags.vim file.
4493>
4494 :map <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
4495 :map <F12> :so tags.vim<CR>
4496
4497WARNING: The longer the tags file, the slower this will be, and the more
4498memory Vim will consume.
4499
4500Only highlighting typedefs, unions and structs can be done too. For this you
4501must use Exuberant ctags (found at http://ctags.sf.net).
4502
4503Put these lines in your Makefile:
4504
4505# Make a highlight file for types. Requires Exuberant ctags and awk
4506types: types.vim
4507types.vim: *.[ch]
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004508 ctags --c-kinds=gstu -o- *.[ch] |\
Bram Moolenaar071d4272004-06-13 20:20:40 +00004509 awk 'BEGIN{printf("syntax keyword Type\t")}\
4510 {printf("%s ", $$1)}END{print ""}' > $@
4511
4512And put these lines in your .vimrc: >
4513
4514 " load the types.vim highlighting file, if it exists
4515 autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
4516 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
4517 autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname
4518 autocmd BufRead,BufNewFile *.[ch] endif
4519
4520==============================================================================
Bram Moolenaar860cae12010-06-05 23:22:07 +0200452116. Window-local syntax *:ownsyntax*
4522
4523Normally all windows on a buffer share the same syntax settings. It is
4524possible, however, to set a particular window on a file to have its own
4525private syntax setting. A possible example would be to edit LaTeX source
4526with conventional highlighting in one window, while seeing the same source
4527highlighted differently (so as to hide control sequences and indicate bold,
4528italic etc regions) in another. The 'scrollbind' option is useful here.
4529
4530To set the current window to have the syntax "foo", separately from all other
4531windows on the buffer: >
4532 :ownsyntax foo
Bram Moolenaardebe25a2010-06-06 17:41:24 +02004533< *w:current_syntax*
4534This will set the "w:current_syntax" variable to "foo". The value of
4535"b:current_syntax" does not change. This is implemented by saving and
4536restoring "b:current_syntax", since the syntax files do set
4537"b:current_syntax". The value set by the syntax file is assigned to
4538"w:current_syntax".
Bram Moolenaar860cae12010-06-05 23:22:07 +02004539
4540Once a window has its own syntax, syntax commands executed from other windows
4541on the same buffer (including :syntax clear) have no effect. Conversely,
4542syntax commands executed from that window do not effect other windows on the
4543same buffer.
4544
Bram Moolenaardebe25a2010-06-06 17:41:24 +02004545A window with its own syntax reverts to normal behavior when another buffer
4546is loaded into that window or the file is reloaded.
4547When splitting the window, the new window will use the original syntax.
Bram Moolenaar860cae12010-06-05 23:22:07 +02004548
4549==============================================================================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000455016. Color xterms *xterm-color* *color-xterm*
4551
4552Most color xterms have only eight colors. If you don't get colors with the
4553default setup, it should work with these lines in your .vimrc: >
4554 :if &term =~ "xterm"
4555 : if has("terminfo")
4556 : set t_Co=8
4557 : set t_Sf=<Esc>[3%p1%dm
4558 : set t_Sb=<Esc>[4%p1%dm
4559 : else
4560 : set t_Co=8
4561 : set t_Sf=<Esc>[3%dm
4562 : set t_Sb=<Esc>[4%dm
4563 : endif
4564 :endif
4565< [<Esc> is a real escape, type CTRL-V <Esc>]
4566
4567You might want to change the first "if" to match the name of your terminal,
4568e.g. "dtterm" instead of "xterm".
4569
4570Note: Do these settings BEFORE doing ":syntax on". Otherwise the colors may
4571be wrong.
4572 *xiterm* *rxvt*
4573The above settings have been mentioned to work for xiterm and rxvt too.
4574But for using 16 colors in an rxvt these should work with terminfo: >
4575 :set t_AB=<Esc>[%?%p1%{8}%<%t25;%p1%{40}%+%e5;%p1%{32}%+%;%dm
4576 :set t_AF=<Esc>[%?%p1%{8}%<%t22;%p1%{30}%+%e1;%p1%{22}%+%;%dm
4577<
4578 *colortest.vim*
4579To test your color setup, a file has been included in the Vim distribution.
Bram Moolenaarf740b292006-02-16 22:11:02 +00004580To use it, execute this command: >
4581 :runtime syntax/colortest.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00004582
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004583Some versions of xterm (and other terminals, like the Linux console) can
Bram Moolenaar071d4272004-06-13 20:20:40 +00004584output lighter foreground colors, even though the number of colors is defined
4585at 8. Therefore Vim sets the "cterm=bold" attribute for light foreground
4586colors, when 't_Co' is 8.
4587
4588 *xfree-xterm*
4589To get 16 colors or more, get the newest xterm version (which should be
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004590included with XFree86 3.3 and later). You can also find the latest version
Bram Moolenaar071d4272004-06-13 20:20:40 +00004591at: >
4592 http://invisible-island.net/xterm/xterm.html
4593Here is a good way to configure it. This uses 88 colors and enables the
4594termcap-query feature, which allows Vim to ask the xterm how many colors it
4595supports. >
4596 ./configure --disable-bold-color --enable-88-color --enable-tcap-query
4597If you only get 8 colors, check the xterm compilation settings.
4598(Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
4599
4600This xterm should work with these lines in your .vimrc (for 16 colors): >
4601 :if has("terminfo")
4602 : set t_Co=16
4603 : set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
4604 : set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
4605 :else
4606 : set t_Co=16
4607 : set t_Sf=<Esc>[3%dm
4608 : set t_Sb=<Esc>[4%dm
4609 :endif
4610< [<Esc> is a real escape, type CTRL-V <Esc>]
4611
4612Without |+terminfo|, Vim will recognize these settings, and automatically
4613translate cterm colors of 8 and above to "<Esc>[9%dm" and "<Esc>[10%dm".
4614Colors above 16 are also translated automatically.
4615
4616For 256 colors this has been reported to work: >
4617
4618 :set t_AB=<Esc>[48;5;%dm
4619 :set t_AF=<Esc>[38;5;%dm
4620
4621Or just set the TERM environment variable to "xterm-color" or "xterm-16color"
4622and try if that works.
4623
4624You probably want to use these X resources (in your ~/.Xdefaults file):
4625 XTerm*color0: #000000
4626 XTerm*color1: #c00000
4627 XTerm*color2: #008000
4628 XTerm*color3: #808000
4629 XTerm*color4: #0000c0
4630 XTerm*color5: #c000c0
4631 XTerm*color6: #008080
4632 XTerm*color7: #c0c0c0
4633 XTerm*color8: #808080
4634 XTerm*color9: #ff6060
4635 XTerm*color10: #00ff00
4636 XTerm*color11: #ffff00
4637 XTerm*color12: #8080ff
4638 XTerm*color13: #ff40ff
4639 XTerm*color14: #00ffff
4640 XTerm*color15: #ffffff
4641 Xterm*cursorColor: Black
4642
4643[Note: The cursorColor is required to work around a bug, which changes the
4644cursor color to the color of the last drawn text. This has been fixed by a
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004645newer version of xterm, but not everybody is using it yet.]
Bram Moolenaar071d4272004-06-13 20:20:40 +00004646
4647To get these right away, reload the .Xdefaults file to the X Option database
4648Manager (you only need to do this when you just changed the .Xdefaults file): >
4649 xrdb -merge ~/.Xdefaults
4650<
4651 *xterm-blink* *xterm-blinking-cursor*
4652To make the cursor blink in an xterm, see tools/blink.c. Or use Thomas
4653Dickey's xterm above patchlevel 107 (see above for where to get it), with
4654these resources:
4655 XTerm*cursorBlink: on
4656 XTerm*cursorOnTime: 400
4657 XTerm*cursorOffTime: 250
4658 XTerm*cursorColor: White
4659
4660 *hpterm-color*
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004661These settings work (more or less) for an hpterm, which only supports 8
Bram Moolenaar071d4272004-06-13 20:20:40 +00004662foreground colors: >
4663 :if has("terminfo")
4664 : set t_Co=8
4665 : set t_Sf=<Esc>[&v%p1%dS
4666 : set t_Sb=<Esc>[&v7S
4667 :else
4668 : set t_Co=8
4669 : set t_Sf=<Esc>[&v%dS
4670 : set t_Sb=<Esc>[&v7S
4671 :endif
4672< [<Esc> is a real escape, type CTRL-V <Esc>]
4673
4674 *Eterm* *enlightened-terminal*
4675These settings have been reported to work for the Enlightened terminal
4676emulator, or Eterm. They might work for all xterm-like terminals that use the
4677bold attribute to get bright colors. Add an ":if" like above when needed. >
4678 :set t_Co=16
4679 :set t_AF=^[[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
4680 :set t_AB=^[[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m
4681<
4682 *TTpro-telnet*
4683These settings should work for TTpro telnet. Tera Term Pro is a freeware /
4684open-source program for MS-Windows. >
4685 set t_Co=16
4686 set t_AB=^[[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{32}%+5;%;%dm
4687 set t_AF=^[[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{22}%+1;%;%dm
4688Also make sure TTpro's Setup / Window / Full Color is enabled, and make sure
4689that Setup / Font / Enable Bold is NOT enabled.
4690(info provided by John Love-Jensen <eljay@Adobe.COM>)
4691
4692 vim:tw=78:sw=4:ts=8:ft=help:norl: