blob: 109276f40d5dccd47abe81d8ac060048062e65f5 [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|
3816. Color xterms |xterm-color|
39
40{Vi does not have any of these commands}
41
42Syntax highlighting is not available when the |+syntax| feature has been
43disabled at compile time.
44
45==============================================================================
461. Quick start *:syn-qstart*
47
48 *:syn-enable* *:syntax-enable*
49This command switches on syntax highlighting: >
50
51 :syntax enable
52
53What this command actually does is to execute the command >
54 :source $VIMRUNTIME/syntax/syntax.vim
55
56If the VIM environment variable is not set, Vim will try to find
57the path in another way (see |$VIMRUNTIME|). Usually this works just
58fine. If it doesn't, try setting the VIM environment variable to the
59directory where the Vim stuff is located. For example, if your syntax files
60are in the "/usr/vim/vim50/syntax" directory, set $VIMRUNTIME to
61"/usr/vim/vim50". You must do this in the shell, before starting Vim.
62
63 *:syn-on* *:syntax-on*
64The ":syntax enable" command will keep your current color settings. This
65allows using ":highlight" commands to set your preferred colors before or
66after using this command. If you want Vim to overrule your settings with the
67defaults, use: >
68 :syntax on
69<
70 *:hi-normal* *:highlight-normal*
71If you are running in the GUI, you can get white text on a black background
72with: >
73 :highlight Normal guibg=Black guifg=White
74For a color terminal see |:hi-normal-cterm|.
75For setting up your own colors syntax highlighting see |syncolor|.
76
77NOTE: The syntax files on MS-DOS and Windows have lines that end in <CR><NL>.
78The files for Unix end in <NL>. This means you should use the right type of
79file for your system. Although on MS-DOS and Windows the right format is
80automatically selected if the 'fileformats' option is not empty.
81
82NOTE: When using reverse video ("gvim -fg white -bg black"), the default value
83of 'background' will not be set until the GUI window is opened, which is after
Bram Moolenaar910f66f2006-04-05 20:41:53 +000084reading the |gvimrc|. This will cause the wrong default highlighting to be
Bram Moolenaar071d4272004-06-13 20:20:40 +000085used. To set the default value of 'background' before switching on
Bram Moolenaar910f66f2006-04-05 20:41:53 +000086highlighting, include the ":gui" command in the |gvimrc|: >
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
88 :gui " open window and set default for 'background'
89 :syntax on " start highlighting, use 'background' to set colors
90
Bram Moolenaar910f66f2006-04-05 20:41:53 +000091NOTE: Using ":gui" in the |gvimrc| means that "gvim -f" won't start in the
Bram Moolenaar071d4272004-06-13 20:20:40 +000092foreground! Use ":gui -f" then.
93
94
95You can toggle the syntax on/off with this command >
96 :if exists("syntax_on") | syntax off | else | syntax enable | endif
97
98To put this into a mapping, you can use: >
99 :map <F7> :if exists("syntax_on") <Bar>
100 \ syntax off <Bar>
101 \ else <Bar>
102 \ syntax enable <Bar>
103 \ endif <CR>
104[using the |<>| notation, type this literally]
105
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000106Details:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107The ":syntax" commands are implemented by sourcing a file. To see exactly how
108this works, look in the file:
109 command file ~
110 :syntax enable $VIMRUNTIME/syntax/syntax.vim
111 :syntax on $VIMRUNTIME/syntax/syntax.vim
112 :syntax manual $VIMRUNTIME/syntax/manual.vim
113 :syntax off $VIMRUNTIME/syntax/nosyntax.vim
114Also see |syntax-loading|.
115
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100116NOTE: If displaying long lines is slow and switching off syntax highlighting
117makes it fast, consider setting the 'synmaxcol' option to a lower value.
118
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119==============================================================================
1202. Syntax files *:syn-files*
121
122The syntax and highlighting commands for one language are normally stored in
123a syntax file. The name convention is: "{name}.vim". Where {name} is the
124name of the language, or an abbreviation (to fit the name in 8.3 characters,
125a requirement in case the file is used on a DOS filesystem).
126Examples:
127 c.vim perl.vim java.vim html.vim
128 cpp.vim sh.vim csh.vim
129
130The syntax file can contain any Ex commands, just like a vimrc file. But
131the idea is that only commands for a specific language are included. When a
132language is a superset of another language, it may include the other one,
133for example, the cpp.vim file could include the c.vim file: >
134 :so $VIMRUNTIME/syntax/c.vim
135
136The .vim files are normally loaded with an autocommand. For example: >
137 :au Syntax c runtime! syntax/c.vim
138 :au Syntax cpp runtime! syntax/cpp.vim
139These commands are normally in the file $VIMRUNTIME/syntax/synload.vim.
140
141
142MAKING YOUR OWN SYNTAX FILES *mysyntaxfile*
143
144When you create your own syntax files, and you want to have Vim use these
145automatically with ":syntax enable", do this:
146
1471. Create your user runtime directory. You would normally use the first item
148 of the 'runtimepath' option. Example for Unix: >
149 mkdir ~/.vim
150
1512. Create a directory in there called "syntax". For Unix: >
152 mkdir ~/.vim/syntax
153
1543. Write the Vim syntax file. Or download one from the internet. Then write
155 it in your syntax directory. For example, for the "mine" syntax: >
156 :w ~/.vim/syntax/mine.vim
157
158Now you can start using your syntax file manually: >
159 :set syntax=mine
160You don't have to exit Vim to use this.
161
162If you also want Vim to detect the type of file, see |new-filetype|.
163
164If you are setting up a system with many users and you don't want each user
165to add the same syntax file, you can use another directory from 'runtimepath'.
166
167
168ADDING TO AN EXISTING SYNTAX FILE *mysyntaxfile-add*
169
170If you are mostly satisfied with an existing syntax file, but would like to
171add a few items or change the highlighting, follow these steps:
172
1731. Create your user directory from 'runtimepath', see above.
174
1752. Create a directory in there called "after/syntax". For Unix: >
176 mkdir ~/.vim/after
177 mkdir ~/.vim/after/syntax
178
1793. Write a Vim script that contains the commands you want to use. For
180 example, to change the colors for the C syntax: >
181 highlight cComment ctermfg=Green guifg=Green
182
1834. Write that file in the "after/syntax" directory. Use the name of the
184 syntax, with ".vim" added. For our C syntax: >
185 :w ~/.vim/after/syntax/c.vim
186
187That's it. The next time you edit a C file the Comment color will be
188different. You don't even have to restart Vim.
189
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000190If you have multiple files, you can use the filetype as the directory name.
191All the "*.vim" files in this directory will be used, for example:
192 ~/.vim/after/syntax/c/one.vim
193 ~/.vim/after/syntax/c/two.vim
194
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195
196REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
197
198If you don't like a distributed syntax file, or you have downloaded a new
199version, follow the same steps as for |mysyntaxfile| above. Just make sure
200that you write the syntax file in a directory that is early in 'runtimepath'.
201Vim will only load the first syntax file found.
202
203
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100204NAMING CONVENTIONS *group-name* *{group-name}* *E669* *W18*
205
206A syntax group name is to be used for syntax items that match the same kind of
207thing. These are then linked to a highlight group that specifies the color.
208A syntax group name doesn't specify any color or attributes itself.
209
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210The name for a highlight or syntax group must consist of ASCII letters, digits
211and the underscore. As a regexp: "[a-zA-Z0-9_]*"
212
213To be able to allow each user to pick his favorite set of colors, there must
214be preferred names for highlight groups that are common for many languages.
215These are the suggested group names (if syntax highlighting works properly
216you can see the actual color, except for "Ignore"):
217
218 *Comment any comment
219
220 *Constant any constant
221 String a string constant: "this is a string"
222 Character a character constant: 'c', '\n'
223 Number a number constant: 234, 0xff
224 Boolean a boolean constant: TRUE, false
225 Float a floating point constant: 2.3e10
226
227 *Identifier any variable name
228 Function function name (also: methods for classes)
229
230 *Statement any statement
231 Conditional if, then, else, endif, switch, etc.
232 Repeat for, do, while, etc.
233 Label case, default, etc.
234 Operator "sizeof", "+", "*", etc.
235 Keyword any other keyword
236 Exception try, catch, throw
237
238 *PreProc generic Preprocessor
239 Include preprocessor #include
240 Define preprocessor #define
241 Macro same as Define
242 PreCondit preprocessor #if, #else, #endif, etc.
243
244 *Type int, long, char, etc.
245 StorageClass static, register, volatile, etc.
246 Structure struct, union, enum, etc.
247 Typedef A typedef
248
249 *Special any special symbol
250 SpecialChar special character in a constant
251 Tag you can use CTRL-] on this
252 Delimiter character that needs attention
253 SpecialComment special things inside a comment
254 Debug debugging statements
255
256 *Underlined text that stands out, HTML links
257
258 *Ignore left blank, hidden
259
260 *Error any erroneous construct
261
262 *Todo anything that needs extra attention; mostly the
263 keywords TODO FIXME and XXX
264
265The names marked with * are the preferred groups; the others are minor groups.
266For the preferred groups, the "syntax.vim" file contains default highlighting.
267The minor groups are linked to the preferred groups, so they get the same
268highlighting. You can override these defaults by using ":highlight" commands
269after sourcing the "syntax.vim" file.
270
271Note that highlight group names are not case sensitive. "String" and "string"
272can be used for the same group.
273
274The following names are reserved and cannot be used as a group name:
275 NONE ALL ALLBUT contains contained
276
277==============================================================================
2783. Syntax loading procedure *syntax-loading*
279
280This explains the details that happen when the command ":syntax enable" is
281issued. When Vim initializes itself, it finds out where the runtime files are
282located. This is used here as the variable |$VIMRUNTIME|.
283
284":syntax enable" and ":syntax on" do the following:
285
286 Source $VIMRUNTIME/syntax/syntax.vim
287 |
288 +- Clear out any old syntax by sourcing $VIMRUNTIME/syntax/nosyntax.vim
289 |
290 +- Source first syntax/synload.vim in 'runtimepath'
291 | |
292 | +- Setup the colors for syntax highlighting. If a color scheme is
293 | | defined it is loaded again with ":colors {name}". Otherwise
294 | | ":runtime! syntax/syncolor.vim" is used. ":syntax on" overrules
295 | | existing colors, ":syntax enable" only sets groups that weren't
296 | | set yet.
297 | |
298 | +- Set up syntax autocmds to load the appropriate syntax file when
299 | | the 'syntax' option is set. *synload-1*
300 | |
301 | +- Source the user's optional file, from the |mysyntaxfile| variable.
302 | This is for backwards compatibility with Vim 5.x only. *synload-2*
303 |
304 +- Do ":filetype on", which does ":runtime! filetype.vim". It loads any
305 | filetype.vim files found. It should always Source
306 | $VIMRUNTIME/filetype.vim, which does the following.
307 | |
308 | +- Install autocmds based on suffix to set the 'filetype' option
309 | | This is where the connection between file name and file type is
310 | | made for known file types. *synload-3*
311 | |
312 | +- Source the user's optional file, from the *myfiletypefile*
313 | | variable. This is for backwards compatibility with Vim 5.x only.
314 | | *synload-4*
315 | |
316 | +- Install one autocommand which sources scripts.vim when no file
317 | | type was detected yet. *synload-5*
318 | |
319 | +- Source $VIMRUNTIME/menu.vim, to setup the Syntax menu. |menu.vim|
320 |
321 +- Install a FileType autocommand to set the 'syntax' option when a file
322 | type has been detected. *synload-6*
323 |
324 +- Execute syntax autocommands to start syntax highlighting for each
325 already loaded buffer.
326
327
328Upon loading a file, Vim finds the relevant syntax file as follows:
329
330 Loading the file triggers the BufReadPost autocommands.
331 |
332 +- If there is a match with one of the autocommands from |synload-3|
333 | (known file types) or |synload-4| (user's file types), the 'filetype'
334 | option is set to the file type.
335 |
336 +- The autocommand at |synload-5| is triggered. If the file type was not
337 | found yet, then scripts.vim is searched for in 'runtimepath'. This
338 | should always load $VIMRUNTIME/scripts.vim, which does the following.
339 | |
340 | +- Source the user's optional file, from the *myscriptsfile*
341 | | variable. This is for backwards compatibility with Vim 5.x only.
342 | |
343 | +- If the file type is still unknown, check the contents of the file,
344 | again with checks like "getline(1) =~ pattern" as to whether the
345 | file type can be recognized, and set 'filetype'.
346 |
347 +- When the file type was determined and 'filetype' was set, this
348 | triggers the FileType autocommand |synload-6| above. It sets
349 | 'syntax' to the determined file type.
350 |
351 +- When the 'syntax' option was set above, this triggers an autocommand
352 | from |synload-1| (and |synload-2|). This find the main syntax file in
353 | 'runtimepath', with this command:
354 | runtime! syntax/<name>.vim
355 |
356 +- Any other user installed FileType or Syntax autocommands are
357 triggered. This can be used to change the highlighting for a specific
358 syntax.
359
360==============================================================================
3614. Syntax file remarks *:syn-file-remarks*
362
363 *b:current_syntax-variable*
364Vim stores the name of the syntax that has been loaded in the
365"b:current_syntax" variable. You can use this if you want to load other
366settings, depending on which syntax is active. Example: >
367 :au BufReadPost * if b:current_syntax == "csh"
368 :au BufReadPost * do-some-things
369 :au BufReadPost * endif
370
371
3722HTML *2html.vim* *convert-to-HTML*
373
374This is not a syntax file itself, but a script that converts the current
375window into HTML. Vim opens a new window in which it builds the HTML file.
376
377You are not supposed to set the 'filetype' or 'syntax' option to "2html"!
378Source the script to convert the current file: >
379
380 :runtime! syntax/2html.vim
381<
382Warning: This is slow!
383 *:TOhtml*
384Or use the ":TOhtml" user command. It is defined in a standard plugin.
385":TOhtml" also works with a range and in a Visual area: >
386
387 :10,40TOhtml
388
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100389After you save the resulting file, you can view it with any browser. The
390colors should be exactly the same as you see them in Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391
392To restrict the conversion to a range of lines set "html_start_line" and
393"html_end_line" to the first and last line to be converted. Example, using
394the last set Visual area: >
395
396 :let html_start_line = line("'<")
397 :let html_end_line = line("'>")
398
399The lines are numbered according to 'number' option and the Number
400highlighting. You can force lines to be numbered in the HTML output by
401setting "html_number_lines" to non-zero value: >
402 :let html_number_lines = 1
403Force to omit the line numbers by using a zero value: >
404 :let html_number_lines = 0
405Go back to the default to use 'number' by deleting the variable: >
406 :unlet html_number_lines
407
408By default, HTML optimized for old browsers is generated. If you prefer using
409cascading style sheets (CSS1) for the attributes (resulting in considerably
410shorter and valid HTML 4 file), use: >
411 :let html_use_css = 1
412
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100413Closed folds are put in the HTML as they are displayed. If you don't want
414this, use the |zR| command before invoking 2html, or use: >
415 :let html_ignore_folding = 1
416
417You may want to generate HTML that includes all the data within the folds, and
418allow the user to view the folded data similar to how they would in Vim. To
419generate this dynamic fold information, use: >
420 :let html_dynamic_folds = 1
421
422Using html_dynamic_folds will imply html_use_css, because it would be far too
423difficult to do it for old browsers. However, html_ignore_folding overrides
424html_dynamic_folds.
425
426Using html_dynamic_folds will default to generating a foldcolumn in the html
427similar to Vim's foldcolumn, that will use javascript to open and close the
428folds in the HTML document. The width of this foldcolumn starts at the current
429setting of |'foldcolumn'| but grows to fit the greatest foldlevel in your
430document. If you do not want to show a foldcolumn at all, use: >
431 :let html_no_foldcolumn = 1
432
433Using this option, there will be no foldcolumn available to open the folds in
434the HTML. For this reason, another option is provided: html_hover_unfold.
435Enabling this option will use CSS 2.0 to allow a user to open a fold by
436hovering the mouse pointer over it. Note that old browsers (notably Internet
437Explorer 6) will not support this feature. Browser-specific markup for IE6 is
438included to fall back to the normal CSS1 code so that the folds show up
439correctly for this browser, but they will not be openable without a
440foldcolumn. Note that using html_hover_unfold will allow modern browsers with
441disabled javascript to view closed folds. To use this option, use: >
442 :let html_hover_unfold = 1
443
444Setting html_no_foldcolumn with html_dynamic_folds will automatically set
445html_hover_unfold, because otherwise the folds wouldn't be dynamic.
446
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447By default "<pre>" and "</pre>" is used around the text. This makes it show
448up as you see it in Vim, but without wrapping. If you prefer wrapping, at the
449risk of making some things look a bit different, use: >
450 :let html_no_pre = 1
451This will use <br> at the end of each line and use "&nbsp;" for repeated
452spaces.
453
454The current value of 'encoding' is used to specify the charset of the HTML
455file. This only works for those values of 'encoding' that have an equivalent
456HTML charset name. To overrule this set g:html_use_encoding to the name of
457the charset to be used: >
458 :let html_use_encoding = "foobar"
459To omit the line that specifies the charset, set g:html_use_encoding to an
460empty string: >
461 :let html_use_encoding = ""
462To go back to the automatic mechanism, delete the g:html_use_encoding
463variable: >
464 :unlet html_use_encoding
465<
Bram Moolenaar47136d72004-10-12 20:02:24 +0000466For diff mode a sequence of more than 3 filler lines is displayed as three
467lines with the middle line mentioning the total number of inserted lines. If
468you prefer to see all the inserted lines use: >
469 :let html_whole_filler = 1
470And to go back to displaying up to three lines again: >
471 :unlet html_whole_filler
Bram Moolenaar488c6512005-08-11 20:09:58 +0000472<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473 *convert-to-XML* *convert-to-XHTML*
474An alternative is to have the script generate XHTML (XML compliant HTML). To
475do this set the "use_xhtml" variable: >
476 :let use_xhtml = 1
477To disable it again delete the variable: >
478 :unlet use_xhtml
479The generated XHTML file can be used in DocBook XML documents. See:
480 http://people.mech.kuleuven.ac.be/~pissaris/howto/src2db.html
481
482Remarks:
483- This only works in a version with GUI support. If the GUI is not actually
484 running (possible for X11) it still works, but not very well (the colors
485 may be wrong).
486- Older browsers will not show the background colors.
487- From most browsers you can also print the file (in color)!
488
489Here is an example how to run the script over all .c and .h files from a
490Unix shell: >
491 for f in *.[ch]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done
492<
493
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000494ABEL *abel.vim* *ft-abel-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000495
496ABEL highlighting provides some user-defined options. To enable them, assign
497any value to the respective variable. Example: >
498 :let abel_obsolete_ok=1
499To disable them use ":unlet". Example: >
500 :unlet abel_obsolete_ok
501
502Variable Highlight ~
503abel_obsolete_ok obsolete keywords are statements, not errors
504abel_cpp_comments_illegal do not interpret '//' as inline comment leader
505
506
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000507ADA
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000509See |ft-ada-syntax|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000510
511
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000512ANT *ant.vim* *ft-ant-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513
514The ant syntax file provides syntax highlighting for javascript and python
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000515by default. Syntax highlighting for other script languages can be installed
Bram Moolenaar071d4272004-06-13 20:20:40 +0000516by the function AntSyntaxScript(), which takes the tag name as first argument
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000517and the script syntax file name as second argument. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518
519 :call AntSyntaxScript('perl', 'perl.vim')
520
521will install syntax perl highlighting for the following ant code >
522
523 <script language = 'perl'><![CDATA[
524 # everything inside is highlighted as perl
525 ]]></script>
526
527See |mysyntaxfile-add| for installing script languages permanently.
528
529
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000530APACHE *apache.vim* *ft-apache-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531
532The apache syntax file provides syntax highlighting depending on Apache HTTP
533server version, by default for 1.3.x. Set "apache_version" to Apache version
534(as a string) to get highlighting for another version. Example: >
535
536 :let apache_version = "2.0"
537<
538
539 *asm.vim* *asmh8300.vim* *nasm.vim* *masm.vim* *asm68k*
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000540ASSEMBLY *ft-asm-syntax* *ft-asmh8300-syntax* *ft-nasm-syntax*
541 *ft-masm-syntax* *ft-asm68k-syntax* *fasm.vim*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542
543Files matching "*.i" could be Progress or Assembly. If the automatic detection
544doesn't work for you, or you don't edit Progress at all, use this in your
545startup vimrc: >
546 :let filetype_i = "asm"
547Replace "asm" with the type of assembly you use.
548
549There are many types of assembly languages that all use the same file name
550extensions. Therefore you will have to select the type yourself, or add a
551line in the assembly file that Vim will recognize. Currently these syntax
552files are included:
553 asm GNU assembly (the default)
554 asm68k Motorola 680x0 assembly
555 asmh8300 Hitachi H-8300 version of GNU assembly
556 ia64 Intel Itanium 64
557 fasm Flat assembly (http://flatassembler.net)
558 masm Microsoft assembly (probably works for any 80x86)
559 nasm Netwide assembly
560 tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and
561 MMX)
562 pic PIC assembly (currently for PIC16F84)
563
564The most flexible is to add a line in your assembly file containing: >
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100565 asmsyntax=nasm
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566Replace "nasm" with the name of the real assembly syntax. This line must be
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100567one of the first five lines in the file. No non-white text must be
568immediately before or after this text.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569
570The syntax type can always be overruled for a specific buffer by setting the
571b:asmsyntax variable: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000572 :let b:asmsyntax = "nasm"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573
574If b:asmsyntax is not set, either automatically or by hand, then the value of
575the global variable asmsyntax is used. This can be seen as a default assembly
576language: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000577 :let asmsyntax = "nasm"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578
579As a last resort, if nothing is defined, the "asm" syntax is used.
580
581
582Netwide assembler (nasm.vim) optional highlighting ~
583
584To enable a feature: >
585 :let {variable}=1|set syntax=nasm
586To disable a feature: >
587 :unlet {variable} |set syntax=nasm
588
589Variable Highlight ~
590nasm_loose_syntax unofficial parser allowed syntax not as Error
591 (parser dependent; not recommended)
592nasm_ctx_outside_macro contexts outside macro not as Error
593nasm_no_warn potentially risky syntax not as ToDo
594
595
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000596ASPPERL and ASPVBS *ft-aspperl-syntax* *ft-aspvbs-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597
598*.asp and *.asa files could be either Perl or Visual Basic script. Since it's
599hard to detect this you can set two global variables to tell Vim what you are
600using. For Perl script use: >
601 :let g:filetype_asa = "aspperl"
602 :let g:filetype_asp = "aspperl"
603For Visual Basic use: >
604 :let g:filetype_asa = "aspvbs"
605 :let g:filetype_asp = "aspvbs"
606
607
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000608BAAN *baan.vim* *baan-syntax*
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000609
610The baan.vim gives syntax support for BaanC of release BaanIV upto SSA ERP LN
611for both 3 GL and 4 GL programming. Large number of standard defines/constants
612are supported.
613
614Some special violation of coding standards will be signalled when one specify
615in ones |.vimrc|: >
616 let baan_code_stds=1
617
618*baan-folding*
619
620Syntax folding can be enabled at various levels through the variables
621mentioned below (Set those in your |.vimrc|). The more complex folding on
622source blocks and SQL can be CPU intensive.
623
624To allow any folding and enable folding at function level use: >
625 let baan_fold=1
626Folding can be enabled at source block level as if, while, for ,... The
627indentation preceding the begin/end keywords has to match (spaces are not
628considered equal to a tab). >
629 let baan_fold_block=1
630Folding can be enabled for embedded SQL blocks as SELECT, SELECTDO,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000631SELECTEMPTY, ... The indentation preceding the begin/end keywords has to
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000632match (spaces are not considered equal to a tab). >
633 let baan_fold_sql=1
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000634Note: Block folding can result in many small folds. It is suggested to |:set|
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000635the options 'foldminlines' and 'foldnestmax' in |.vimrc| or use |:setlocal| in
636.../after/syntax/baan.vim (see |after-directory|). Eg: >
637 set foldminlines=5
638 set foldnestmax=6
639
640
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000641BASIC *basic.vim* *vb.vim* *ft-basic-syntax* *ft-vb-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000642
643Both Visual Basic and "normal" basic use the extension ".bas". To detect
644which one should be used, Vim checks for the string "VB_Name" in the first
645five lines of the file. If it is not found, filetype will be "basic",
646otherwise "vb". Files with the ".frm" extension will always be seen as Visual
647Basic.
648
649
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000650C *c.vim* *ft-c-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000651
652A few things in C highlighting are optional. To enable them assign any value
653to the respective variable. Example: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000654 :let c_comment_strings = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000655To disable them use ":unlet". Example: >
656 :unlet c_comment_strings
657
658Variable Highlight ~
659c_gnu GNU gcc specific items
660c_comment_strings strings and numbers inside a comment
661c_space_errors trailing white space and spaces before a <Tab>
662c_no_trail_space_error ... but no trailing spaces
663c_no_tab_space_error ... but no spaces before a <Tab>
664c_no_bracket_error don't highlight {}; inside [] as errors
Bram Moolenaar677ee682005-01-27 14:41:15 +0000665c_no_curly_error don't highlight {}; inside [] and () as errors;
666 except { and } in first column
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000667c_curly_error highlight a missing }; this forces syncing from the
668 start of the file, can be slow
Bram Moolenaar071d4272004-06-13 20:20:40 +0000669c_no_ansi don't do standard ANSI types and constants
670c_ansi_typedefs ... but do standard ANSI types
671c_ansi_constants ... but do standard ANSI constants
672c_no_utf don't highlight \u and \U in strings
673c_syntax_for_h use C syntax for *.h files, instead of C++
674c_no_if0 don't highlight "#if 0" blocks as comments
675c_no_cformat don't highlight %-formats in strings
676c_no_c99 don't highlight C99 standard items
677
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000678When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will
679become a fold. If you don't want comments to become a fold use: >
680 :let c_no_comment_fold = 1
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000681"#if 0" blocks are also folded, unless: >
682 :let c_no_if0_fold = 1
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000683
Bram Moolenaar071d4272004-06-13 20:20:40 +0000684If you notice highlighting errors while scrolling backwards, which are fixed
685when redrawing with CTRL-L, try setting the "c_minlines" internal variable
686to a larger number: >
687 :let c_minlines = 100
688This will make the syntax synchronization start 100 lines before the first
689displayed line. The default value is 50 (15 when c_no_if0 is set). The
690disadvantage of using a larger number is that redrawing can become slow.
691
692When using the "#if 0" / "#endif" comment highlighting, notice that this only
693works when the "#if 0" is within "c_minlines" from the top of the window. If
694you have a long "#if 0" construct it will not be highlighted correctly.
695
696To match extra items in comments, use the cCommentGroup cluster.
697Example: >
698 :au Syntax c call MyCadd()
699 :function MyCadd()
700 : syn keyword cMyItem contained Ni
701 : syn cluster cCommentGroup add=cMyItem
702 : hi link cMyItem Title
703 :endfun
704
705ANSI constants will be highlighted with the "cConstant" group. This includes
706"NULL", "SIG_IGN" and others. But not "TRUE", for example, because this is
707not in the ANSI standard. If you find this confusing, remove the cConstant
708highlighting: >
709 :hi link cConstant NONE
710
711If you see '{' and '}' highlighted as an error where they are OK, reset the
712highlighting for cErrInParen and cErrInBracket.
713
714If you want to use folding in your C files, you can add these lines in a file
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200715in the "after" directory in 'runtimepath'. For Unix this would be
Bram Moolenaar071d4272004-06-13 20:20:40 +0000716~/.vim/after/syntax/c.vim. >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000717 syn sync fromstart
718 set foldmethod=syntax
719
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000720CH *ch.vim* *ft-ch-syntax*
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000721
722C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon
723the C syntax file. See |c.vim| for all the settings that are available for C.
724
725By setting a variable you can tell Vim to use Ch syntax for *.h files, instead
726of C or C++: >
727 :let ch_syntax_for_h = 1
728
Bram Moolenaar071d4272004-06-13 20:20:40 +0000729
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000730CHILL *chill.vim* *ft-chill-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000731
732Chill syntax highlighting is similar to C. See |c.vim| for all the settings
733that are available. Additionally there is:
734
Bram Moolenaar071d4272004-06-13 20:20:40 +0000735chill_space_errors like c_space_errors
736chill_comment_string like c_comment_strings
737chill_minlines like c_minlines
738
739
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000740CHANGELOG *changelog.vim* *ft-changelog-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741
742ChangeLog supports highlighting spaces at the start of a line.
743If you do not like this, add following line to your .vimrc: >
744 let g:changelog_spacing_errors = 0
745This works the next time you edit a changelog file. You can also use
746"b:changelog_spacing_errors" to set this per buffer (before loading the syntax
747file).
748
749You can change the highlighting used, e.g., to flag the spaces as an error: >
750 :hi link ChangelogError Error
751Or to avoid the highlighting: >
752 :hi link ChangelogError NONE
753This works immediately.
754
755
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000756COBOL *cobol.vim* *ft-cobol-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000757
758COBOL highlighting has different needs for legacy code than it does for fresh
759development. This is due to differences in what is being done (maintenance
760versus development) and other factors. To enable legacy code highlighting,
761add this line to your .vimrc: >
762 :let cobol_legacy_code = 1
763To disable it again, use this: >
764 :unlet cobol_legacy_code
765
766
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000767COLD FUSION *coldfusion.vim* *ft-coldfusion-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000768
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000769The ColdFusion has its own version of HTML comments. To turn on ColdFusion
Bram Moolenaar071d4272004-06-13 20:20:40 +0000770comment highlighting, add the following line to your startup file: >
771
772 :let html_wrong_comments = 1
773
774The ColdFusion syntax file is based on the HTML syntax file.
775
776
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000777CSH *csh.vim* *ft-csh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000778
779This covers the shell named "csh". Note that on some systems tcsh is actually
780used.
781
782Detecting whether a file is csh or tcsh is notoriously hard. Some systems
783symlink /bin/csh to /bin/tcsh, making it almost impossible to distinguish
784between csh and tcsh. In case VIM guesses wrong you can set the
785"filetype_csh" variable. For using csh: >
786
787 :let filetype_csh = "csh"
788
789For using tcsh: >
790
791 :let filetype_csh = "tcsh"
792
793Any script with a tcsh extension or a standard tcsh filename (.tcshrc,
794tcsh.tcshrc, tcsh.login) will have filetype tcsh. All other tcsh/csh scripts
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000795will be classified as tcsh, UNLESS the "filetype_csh" variable exists. If the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000796"filetype_csh" variable exists, the filetype will be set to the value of the
797variable.
798
799
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000800CYNLIB *cynlib.vim* *ft-cynlib-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000801
802Cynlib files are C++ files that use the Cynlib class library to enable
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000803hardware modelling and simulation using C++. Typically Cynlib files have a .cc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000804or a .cpp extension, which makes it very difficult to distinguish them from a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000805normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000806line to your .vimrc file: >
807
808 :let cynlib_cyntax_for_cc=1
809
810Similarly for cpp files (this extension is only usually used in Windows) >
811
812 :let cynlib_cyntax_for_cpp=1
813
814To disable these again, use this: >
815
816 :unlet cynlib_cyntax_for_cc
817 :unlet cynlib_cyntax_for_cpp
818<
819
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000820CWEB *cweb.vim* *ft-cweb-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000821
822Files matching "*.w" could be Progress or cweb. If the automatic detection
823doesn't work for you, or you don't edit Progress at all, use this in your
824startup vimrc: >
825 :let filetype_w = "cweb"
826
827
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000828DESKTOP *desktop.vim* *ft-desktop-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000829
830Primary goal of this syntax file is to highlight .desktop and .directory files
Bram Moolenaara17d4c12010-05-30 18:30:36 +0200831according to freedesktop.org standard:
832http://standards.freedesktop.org/desktop-entry-spec/latest/
Bram Moolenaar071d4272004-06-13 20:20:40 +0000833But actually almost none implements this standard fully. Thus it will
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000834highlight all Unix ini files. But you can force strict highlighting according
Bram Moolenaar071d4272004-06-13 20:20:40 +0000835to standard by placing this in your vimrc file: >
836 :let enforce_freedesktop_standard = 1
837
838
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000839DIRCOLORS *dircolors.vim* *ft-dircolors-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000840
841The dircolors utility highlighting definition has one option. It exists to
842provide compatibility with the Slackware GNU/Linux distributions version of
843the command. It adds a few keywords that are generally ignored by most
844versions. On Slackware systems, however, the utility accepts the keywords and
845uses them for processing. To enable the Slackware keywords add the following
846line to your startup file: >
847 let dircolors_is_slackware = 1
848
849
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000850DOCBOOK *docbk.vim* *ft-docbk-syntax* *docbook*
851DOCBOOK XML *docbkxml.vim* *ft-docbkxml-syntax*
852DOCBOOK SGML *docbksgml.vim* *ft-docbksgml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000853
854There are two types of DocBook files: SGML and XML. To specify what type you
855are using the "b:docbk_type" variable should be set. Vim does this for you
856automatically if it can recognize the type. When Vim can't guess it the type
857defaults to XML.
858You can set the type manually: >
859 :let docbk_type = "sgml"
860or: >
861 :let docbk_type = "xml"
862You need to do this before loading the syntax file, which is complicated.
863Simpler is setting the filetype to "docbkxml" or "docbksgml": >
864 :set filetype=docbksgml
865or: >
866 :set filetype=docbkxml
867
868
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000869DOSBATCH *dosbatch.vim* *ft-dosbatch-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000870
871There is one option with highlighting DOS batch files. This covers new
872extensions to the Command Interpreter introduced with Windows 2000 and
873is controlled by the variable dosbatch_cmdextversion. For Windows NT
874this should have the value 1, and for Windows 2000 it should be 2.
875Select the version you want with the following line: >
876
Bram Moolenaar8299df92004-07-10 09:47:34 +0000877 :let dosbatch_cmdextversion = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000878
879If this variable is not defined it defaults to a value of 2 to support
880Windows 2000.
881
Bram Moolenaar8299df92004-07-10 09:47:34 +0000882A second option covers whether *.btm files should be detected as type
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000883"dosbatch" (MS-DOS batch files) or type "btm" (4DOS batch files). The latter
884is used by default. You may select the former with the following line: >
Bram Moolenaar8299df92004-07-10 09:47:34 +0000885
886 :let g:dosbatch_syntax_for_btm = 1
887
888If this variable is undefined or zero, btm syntax is selected.
889
890
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000891DOXYGEN *doxygen.vim* *doxygen-syntax*
892
893Doxygen generates code documentation using a special documentation format
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000894(similar to Javadoc). This syntax script adds doxygen highlighting to c, cpp,
895idl and php files, and should also work with java.
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000896
Bram Moolenaar25394022007-05-10 19:06:20 +0000897There are a few of ways to turn on doxygen formatting. It can be done
898explicitly or in a modeline by appending '.doxygen' to the syntax of the file.
899Example: >
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000900 :set syntax=c.doxygen
901or >
902 // vim:syntax=c.doxygen
903
Bram Moolenaar25394022007-05-10 19:06:20 +0000904It can also be done automatically for c, cpp and idl files by setting the
905global or buffer-local variable load_doxygen_syntax. This is done by adding
906the following to your .vimrc. >
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000907 :let g:load_doxygen_syntax=1
908
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200909There are a couple of variables that have an effect on syntax highlighting, and
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000910are to do with non-standard highlighting options.
911
912Variable Default Effect ~
913g:doxygen_enhanced_color
914g:doxygen_enhanced_colour 0 Use non-standard highlighting for
915 doxygen comments.
916
917doxygen_my_rendering 0 Disable rendering of HTML bold, italic
918 and html_my_rendering underline.
919
920doxygen_javadoc_autobrief 1 Set to 0 to disable javadoc autobrief
921 colour highlighting.
922
923doxygen_end_punctuation '[.]' Set to regexp match for the ending
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000924 punctuation of brief
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000925
926There are also some hilight groups worth mentioning as they can be useful in
927configuration.
928
929Highlight Effect ~
930doxygenErrorComment The colour of an end-comment when missing
931 punctuation in a code, verbatim or dot section
932doxygenLinkError The colour of an end-comment when missing the
933 \endlink from a \link section.
934
Bram Moolenaar071d4272004-06-13 20:20:40 +0000935
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000936DTD *dtd.vim* *ft-dtd-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000937
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000938The DTD syntax highlighting is case sensitive by default. To disable
Bram Moolenaar071d4272004-06-13 20:20:40 +0000939case-sensitive highlighting, add the following line to your startup file: >
940
941 :let dtd_ignore_case=1
942
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000943The DTD syntax file will highlight unknown tags as errors. If
Bram Moolenaar071d4272004-06-13 20:20:40 +0000944this is annoying, it can be turned off by setting: >
945
946 :let dtd_no_tag_errors=1
947
948before sourcing the dtd.vim syntax file.
949Parameter entity names are highlighted in the definition using the
950'Type' highlighting group and 'Comment' for punctuation and '%'.
951Parameter entity instances are highlighted using the 'Constant'
952highlighting group and the 'Type' highlighting group for the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000953delimiters % and ;. This can be turned off by setting: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000954
955 :let dtd_no_param_entities=1
956
957The DTD syntax file is also included by xml.vim to highlight included dtd's.
958
959
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000960EIFFEL *eiffel.vim* *ft-eiffel-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961
962While Eiffel is not case-sensitive, its style guidelines are, and the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000963syntax highlighting file encourages their use. This also allows to
964highlight class names differently. If you want to disable case-sensitive
Bram Moolenaar071d4272004-06-13 20:20:40 +0000965highlighting, add the following line to your startup file: >
966
967 :let eiffel_ignore_case=1
968
969Case still matters for class names and TODO marks in comments.
970
971Conversely, for even stricter checks, add one of the following lines: >
972
973 :let eiffel_strict=1
974 :let eiffel_pedantic=1
975
976Setting eiffel_strict will only catch improper capitalization for the
977five predefined words "Current", "Void", "Result", "Precursor", and
978"NONE", to warn against their accidental use as feature or class names.
979
980Setting eiffel_pedantic will enforce adherence to the Eiffel style
981guidelines fairly rigorously (like arbitrary mixes of upper- and
982lowercase letters as well as outdated ways to capitalize keywords).
983
984If you want to use the lower-case version of "Current", "Void",
985"Result", and "Precursor", you can use >
986
987 :let eiffel_lower_case_predef=1
988
989instead of completely turning case-sensitive highlighting off.
990
991Support for ISE's proposed new creation syntax that is already
992experimentally handled by some compilers can be enabled by: >
993
994 :let eiffel_ise=1
995
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000996Finally, some vendors support hexadecimal constants. To handle them, add >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997
998 :let eiffel_hex_constants=1
999
1000to your startup file.
1001
1002
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001003ERLANG *erlang.vim* *ft-erlang-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001004
1005The erlang highlighting supports Erlang (ERicsson LANGuage).
1006Erlang is case sensitive and default extension is ".erl".
1007
1008If you want to disable keywords highlighting, put in your .vimrc: >
1009 :let erlang_keywords = 1
1010If you want to disable built-in-functions highlighting, put in your
1011.vimrc file: >
1012 :let erlang_functions = 1
1013If you want to disable special characters highlighting, put in
1014your .vimrc: >
1015 :let erlang_characters = 1
1016
1017
Bram Moolenaard68071d2006-05-02 22:08:30 +00001018FLEXWIKI *flexwiki.vim* *ft-flexwiki-syntax*
1019
1020FlexWiki is an ASP.NET-based wiki package available at http://www.flexwiki.com
1021
1022Syntax highlighting is available for the most common elements of FlexWiki
1023syntax. The associated ftplugin script sets some buffer-local options to make
1024editing FlexWiki pages more convenient. FlexWiki considers a newline as the
1025start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length),
1026'wrap' (wrap long lines instead of using horizontal scrolling), 'linebreak'
1027(to wrap at a character in 'breakat' instead of at the last char on screen),
1028and so on. It also includes some keymaps that are disabled by default.
1029
1030If you want to enable the keymaps that make "j" and "k" and the cursor keys
1031move up and down by display lines, add this to your .vimrc: >
1032 :let flexwiki_maps = 1
1033
1034
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001035FORM *form.vim* *ft-form-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001036
1037The coloring scheme for syntax elements in the FORM file uses the default
1038modes Conditional, Number, Statement, Comment, PreProc, Type, and String,
Bram Moolenaardd2a0d82007-05-12 15:07:00 +00001039following the language specifications in 'Symbolic Manipulation with FORM' by
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040J.A.M. Vermaseren, CAN, Netherlands, 1991.
1041
1042If you want include your own changes to the default colors, you have to
1043redefine the following syntax groups:
1044
1045 - formConditional
1046 - formNumber
1047 - formStatement
1048 - formHeaderStatement
1049 - formComment
1050 - formPreProc
1051 - formDirective
1052 - formType
1053 - formString
1054
1055Note that the form.vim syntax file implements FORM preprocessor commands and
1056directives per default in the same syntax group.
1057
1058A predefined enhanced color mode for FORM is available to distinguish between
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001059header statements and statements in the body of a FORM program. To activate
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060this mode define the following variable in your vimrc file >
1061
1062 :let form_enhanced_color=1
1063
1064The enhanced mode also takes advantage of additional color features for a dark
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001065gvim display. Here, statements are colored LightYellow instead of Yellow, and
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066conditionals are LightBlue for better distinction.
1067
1068
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001069FORTRAN *fortran.vim* *ft-fortran-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070
1071Default highlighting and dialect ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001072Highlighting appropriate for f95 (Fortran 95) is used by default. This choice
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073should be appropriate for most users most of the time because Fortran 95 is a
1074superset of Fortran 90 and almost a superset of Fortran 77.
1075
1076Fortran source code form ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001077Fortran 9x code can be in either fixed or free source form. Note that the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078syntax highlighting will not be correct if the form is incorrectly set.
1079
1080When you create a new fortran file, the syntax script assumes fixed source
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001081form. If you always use free source form, then >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001082 :let fortran_free_source=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001083in your .vimrc prior to the :syntax on command. If you always use fixed source
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084form, then >
1085 :let fortran_fixed_source=1
1086in your .vimrc prior to the :syntax on command.
1087
1088If the form of the source code depends upon the file extension, then it is
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001089most convenient to set fortran_free_source in a ftplugin file. For more
1090information on ftplugin files, see |ftplugin|. For example, if all your
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091fortran files with an .f90 extension are written in free source form and the
1092rest in fixed source form, add the following code to your ftplugin file >
1093 let s:extfname = expand("%:e")
1094 if s:extfname ==? "f90"
1095 let fortran_free_source=1
1096 unlet! fortran_fixed_source
1097 else
1098 let fortran_fixed_source=1
1099 unlet! fortran_free_source
1100 endif
1101Note that this will work only if the "filetype plugin indent on" command
1102precedes the "syntax on" command in your .vimrc file.
1103
1104When you edit an existing fortran file, the syntax script will assume free
1105source form if the fortran_free_source variable has been set, and assumes
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001106fixed source form if the fortran_fixed_source variable has been set. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107neither of these variables have been set, the syntax script attempts to
1108determine which source form has been used by examining the first five columns
Bram Moolenaar910f66f2006-04-05 20:41:53 +00001109of the first 250 lines of your file. If no signs of free source form are
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001110detected, then the file is assumed to be in fixed source form. The algorithm
1111should work in the vast majority of cases. In some cases, such as a file that
Bram Moolenaar910f66f2006-04-05 20:41:53 +00001112begins with 250 or more full-line comments, the script may incorrectly decide
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001113that the fortran code is in fixed form. If that happens, just add a
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114non-comment statement beginning anywhere in the first five columns of the
1115first twenty five lines, save (:w) and then reload (:e!) the file.
1116
1117Tabs in fortran files ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001118Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
Bram Moolenaar071d4272004-06-13 20:20:40 +00001119fixed format fortran source code which requires fixed column boundaries.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001120Therefore, tabs are marked as errors. Nevertheless, some programmers like
1121using tabs. If your fortran files contain tabs, then you should set the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122variable fortran_have_tabs in your .vimrc with a command such as >
1123 :let fortran_have_tabs=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001124placed prior to the :syntax on command. Unfortunately, the use of tabs will
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125mean that the syntax file will not be able to detect incorrect margins.
1126
1127Syntax folding of fortran files ~
1128If you wish to use foldmethod=syntax, then you must first set the variable
1129fortran_fold with a command such as >
1130 :let fortran_fold=1
1131to instruct the syntax script to define fold regions for program units, that
1132is main programs starting with a program statement, subroutines, function
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001133subprograms, block data subprograms, interface blocks, and modules. If you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134also set the variable fortran_fold_conditionals with a command such as >
1135 :let fortran_fold_conditionals=1
1136then fold regions will also be defined for do loops, if blocks, and select
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001137case constructs. If you also set the variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138fortran_fold_multilinecomments with a command such as >
1139 :let fortran_fold_multilinecomments=1
1140then fold regions will also be defined for three or more consecutive comment
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001141lines. Note that defining fold regions can be slow for large files.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142
1143If fortran_fold, and possibly fortran_fold_conditionals and/or
1144fortran_fold_multilinecomments, have been set, then vim will fold your file if
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001145you set foldmethod=syntax. Comments or blank lines placed between two program
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146units are not folded because they are seen as not belonging to any program
1147unit.
1148
1149More precise fortran syntax ~
1150If you set the variable fortran_more_precise with a command such as >
1151 :let fortran_more_precise=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001152then the syntax coloring will be more precise but slower. In particular,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001153statement labels used in do, goto and arithmetic if statements will be
1154recognized, as will construct names at the end of a do, if, select or forall
1155construct.
1156
1157Non-default fortran dialects ~
1158The syntax script supports five Fortran dialects: f95, f90, f77, the Lahey
1159subset elf90, and the Imagine1 subset F.
1160
1161If you use f77 with extensions, even common ones like do/enddo loops, do/while
1162loops and free source form that are supported by most f77 compilers including
1163g77 (GNU Fortran), then you will probably find the default highlighting
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001164satisfactory. However, if you use strict f77 with no extensions, not even free
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165source form or the MIL STD 1753 extensions, then the advantages of setting the
1166dialect to f77 are that names such as SUM are recognized as user variable
1167names and not highlighted as f9x intrinsic functions, that obsolete constructs
1168such as ASSIGN statements are not highlighted as todo items, and that fixed
1169source form will be assumed.
1170
1171If you use elf90 or F, the advantage of setting the dialect appropriately is
1172that f90 features excluded from these dialects will be highlighted as todo
1173items and that free source form will be assumed as required for these
1174dialects.
1175
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001176The dialect can be selected by setting the variable fortran_dialect. The
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177permissible values of fortran_dialect are case-sensitive and must be "f95",
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001178"f90", "f77", "elf" or "F". Invalid values of fortran_dialect are ignored.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001179
1180If all your fortran files use the same dialect, set fortran_dialect in your
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001181.vimrc prior to your syntax on statement. If the dialect depends upon the file
1182extension, then it is most convenient to set it in a ftplugin file. For more
1183information on ftplugin files, see |ftplugin|. For example, if all your
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184fortran files with an .f90 extension are written in the elf subset, your
1185ftplugin file should contain the code >
1186 let s:extfname = expand("%:e")
1187 if s:extfname ==? "f90"
1188 let fortran_dialect="elf"
1189 else
1190 unlet! fortran_dialect
1191 endif
1192Note that this will work only if the "filetype plugin indent on" command
1193precedes the "syntax on" command in your .vimrc file.
1194
1195Finer control is necessary if the file extension does not uniquely identify
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001196the dialect. You can override the default dialect, on a file-by-file basis, by
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197including a comment with the directive "fortran_dialect=xx" (where xx=f77 or
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001198elf or F or f90 or f95) in one of the first three lines in your file. For
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199example, your older .f files may be written in extended f77 but your newer
1200ones may be F codes, and you would identify the latter by including in the
1201first three lines of those files a Fortran comment of the form >
1202 ! fortran_dialect=F
1203F overrides elf if both directives are present.
1204
1205Limitations ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001206Parenthesis checking does not catch too few closing parentheses. Hollerith
1207strings are not recognized. Some keywords may be highlighted incorrectly
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208because Fortran90 has no reserved words.
1209
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001210For further information related to fortran, see |ft-fortran-indent| and
1211|ft-fortran-plugin|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212
1213
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001214FVWM CONFIGURATION FILES *fvwm.vim* *ft-fvwm-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215
1216In order for Vim to recognize Fvwm configuration files that do not match
1217the patterns *fvwmrc* or *fvwm2rc* , you must put additional patterns
1218appropriate to your system in your myfiletypes.vim file. For these
1219patterns, you must set the variable "b:fvwm_version" to the major version
1220number of Fvwm, and the 'filetype' option to fvwm.
1221
1222For example, to make Vim identify all files in /etc/X11/fvwm2/
1223as Fvwm2 configuration files, add the following: >
1224
1225 :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 |
1226 \ set filetype=fvwm
1227
1228If you'd like Vim to highlight all valid color names, tell it where to
1229find the color database (rgb.txt) on your system. Do this by setting
1230"rgb_file" to its location. Assuming your color database is located
1231in /usr/X11/lib/X11/, you should add the line >
1232
1233 :let rgb_file = "/usr/X11/lib/X11/rgb.txt"
1234
1235to your .vimrc file.
1236
1237
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001238GSP *gsp.vim* *ft-gsp-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239
1240The default coloring style for GSP pages is defined by |html.vim|, and
1241the coloring for java code (within java tags or inline between backticks)
1242is defined by |java.vim|. The following HTML groups defined in |html.vim|
1243are redefined to incorporate and highlight inline java code:
1244
1245 htmlString
1246 htmlValue
1247 htmlEndTag
1248 htmlTag
1249 htmlTagN
1250
1251Highlighting should look fine most of the places where you'd see inline
1252java code, but in some special cases it may not. To add another HTML
1253group where you will have inline java code where it does not highlight
1254correctly, just copy the line you want from |html.vim| and add gspJava
1255to the contains clause.
1256
1257The backticks for inline java are highlighted according to the htmlError
1258group to make them easier to see.
1259
1260
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001261GROFF *groff.vim* *ft-groff-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001262
1263The groff syntax file is a wrapper for |nroff.vim|, see the notes
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001264under that heading for examples of use and configuration. The purpose
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265of this wrapper is to set up groff syntax extensions by setting the
1266filetype from a |modeline| or in a personal filetype definitions file
1267(see |filetype.txt|).
1268
1269
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001270HASKELL *haskell.vim* *lhaskell.vim* *ft-haskell-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271
1272The Haskell syntax files support plain Haskell code as well as literate
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001273Haskell code, the latter in both Bird style and TeX style. The Haskell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274syntax highlighting will also highlight C preprocessor directives.
1275
1276If you want to highlight delimiter characters (useful if you have a
1277light-coloured background), add to your .vimrc: >
1278 :let hs_highlight_delimiters = 1
1279To treat True and False as keywords as opposed to ordinary identifiers,
1280add: >
1281 :let hs_highlight_boolean = 1
1282To also treat the names of primitive types as keywords: >
1283 :let hs_highlight_types = 1
1284And to treat the names of even more relatively common types as keywords: >
1285 :let hs_highlight_more_types = 1
1286If you want to highlight the names of debugging functions, put in
1287your .vimrc: >
1288 :let hs_highlight_debug = 1
1289
1290The Haskell syntax highlighting also highlights C preprocessor
1291directives, and flags lines that start with # but are not valid
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001292directives as erroneous. This interferes with Haskell's syntax for
1293operators, as they may start with #. If you want to highlight those
Bram Moolenaar071d4272004-06-13 20:20:40 +00001294as operators as opposed to errors, put in your .vimrc: >
1295 :let hs_allow_hash_operator = 1
1296
1297The syntax highlighting for literate Haskell code will try to
1298automatically guess whether your literate Haskell code contains
1299TeX markup or not, and correspondingly highlight TeX constructs
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001300or nothing at all. You can override this globally by putting
Bram Moolenaar071d4272004-06-13 20:20:40 +00001301in your .vimrc >
1302 :let lhs_markup = none
1303for no highlighting at all, or >
1304 :let lhs_markup = tex
1305to force the highlighting to always try to highlight TeX markup.
1306For more flexibility, you may also use buffer local versions of
1307this variable, so e.g. >
1308 :let b:lhs_markup = tex
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001309will force TeX highlighting for a particular buffer. It has to be
Bram Moolenaar071d4272004-06-13 20:20:40 +00001310set before turning syntax highlighting on for the buffer or
1311loading a file.
1312
1313
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001314HTML *html.vim* *ft-html-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001315
1316The coloring scheme for tags in the HTML file works as follows.
1317
1318The <> of opening tags are colored differently than the </> of a closing tag.
1319This is on purpose! For opening tags the 'Function' color is used, while for
1320closing tags the 'Type' color is used (See syntax.vim to check how those are
1321defined for you)
1322
1323Known tag names are colored the same way as statements in C. Unknown tag
1324names are colored with the same color as the <> or </> respectively which
1325makes it easy to spot errors
1326
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001327Note that the same is true for argument (or attribute) names. Known attribute
Bram Moolenaar071d4272004-06-13 20:20:40 +00001328names are colored differently than unknown ones.
1329
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001330Some HTML tags are used to change the rendering of text. The following tags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331are recognized by the html.vim syntax coloring file and change the way normal
1332text is shown: <B> <I> <U> <EM> <STRONG> (<EM> is used as an alias for <I>,
1333while <STRONG> as an alias for <B>), <H1> - <H6>, <HEAD>, <TITLE> and <A>, but
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001334only if used as a link (that is, it must include a href as in
Bram Moolenaar25394022007-05-10 19:06:20 +00001335<A href="somefile.html">).
Bram Moolenaar071d4272004-06-13 20:20:40 +00001336
1337If you want to change how such text is rendered, you must redefine the
1338following syntax groups:
1339
1340 - htmlBold
1341 - htmlBoldUnderline
1342 - htmlBoldUnderlineItalic
1343 - htmlUnderline
1344 - htmlUnderlineItalic
1345 - htmlItalic
1346 - htmlTitle for titles
1347 - htmlH1 - htmlH6 for headings
1348
1349To make this redefinition work you must redefine them all with the exception
1350of the last two (htmlTitle and htmlH[1-6], which are optional) and define the
1351following variable in your vimrc (this is due to the order in which the files
1352are read during initialization) >
1353 :let html_my_rendering=1
1354
1355If you'd like to see an example download mysyntax.vim at
1356http://www.fleiner.com/vim/download.html
1357
1358You can also disable this rendering by adding the following line to your
1359vimrc file: >
1360 :let html_no_rendering=1
1361
1362HTML comments are rather special (see an HTML reference document for the
1363details), and the syntax coloring scheme will highlight all errors.
1364However, if you prefer to use the wrong style (starts with <!-- and
1365ends with --!>) you can define >
1366 :let html_wrong_comments=1
1367
1368JavaScript and Visual Basic embedded inside HTML documents are highlighted as
1369'Special' with statements, comments, strings and so on colored as in standard
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001370programming languages. Note that only JavaScript and Visual Basic are currently
Bram Moolenaar071d4272004-06-13 20:20:40 +00001371supported, no other scripting language has been added yet.
1372
1373Embedded and inlined cascading style sheets (CSS) are highlighted too.
1374
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001375There are several html preprocessor languages out there. html.vim has been
1376written such that it should be trivial to include it. To do so add the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001377following two lines to the syntax coloring file for that language
1378(the example comes from the asp.vim file):
1379
1380 runtime! syntax/html.vim
1381 syn cluster htmlPreproc add=asp
1382
1383Now you just need to make sure that you add all regions that contain
1384the preprocessor language to the cluster htmlPreproc.
1385
1386
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001387HTML/OS (by Aestiva) *htmlos.vim* *ft-htmlos-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001388
1389The coloring scheme for HTML/OS works as follows:
1390
1391Functions and variable names are the same color by default, because VIM
1392doesn't specify different colors for Functions and Identifiers. To change
1393this (which is recommended if you want function names to be recognizable in a
1394different color) you need to add the following line to either your ~/.vimrc: >
1395 :hi Function term=underline cterm=bold ctermfg=LightGray
1396
1397Of course, the ctermfg can be a different color if you choose.
1398
1399Another issues that HTML/OS runs into is that there is no special filetype to
1400signify that it is a file with HTML/OS coding. You can change this by opening
1401a file and turning on HTML/OS syntax by doing the following: >
1402 :set syntax=htmlos
1403
1404Lastly, it should be noted that the opening and closing characters to begin a
1405block of HTML/OS code can either be << or [[ and >> or ]], respectively.
1406
1407
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001408IA64 *ia64.vim* *intel-itanium* *ft-ia64-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001409
1410Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
1411how to recognize this filetype.
1412
1413To have *.inc files be recognized as IA64, add this to your .vimrc file: >
1414 :let g:filetype_inc = "ia64"
1415
1416
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001417INFORM *inform.vim* *ft-inform-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001418
1419Inform highlighting includes symbols provided by the Inform Library, as
1420most programs make extensive use of it. If do not wish Library symbols
1421to be highlighted add this to your vim startup: >
1422 :let inform_highlight_simple=1
1423
1424By default it is assumed that Inform programs are Z-machine targeted,
1425and highlights Z-machine assembly language symbols appropriately. If
1426you intend your program to be targeted to a Glulx/Glk environment you
1427need to add this to your startup sequence: >
1428 :let inform_highlight_glulx=1
1429
1430This will highlight Glulx opcodes instead, and also adds glk() to the
1431set of highlighted system functions.
1432
1433The Inform compiler will flag certain obsolete keywords as errors when
1434it encounters them. These keywords are normally highlighted as errors
1435by Vim. To prevent such error highlighting, you must add this to your
1436startup sequence: >
1437 :let inform_suppress_obsolete=1
1438
1439By default, the language features highlighted conform to Compiler
1440version 6.30 and Library version 6.11. If you are using an older
1441Inform development environment, you may with to add this to your
1442startup sequence: >
1443 :let inform_highlight_old=1
1444
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001445IDL *idl.vim* *idl-syntax*
1446
1447IDL (Interface Definition Language) files are used to define RPC calls. In
1448Microsoft land, this is also used for defining COM interfaces and calls.
1449
1450IDL's structure is simple enough to permit a full grammar based approach to
1451rather than using a few heuristics. The result is large and somewhat
Bram Moolenaar25394022007-05-10 19:06:20 +00001452repetitive but seems to work.
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001453
1454There are some Microsoft extensions to idl files that are here. Some of them
1455are disabled by defining idl_no_ms_extensions.
1456
1457The more complex of the extensions are disabled by defining idl_no_extensions.
1458
1459Variable Effect ~
1460
1461idl_no_ms_extensions Disable some of the Microsoft specific
1462 extensions
1463idl_no_extensions Disable complex extensions
1464idlsyntax_showerror Show IDL errors (can be rather intrusive, but
1465 quite helpful)
1466idlsyntax_showerror_soft Use softer colours by default for errors
1467
Bram Moolenaar071d4272004-06-13 20:20:40 +00001468
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001469JAVA *java.vim* *ft-java-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001470
1471The java.vim syntax highlighting file offers several options:
1472
1473In Java 1.0.2 it was never possible to have braces inside parens, so this was
1474flagged as an error. Since Java 1.1 this is possible (with anonymous
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001475classes), and therefore is no longer marked as an error. If you prefer the old
Bram Moolenaar071d4272004-06-13 20:20:40 +00001476way, put the following line into your vim startup file: >
1477 :let java_mark_braces_in_parens_as_errors=1
1478
1479All identifiers in java.lang.* are always visible in all classes. To
1480highlight them use: >
1481 :let java_highlight_java_lang_ids=1
1482
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001483You can also highlight identifiers of most standard Java packages if you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001484download the javaid.vim script at http://www.fleiner.com/vim/download.html.
1485If you prefer to only highlight identifiers of a certain package, say java.io
1486use the following: >
1487 :let java_highlight_java_io=1
1488Check the javaid.vim file for a list of all the packages that are supported.
1489
1490Function names are not highlighted, as the way to find functions depends on
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001491how you write Java code. The syntax file knows two possible ways to highlight
Bram Moolenaar071d4272004-06-13 20:20:40 +00001492functions:
1493
1494If you write function declarations that are always indented by either
1495a tab, 8 spaces or 2 spaces you may want to set >
1496 :let java_highlight_functions="indent"
1497However, if you follow the Java guidelines about how functions and classes are
1498supposed to be named (with respect to upper and lowercase), use >
1499 :let java_highlight_functions="style"
1500If both options do not work for you, but you would still want function
1501declarations to be highlighted create your own definitions by changing the
1502definitions in java.vim or by creating your own java.vim which includes the
1503original one and then adds the code to highlight functions.
1504
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001505In Java 1.1 the functions System.out.println() and System.err.println() should
Bram Moolenaared203462004-06-16 11:19:22 +00001506only be used for debugging. Therefore it is possible to highlight debugging
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001507statements differently. To do this you must add the following definition in
Bram Moolenaar071d4272004-06-13 20:20:40 +00001508your startup file: >
1509 :let java_highlight_debug=1
1510The result will be that those statements are highlighted as 'Special'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001511characters. If you prefer to have them highlighted differently you must define
Bram Moolenaar071d4272004-06-13 20:20:40 +00001512new highlightings for the following groups.:
1513 Debug, DebugSpecial, DebugString, DebugBoolean, DebugType
1514which are used for the statement itself, special characters used in debug
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001515strings, strings, boolean constants and types (this, super) respectively. I
Bram Moolenaar071d4272004-06-13 20:20:40 +00001516have opted to chose another background for those statements.
1517
Bram Moolenaar8c8de832008-06-24 22:58:06 +00001518In order to help you write code that can be easily ported between Java and
1519C++, all C++ keywords can be marked as an error in a Java program. To
1520have this add this line in your .vimrc file: >
1521 :let java_allow_cpp_keywords = 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001522
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001523Javadoc is a program that takes special comments out of Java program files and
1524creates HTML pages. The standard configuration will highlight this HTML code
1525similarly to HTML files (see |html.vim|). You can even add Javascript
1526and CSS inside this code (see below). There are four differences however:
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 1. The title (all characters up to the first '.' which is followed by
1528 some white space or up to the first '@') is colored differently (to change
1529 the color change the group CommentTitle).
1530 2. The text is colored as 'Comment'.
1531 3. HTML comments are colored as 'Special'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001532 4. The special Javadoc tags (@see, @param, ...) are highlighted as specials
Bram Moolenaar071d4272004-06-13 20:20:40 +00001533 and the argument (for @see, @param, @exception) as Function.
1534To turn this feature off add the following line to your startup file: >
1535 :let java_ignore_javadoc=1
1536
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001537If you use the special Javadoc comment highlighting described above you
1538can also turn on special highlighting for Javascript, visual basic
1539scripts and embedded CSS (stylesheets). This makes only sense if you
1540actually have Javadoc comments that include either Javascript or embedded
1541CSS. The options to use are >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001542 :let java_javascript=1
1543 :let java_css=1
1544 :let java_vb=1
1545
1546In order to highlight nested parens with different colors define colors
1547for javaParen, javaParen1 and javaParen2, for example with >
1548 :hi link javaParen Comment
1549or >
1550 :hi javaParen ctermfg=blue guifg=#0000ff
1551
1552If you notice highlighting errors while scrolling backwards, which are fixed
1553when redrawing with CTRL-L, try setting the "java_minlines" internal variable
1554to a larger number: >
1555 :let java_minlines = 50
1556This will make the syntax synchronization start 50 lines before the first
1557displayed line. The default value is 10. The disadvantage of using a larger
1558number is that redrawing can become slow.
1559
1560
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001561LACE *lace.vim* *ft-lace-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001562
1563Lace (Language for Assembly of Classes in Eiffel) is case insensitive, but the
1564style guide lines are not. If you prefer case insensitive highlighting, just
1565define the vim variable 'lace_case_insensitive' in your startup file: >
1566 :let lace_case_insensitive=1
1567
1568
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001569LEX *lex.vim* *ft-lex-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001570
1571Lex uses brute-force synchronizing as the "^%%$" section delimiter
1572gives no clue as to what section follows. Consequently, the value for >
1573 :syn sync minlines=300
1574may be changed by the user if s/he is experiencing synchronization
1575difficulties (such as may happen with large lex files).
1576
1577
Bram Moolenaara5fac542005-10-12 20:58:49 +00001578LISP *lisp.vim* *ft-lisp-syntax*
1579
1580The lisp syntax highlighting provides two options: >
1581
1582 g:lisp_instring : if it exists, then "(...)" strings are highlighted
1583 as if the contents of the string were lisp.
1584 Useful for AutoLisp.
1585 g:lisp_rainbow : if it exists and is nonzero, then differing levels
1586 of parenthesization will receive different
1587 highlighting.
1588<
1589The g:lisp_rainbow option provides 10 levels of individual colorization for
1590the parentheses and backquoted parentheses. Because of the quantity of
1591colorization levels, unlike non-rainbow highlighting, the rainbow mode
1592specifies its highlighting using ctermfg and guifg, thereby bypassing the
1593usual colorscheme control using standard highlighting groups. The actual
1594highlighting used depends on the dark/bright setting (see |'bg'|).
1595
1596
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001597LITE *lite.vim* *ft-lite-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598
1599There are two options for the lite syntax highlighting.
1600
1601If you like SQL syntax highlighting inside Strings, use this: >
1602
1603 :let lite_sql_query = 1
1604
1605For syncing, minlines defaults to 100. If you prefer another value, you can
1606set "lite_minlines" to the value you desire. Example: >
1607
1608 :let lite_minlines = 200
1609
1610
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001611LPC *lpc.vim* *ft-lpc-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001612
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001613LPC stands for a simple, memory-efficient language: Lars Pensj| C. The
Bram Moolenaar071d4272004-06-13 20:20:40 +00001614file name of LPC is usually *.c. Recognizing these files as LPC would bother
1615users writing only C programs. If you want to use LPC syntax in Vim, you
1616should set a variable in your .vimrc file: >
1617
1618 :let lpc_syntax_for_c = 1
1619
1620If it doesn't work properly for some particular C or LPC files, use a
1621modeline. For a LPC file:
1622
1623 // vim:set ft=lpc:
1624
1625For a C file that is recognized as LPC:
1626
1627 // vim:set ft=c:
1628
1629If you don't want to set the variable, use the modeline in EVERY LPC file.
1630
1631There are several implementations for LPC, we intend to support most widely
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001632used ones. Here the default LPC syntax is for MudOS series, for MudOS v22
Bram Moolenaar071d4272004-06-13 20:20:40 +00001633and before, you should turn off the sensible modifiers, and this will also
1634asserts the new efuns after v22 to be invalid, don't set this variable when
1635you are using the latest version of MudOS: >
1636
1637 :let lpc_pre_v22 = 1
1638
1639For LpMud 3.2 series of LPC: >
1640
1641 :let lpc_compat_32 = 1
1642
1643For LPC4 series of LPC: >
1644
1645 :let lpc_use_lpc4_syntax = 1
1646
1647For uLPC series of LPC:
1648uLPC has been developed to Pike, so you should use Pike syntax
1649instead, and the name of your source file should be *.pike
1650
1651
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001652LUA *lua.vim* *ft-lua-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001653
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001654This syntax file may be used for Lua 4.0, Lua 5.0 or Lua 5.1 (the latter is
1655the default). You can select one of these versions using the global variables
1656lua_version and lua_subversion. For example, to activate Lua
16574.0 syntax highlighting, use this command: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001658
1659 :let lua_version = 4
1660
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001661If you are using Lua 5.0, use these commands: >
1662
1663 :let lua_version = 5
1664 :let lua_subversion = 0
1665
1666To restore highlighting for Lua 5.1: >
1667
1668 :let lua_version = 5
1669 :let lua_subversion = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001670
1671
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001672MAIL *mail.vim* *ft-mail.vim*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673
1674Vim highlights all the standard elements of an email (headers, signatures,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001675quoted text and URLs / email addresses). In keeping with standard conventions,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001676signatures begin in a line containing only "--" followed optionally by
1677whitespaces and end with a newline.
1678
1679Vim treats lines beginning with ']', '}', '|', '>' or a word followed by '>'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001680as quoted text. However Vim highlights headers and signatures in quoted text
Bram Moolenaar071d4272004-06-13 20:20:40 +00001681only if the text is quoted with '>' (optionally followed by one space).
1682
1683By default mail.vim synchronises syntax to 100 lines before the first
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001684displayed line. If you have a slow machine, and generally deal with emails
Bram Moolenaar071d4272004-06-13 20:20:40 +00001685with short headers, you can change this to a smaller value: >
1686
1687 :let mail_minlines = 30
1688
1689
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001690MAKE *make.vim* *ft-make-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001691
1692In makefiles, commands are usually highlighted to make it easy for you to spot
1693errors. However, this may be too much coloring for you. You can turn this
1694feature off by using: >
1695
1696 :let make_no_commands = 1
1697
1698
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001699MAPLE *maple.vim* *ft-maple-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001700
1701Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
1702supports many packages of functions which are selectively loaded by the user.
1703The standard set of packages' functions as supplied in Maple V release 4 may be
1704highlighted at the user's discretion. Users may place in their .vimrc file: >
1705
1706 :let mvpkg_all= 1
1707
1708to get all package functions highlighted, or users may select any subset by
1709choosing a variable/package from the table below and setting that variable to
17101, also in their .vimrc file (prior to sourcing
1711$VIMRUNTIME/syntax/syntax.vim).
1712
1713 Table of Maple V Package Function Selectors >
1714 mv_DEtools mv_genfunc mv_networks mv_process
1715 mv_Galois mv_geometry mv_numapprox mv_simplex
1716 mv_GaussInt mv_grobner mv_numtheory mv_stats
1717 mv_LREtools mv_group mv_orthopoly mv_student
1718 mv_combinat mv_inttrans mv_padic mv_sumtools
1719 mv_combstruct mv_liesymm mv_plots mv_tensor
1720 mv_difforms mv_linalg mv_plottools mv_totorder
1721 mv_finance mv_logic mv_powseries
1722
1723
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001724MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +00001725
1726Empty *.m files will automatically be presumed to be Matlab files unless you
1727have the following in your .vimrc: >
1728
1729 let filetype_m = "mma"
1730
1731
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001732MOO *moo.vim* *ft-moo-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733
1734If you use C-style comments inside expressions and find it mangles your
1735highlighting, you may want to use extended (slow!) matches for C-style
1736comments: >
1737
1738 :let moo_extended_cstyle_comments = 1
1739
1740To disable highlighting of pronoun substitution patterns inside strings: >
1741
1742 :let moo_no_pronoun_sub = 1
1743
1744To disable highlighting of the regular expression operator '%|', and matching
1745'%(' and '%)' inside strings: >
1746
1747 :let moo_no_regexp = 1
1748
1749Unmatched double quotes can be recognized and highlighted as errors: >
1750
1751 :let moo_unmatched_quotes = 1
1752
1753To highlight builtin properties (.name, .location, .programmer etc.): >
1754
1755 :let moo_builtin_properties = 1
1756
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001757Unknown builtin functions can be recognized and highlighted as errors. If you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758use this option, add your own extensions to the mooKnownBuiltinFunction group.
1759To enable this option: >
1760
1761 :let moo_unknown_builtin_functions = 1
1762
1763An example of adding sprintf() to the list of known builtin functions: >
1764
1765 :syn keyword mooKnownBuiltinFunction sprintf contained
1766
1767
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001768MSQL *msql.vim* *ft-msql-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769
1770There are two options for the msql syntax highlighting.
1771
1772If you like SQL syntax highlighting inside Strings, use this: >
1773
1774 :let msql_sql_query = 1
1775
1776For syncing, minlines defaults to 100. If you prefer another value, you can
1777set "msql_minlines" to the value you desire. Example: >
1778
1779 :let msql_minlines = 200
1780
1781
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001782NCF *ncf.vim* *ft-ncf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783
1784There is one option for NCF syntax highlighting.
1785
1786If you want to have unrecognized (by ncf.vim) statements highlighted as
1787errors, use this: >
1788
1789 :let ncf_highlight_unknowns = 1
1790
1791If you don't want to highlight these errors, leave it unset.
1792
1793
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001794NROFF *nroff.vim* *ft-nroff-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795
1796The nroff syntax file works with AT&T n/troff out of the box. You need to
1797activate the GNU groff extra features included in the syntax file before you
1798can use them.
1799
1800For example, Linux and BSD distributions use groff as their default text
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001801processing package. In order to activate the extra syntax highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802features for groff, add the following option to your start-up files: >
1803
1804 :let b:nroff_is_groff = 1
1805
1806Groff is different from the old AT&T n/troff that you may still find in
1807Solaris. Groff macro and request names can be longer than 2 characters and
1808there are extensions to the language primitives. For example, in AT&T troff
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001809you access the year as a 2-digit number with the request \(yr. In groff you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001810can use the same request, recognized for compatibility, or you can use groff's
1811native syntax, \[yr]. Furthermore, you can use a 4-digit year directly:
1812\[year]. Macro requests can be longer than 2 characters, for example, GNU mm
1813accepts the requests ".VERBON" and ".VERBOFF" for creating verbatim
1814environments.
1815
1816In order to obtain the best formatted output g/troff can give you, you should
1817follow a few simple rules about spacing and punctuation.
1818
18191. Do not leave empty spaces at the end of lines.
1820
18212. Leave one space and one space only after an end-of-sentence period,
1822 exclamation mark, etc.
1823
18243. For reasons stated below, it is best to follow all period marks with a
1825 carriage return.
1826
1827The reason behind these unusual tips is that g/n/troff have a line breaking
1828algorithm that can be easily upset if you don't follow the rules given above.
1829
1830Unlike TeX, troff fills text line-by-line, not paragraph-by-paragraph and,
1831furthermore, it does not have a concept of glue or stretch, all horizontal and
1832vertical space input will be output as is.
1833
1834Therefore, you should be careful about not using more space between sentences
1835than you intend to have in your final document. For this reason, the common
1836practice is to insert a carriage return immediately after all punctuation
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001837marks. If you want to have "even" text in your final processed output, you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001838need to maintaining regular spacing in the input text. To mark both trailing
1839spaces and two or more spaces after a punctuation as an error, use: >
1840
1841 :let nroff_space_errors = 1
1842
1843Another technique to detect extra spacing and other errors that will interfere
1844with the correct typesetting of your file, is to define an eye-catching
1845highlighting definition for the syntax groups "nroffDefinition" and
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001846"nroffDefSpecial" in your configuration files. For example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001847
1848 hi def nroffDefinition term=italic cterm=italic gui=reverse
1849 hi def nroffDefSpecial term=italic,bold cterm=italic,bold
1850 \ gui=reverse,bold
1851
1852If you want to navigate preprocessor entries in your source file as easily as
1853with section markers, you can activate the following option in your .vimrc
1854file: >
1855
1856 let b:preprocs_as_sections = 1
1857
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00001858As well, the syntax file adds an extra paragraph marker for the extended
Bram Moolenaar071d4272004-06-13 20:20:40 +00001859paragraph macro (.XP) in the ms package.
1860
1861Finally, there is a |groff.vim| syntax file that can be used for enabling
1862groff syntax highlighting either on a file basis or globally by default.
1863
1864
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001865OCAML *ocaml.vim* *ft-ocaml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866
1867The OCaml syntax file handles files having the following prefixes: .ml,
1868.mli, .mll and .mly. By setting the following variable >
1869
1870 :let ocaml_revised = 1
1871
1872you can switch from standard OCaml-syntax to revised syntax as supported
1873by the camlp4 preprocessor. Setting the variable >
1874
1875 :let ocaml_noend_error = 1
1876
1877prevents highlighting of "end" as error, which is useful when sources
1878contain very long structures that Vim does not synchronize anymore.
1879
1880
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001881PAPP *papp.vim* *ft-papp-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882
1883The PApp syntax file handles .papp files and, to a lesser extend, .pxml
1884and .pxsl files which are all a mixture of perl/xml/html/other using xml
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001885as the top-level file format. By default everything inside phtml or pxml
1886sections is treated as a string with embedded preprocessor commands. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001887you set the variable: >
1888
1889 :let papp_include_html=1
1890
1891in your startup file it will try to syntax-hilight html code inside phtml
1892sections, but this is relatively slow and much too colourful to be able to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001893edit sensibly. ;)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894
1895The newest version of the papp.vim syntax file can usually be found at
1896http://papp.plan9.de.
1897
1898
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001899PASCAL *pascal.vim* *ft-pascal-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900
1901Files matching "*.p" could be Progress or Pascal. If the automatic detection
1902doesn't work for you, or you don't edit Progress at all, use this in your
1903startup vimrc: >
1904
1905 :let filetype_p = "pascal"
1906
1907The Pascal syntax file has been extended to take into account some extensions
1908provided by Turbo Pascal, Free Pascal Compiler and GNU Pascal Compiler.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001909Delphi keywords are also supported. By default, Turbo Pascal 7.0 features are
Bram Moolenaar071d4272004-06-13 20:20:40 +00001910enabled. If you prefer to stick with the standard Pascal keywords, add the
1911following line to your startup file: >
1912
1913 :let pascal_traditional=1
1914
1915To switch on Delphi specific constructions (such as one-line comments,
1916keywords, etc): >
1917
1918 :let pascal_delphi=1
1919
1920
1921The option pascal_symbol_operator controls whether symbol operators such as +,
1922*, .., etc. are displayed using the Operator color or not. To colorize symbol
1923operators, add the following line to your startup file: >
1924
1925 :let pascal_symbol_operator=1
1926
1927Some functions are highlighted by default. To switch it off: >
1928
1929 :let pascal_no_functions=1
1930
1931Furthermore, there are specific variable for some compiler. Besides
1932pascal_delphi, there are pascal_gpc and pascal_fpc. Default extensions try to
1933match Turbo Pascal. >
1934
1935 :let pascal_gpc=1
1936
1937or >
1938
1939 :let pascal_fpc=1
1940
1941To ensure that strings are defined on a single line, you can define the
1942pascal_one_line_string variable. >
1943
1944 :let pascal_one_line_string=1
1945
1946If you dislike <Tab> chars, you can set the pascal_no_tabs variable. Tabs
1947will be highlighted as Error. >
1948
1949 :let pascal_no_tabs=1
1950
1951
1952
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001953PERL *perl.vim* *ft-perl-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954
1955There are a number of possible options to the perl syntax highlighting.
1956
1957If you use POD files or POD segments, you might: >
1958
1959 :let perl_include_pod = 1
1960
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001961The reduce the complexity of parsing (and increase performance) you can switch
1962off two elements in the parsing of variable names and contents. >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001963
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001964To handle package references in variable and function names not differently
1965from the rest of the name (like 'PkgName::' in '$PkgName::VarName'): >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001966
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001967 :let perl_no_scope_in_variables = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001968
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001969(In Vim 6.x it was the other way around: "perl_want_scope_in_variables"
1970enabled it.)
1971
1972If you do not want complex things like '@{${"foo"}}' to be parsed: >
1973
1974 :let perl_no_extended_vars = 1
1975
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +00001976(In Vim 6.x it was the other way around: "perl_extended_vars" enabled it.)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001977
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001978The coloring strings can be changed. By default strings and qq friends will be
1979highlighted like the first line. If you set the variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00001980perl_string_as_statement, it will be highlighted as in the second line.
1981
1982 "hello world!"; qq|hello world|;
1983 ^^^^^^^^^^^^^^NN^^^^^^^^^^^^^^^N (unlet perl_string_as_statement)
1984 S^^^^^^^^^^^^SNNSSS^^^^^^^^^^^SN (let perl_string_as_statement)
1985
1986(^ = perlString, S = perlStatement, N = None at all)
1987
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001988The syncing has 3 options. The first two switch off some triggering of
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989synchronization and should only be needed in case it fails to work properly.
1990If while scrolling all of a sudden the whole screen changes color completely
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001991then you should try and switch off one of those. Let me know if you can figure
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992out the line that causes the mistake.
1993
1994One triggers on "^\s*sub\s*" and the other on "^[$@%]" more or less. >
1995
1996 :let perl_no_sync_on_sub
1997 :let perl_no_sync_on_global_var
1998
1999Below you can set the maximum distance VIM should look for starting points for
2000its attempts in syntax highlighting. >
2001
2002 :let perl_sync_dist = 100
2003
2004If you want to use folding with perl, set perl_fold: >
2005
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002006 :let perl_fold = 1
2007
2008If you want to fold blocks in if statements, etc. as well set the following: >
2009
2010 :let perl_fold_blocks = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002011
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00002012To avoid folding packages or subs when perl_fold is let, let the appropriate
2013variable(s): >
2014
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002015 :unlet perl_nofold_packages
2016 :unlet perl_nofold_subs
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00002017
2018
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002020PHP3 and PHP4 *php.vim* *php3.vim* *ft-php-syntax* *ft-php3-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002021
2022[note: previously this was called "php3", but since it now also supports php4
2023it has been renamed to "php"]
2024
2025There are the following options for the php syntax highlighting.
2026
2027If you like SQL syntax highlighting inside Strings: >
2028
2029 let php_sql_query = 1
2030
2031For highlighting the Baselib methods: >
2032
2033 let php_baselib = 1
2034
2035Enable HTML syntax highlighting inside strings: >
2036
2037 let php_htmlInStrings = 1
2038
2039Using the old colorstyle: >
2040
2041 let php_oldStyle = 1
2042
2043Enable highlighting ASP-style short tags: >
2044
2045 let php_asp_tags = 1
2046
2047Disable short tags: >
2048
2049 let php_noShortTags = 1
2050
2051For highlighting parent error ] or ): >
2052
2053 let php_parent_error_close = 1
2054
2055For skipping an php end tag, if there exists an open ( or [ without a closing
2056one: >
2057
2058 let php_parent_error_open = 1
2059
2060Enable folding for classes and functions: >
2061
2062 let php_folding = 1
2063
2064Selecting syncing method: >
2065
2066 let php_sync_method = x
2067
2068x = -1 to sync by search (default),
2069x > 0 to sync at least x lines backwards,
2070x = 0 to sync from start.
2071
2072
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00002073PLAINTEX *plaintex.vim* *ft-plaintex-syntax*
2074
2075TeX is a typesetting language, and plaintex is the file type for the "plain"
2076variant of TeX. If you never want your *.tex files recognized as plain TeX,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002077see |ft-tex-plugin|.
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00002078
2079This syntax file has the option >
2080
2081 let g:plaintex_delimiters = 1
2082
2083if you want to highlight brackets "[]" and braces "{}".
2084
2085
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002086PPWIZARD *ppwiz.vim* *ft-ppwiz-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087
2088PPWizard is a preprocessor for HTML and OS/2 INF files
2089
2090This syntax file has the options:
2091
2092- ppwiz_highlight_defs : determines highlighting mode for PPWizard's
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002093 definitions. Possible values are
Bram Moolenaar071d4272004-06-13 20:20:40 +00002094
2095 ppwiz_highlight_defs = 1 : PPWizard #define statements retain the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002096 colors of their contents (e.g. PPWizard macros and variables)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002097
2098 ppwiz_highlight_defs = 2 : preprocessor #define and #evaluate
2099 statements are shown in a single color with the exception of line
2100 continuation symbols
2101
2102 The default setting for ppwiz_highlight_defs is 1.
2103
2104- ppwiz_with_html : If the value is 1 (the default), highlight literal
2105 HTML code; if 0, treat HTML code like ordinary text.
2106
2107
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002108PHTML *phtml.vim* *ft-phtml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002109
2110There are two options for the phtml syntax highlighting.
2111
2112If you like SQL syntax highlighting inside Strings, use this: >
2113
2114 :let phtml_sql_query = 1
2115
2116For syncing, minlines defaults to 100. If you prefer another value, you can
2117set "phtml_minlines" to the value you desire. Example: >
2118
2119 :let phtml_minlines = 200
2120
2121
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002122POSTSCRIPT *postscr.vim* *ft-postscr-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123
2124There are several options when it comes to highlighting PostScript.
2125
2126First which version of the PostScript language to highlight. There are
2127currently three defined language versions, or levels. Level 1 is the original
2128and base version, and includes all extensions prior to the release of level 2.
2129Level 2 is the most common version around, and includes its own set of
2130extensions prior to the release of level 3. Level 3 is currently the highest
2131level supported. You select which level of the PostScript language you want
2132highlighted by defining the postscr_level variable as follows: >
2133
2134 :let postscr_level=2
2135
2136If this variable is not defined it defaults to 2 (level 2) since this is
2137the most prevalent version currently.
2138
2139Note, not all PS interpreters will support all language features for a
2140particular language level. In particular the %!PS-Adobe-3.0 at the start of
2141PS files does NOT mean the PostScript present is level 3 PostScript!
2142
2143If you are working with Display PostScript, you can include highlighting of
2144Display PS language features by defining the postscr_display variable as
2145follows: >
2146
2147 :let postscr_display=1
2148
2149If you are working with Ghostscript, you can include highlighting of
2150Ghostscript specific language features by defining the variable
2151postscr_ghostscript as follows: >
2152
2153 :let postscr_ghostscript=1
2154
2155PostScript is a large language, with many predefined elements. While it
2156useful to have all these elements highlighted, on slower machines this can
2157cause Vim to slow down. In an attempt to be machine friendly font names and
2158character encodings are not highlighted by default. Unless you are working
2159explicitly with either of these this should be ok. If you want them to be
2160highlighted you should set one or both of the following variables: >
2161
2162 :let postscr_fonts=1
2163 :let postscr_encodings=1
2164
2165There is a stylistic option to the highlighting of and, or, and not. In
2166PostScript the function of these operators depends on the types of their
2167operands - if the operands are booleans then they are the logical operators,
2168if they are integers then they are binary operators. As binary and logical
2169operators can be highlighted differently they have to be highlighted one way
2170or the other. By default they are treated as logical operators. They can be
2171highlighted as binary operators by defining the variable
2172postscr_andornot_binary as follows: >
2173
2174 :let postscr_andornot_binary=1
2175<
2176
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002177 *ptcap.vim* *ft-printcap-syntax*
2178PRINTCAP + TERMCAP *ft-ptcap-syntax* *ft-termcap-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002179
2180This syntax file applies to the printcap and termcap databases.
2181
2182In order for Vim to recognize printcap/termcap files that do not match
2183the patterns *printcap*, or *termcap*, you must put additional patterns
2184appropriate to your system in your |myfiletypefile| file. For these
2185patterns, you must set the variable "b:ptcap_type" to either "print" or
2186"term", and then the 'filetype' option to ptcap.
2187
2188For example, to make Vim identify all files in /etc/termcaps/ as termcap
2189files, add the following: >
2190
2191 :au BufNewFile,BufRead /etc/termcaps/* let b:ptcap_type = "term" |
2192 \ set filetype=ptcap
2193
2194If you notice highlighting errors while scrolling backwards, which
2195are fixed when redrawing with CTRL-L, try setting the "ptcap_minlines"
2196internal variable to a larger number: >
2197
2198 :let ptcap_minlines = 50
2199
2200(The default is 20 lines.)
2201
2202
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002203PROGRESS *progress.vim* *ft-progress-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002204
2205Files matching "*.w" could be Progress or cweb. If the automatic detection
2206doesn't work for you, or you don't edit cweb at all, use this in your
2207startup vimrc: >
2208 :let filetype_w = "progress"
2209The same happens for "*.i", which could be assembly, and "*.p", which could be
2210Pascal. Use this if you don't use assembly and Pascal: >
2211 :let filetype_i = "progress"
2212 :let filetype_p = "progress"
2213
2214
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002215PYTHON *python.vim* *ft-python-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002216
2217There are four options to control Python syntax highlighting.
2218
2219For highlighted numbers: >
2220 :let python_highlight_numbers = 1
2221
2222For highlighted builtin functions: >
2223 :let python_highlight_builtins = 1
2224
2225For highlighted standard exceptions: >
2226 :let python_highlight_exceptions = 1
2227
2228For highlighted trailing whitespace and mix of spaces and tabs:
2229 :let python_highlight_space_errors = 1
2230
2231If you want all possible Python highlighting (the same as setting the
2232preceding three options): >
2233 :let python_highlight_all = 1
2234
2235
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002236QUAKE *quake.vim* *ft-quake-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002237
2238The Quake syntax definition should work for most any FPS (First Person
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002239Shooter) based on one of the Quake engines. However, the command names vary
Bram Moolenaar071d4272004-06-13 20:20:40 +00002240a bit between the three games (Quake, Quake 2, and Quake 3 Arena) so the
2241syntax definition checks for the existence of three global variables to allow
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002242users to specify what commands are legal in their files. The three variables
Bram Moolenaar071d4272004-06-13 20:20:40 +00002243can be set for the following effects:
2244
2245set to highlight commands only available in Quake: >
2246 :let quake_is_quake1 = 1
2247
2248set to highlight commands only available in Quake 2: >
2249 :let quake_is_quake2 = 1
2250
2251set to highlight commands only available in Quake 3 Arena: >
2252 :let quake_is_quake3 = 1
2253
2254Any combination of these three variables is legal, but might highlight more
2255commands than are actually available to you by the game.
2256
2257
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002258READLINE *readline.vim* *ft-readline-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259
2260The readline library is primarily used by the BASH shell, which adds quite a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002261few commands and options to the ones already available. To highlight these
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262items as well you can add the following to your |vimrc| or just type it in the
2263command line before loading a file with the readline syntax: >
2264 let readline_has_bash = 1
2265
2266This will add highlighting for the commands that BASH (version 2.05a and
2267later, and part earlier) adds.
2268
2269
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002270REXX *rexx.vim* *ft-rexx-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002271
2272If you notice highlighting errors while scrolling backwards, which are fixed
2273when redrawing with CTRL-L, try setting the "rexx_minlines" internal variable
2274to a larger number: >
2275 :let rexx_minlines = 50
2276This will make the syntax synchronization start 50 lines before the first
2277displayed line. The default value is 10. The disadvantage of using a larger
2278number is that redrawing can become slow.
2279
2280
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002281RUBY *ruby.vim* *ft-ruby-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002283There are a number of options to the Ruby syntax highlighting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002284
2285By default, the "end" keyword is colorized according to the opening statement
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002286of the block it closes. While useful, this feature can be expensive; if you
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287experience slow redrawing (or you are on a terminal with poor color support)
2288you may want to turn it off by defining the "ruby_no_expensive" variable: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002289
Bram Moolenaar071d4272004-06-13 20:20:40 +00002290 :let ruby_no_expensive = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002291<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292In this case the same color will be used for all control keywords.
2293
2294If you do want this feature enabled, but notice highlighting errors while
2295scrolling backwards, which are fixed when redrawing with CTRL-L, try setting
2296the "ruby_minlines" variable to a value larger than 50: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002297
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 :let ruby_minlines = 100
Bram Moolenaar25394022007-05-10 19:06:20 +00002299<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300Ideally, this value should be a number of lines large enough to embrace your
2301largest class or module.
2302
Bram Moolenaar25394022007-05-10 19:06:20 +00002303Highlighting of special identifiers can be disabled by removing the
2304rubyIdentifier highlighting: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002305
Bram Moolenaar25394022007-05-10 19:06:20 +00002306 :hi link rubyIdentifier NONE
2307<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308This will prevent highlighting of special identifiers like "ConstantName",
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002309"$global_var", "@@class_var", "@instance_var", "| block_param |", and
2310":symbol".
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002312Significant methods of Kernel, Module and Object are highlighted by default.
2313This can be disabled by defining "ruby_no_special_methods": >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002314
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002315 :let ruby_no_special_methods = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002316<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002317This will prevent highlighting of important methods such as "require", "attr",
2318"private", "raise" and "proc".
2319
Bram Moolenaar25394022007-05-10 19:06:20 +00002320Ruby operators can be highlighted. This is enabled by defining
2321"ruby_operators": >
2322
2323 :let ruby_operators = 1
2324<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002325Whitespace errors can be highlighted by defining "ruby_space_errors": >
2326
2327 :let ruby_space_errors = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002328<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002329This will highlight trailing whitespace and tabs preceded by a space character
2330as errors. This can be refined by defining "ruby_no_trail_space_error" and
2331"ruby_no_tab_space_error" which will ignore trailing whitespace and tabs after
2332spaces respectively.
2333
2334Folding can be enabled by defining "ruby_fold": >
2335
2336 :let ruby_fold = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002337<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002338This will set the 'foldmethod' option to "syntax" and allow folding of
2339classes, modules, methods, code blocks, heredocs and comments.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002340
Bram Moolenaar25394022007-05-10 19:06:20 +00002341Folding of multiline comments can be disabled by defining
2342"ruby_no_comment_fold": >
2343
2344 :let ruby_no_comment_fold = 1
2345<
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002346
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002347SCHEME *scheme.vim* *ft-scheme-syntax*
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002348
2349By default only R5RS keywords are highlighted and properly indented.
2350
2351MzScheme-specific stuff will be used if b:is_mzscheme or g:is_mzscheme
2352variables are defined.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002353
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002354Also scheme.vim supports keywords of the Chicken Scheme->C compiler. Define
2355b:is_chicken or g:is_chicken, if you need them.
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002356
2357
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002358SDL *sdl.vim* *ft-sdl-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359
2360The SDL highlighting probably misses a few keywords, but SDL has so many
2361of them it's almost impossibly to cope.
2362
2363The new standard, SDL-2000, specifies that all identifiers are
2364case-sensitive (which was not so before), and that all keywords can be
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002365used either completely lowercase or completely uppercase. To have the
Bram Moolenaar071d4272004-06-13 20:20:40 +00002366highlighting reflect this, you can set the following variable: >
2367 :let sdl_2000=1
2368
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002369This also sets many new keywords. If you want to disable the old
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370keywords, which is probably a good idea, use: >
2371 :let SDL_no_96=1
2372
2373
2374The indentation is probably also incomplete, but right now I am very
2375satisfied with it for my own projects.
2376
2377
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002378SED *sed.vim* *ft-sed-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379
2380To make tabs stand out from regular blanks (accomplished by using Todo
2381highlighting on the tabs), define "highlight_sedtabs" by putting >
2382
2383 :let highlight_sedtabs = 1
2384
2385in the vimrc file. (This special highlighting only applies for tabs
2386inside search patterns, replacement texts, addresses or text included
2387by an Append/Change/Insert command.) If you enable this option, it is
2388also a good idea to set the tab width to one character; by doing that,
2389you can easily count the number of tabs in a string.
2390
2391Bugs:
2392
2393 The transform command (y) is treated exactly like the substitute
2394 command. This means that, as far as this syntax file is concerned,
2395 transform accepts the same flags as substitute, which is wrong.
2396 (Transform accepts no flags.) I tolerate this bug because the
2397 involved commands need very complex treatment (95 patterns, one for
2398 each plausible pattern delimiter).
2399
2400
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002401SGML *sgml.vim* *ft-sgml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402
2403The coloring scheme for tags in the SGML file works as follows.
2404
2405The <> of opening tags are colored differently than the </> of a closing tag.
2406This is on purpose! For opening tags the 'Function' color is used, while for
2407closing tags the 'Type' color is used (See syntax.vim to check how those are
2408defined for you)
2409
2410Known tag names are colored the same way as statements in C. Unknown tag
2411names are not colored which makes it easy to spot errors.
2412
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002413Note that the same is true for argument (or attribute) names. Known attribute
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414names are colored differently than unknown ones.
2415
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002416Some SGML tags are used to change the rendering of text. The following tags
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417are recognized by the sgml.vim syntax coloring file and change the way normal
2418text is shown: <varname> <emphasis> <command> <function> <literal>
2419<replaceable> <ulink> and <link>.
2420
2421If you want to change how such text is rendered, you must redefine the
2422following syntax groups:
2423
2424 - sgmlBold
2425 - sgmlBoldItalic
2426 - sgmlUnderline
2427 - sgmlItalic
2428 - sgmlLink for links
2429
2430To make this redefinition work you must redefine them all and define the
2431following variable in your vimrc (this is due to the order in which the files
2432are read during initialization) >
2433 let sgml_my_rendering=1
2434
2435You can also disable this rendering by adding the following line to your
2436vimrc file: >
2437 let sgml_no_rendering=1
2438
2439(Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>)
2440
2441
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002442SH *sh.vim* *ft-sh-syntax* *ft-bash-syntax* *ft-ksh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002444This covers the "normal" Unix (Bourne) sh, bash and the Korn shell.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445
2446Vim attempts to determine which shell type is in use by specifying that
2447various filenames are of specific types: >
2448
2449 ksh : .kshrc* *.ksh
2450 bash: .bashrc* bashrc bash.bashrc .bash_profile* *.bash
2451<
2452If none of these cases pertain, then the first line of the file is examined
2453(ex. /bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype,
2454then that shelltype is used. However some files (ex. .profile) are known to
2455be shell files but the type is not apparent. Furthermore, on many systems
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002456sh is symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457
2458One may specify a global default by instantiating one of the following three
2459variables in your <.vimrc>:
2460
2461 ksh: >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002462 let g:is_kornshell = 1
2463< posix: (using this is the same as setting is_kornshell to 1) >
2464 let g:is_posix = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465< bash: >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002466 let g:is_bash = 1
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002467< sh: (default) Bourne shell >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002468 let g:is_sh = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002469
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002470If there's no "#! ..." line, and the user hasn't availed himself/herself of a
2471default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002472the Bourne shell syntax. No need to quote RFCs or market penetration
2473statistics in error reports, please -- just select the default version of the
2474sh your system uses in your <.vimrc>.
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002475
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002476The syntax/sh.vim file provides several levels of syntax-based folding: >
2477
2478 let g:sh_fold_enabled= 0 (default, no syntax folding)
2479 let g:sh_fold_enabled= 1 (enable function folding)
2480 let g:sh_fold_enabled= 2 (enable heredoc folding)
2481 let g:sh_fold_enabled= 4 (enable if/do/for folding)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482>
2483then various syntax items (HereDocuments and function bodies) become
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002484syntax-foldable (see |:syn-fold|). You also may add these together
2485to get multiple types of folding: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002486
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002487 let g:sh_fold_enabled= 3 (enables function and heredoc folding)
2488
2489If you notice highlighting errors while scrolling backwards which are fixed
2490when one redraws with CTRL-L, try setting the "sh_minlines" internal variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491to a larger number. Example: >
2492
2493 let sh_minlines = 500
2494
2495This will make syntax synchronization start 500 lines before the first
2496displayed line. The default value is 200. The disadvantage of using a larger
2497number is that redrawing can become slow.
2498
2499If you don't have much to synchronize on, displaying can be very slow. To
2500reduce this, the "sh_maxlines" internal variable can be set. Example: >
2501
2502 let sh_maxlines = 100
2503<
2504The default is to use the twice sh_minlines. Set it to a smaller number to
2505speed up displaying. The disadvantage is that highlight errors may appear.
2506
2507
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002508SPEEDUP (AspenTech plant simulator) *spup.vim* *ft-spup-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509
2510The Speedup syntax file has some options:
2511
2512- strict_subsections : If this variable is defined, only keywords for
2513 sections and subsections will be highlighted as statements but not
2514 other keywords (like WITHIN in the OPERATION section).
2515
2516- highlight_types : Definition of this variable causes stream types
2517 like temperature or pressure to be highlighted as Type, not as a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002518 plain Identifier. Included are the types that are usually found in
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519 the DECLARE section; if you defined own types, you have to include
2520 them in the syntax file.
2521
2522- oneline_comments : this value ranges from 1 to 3 and determines the
2523 highlighting of # style comments.
2524
2525 oneline_comments = 1 : allow normal Speedup code after an even
2526 number of #s.
2527
2528 oneline_comments = 2 : show code starting with the second # as
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002529 error. This is the default setting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530
2531 oneline_comments = 3 : show the whole line as error if it contains
2532 more than one #.
2533
2534Since especially OPERATION sections tend to become very large due to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002535PRESETting variables, syncing may be critical. If your computer is
Bram Moolenaar071d4272004-06-13 20:20:40 +00002536fast enough, you can increase minlines and/or maxlines near the end of
2537the syntax file.
2538
2539
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002540SQL *sql.vim* *ft-sql-syntax*
2541 *sqlinformix.vim* *ft-sqlinformix-syntax*
Bram Moolenaar1056d982006-03-09 22:37:52 +00002542 *sqlanywhere.vim* *ft-sqlanywhere-syntax*
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002543
Bram Moolenaar1056d982006-03-09 22:37:52 +00002544While there is an ANSI standard for SQL, most database engines add their own
2545custom extensions. Vim currently supports the Oracle and Informix dialects of
2546SQL. Vim assumes "*.sql" files are Oracle SQL by default.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002547
Bram Moolenaar1056d982006-03-09 22:37:52 +00002548Vim currently has SQL support for a variety of different vendors via syntax
2549scripts. You can change Vim's default from Oracle to any of the current SQL
2550supported types. You can also easily alter the SQL dialect being used on a
2551buffer by buffer basis.
2552
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002553For more detailed instructions see |ft_sql.txt|.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002554
2555
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002556TCSH *tcsh.vim* *ft-tcsh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002557
2558This covers the shell named "tcsh". It is a superset of csh. See |csh.vim|
2559for how the filetype is detected.
2560
2561Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002562is set. If you want VIM to assume that no backslash quote constructs exist add
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563this line to your .vimrc: >
2564
2565 :let tcsh_backslash_quote = 0
2566
2567If you notice highlighting errors while scrolling backwards, which are fixed
2568when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable
2569to a larger number: >
2570
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01002571 :let tcsh_minlines = 1000
Bram Moolenaar071d4272004-06-13 20:20:40 +00002572
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01002573This will make the syntax synchronization start 1000 lines before the first
2574displayed line. If you set "tcsh_minlines" to "fromstart", then
2575synchronization is done from the start of the file. The default value for
2576tcsh_minlines is 100. The disadvantage of using a larger number is that
2577redrawing can become slow.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002578
2579
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002580TEX *tex.vim* *ft-tex-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002581
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002582 *tex-folding*
Bram Moolenaar488c6512005-08-11 20:09:58 +00002583Want Syntax Folding? ~
2584
2585As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
2586sections, subsections, etc are supported. Put >
2587 let g:tex_fold_enabled=1
2588in your <.vimrc>, and :set fdm=syntax. I suggest doing the latter via a
2589modeline at the end of your LaTeX file: >
2590 % vim: fdm=syntax
2591<
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002592 *tex-nospell*
2593Don't Want Spell Checking In Comments? ~
2594
2595Some folks like to include things like source code in comments and so would
2596prefer that spell checking be disabled in comments in LaTeX files. To do
2597this, put the following in your <.vimrc>: >
2598 let g:tex_comment_nospell= 1
2599<
2600 *tex-runon*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002601Run-on Comments/Math? ~
2602
Bram Moolenaar488c6512005-08-11 20:09:58 +00002603The <syntax/tex.vim> highlighting supports TeX, LaTeX, and some AmsTeX. The
2604highlighting supports three primary zones/regions: normal, texZone, and
2605texMathZone. Although considerable effort has been made to have these zones
2606terminate properly, zones delineated by $..$ and $$..$$ cannot be synchronized
2607as there's no difference between start and end patterns. Consequently, a
Bram Moolenaar071d4272004-06-13 20:20:40 +00002608special "TeX comment" has been provided >
2609 %stopzone
2610which will forcibly terminate the highlighting of either a texZone or a
2611texMathZone.
2612
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002613 *tex-slow*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002614Slow Syntax Highlighting? ~
2615
2616If you have a slow computer, you may wish to reduce the values for >
2617 :syn sync maxlines=200
2618 :syn sync minlines=50
2619(especially the latter). If your computer is fast, you may wish to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002620increase them. This primarily affects synchronizing (i.e. just what group,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002621if any, is the text at the top of the screen supposed to be in?).
2622
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002623 *tex-morecommands* *tex-package*
2624Want To Highlight More Commands? ~
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002625
2626LaTeX is a programmable language, and so there are thousands of packages full
2627of specialized LaTeX commands, syntax, and fonts. If you're using such a
2628package you'll often wish that the distributed syntax/tex.vim would support
2629it. However, clearly this is impractical. So please consider using the
2630techniques in |mysyntaxfile-add| to extend or modify the highlighting provided
2631by syntax/tex.vim.
2632
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002633 *tex-error*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634Excessive Error Highlighting? ~
2635
2636The <tex.vim> supports lexical error checking of various sorts. Thus,
2637although the error checking is ofttimes very useful, it can indicate
2638errors where none actually are. If this proves to be a problem for you,
2639you may put in your <.vimrc> the following statement: >
2640 let tex_no_error=1
Bram Moolenaar488c6512005-08-11 20:09:58 +00002641and all error checking by <syntax/tex.vim> will be suppressed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002643 *tex-math*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644Need a new Math Group? ~
2645
2646If you want to include a new math group in your LaTeX, the following
2647code shows you an example as to how you might do so: >
Bram Moolenaar488c6512005-08-11 20:09:58 +00002648 call TexNewMathZone(sfx,mathzone,starform)
2649You'll want to provide the new math group with a unique suffix
2650(currently, A-L and V-Z are taken by <syntax/tex.vim> itself).
2651As an example, consider how eqnarray is set up by <syntax/tex.vim>: >
2652 call TexNewMathZone("D","eqnarray",1)
2653You'll need to change "mathzone" to the name of your new math group,
2654and then to the call to it in .vim/after/syntax/tex.vim.
2655The "starform" variable, if true, implies that your new math group
2656has a starred form (ie. eqnarray*).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002658 *tex-style*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002659Starting a New Style? ~
2660
2661One may use "\makeatletter" in *.tex files, thereby making the use of "@" in
2662commands available. However, since the *.tex file doesn't have one of the
2663following suffices: sty cls clo dtx ltx, the syntax highlighting will flag
2664such use of @ as an error. To solve this: >
2665
2666 :let b:tex_stylish = 1
2667 :set ft=tex
2668
2669Putting "let g:tex_stylish=1" into your <.vimrc> will make <syntax/tex.vim>
2670always accept such use of @.
2671
2672
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002673TF *tf.vim* *ft-tf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002674
2675There is one option for the tf syntax highlighting.
2676
2677For syncing, minlines defaults to 100. If you prefer another value, you can
2678set "tf_minlines" to the value you desire. Example: >
2679
2680 :let tf_minlines = your choice
2681
2682
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002683VIM *vim.vim* *ft-vim-syntax*
2684 *g:vimsyn_minlines* *g:vimsyn_maxlines*
2685There is a tradeoff between more accurate syntax highlighting versus screen
2686updating speed. To improve accuracy, you may wish to increase the
2687g:vimsyn_minlines variable. The g:vimsyn_maxlines variable may be used to
2688improve screen updating rates (see |:syn-sync| for more on this). >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002690 g:vimsyn_minlines : used to set synchronization minlines
2691 g:vimsyn_maxlines : used to set synchronization maxlines
2692<
2693 (g:vim_minlines and g:vim_maxlines are deprecated variants of
2694 these two options)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002695
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002696 *g:vimsyn_embed*
2697The g:vimsyn_embed option allows users to select what, if any, types of
2698embedded script highlighting they wish to have. >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002700 g:vimsyn_embed == 0 : don't embed any scripts
2701 g:vimsyn_embed =~ 'm' : embed mzscheme (but only if vim supports it)
2702 g:vimsyn_embed =~ 'p' : embed perl (but only if vim supports it)
2703 g:vimsyn_embed =~ 'P' : embed python (but only if vim supports it)
2704 g:vimsyn_embed =~ 'r' : embed ruby (but only if vim supports it)
2705 g:vimsyn_embed =~ 't' : embed tcl (but only if vim supports it)
2706<
2707By default, g:vimsyn_embed is "mpPr"; ie. syntax/vim.vim will support
2708highlighting mzscheme, perl, python, and ruby by default. Vim's has("tcl")
2709test appears to hang vim when tcl is not truly available. Thus, by default,
2710tcl is not supported for embedding (but those of you who like tcl embedded in
2711their vim syntax highlighting can simply include it in the g:vimembedscript
2712option).
2713 *g:vimsyn_folding*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002714
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002715Some folding is now supported with syntax/vim.vim: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002717 g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding
2718 g:vimsyn_folding =~ 'a' : augroups
2719 g:vimsyn_folding =~ 'f' : fold functions
2720 g:vimsyn_folding =~ 'm' : fold mzscheme script
2721 g:vimsyn_folding =~ 'p' : fold perl script
2722 g:vimsyn_folding =~ 'P' : fold python script
2723 g:vimsyn_folding =~ 'r' : fold ruby script
2724 g:vimsyn_folding =~ 't' : fold tcl script
Bram Moolenaar071d4272004-06-13 20:20:40 +00002725
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002726 *g:vimsyn_noerror*
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002727Not all error highlighting that syntax/vim.vim does may be correct; VimL is a
2728difficult language to highlight correctly. A way to suppress error
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002729highlighting is to put the following line in your |vimrc|: >
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002730
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002731 let g:vimsyn_noerror = 1
2732<
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002733
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002735XF86CONFIG *xf86conf.vim* *ft-xf86conf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002736
2737The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both
2738variants are supported. Automatic detection is used, but is far from perfect.
2739You may need to specify the version manually. Set the variable
2740xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
2741your .vimrc. Example: >
2742 :let xf86conf_xfree86_version=3
2743When using a mix of versions, set the b:xf86conf_xfree86_version variable.
2744
2745Note that spaces and underscores in option names are not supported. Use
2746"SyncOnGreen" instead of "__s yn con gr_e_e_n" if you want the option name
2747highlighted.
2748
2749
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002750XML *xml.vim* *ft-xml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002751
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002752Xml namespaces are highlighted by default. This can be inhibited by
Bram Moolenaar071d4272004-06-13 20:20:40 +00002753setting a global variable: >
2754
2755 :let g:xml_namespace_transparent=1
2756<
2757 *xml-folding*
2758The xml syntax file provides syntax |folding| (see |:syn-fold|) between
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002759start and end tags. This can be turned on by >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002760
2761 :let g:xml_syntax_folding = 1
2762 :set foldmethod=syntax
2763
2764Note: syntax folding might slow down syntax highlighting significantly,
2765especially for large files.
2766
2767
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002768X Pixmaps (XPM) *xpm.vim* *ft-xpm-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769
2770xpm.vim creates its syntax items dynamically based upon the contents of the
2771XPM file. Thus if you make changes e.g. in the color specification strings,
2772you have to source it again e.g. with ":set syn=xpm".
2773
2774To copy a pixel with one of the colors, yank a "pixel" with "yl" and insert it
2775somewhere else with "P".
2776
2777Do you want to draw with the mouse? Try the following: >
2778 :function! GetPixel()
Bram Moolenaar61660ea2006-04-07 21:40:07 +00002779 : let c = getline(".")[col(".") - 1]
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780 : echo c
2781 : exe "noremap <LeftMouse> <LeftMouse>r".c
2782 : exe "noremap <LeftDrag> <LeftMouse>r".c
2783 :endfunction
2784 :noremap <RightMouse> <LeftMouse>:call GetPixel()<CR>
2785 :set guicursor=n:hor20 " to see the color beneath the cursor
2786This turns the right button into a pipette and the left button into a pen.
2787It will work with XPM files that have one character per pixel only and you
2788must not click outside of the pixel strings, but feel free to improve it.
2789
2790It will look much better with a font in a quadratic cell size, e.g. for X: >
2791 :set guifont=-*-clean-medium-r-*-*-8-*-*-*-*-80-*
2792
2793==============================================================================
27945. Defining a syntax *:syn-define* *E410*
2795
2796Vim understands three types of syntax items:
2797
Bram Moolenaarce0842a2005-07-18 21:58:11 +000027981. Keyword
Bram Moolenaar071d4272004-06-13 20:20:40 +00002799 It can only contain keyword characters, according to the 'iskeyword'
2800 option. It cannot contain other syntax items. It will only match with a
2801 complete word (there are no keyword characters before or after the match).
2802 The keyword "if" would match in "if(a=b)", but not in "ifdef x", because
2803 "(" is not a keyword character and "d" is.
2804
Bram Moolenaarce0842a2005-07-18 21:58:11 +000028052. Match
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 This is a match with a single regexp pattern.
2807
Bram Moolenaarce0842a2005-07-18 21:58:11 +000028083. Region
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 This starts at a match of the "start" regexp pattern and ends with a match
2810 with the "end" regexp pattern. Any other text can appear in between. A
2811 "skip" regexp pattern can be used to avoid matching the "end" pattern.
2812
2813Several syntax ITEMs can be put into one syntax GROUP. For a syntax group
2814you can give highlighting attributes. For example, you could have an item
2815to define a "/* .. */" comment and another one that defines a "// .." comment,
2816and put them both in the "Comment" group. You can then specify that a
2817"Comment" will be in bold font and have a blue color. You are free to make
2818one highlight group for one syntax item, or put all items into one group.
2819This depends on how you want to specify your highlighting attributes. Putting
2820each item in its own group results in having to specify the highlighting
2821for a lot of groups.
2822
2823Note that a syntax group and a highlight group are similar. For a highlight
2824group you will have given highlight attributes. These attributes will be used
2825for the syntax group with the same name.
2826
2827In case more than one item matches at the same position, the one that was
2828defined LAST wins. Thus you can override previously defined syntax items by
2829using an item that matches the same text. But a keyword always goes before a
2830match or region. And a keyword with matching case always goes before a
2831keyword with ignoring case.
2832
2833
2834PRIORITY *:syn-priority*
2835
2836When several syntax items may match, these rules are used:
2837
28381. When multiple Match or Region items start in the same position, the item
2839 defined last has priority.
28402. A Keyword has priority over Match and Region items.
28413. An item that starts in an earlier position has priority over items that
2842 start in later positions.
2843
2844
2845DEFINING CASE *:syn-case* *E390*
2846
Bram Moolenaarce0842a2005-07-18 21:58:11 +00002847:sy[ntax] case [match | ignore]
Bram Moolenaar071d4272004-06-13 20:20:40 +00002848 This defines if the following ":syntax" commands will work with
2849 matching case, when using "match", or with ignoring case, when using
2850 "ignore". Note that any items before this are not affected, and all
2851 items until the next ":syntax case" command are affected.
2852
2853
Bram Moolenaarce0842a2005-07-18 21:58:11 +00002854SPELL CHECKING *:syn-spell*
2855
2856:sy[ntax] spell [toplevel | notoplevel | default]
2857 This defines where spell checking is to be done for text that is not
2858 in a syntax item:
2859
2860 toplevel: Text is spell checked.
2861 notoplevel: Text is not spell checked.
2862 default: When there is a @Spell cluster no spell checking.
2863
2864 For text in syntax items use the @Spell and @NoSpell clusters
2865 |spell-syntax|. When there is no @Spell and no @NoSpell cluster then
2866 spell checking is done for "default" and "toplevel".
2867
2868 To activate spell checking the 'spell' option must be set.
2869
2870
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871DEFINING KEYWORDS *:syn-keyword*
2872
2873:sy[ntax] keyword {group-name} [{options}] {keyword} .. [{options}]
2874
2875 This defines a number of keywords.
2876
2877 {group-name} Is a syntax group name such as "Comment".
2878 [{options}] See |:syn-arguments| below.
2879 {keyword} .. Is a list of keywords which are part of this group.
2880
2881 Example: >
2882 :syntax keyword Type int long char
2883<
2884 The {options} can be given anywhere in the line. They will apply to
2885 all keywords given, also for options that come after a keyword.
2886 These examples do exactly the same: >
2887 :syntax keyword Type contained int long char
2888 :syntax keyword Type int long contained char
2889 :syntax keyword Type int long char contained
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00002890< *E789*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002891 When you have a keyword with an optional tail, like Ex commands in
2892 Vim, you can put the optional characters inside [], to define all the
2893 variations at once: >
2894 :syntax keyword vimCommand ab[breviate] n[ext]
2895<
2896 Don't forget that a keyword can only be recognized if all the
2897 characters are included in the 'iskeyword' option. If one character
2898 isn't, the keyword will never be recognized.
2899 Multi-byte characters can also be used. These do not have to be in
2900 'iskeyword'.
2901
2902 A keyword always has higher priority than a match or region, the
2903 keyword is used if more than one item matches. Keywords do not nest
2904 and a keyword can't contain anything else.
2905
2906 Note that when you have a keyword that is the same as an option (even
2907 one that isn't allowed here), you can not use it. Use a match
2908 instead.
2909
2910 The maximum length of a keyword is 80 characters.
2911
2912 The same keyword can be defined multiple times, when its containment
2913 differs. For example, you can define the keyword once not contained
2914 and use one highlight group, and once contained, and use a different
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002915 highlight group. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002916 :syn keyword vimCommand tag
2917 :syn keyword vimSetting contained tag
2918< When finding "tag" outside of any syntax item, the "vimCommand"
2919 highlight group is used. When finding "tag" in a syntax item that
2920 contains "vimSetting", the "vimSetting" group is used.
2921
2922
2923DEFINING MATCHES *:syn-match*
2924
2925:sy[ntax] match {group-name} [{options}] [excludenl] {pattern} [{options}]
2926
2927 This defines one match.
2928
2929 {group-name} A syntax group name such as "Comment".
2930 [{options}] See |:syn-arguments| below.
2931 [excludenl] Don't make a pattern with the end-of-line "$"
2932 extend a containing match or region. Must be
2933 given before the pattern. |:syn-excludenl|
2934 {pattern} The search pattern that defines the match.
2935 See |:syn-pattern| below.
2936 Note that the pattern may match more than one
2937 line, which makes the match depend on where
2938 Vim starts searching for the pattern. You
2939 need to make sure syncing takes care of this.
2940
2941 Example (match a character constant): >
2942 :syntax match Character /'.'/hs=s+1,he=e-1
2943<
2944
2945DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
2946 *E398* *E399*
2947:sy[ntax] region {group-name} [{options}]
2948 [matchgroup={group-name}]
2949 [keepend]
2950 [extend]
2951 [excludenl]
2952 start={start_pattern} ..
2953 [skip={skip_pattern}]
2954 end={end_pattern} ..
2955 [{options}]
2956
2957 This defines one region. It may span several lines.
2958
2959 {group-name} A syntax group name such as "Comment".
2960 [{options}] See |:syn-arguments| below.
2961 [matchgroup={group-name}] The syntax group to use for the following
2962 start or end pattern matches only. Not used
2963 for the text in between the matched start and
2964 end patterns. Use NONE to reset to not using
2965 a different group for the start or end match.
2966 See |:syn-matchgroup|.
2967 keepend Don't allow contained matches to go past a
2968 match with the end pattern. See
2969 |:syn-keepend|.
2970 extend Override a "keepend" for an item this region
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002971 is contained in. See |:syn-extend|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972 excludenl Don't make a pattern with the end-of-line "$"
2973 extend a containing match or item. Only
2974 useful for end patterns. Must be given before
2975 the patterns it applies to. |:syn-excludenl|
2976 start={start_pattern} The search pattern that defines the start of
2977 the region. See |:syn-pattern| below.
2978 skip={skip_pattern} The search pattern that defines text inside
2979 the region where not to look for the end
2980 pattern. See |:syn-pattern| below.
2981 end={end_pattern} The search pattern that defines the end of
2982 the region. See |:syn-pattern| below.
2983
2984 Example: >
2985 :syntax region String start=+"+ skip=+\\"+ end=+"+
2986<
2987 The start/skip/end patterns and the options can be given in any order.
2988 There can be zero or one skip pattern. There must be one or more
2989 start and end patterns. This means that you can omit the skip
2990 pattern, but you must give at least one start and one end pattern. It
2991 is allowed to have white space before and after the equal sign
2992 (although it mostly looks better without white space).
2993
2994 When more than one start pattern is given, a match with one of these
2995 is sufficient. This means there is an OR relation between the start
2996 patterns. The last one that matches is used. The same is true for
2997 the end patterns.
2998
2999 The search for the end pattern starts right after the start pattern.
3000 Offsets are not used for this. This implies that the match for the
3001 end pattern will never overlap with the start pattern.
3002
3003 The skip and end pattern can match across line breaks, but since the
3004 search for the pattern can start in any line it often does not do what
3005 you want. The skip pattern doesn't avoid a match of an end pattern in
3006 the next line. Use single-line patterns to avoid trouble.
3007
3008 Note: The decision to start a region is only based on a matching start
3009 pattern. There is no check for a matching end pattern. This does NOT
3010 work: >
3011 :syn region First start="(" end=":"
3012 :syn region Second start="(" end=";"
3013< The Second always matches before the First (last defined pattern has
3014 higher priority). The Second region then continues until the next
3015 ';', no matter if there is a ':' before it. Using a match does work: >
3016 :syn match First "(\_.\{-}:"
3017 :syn match Second "(\_.\{-};"
3018< This pattern matches any character or line break with "\_." and
3019 repeats that with "\{-}" (repeat as few as possible).
3020
3021 *:syn-keepend*
3022 By default, a contained match can obscure a match for the end pattern.
3023 This is useful for nesting. For example, a region that starts with
3024 "{" and ends with "}", can contain another region. An encountered "}"
3025 will then end the contained region, but not the outer region:
3026 { starts outer "{}" region
3027 { starts contained "{}" region
3028 } ends contained "{}" region
3029 } ends outer "{} region
3030 If you don't want this, the "keepend" argument will make the matching
3031 of an end pattern of the outer region also end any contained item.
3032 This makes it impossible to nest the same region, but allows for
3033 contained items to highlight parts of the end pattern, without causing
3034 that to skip the match with the end pattern. Example: >
3035 :syn match vimComment +"[^"]\+$+
3036 :syn region vimCommand start="set" end="$" contains=vimComment keepend
3037< The "keepend" makes the vimCommand always end at the end of the line,
3038 even though the contained vimComment includes a match with the <EOL>.
3039
3040 When "keepend" is not used, a match with an end pattern is retried
3041 after each contained match. When "keepend" is included, the first
3042 encountered match with an end pattern is used, truncating any
3043 contained matches.
3044 *:syn-extend*
3045 The "keepend" behavior can be changed by using the "extend" argument.
3046 When an item with "extend" is contained in an item that uses
3047 "keepend", the "keepend" is ignored and the containing region will be
3048 extended.
3049 This can be used to have some contained items extend a region while
3050 others don't. Example: >
3051
3052 :syn region htmlRef start=+<a>+ end=+</a>+ keepend contains=htmlItem,htmlScript
3053 :syn match htmlItem +<[^>]*>+ contained
3054 :syn region htmlScript start=+<script+ end=+</script[^>]*>+ contained extend
3055
3056< Here the htmlItem item does not make the htmlRef item continue
3057 further, it is only used to highlight the <> items. The htmlScript
3058 item does extend the htmlRef item.
3059
3060 Another example: >
3061 :syn region xmlFold start="<a>" end="</a>" fold transparent keepend extend
3062< This defines a region with "keepend", so that its end cannot be
3063 changed by contained items, like when the "</a>" is matched to
3064 highlight it differently. But when the xmlFold region is nested (it
3065 includes itself), the "extend" applies, so that the "</a>" of a nested
3066 region only ends that region, and not the one it is contained in.
3067
3068 *:syn-excludenl*
3069 When a pattern for a match or end pattern of a region includes a '$'
3070 to match the end-of-line, it will make a region item that it is
3071 contained in continue on the next line. For example, a match with
3072 "\\$" (backslash at the end of the line) can make a region continue
3073 that would normally stop at the end of the line. This is the default
3074 behavior. If this is not wanted, there are two ways to avoid it:
3075 1. Use "keepend" for the containing item. This will keep all
3076 contained matches from extending the match or region. It can be
3077 used when all contained items must not extend the containing item.
3078 2. Use "excludenl" in the contained item. This will keep that match
3079 from extending the containing match or region. It can be used if
3080 only some contained items must not extend the containing item.
3081 "excludenl" must be given before the pattern it applies to.
3082
3083 *:syn-matchgroup*
3084 "matchgroup" can be used to highlight the start and/or end pattern
3085 differently than the body of the region. Example: >
3086 :syntax region String matchgroup=Quote start=+"+ skip=+\\"+ end=+"+
3087< This will highlight the quotes with the "Quote" group, and the text in
3088 between with the "String" group.
3089 The "matchgroup" is used for all start and end patterns that follow,
3090 until the next "matchgroup". Use "matchgroup=NONE" to go back to not
3091 using a matchgroup.
3092
3093 In a start or end pattern that is highlighted with "matchgroup" the
3094 contained items of the region are not used. This can be used to avoid
3095 that a contained item matches in the start or end pattern match. When
3096 using "transparent", this does not apply to a start or end pattern
3097 match that is highlighted with "matchgroup".
3098
3099 Here is an example, which highlights three levels of parentheses in
3100 different colors: >
3101 :sy region par1 matchgroup=par1 start=/(/ end=/)/ contains=par2
3102 :sy region par2 matchgroup=par2 start=/(/ end=/)/ contains=par3 contained
3103 :sy region par3 matchgroup=par3 start=/(/ end=/)/ contains=par1 contained
3104 :hi par1 ctermfg=red guifg=red
3105 :hi par2 ctermfg=blue guifg=blue
3106 :hi par3 ctermfg=darkgreen guifg=darkgreen
3107
3108==============================================================================
31096. :syntax arguments *:syn-arguments*
3110
3111The :syntax commands that define syntax items take a number of arguments.
3112The common ones are explained here. The arguments may be given in any order
3113and may be mixed with patterns.
3114
3115Not all commands accept all arguments. This table shows which arguments
3116can not be used for all commands:
3117 *E395* *E396*
3118 contains oneline fold display extend ~
3119:syntax keyword - - - - -
3120:syntax match yes - yes yes yes
3121:syntax region yes yes yes yes yes
3122
3123These arguments can be used for all three commands:
3124 contained
3125 containedin
3126 nextgroup
3127 transparent
3128 skipwhite
3129 skipnl
3130 skipempty
3131
3132
3133contained *:syn-contained*
3134
3135When the "contained" argument is given, this item will not be recognized at
3136the top level, but only when it is mentioned in the "contains" field of
3137another match. Example: >
3138 :syntax keyword Todo TODO contained
3139 :syntax match Comment "//.*" contains=Todo
3140
3141
3142display *:syn-display*
3143
3144If the "display" argument is given, this item will be skipped when the
3145detected highlighting will not be displayed. This will speed up highlighting,
3146by skipping this item when only finding the syntax state for the text that is
3147to be displayed.
3148
3149Generally, you can use "display" for match and region items that meet these
3150conditions:
3151- The item does not continue past the end of a line. Example for C: A region
3152 for a "/*" comment can't contain "display", because it continues on the next
3153 line.
3154- The item does not contain items that continue past the end of the line or
3155 make it continue on the next line.
3156- The item does not change the size of any item it is contained in. Example
3157 for C: A match with "\\$" in a preprocessor match can't have "display",
3158 because it may make that preprocessor match shorter.
3159- The item does not allow other items to match that didn't match otherwise,
3160 and that item may extend the match too far. Example for C: A match for a
3161 "//" comment can't use "display", because a "/*" inside that comment would
3162 match then and start a comment which extends past the end of the line.
3163
3164Examples, for the C language, where "display" can be used:
3165- match with a number
3166- match with a label
3167
3168
3169transparent *:syn-transparent*
3170
3171If the "transparent" argument is given, this item will not be highlighted
3172itself, but will take the highlighting of the item it is contained in. This
3173is useful for syntax items that don't need any highlighting but are used
3174only to skip over a part of the text.
3175
3176The "contains=" argument is also inherited from the item it is contained in,
3177unless a "contains" argument is given for the transparent item itself. To
3178avoid that unwanted items are contained, use "contains=NONE". Example, which
3179highlights words in strings, but makes an exception for "vim": >
3180 :syn match myString /'[^']*'/ contains=myWord,myVim
3181 :syn match myWord /\<[a-z]*\>/ contained
3182 :syn match myVim /\<vim\>/ transparent contained contains=NONE
3183 :hi link myString String
3184 :hi link myWord Comment
3185Since the "myVim" match comes after "myWord" it is the preferred match (last
3186match in the same position overrules an earlier one). The "transparent"
3187argument makes the "myVim" match use the same highlighting as "myString". But
3188it does not contain anything. If the "contains=NONE" argument would be left
3189out, then "myVim" would use the contains argument from myString and allow
3190"myWord" to be contained, which will be highlighted as a Constant. This
3191happens because a contained match doesn't match inside itself in the same
3192position, thus the "myVim" match doesn't overrule the "myWord" match here.
3193
3194When you look at the colored text, it is like looking at layers of contained
3195items. The contained item is on top of the item it is contained in, thus you
3196see the contained item. When a contained item is transparent, you can look
3197through, thus you see the item it is contained in. In a picture:
3198
3199 look from here
3200
3201 | | | | | |
3202 V V V V V V
3203
3204 xxxx yyy more contained items
3205 .................... contained item (transparent)
3206 ============================= first item
3207
3208The 'x', 'y' and '=' represent a highlighted syntax item. The '.' represent a
3209transparent group.
3210
3211What you see is:
3212
3213 =======xxxx=======yyy========
3214
3215Thus you look through the transparent "....".
3216
3217
3218oneline *:syn-oneline*
3219
3220The "oneline" argument indicates that the region does not cross a line
3221boundary. It must match completely in the current line. However, when the
3222region has a contained item that does cross a line boundary, it continues on
3223the next line anyway. A contained item can be used to recognize a line
3224continuation pattern. But the "end" pattern must still match in the first
3225line, otherwise the region doesn't even start.
3226
3227When the start pattern includes a "\n" to match an end-of-line, the end
3228pattern must be found in the same line as where the start pattern ends. The
3229end pattern may also include an end-of-line. Thus the "oneline" argument
3230means that the end of the start pattern and the start of the end pattern must
3231be within one line. This can't be changed by a skip pattern that matches a
3232line break.
3233
3234
3235fold *:syn-fold*
3236
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003237The "fold" argument makes the fold level increase by one for this item.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238Example: >
3239 :syn region myFold start="{" end="}" transparent fold
3240 :syn sync fromstart
3241 :set foldmethod=syntax
3242This will make each {} block form one fold.
3243
3244The fold will start on the line where the item starts, and end where the item
3245ends. If the start and end are within the same line, there is no fold.
3246The 'foldnestmax' option limits the nesting of syntax folds.
3247{not available when Vim was compiled without |+folding| feature}
3248
3249
3250 *:syn-contains* *E405* *E406* *E407* *E408* *E409*
3251contains={groupname},..
3252
3253The "contains" argument is followed by a list of syntax group names. These
3254groups will be allowed to begin inside the item (they may extend past the
3255containing group's end). This allows for recursive nesting of matches and
3256regions. If there is no "contains" argument, no groups will be contained in
3257this item. The group names do not need to be defined before they can be used
3258here.
3259
3260contains=ALL
3261 If the only item in the contains list is "ALL", then all
3262 groups will be accepted inside the item.
3263
3264contains=ALLBUT,{group-name},..
3265 If the first item in the contains list is "ALLBUT", then all
3266 groups will be accepted inside the item, except the ones that
3267 are listed. Example: >
3268 :syntax region Block start="{" end="}" ... contains=ALLBUT,Function
3269
3270contains=TOP
3271 If the first item in the contains list is "TOP", then all
3272 groups will be accepted that don't have the "contained"
3273 argument.
3274contains=TOP,{group-name},..
3275 Like "TOP", but excluding the groups that are listed.
3276
3277contains=CONTAINED
3278 If the first item in the contains list is "CONTAINED", then
3279 all groups will be accepted that have the "contained"
3280 argument.
3281contains=CONTAINED,{group-name},..
3282 Like "CONTAINED", but excluding the groups that are
3283 listed.
3284
3285
3286The {group-name} in the "contains" list can be a pattern. All group names
3287that match the pattern will be included (or excluded, if "ALLBUT" is used).
3288The pattern cannot contain white space or a ','. Example: >
3289 ... contains=Comment.*,Keyw[0-3]
3290The matching will be done at moment the syntax command is executed. Groups
3291that are defined later will not be matched. Also, if the current syntax
3292command defines a new group, it is not matched. Be careful: When putting
3293syntax commands in a file you can't rely on groups NOT being defined, because
3294the file may have been sourced before, and ":syn clear" doesn't remove the
3295group names.
3296
3297The contained groups will also match in the start and end patterns of a
3298region. If this is not wanted, the "matchgroup" argument can be used
3299|:syn-matchgroup|. The "ms=" and "me=" offsets can be used to change the
3300region where contained items do match. Note that this may also limit the
3301area that is highlighted
3302
3303
3304containedin={groupname}... *:syn-containedin*
3305
3306The "containedin" argument is followed by a list of syntax group names. The
3307item will be allowed to begin inside these groups. This works as if the
3308containing item has a "contains=" argument that includes this item.
3309
3310The {groupname}... can be used just like for "contains", as explained above.
3311
3312This is useful when adding a syntax item afterwards. An item can be told to
3313be included inside an already existing item, without changing the definition
3314of that item. For example, to highlight a word in a C comment after loading
3315the C syntax: >
3316 :syn keyword myword HELP containedin=cComment contained
3317Note that "contained" is also used, to avoid that the item matches at the top
3318level.
3319
3320Matches for "containedin" are added to the other places where the item can
3321appear. A "contains" argument may also be added as usual. Don't forget that
3322keywords never contain another item, thus adding them to "containedin" won't
3323work.
3324
3325
3326nextgroup={groupname},.. *:syn-nextgroup*
3327
3328The "nextgroup" argument is followed by a list of syntax group names,
3329separated by commas (just like with "contains", so you can also use patterns).
3330
3331If the "nextgroup" argument is given, the mentioned syntax groups will be
3332tried for a match, after the match or region ends. If none of the groups have
3333a match, highlighting continues normally. If there is a match, this group
3334will be used, even when it is not mentioned in the "contains" field of the
3335current group. This is like giving the mentioned group priority over all
3336other groups. Example: >
3337 :syntax match ccFoobar "Foo.\{-}Bar" contains=ccFoo
3338 :syntax match ccFoo "Foo" contained nextgroup=ccFiller
3339 :syntax region ccFiller start="." matchgroup=ccBar end="Bar" contained
3340
3341This will highlight "Foo" and "Bar" differently, and only when there is a
3342"Bar" after "Foo". In the text line below, "f" shows where ccFoo is used for
3343highlighting, and "bbb" where ccBar is used. >
3344
3345 Foo asdfasd Bar asdf Foo asdf Bar asdf
3346 fff bbb fff bbb
3347
3348Note the use of ".\{-}" to skip as little as possible until the next Bar.
3349when ".*" would be used, the "asdf" in between "Bar" and "Foo" would be
3350highlighted according to the "ccFoobar" group, because the ccFooBar match
3351would include the first "Foo" and the last "Bar" in the line (see |pattern|).
3352
3353
3354skipwhite *:syn-skipwhite*
3355skipnl *:syn-skipnl*
3356skipempty *:syn-skipempty*
3357
3358These arguments are only used in combination with "nextgroup". They can be
3359used to allow the next group to match after skipping some text:
Bram Moolenaardd2a0d82007-05-12 15:07:00 +00003360 skipwhite skip over space and tab characters
Bram Moolenaar071d4272004-06-13 20:20:40 +00003361 skipnl skip over the end of a line
3362 skipempty skip over empty lines (implies a "skipnl")
3363
3364When "skipwhite" is present, the white space is only skipped if there is no
3365next group that matches the white space.
3366
3367When "skipnl" is present, the match with nextgroup may be found in the next
3368line. This only happens when the current item ends at the end of the current
3369line! When "skipnl" is not present, the nextgroup will only be found after
3370the current item in the same line.
3371
3372When skipping text while looking for a next group, the matches for other
3373groups are ignored. Only when no next group matches, other items are tried
3374for a match again. This means that matching a next group and skipping white
3375space and <EOL>s has a higher priority than other items.
3376
3377Example: >
3378 :syn match ifstart "\<if.*" nextgroup=ifline skipwhite skipempty
3379 :syn match ifline "[^ \t].*" nextgroup=ifline skipwhite skipempty contained
3380 :syn match ifline "endif" contained
3381Note that the "[^ \t].*" match matches all non-white text. Thus it would also
3382match "endif". Therefore the "endif" match is put last, so that it takes
3383precedence.
3384Note that this example doesn't work for nested "if"s. You need to add
3385"contains" arguments to make that work (omitted for simplicity of the
3386example).
3387
3388==============================================================================
33897. Syntax patterns *:syn-pattern* *E401* *E402*
3390
3391In the syntax commands, a pattern must be surrounded by two identical
3392characters. This is like it works for the ":s" command. The most common to
3393use is the double quote. But if the pattern contains a double quote, you can
3394use another character that is not used in the pattern. Examples: >
3395 :syntax region Comment start="/\*" end="\*/"
3396 :syntax region String start=+"+ end=+"+ skip=+\\"+
3397
3398See |pattern| for the explanation of what a pattern is. Syntax patterns are
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003399always interpreted like the 'magic' option is set, no matter what the actual
Bram Moolenaar071d4272004-06-13 20:20:40 +00003400value of 'magic' is. And the patterns are interpreted like the 'l' flag is
3401not included in 'cpoptions'. This was done to make syntax files portable and
3402independent of 'compatible' and 'magic' settings.
3403
3404Try to avoid patterns that can match an empty string, such as "[a-z]*".
3405This slows down the highlighting a lot, because it matches everywhere.
3406
3407 *:syn-pattern-offset*
3408The pattern can be followed by a character offset. This can be used to
3409change the highlighted part, and to change the text area included in the
3410match or region (which only matters when trying to match other items). Both
3411are relative to the matched pattern. The character offset for a skip
3412pattern can be used to tell where to continue looking for an end pattern.
3413
3414The offset takes the form of "{what}={offset}"
3415The {what} can be one of seven strings:
3416
3417ms Match Start offset for the start of the matched text
3418me Match End offset for the end of the matched text
3419hs Highlight Start offset for where the highlighting starts
3420he Highlight End offset for where the highlighting ends
3421rs Region Start offset for where the body of a region starts
3422re Region End offset for where the body of a region ends
3423lc Leading Context offset past "leading context" of pattern
3424
3425The {offset} can be:
3426
3427s start of the matched pattern
3428s+{nr} start of the matched pattern plus {nr} chars to the right
3429s-{nr} start of the matched pattern plus {nr} chars to the left
3430e end of the matched pattern
3431e+{nr} end of the matched pattern plus {nr} chars to the right
3432e-{nr} end of the matched pattern plus {nr} chars to the left
3433{nr} (for "lc" only): start matching {nr} chars to the left
3434
3435Examples: "ms=s+1", "hs=e-2", "lc=3".
3436
3437Although all offsets are accepted after any pattern, they are not always
3438meaningful. This table shows which offsets are actually used:
3439
3440 ms me hs he rs re lc ~
3441match item yes yes yes yes - - yes
3442region item start yes - yes - yes - yes
3443region item skip - yes - - - - yes
3444region item end - yes - yes - yes yes
3445
3446Offsets can be concatenated, with a ',' in between. Example: >
3447 :syn match String /"[^"]*"/hs=s+1,he=e-1
3448<
3449 some "string" text
3450 ^^^^^^ highlighted
3451
3452Notes:
3453- There must be no white space between the pattern and the character
3454 offset(s).
3455- The highlighted area will never be outside of the matched text.
3456- A negative offset for an end pattern may not always work, because the end
3457 pattern may be detected when the highlighting should already have stopped.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003458- Before Vim 7.2 the offsets were counted in bytes instead of characters.
3459 This didn't work well for multi-byte characters, so it was changed with the
3460 Vim 7.2 release.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003461- The start of a match cannot be in a line other than where the pattern
3462 matched. This doesn't work: "a\nb"ms=e. You can make the highlighting
3463 start in another line, this does work: "a\nb"hs=e.
3464
3465Example (match a comment but don't highlight the /* and */): >
3466 :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1
3467<
3468 /* this is a comment */
3469 ^^^^^^^^^^^^^^^^^^^ highlighted
3470
3471A more complicated Example: >
3472 :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
3473<
3474 abcfoostringbarabc
3475 mmmmmmmmmmm match
Bram Moolenaar4770d092006-01-12 23:22:24 +00003476 sssrrreee highlight start/region/end ("Foo", "Exa" and "Bar")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003477
3478Leading context *:syn-lc* *:syn-leading* *:syn-context*
3479
3480Note: This is an obsolete feature, only included for backwards compatibility
3481with previous Vim versions. It's now recommended to use the |/\@<=| construct
3482in the pattern.
3483
3484The "lc" offset specifies leading context -- a part of the pattern that must
3485be present, but is not considered part of the match. An offset of "lc=n" will
3486cause Vim to step back n columns before attempting the pattern match, allowing
3487characters which have already been matched in previous patterns to also be
3488used as leading context for this match. This can be used, for instance, to
3489specify that an "escaping" character must not precede the match: >
3490
3491 :syn match ZNoBackslash "[^\\]z"ms=s+1
3492 :syn match WNoBackslash "[^\\]w"lc=1
3493 :syn match Underline "_\+"
3494<
3495 ___zzzz ___wwww
3496 ^^^ ^^^ matches Underline
3497 ^ ^ matches ZNoBackslash
3498 ^^^^ matches WNoBackslash
3499
3500The "ms" offset is automatically set to the same value as the "lc" offset,
3501unless you set "ms" explicitly.
3502
3503
3504Multi-line patterns *:syn-multi-line*
3505
3506The patterns can include "\n" to match an end-of-line. Mostly this works as
3507expected, but there are a few exceptions.
3508
3509When using a start pattern with an offset, the start of the match is not
3510allowed to start in a following line. The highlighting can start in a
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003511following line though. Using the "\zs" item also requires that the start of
3512the match doesn't move to another line.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003513
3514The skip pattern can include the "\n", but the search for an end pattern will
3515continue in the first character of the next line, also when that character is
3516matched by the skip pattern. This is because redrawing may start in any line
3517halfway a region and there is no check if the skip pattern started in a
3518previous line. For example, if the skip pattern is "a\nb" and an end pattern
3519is "b", the end pattern does match in the second line of this: >
3520 x x a
3521 b x x
3522Generally this means that the skip pattern should not match any characters
3523after the "\n".
3524
3525
3526External matches *:syn-ext-match*
3527
3528These extra regular expression items are available in region patterns:
3529
3530 */\z(* */\z(\)* *E50* *E52*
3531 \z(\) Marks the sub-expression as "external", meaning that it is can
3532 be accessed from another pattern match. Currently only usable
3533 in defining a syntax region start pattern.
3534
3535 */\z1* */\z2* */\z3* */\z4* */\z5*
3536 \z1 ... \z9 */\z6* */\z7* */\z8* */\z9* *E66* *E67*
3537 Matches the same string that was matched by the corresponding
3538 sub-expression in a previous start pattern match.
3539
3540Sometimes the start and end patterns of a region need to share a common
3541sub-expression. A common example is the "here" document in Perl and many Unix
3542shells. This effect can be achieved with the "\z" special regular expression
3543items, which marks a sub-expression as "external", in the sense that it can be
3544referenced from outside the pattern in which it is defined. The here-document
3545example, for instance, can be done like this: >
3546 :syn region hereDoc start="<<\z(\I\i*\)" end="^\z1$"
3547
3548As can be seen here, the \z actually does double duty. In the start pattern,
3549it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it
3550changes the \1 back-reference into an external reference referring to the
3551first external sub-expression in the start pattern. External references can
3552also be used in skip patterns: >
3553 :syn region foo start="start \(\I\i*\)" skip="not end \z1" end="end \z1"
3554
3555Note that normal and external sub-expressions are completely orthogonal and
3556indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied
3557to the string "aabb", then \1 will refer to "bb" and \z1 will refer to "aa".
3558Note also that external sub-expressions cannot be accessed as back-references
3559within the same pattern like normal sub-expressions. If you want to use one
3560sub-expression as both a normal and an external sub-expression, you can nest
3561the two, as in "\(\z(...\)\)".
3562
3563Note that only matches within a single line can be used. Multi-line matches
3564cannot be referred to.
3565
3566==============================================================================
35678. Syntax clusters *:syn-cluster* *E400*
3568
3569:sy[ntax] cluster {cluster-name} [contains={group-name}..]
3570 [add={group-name}..]
3571 [remove={group-name}..]
3572
3573This command allows you to cluster a list of syntax groups together under a
3574single name.
3575
3576 contains={group-name}..
3577 The cluster is set to the specified list of groups.
3578 add={group-name}..
3579 The specified groups are added to the cluster.
3580 remove={group-name}..
3581 The specified groups are removed from the cluster.
3582
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003583A cluster so defined may be referred to in a contains=.., containedin=..,
3584nextgroup=.., add=.. or remove=.. list with a "@" prefix. You can also use
3585this notation to implicitly declare a cluster before specifying its contents.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003586
3587Example: >
3588 :syntax match Thing "# [^#]\+ #" contains=@ThingMembers
3589 :syntax cluster ThingMembers contains=ThingMember1,ThingMember2
3590
3591As the previous example suggests, modifications to a cluster are effectively
3592retroactive; the membership of the cluster is checked at the last minute, so
3593to speak: >
3594 :syntax keyword A aaa
3595 :syntax keyword B bbb
3596 :syntax cluster AandB contains=A
3597 :syntax match Stuff "( aaa bbb )" contains=@AandB
3598 :syntax cluster AandB add=B " now both keywords are matched in Stuff
3599
3600This also has implications for nested clusters: >
3601 :syntax keyword A aaa
3602 :syntax keyword B bbb
3603 :syntax cluster SmallGroup contains=B
3604 :syntax cluster BigGroup contains=A,@SmallGroup
3605 :syntax match Stuff "( aaa bbb )" contains=@BigGroup
3606 :syntax cluster BigGroup remove=B " no effect, since B isn't in BigGroup
3607 :syntax cluster SmallGroup remove=B " now bbb isn't matched within Stuff
3608
3609==============================================================================
36109. Including syntax files *:syn-include* *E397*
3611
3612It is often useful for one language's syntax file to include a syntax file for
3613a related language. Depending on the exact relationship, this can be done in
3614two different ways:
3615
3616 - If top-level syntax items in the included syntax file are to be
3617 allowed at the top level in the including syntax, you can simply use
3618 the |:runtime| command: >
3619
3620 " In cpp.vim:
3621 :runtime! syntax/c.vim
3622 :unlet b:current_syntax
3623
3624< - If top-level syntax items in the included syntax file are to be
3625 contained within a region in the including syntax, you can use the
3626 ":syntax include" command:
3627
3628:sy[ntax] include [@{grouplist-name}] {file-name}
3629
3630 All syntax items declared in the included file will have the
3631 "contained" flag added. In addition, if a group list is specified,
3632 all top-level syntax items in the included file will be added to
3633 that list. >
3634
3635 " In perl.vim:
3636 :syntax include @Pod <sfile>:p:h/pod.vim
3637 :syntax region perlPOD start="^=head" end="^=cut" contains=@Pod
3638<
3639 When {file-name} is an absolute path (starts with "/", "c:", "$VAR"
3640 or "<sfile>") that file is sourced. When it is a relative path
3641 (e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'.
3642 All matching files are loaded. Using a relative path is
3643 recommended, because it allows a user to replace the included file
3644 with his own version, without replacing the file that does the ":syn
3645 include".
3646
3647==============================================================================
364810. Synchronizing *:syn-sync* *E403* *E404*
3649
3650Vim wants to be able to start redrawing in any position in the document. To
3651make this possible it needs to know the syntax state at the position where
3652redrawing starts.
3653
3654:sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
3655
3656There are four ways to synchronize:
36571. Always parse from the start of the file.
3658 |:syn-sync-first|
36592. Based on C-style comments. Vim understands how C-comments work and can
3660 figure out if the current line starts inside or outside a comment.
3661 |:syn-sync-second|
36623. Jumping back a certain number of lines and start parsing there.
3663 |:syn-sync-third|
36644. Searching backwards in the text for a pattern to sync on.
3665 |:syn-sync-fourth|
3666
3667 *:syn-sync-maxlines* *:syn-sync-minlines*
3668For the last three methods, the line range where the parsing can start is
3669limited by "minlines" and "maxlines".
3670
3671If the "minlines={N}" argument is given, the parsing always starts at least
3672that many lines backwards. This can be used if the parsing may take a few
3673lines before it's correct, or when it's not possible to use syncing.
3674
3675If the "maxlines={N}" argument is given, the number of lines that are searched
3676for a comment or syncing pattern is restricted to N lines backwards (after
3677adding "minlines"). This is useful if you have few things to sync on and a
3678slow machine. Example: >
3679 :syntax sync ccomment maxlines=500
3680<
3681 *:syn-sync-linebreaks*
3682When using a pattern that matches multiple lines, a change in one line may
3683cause a pattern to no longer match in a previous line. This means has to
3684start above where the change was made. How many lines can be specified with
3685the "linebreaks" argument. For example, when a pattern may include one line
3686break use this: >
3687 :syntax sync linebreaks=1
3688The result is that redrawing always starts at least one line before where a
3689change was made. The default value for "linebreaks" is zero. Usually the
3690value for "minlines" is bigger than "linebreaks".
3691
3692
3693First syncing method: *:syn-sync-first*
3694>
3695 :syntax sync fromstart
3696
3697The file will be parsed from the start. This makes syntax highlighting
3698accurate, but can be slow for long files. Vim caches previously parsed text,
3699so that it's only slow when parsing the text for the first time. However,
3700when making changes some part of the next needs to be parsed again (worst
3701case: to the end of the file).
3702
3703Using "fromstart" is equivalent to using "minlines" with a very large number.
3704
3705
3706Second syncing method: *:syn-sync-second* *:syn-sync-ccomment*
3707
3708For the second method, only the "ccomment" argument needs to be given.
3709Example: >
3710 :syntax sync ccomment
3711
3712When Vim finds that the line where displaying starts is inside a C-style
3713comment, the last region syntax item with the group-name "Comment" will be
3714used. This requires that there is a region with the group-name "Comment"!
3715An alternate group name can be specified, for example: >
3716 :syntax sync ccomment javaComment
3717This means that the last item specified with "syn region javaComment" will be
3718used for the detected C comment region. This only works properly if that
3719region does have a start pattern "\/*" and an end pattern "*\/".
3720
3721The "maxlines" argument can be used to restrict the search to a number of
3722lines. The "minlines" argument can be used to at least start a number of
3723lines back (e.g., for when there is some construct that only takes a few
3724lines, but it hard to sync on).
3725
3726Note: Syncing on a C comment doesn't work properly when strings are used
3727that cross a line and contain a "*/". Since letting strings cross a line
3728is a bad programming habit (many compilers give a warning message), and the
3729chance of a "*/" appearing inside a comment is very small, this restriction
3730is hardly ever noticed.
3731
3732
3733Third syncing method: *:syn-sync-third*
3734
3735For the third method, only the "minlines={N}" argument needs to be given.
3736Vim will subtract {N} from the line number and start parsing there. This
3737means {N} extra lines need to be parsed, which makes this method a bit slower.
3738Example: >
3739 :syntax sync minlines=50
3740
3741"lines" is equivalent to "minlines" (used by older versions).
3742
3743
3744Fourth syncing method: *:syn-sync-fourth*
3745
3746The idea is to synchronize on the end of a few specific regions, called a
3747sync pattern. Only regions can cross lines, so when we find the end of some
3748region, we might be able to know in which syntax item we are. The search
3749starts in the line just above the one where redrawing starts. From there
3750the search continues backwards in the file.
3751
3752This works just like the non-syncing syntax items. You can use contained
3753matches, nextgroup, etc. But there are a few differences:
3754- Keywords cannot be used.
3755- The syntax items with the "sync" keyword form a completely separated group
3756 of syntax items. You can't mix syncing groups and non-syncing groups.
3757- The matching works backwards in the buffer (line by line), instead of
3758 forwards.
3759- A line continuation pattern can be given. It is used to decide which group
3760 of lines need to be searched like they were one line. This means that the
3761 search for a match with the specified items starts in the first of the
3762 consecutive that contain the continuation pattern.
3763- When using "nextgroup" or "contains", this only works within one line (or
3764 group of continued lines).
3765- When using a region, it must start and end in the same line (or group of
3766 continued lines). Otherwise the end is assumed to be at the end of the
3767 line (or group of continued lines).
3768- When a match with a sync pattern is found, the rest of the line (or group of
3769 continued lines) is searched for another match. The last match is used.
3770 This is used when a line can contain both the start end the end of a region
3771 (e.g., in a C-comment like /* this */, the last "*/" is used).
3772
3773There are two ways how a match with a sync pattern can be used:
37741. Parsing for highlighting starts where redrawing starts (and where the
3775 search for the sync pattern started). The syntax group that is expected
3776 to be valid there must be specified. This works well when the regions
3777 that cross lines cannot contain other regions.
37782. Parsing for highlighting continues just after the match. The syntax group
3779 that is expected to be present just after the match must be specified.
3780 This can be used when the previous method doesn't work well. It's much
3781 slower, because more text needs to be parsed.
3782Both types of sync patterns can be used at the same time.
3783
3784Besides the sync patterns, other matches and regions can be specified, to
3785avoid finding unwanted matches.
3786
3787[The reason that the sync patterns are given separately, is that mostly the
3788search for the sync point can be much simpler than figuring out the
3789highlighting. The reduced number of patterns means it will go (much)
3790faster.]
3791
3792 *syn-sync-grouphere* *E393* *E394*
3793 :syntax sync match {sync-group-name} grouphere {group-name} "pattern" ..
3794
3795 Define a match that is used for syncing. {group-name} is the
3796 name of a syntax group that follows just after the match. Parsing
3797 of the text for highlighting starts just after the match. A region
3798 must exist for this {group-name}. The first one defined will be used.
3799 "NONE" can be used for when there is no syntax group after the match.
3800
3801 *syn-sync-groupthere*
3802 :syntax sync match {sync-group-name} groupthere {group-name} "pattern" ..
3803
3804 Like "grouphere", but {group-name} is the name of a syntax group that
3805 is to be used at the start of the line where searching for the sync
3806 point started. The text between the match and the start of the sync
3807 pattern searching is assumed not to change the syntax highlighting.
3808 For example, in C you could search backwards for "/*" and "*/". If
3809 "/*" is found first, you know that you are inside a comment, so the
3810 "groupthere" is "cComment". If "*/" is found first, you know that you
3811 are not in a comment, so the "groupthere" is "NONE". (in practice
3812 it's a bit more complicated, because the "/*" and "*/" could appear
3813 inside a string. That's left as an exercise to the reader...).
3814
3815 :syntax sync match ..
3816 :syntax sync region ..
3817
3818 Without a "groupthere" argument. Define a region or match that is
3819 skipped while searching for a sync point.
3820
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00003821 *syn-sync-linecont*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003822 :syntax sync linecont {pattern}
3823
3824 When {pattern} matches in a line, it is considered to continue in
3825 the next line. This means that the search for a sync point will
3826 consider the lines to be concatenated.
3827
3828If the "maxlines={N}" argument is given too, the number of lines that are
3829searched for a match is restricted to N. This is useful if you have very
3830few things to sync on and a slow machine. Example: >
3831 :syntax sync maxlines=100
3832
3833You can clear all sync settings with: >
3834 :syntax sync clear
3835
3836You can clear specific sync patterns with: >
3837 :syntax sync clear {sync-group-name} ..
3838
3839==============================================================================
384011. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
3841
Bram Moolenaar482aaeb2005-09-29 18:26:07 +00003842This command lists all the syntax items: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00003843
3844 :sy[ntax] [list]
3845
3846To show the syntax items for one syntax group: >
3847
3848 :sy[ntax] list {group-name}
3849
3850To list the syntax groups in one cluster: *E392* >
3851
3852 :sy[ntax] list @{cluster-name}
3853
3854See above for other arguments for the ":syntax" command.
3855
3856Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
3857is mostly used, because it looks better.
3858
3859==============================================================================
386012. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
3861
3862There are three types of highlight groups:
3863- The ones used for specific languages. For these the name starts with the
3864 name of the language. Many of these don't have any attributes, but are
3865 linked to a group of the second type.
3866- The ones used for all syntax languages.
3867- The ones used for the 'highlight' option.
3868 *hitest.vim*
3869You can see all the groups currently active with this command: >
3870 :so $VIMRUNTIME/syntax/hitest.vim
3871This will open a new window containing all highlight group names, displayed
3872in their own color.
3873
3874 *:colo* *:colorscheme* *E185*
Bram Moolenaar00a927d2010-05-14 23:24:24 +02003875:colo[rscheme] Output the name of the currently active color scheme.
3876 This is basically the same as >
3877 :echo g:colors_name
3878< In case g:colors_name has not been defined :colo will
3879 output "default". When compiled without the |+eval|
3880 feature it will output "unknown".
3881
Bram Moolenaar071d4272004-06-13 20:20:40 +00003882:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
3883 for the file "colors/{name}.vim. The first one that
3884 is found is loaded.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003885 To see the name of the currently active color scheme: >
Bram Moolenaar00a927d2010-05-14 23:24:24 +02003886 :colo
3887< The name is also stored in the g:colors_name variable.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003888 Doesn't work recursively, thus you can't use
Bram Moolenaar071d4272004-06-13 20:20:40 +00003889 ":colorscheme" in a color scheme script.
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00003890 After the color scheme has been loaded the
3891 |ColorScheme| autocommand event is triggered.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00003892 For info about writing a colorscheme file: >
3893 :edit $VIMRUNTIME/colors/README.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +00003894
3895:hi[ghlight] List all the current highlight groups that have
3896 attributes set.
3897
3898:hi[ghlight] {group-name}
3899 List one highlight group.
3900
3901:hi[ghlight] clear Reset all highlighting to the defaults. Removes all
3902 highlighting for groups added by the user!
3903 Uses the current value of 'background' to decide which
3904 default colors to use.
3905
3906:hi[ghlight] clear {group-name}
3907:hi[ghlight] {group-name} NONE
3908 Disable the highlighting for one highlight group. It
3909 is _not_ set back to the default colors.
3910
3911:hi[ghlight] [default] {group-name} {key}={arg} ..
3912 Add a highlight group, or change the highlighting for
3913 an existing group.
3914 See |highlight-args| for the {key}={arg} arguments.
3915 See |:highlight-default| for the optional [default]
3916 argument.
3917
3918Normally a highlight group is added once when starting up. This sets the
3919default values for the highlighting. After that, you can use additional
3920highlight commands to change the arguments that you want to set to non-default
3921values. The value "NONE" can be used to switch the value off or go back to
3922the default value.
3923
3924A simple way to change colors is with the |:colorscheme| command. This loads
3925a file with ":highlight" commands such as this: >
3926
3927 :hi Comment gui=bold
3928
3929Note that all settings that are not included remain the same, only the
3930specified field is used, and settings are merged with previous ones. So, the
3931result is like this single command has been used: >
3932 :hi Comment term=bold ctermfg=Cyan guifg=#80a0ff gui=bold
3933<
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00003934 *:highlight-verbose*
Bram Moolenaar661b1822005-07-28 22:36:45 +00003935When listing a highlight group and 'verbose' is non-zero, the listing will
3936also tell where it was last set. Example: >
3937 :verbose hi Comment
3938< Comment xxx term=bold ctermfg=4 guifg=Blue ~
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00003939 Last set from /home/mool/vim/vim7/runtime/syntax/syncolor.vim ~
Bram Moolenaar661b1822005-07-28 22:36:45 +00003940
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00003941When ":hi clear" is used then the script where this command is used will be
3942mentioned for the default values. See |:verbose-cmd| for more information.
Bram Moolenaar661b1822005-07-28 22:36:45 +00003943
Bram Moolenaar071d4272004-06-13 20:20:40 +00003944 *highlight-args* *E416* *E417* *E423*
3945There are three types of terminals for highlighting:
3946term a normal terminal (vt100, xterm)
3947cterm a color terminal (MS-DOS console, color-xterm, these have the "Co"
3948 termcap entry)
3949gui the GUI
3950
3951For each type the highlighting can be given. This makes it possible to use
3952the same syntax file on all terminals, and use the optimal highlighting.
3953
39541. highlight arguments for normal terminals
3955
Bram Moolenaar75c50c42005-06-04 22:06:24 +00003956 *bold* *underline* *undercurl*
3957 *inverse* *italic* *standout*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003958term={attr-list} *attr-list* *highlight-term* *E418*
3959 attr-list is a comma separated list (without spaces) of the
3960 following items (in any order):
3961 bold
3962 underline
Bram Moolenaar5409c052005-03-18 20:27:04 +00003963 undercurl not always available
Bram Moolenaar071d4272004-06-13 20:20:40 +00003964 reverse
3965 inverse same as reverse
3966 italic
3967 standout
3968 NONE no attributes used (used to reset it)
3969
3970 Note that "bold" can be used here and by using a bold font. They
3971 have the same effect.
Bram Moolenaar5409c052005-03-18 20:27:04 +00003972 "undercurl" is a curly underline. When "undercurl" is not possible
3973 then "underline" is used. In general "undercurl" is only available in
Bram Moolenaar910f66f2006-04-05 20:41:53 +00003974 the GUI. The color is set with |highlight-guisp|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003975
3976start={term-list} *highlight-start* *E422*
3977stop={term-list} *term-list* *highlight-stop*
3978 These lists of terminal codes can be used to get
3979 non-standard attributes on a terminal.
3980
3981 The escape sequence specified with the "start" argument
3982 is written before the characters in the highlighted
3983 area. It can be anything that you want to send to the
3984 terminal to highlight this area. The escape sequence
3985 specified with the "stop" argument is written after the
3986 highlighted area. This should undo the "start" argument.
3987 Otherwise the screen will look messed up.
3988
3989 The {term-list} can have two forms:
3990
3991 1. A string with escape sequences.
3992 This is any string of characters, except that it can't start with
3993 "t_" and blanks are not allowed. The <> notation is recognized
3994 here, so you can use things like "<Esc>" and "<Space>". Example:
3995 start=<Esc>[27h;<Esc>[<Space>r;
3996
3997 2. A list of terminal codes.
3998 Each terminal code has the form "t_xx", where "xx" is the name of
3999 the termcap entry. The codes have to be separated with commas.
4000 White space is not allowed. Example:
4001 start=t_C1,t_BL
4002 The terminal codes must exist for this to work.
4003
4004
40052. highlight arguments for color terminals
4006
4007cterm={attr-list} *highlight-cterm*
4008 See above for the description of {attr-list} |attr-list|.
4009 The "cterm" argument is likely to be different from "term", when
4010 colors are used. For example, in a normal terminal comments could
4011 be underlined, in a color terminal they can be made Blue.
4012 Note: Many terminals (e.g., DOS console) can't mix these attributes
4013 with coloring. Use only one of "cterm=" OR "ctermfg=" OR "ctermbg=".
4014
4015ctermfg={color-nr} *highlight-ctermfg* *E421*
4016ctermbg={color-nr} *highlight-ctermbg*
4017 The {color-nr} argument is a color number. Its range is zero to
4018 (not including) the number given by the termcap entry "Co".
4019 The actual color with this number depends on the type of terminal
4020 and its settings. Sometimes the color also depends on the settings of
4021 "cterm". For example, on some systems "cterm=bold ctermfg=3" gives
4022 another color, on others you just get color 3.
4023
4024 For an xterm this depends on your resources, and is a bit
4025 unpredictable. See your xterm documentation for the defaults. The
4026 colors for a color-xterm can be changed from the .Xdefaults file.
4027 Unfortunately this means that it's not possible to get the same colors
4028 for each user. See |xterm-color| for info about color xterms.
4029
4030 The MSDOS standard colors are fixed (in a console window), so these
4031 have been used for the names. But the meaning of color names in X11
4032 are fixed, so these color settings have been used, to make the
4033 highlighting settings portable (complicated, isn't it?). The
4034 following names are recognized, with the color number used:
4035
4036 *cterm-colors*
4037 NR-16 NR-8 COLOR NAME ~
4038 0 0 Black
4039 1 4 DarkBlue
4040 2 2 DarkGreen
4041 3 6 DarkCyan
4042 4 1 DarkRed
4043 5 5 DarkMagenta
4044 6 3 Brown, DarkYellow
4045 7 7 LightGray, LightGrey, Gray, Grey
4046 8 0* DarkGray, DarkGrey
4047 9 4* Blue, LightBlue
4048 10 2* Green, LightGreen
4049 11 6* Cyan, LightCyan
4050 12 1* Red, LightRed
4051 13 5* Magenta, LightMagenta
4052 14 3* Yellow, LightYellow
4053 15 7* White
4054
4055 The number under "NR-16" is used for 16-color terminals ('t_Co'
4056 greater than or equal to 16). The number under "NR-8" is used for
4057 8-color terminals ('t_Co' less than 16). The '*' indicates that the
4058 bold attribute is set for ctermfg. In many 8-color terminals (e.g.,
4059 "linux"), this causes the bright colors to appear. This doesn't work
4060 for background colors! Without the '*' the bold attribute is removed.
4061 If you want to set the bold attribute in a different way, put a
4062 "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument. Or use
4063 a number instead of a color name.
4064
4065 The case of the color names is ignored.
4066 Note that for 16 color ansi style terminals (including xterms), the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004067 numbers in the NR-8 column is used. Here '*' means 'add 8' so that Blue
Bram Moolenaar071d4272004-06-13 20:20:40 +00004068 is 12, DarkGray is 8 etc.
4069
4070 Note that for some color terminals these names may result in the wrong
4071 colors!
4072
4073 *:hi-normal-cterm*
4074 When setting the "ctermfg" or "ctermbg" colors for the Normal group,
4075 these will become the colors used for the non-highlighted text.
4076 Example: >
4077 :highlight Normal ctermfg=grey ctermbg=darkblue
4078< When setting the "ctermbg" color for the Normal group, the
4079 'background' option will be adjusted automatically. This causes the
4080 highlight groups that depend on 'background' to change! This means
4081 you should set the colors for Normal first, before setting other
4082 colors.
4083 When a colorscheme is being used, changing 'background' causes it to
4084 be reloaded, which may reset all colors (including Normal). First
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01004085 delete the "g:colors_name" variable when you don't want this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004086
4087 When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
4088 needs to reset the color when exiting. This is done with the "op"
4089 termcap entry |t_op|. If this doesn't work correctly, try setting the
4090 't_op' option in your .vimrc.
4091 *E419* *E420*
4092 When Vim knows the normal foreground and background colors, "fg" and
4093 "bg" can be used as color names. This only works after setting the
4094 colors for the Normal group and for the MS-DOS console. Example, for
4095 reverse video: >
4096 :highlight Visual ctermfg=bg ctermbg=fg
4097< Note that the colors are used that are valid at the moment this
4098 command are given. If the Normal group colors are changed later, the
4099 "fg" and "bg" colors will not be adjusted.
4100
4101
41023. highlight arguments for the GUI
4103
4104gui={attr-list} *highlight-gui*
4105 These give the attributes to use in the GUI mode.
4106 See |attr-list| for a description.
4107 Note that "bold" can be used here and by using a bold font. They
4108 have the same effect.
4109 Note that the attributes are ignored for the "Normal" group.
4110
4111font={font-name} *highlight-font*
4112 font-name is the name of a font, as it is used on the system Vim
4113 runs on. For X11 this is a complicated name, for example: >
4114 font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
4115<
4116 The font-name "NONE" can be used to revert to the default font.
4117 When setting the font for the "Normal" group, this becomes the default
4118 font (until the 'guifont' option is changed; the last one set is
4119 used).
4120 The following only works with Motif and Athena, not with other GUIs:
4121 When setting the font for the "Menu" group, the menus will be changed.
4122 When setting the font for the "Tooltip" group, the tooltips will be
4123 changed.
4124 All fonts used, except for Menu and Tooltip, should be of the same
4125 character size as the default font! Otherwise redrawing problems will
4126 occur.
4127
4128guifg={color-name} *highlight-guifg*
4129guibg={color-name} *highlight-guibg*
Bram Moolenaar5409c052005-03-18 20:27:04 +00004130guisp={color-name} *highlight-guisp*
4131 These give the foreground (guifg), background (guibg) and special
Bram Moolenaar7df351e2006-01-23 22:30:28 +00004132 (guisp) color to use in the GUI. "guisp" is used for undercurl.
4133 There are a few special names:
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 NONE no color (transparent)
4135 bg use normal background color
4136 background use normal background color
4137 fg use normal foreground color
4138 foreground use normal foreground color
4139 To use a color name with an embedded space or other special character,
4140 put it in single quotes. The single quote cannot be used then.
4141 Example: >
4142 :hi comment guifg='salmon pink'
4143<
4144 *gui-colors*
4145 Suggested color names (these are available on most systems):
4146 Red LightRed DarkRed
4147 Green LightGreen DarkGreen SeaGreen
4148 Blue LightBlue DarkBlue SlateBlue
4149 Cyan LightCyan DarkCyan
4150 Magenta LightMagenta DarkMagenta
4151 Yellow LightYellow Brown DarkYellow
4152 Gray LightGray DarkGray
4153 Black White
4154 Orange Purple Violet
4155
4156 In the Win32 GUI version, additional system colors are available. See
4157 |win32-colors|.
4158
4159 You can also specify a color by its Red, Green and Blue values.
4160 The format is "#rrggbb", where
4161 "rr" is the Red value
Bram Moolenaar071d4272004-06-13 20:20:40 +00004162 "gg" is the Green value
Bram Moolenaar5409c052005-03-18 20:27:04 +00004163 "bb" is the Blue value
Bram Moolenaar071d4272004-06-13 20:20:40 +00004164 All values are hexadecimal, range from "00" to "ff". Examples: >
4165 :highlight Comment guifg=#11f0c3 guibg=#ff00ff
4166<
4167 *highlight-groups* *highlight-default*
4168These are the default highlighting groups. These groups are used by the
4169'highlight' option default. Note that the highlighting depends on the value
4170of 'background'. You can see the current settings with the ":highlight"
4171command.
4172 *hl-Cursor*
4173Cursor the character under the cursor
4174 *hl-CursorIM*
4175CursorIM like Cursor, but used when in IME mode |CursorIM|
Bram Moolenaar5316eee2006-03-12 22:11:10 +00004176 *hl-CursorColumn*
4177CursorColumn the screen column that the cursor is in when 'cursorcolumn' is
4178 set
4179 *hl-CursorLine*
4180CursorLine the screen line that the cursor is in when 'cursorline' is
4181 set
Bram Moolenaar071d4272004-06-13 20:20:40 +00004182 *hl-Directory*
4183Directory directory names (and other special names in listings)
4184 *hl-DiffAdd*
4185DiffAdd diff mode: Added line |diff.txt|
4186 *hl-DiffChange*
4187DiffChange diff mode: Changed line |diff.txt|
4188 *hl-DiffDelete*
4189DiffDelete diff mode: Deleted line |diff.txt|
4190 *hl-DiffText*
4191DiffText diff mode: Changed text within a changed line |diff.txt|
4192 *hl-ErrorMsg*
4193ErrorMsg error messages on the command line
4194 *hl-VertSplit*
4195VertSplit the column separating vertically split windows
4196 *hl-Folded*
4197Folded line used for closed folds
4198 *hl-FoldColumn*
4199FoldColumn 'foldcolumn'
4200 *hl-SignColumn*
4201SignColumn column where |signs| are displayed
4202 *hl-IncSearch*
4203IncSearch 'incsearch' highlighting; also used for the text replaced with
4204 ":s///c"
4205 *hl-LineNr*
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00004206LineNr Line number for ":number" and ":#" commands, and when 'number'
Bram Moolenaar64486672010-05-16 15:46:46 +02004207 or 'relativenumber' option is set.
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00004208 *hl-MatchParen*
4209MatchParen The character under the cursor or just before it, if it
4210 is a paired bracket, and its match. |pi_paren.txt|
4211
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 *hl-ModeMsg*
4213ModeMsg 'showmode' message (e.g., "-- INSERT --")
4214 *hl-MoreMsg*
4215MoreMsg |more-prompt|
4216 *hl-NonText*
4217NonText '~' and '@' at the end of the window, characters from
4218 'showbreak' and other characters that do not really exist in
4219 the text (e.g., ">" displayed when a double-wide character
4220 doesn't fit at the end of the line).
4221 *hl-Normal*
4222Normal normal text
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00004223 *hl-Pmenu*
4224Pmenu Popup menu: normal item.
4225 *hl-PmenuSel*
4226PmenuSel Popup menu: selected item.
4227 *hl-PmenuSbar*
4228PmenuSbar Popup menu: scrollbar.
4229 *hl-PmenuThumb*
4230PmenuThumb Popup menu: Thumb of the scrollbar.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004231 *hl-Question*
4232Question |hit-enter| prompt and yes/no questions
4233 *hl-Search*
4234Search Last search pattern highlighting (see 'hlsearch').
4235 Also used for highlighting the current line in the quickfix
4236 window and similar items that need to stand out.
4237 *hl-SpecialKey*
4238SpecialKey Meta and special keys listed with ":map", also for text used
4239 to show unprintable characters in the text, 'listchars'.
4240 Generally: text that is displayed differently from what it
4241 really is.
Bram Moolenaar217ad922005-03-20 22:37:15 +00004242 *hl-SpellBad*
4243SpellBad Word that is not recognized by the spellchecker. |spell|
4244 This will be combined with the highlighting used otherwise.
Bram Moolenaar53180ce2005-07-05 21:48:14 +00004245 *hl-SpellCap*
4246SpellCap Word that should start with a capital. |spell|
4247 This will be combined with the highlighting used otherwise.
Bram Moolenaar217ad922005-03-20 22:37:15 +00004248 *hl-SpellLocal*
4249SpellLocal Word that is recognized by the spellchecker as one that is
4250 used in another region. |spell|
4251 This will be combined with the highlighting used otherwise.
4252 *hl-SpellRare*
4253SpellRare Word that is recognized by the spellchecker as one that is
4254 hardly ever used. |spell|
4255 This will be combined with the highlighting used otherwise.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004256 *hl-StatusLine*
4257StatusLine status line of current window
4258 *hl-StatusLineNC*
4259StatusLineNC status lines of not-current windows
4260 Note: if this is equal to "StatusLine" Vim will use "^^^" in
4261 the status line of the current window.
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004262 *hl-TabLine*
4263TabLine tab pages line, not active tab page label
4264 *hl-TabLineFill*
4265TabLineFill tab pages line, where there are no labels
4266 *hl-TabLineSel*
4267TabLineSel tab pages line, active tab page label
Bram Moolenaar071d4272004-06-13 20:20:40 +00004268 *hl-Title*
4269Title titles for output from ":set all", ":autocmd" etc.
4270 *hl-Visual*
4271Visual Visual mode selection
4272 *hl-VisualNOS*
4273VisualNOS Visual mode selection when vim is "Not Owning the Selection".
4274 Only X11 Gui's |gui-x11| and |xterm-clipboard| supports this.
4275 *hl-WarningMsg*
4276WarningMsg warning messages
4277 *hl-WildMenu*
4278WildMenu current match in 'wildmenu' completion
4279
Bram Moolenaarf75a9632005-09-13 21:20:47 +00004280 *hl-User1* *hl-User1..9* *hl-User9*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004281The 'statusline' syntax allows the use of 9 different highlights in the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004282statusline and ruler (via 'rulerformat'). The names are User1 to User9.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004283
Bram Moolenaar8c8de832008-06-24 22:58:06 +00004284For the GUI you can use the following groups to set the colors for the menu,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004285scrollbars and tooltips. They don't have defaults. This doesn't work for the
4286Win32 GUI. Only three highlight arguments have any effect here: font, guibg,
4287and guifg.
4288
4289 *hl-Menu*
4290Menu Current font, background and foreground colors of the menus.
4291 Also used for the toolbar.
4292 Applicable highlight arguments: font, guibg, guifg.
4293
4294 NOTE: For Motif and Athena the font argument actually
4295 specifies a fontset at all times, no matter if 'guifontset' is
4296 empty, and as such it is tied to the current |:language| when
4297 set.
4298
4299 *hl-Scrollbar*
4300Scrollbar Current background and foreground of the main window's
4301 scrollbars.
4302 Applicable highlight arguments: guibg, guifg.
4303
4304 *hl-Tooltip*
4305Tooltip Current font, background and foreground of the tooltips.
4306 Applicable highlight arguments: font, guibg, guifg.
4307
4308 NOTE: For Motif and Athena the font argument actually
4309 specifies a fontset at all times, no matter if 'guifontset' is
4310 empty, and as such it is tied to the current |:language| when
4311 set.
4312
4313==============================================================================
431413. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
4315
4316When you want to use the same highlighting for several syntax groups, you
4317can do this more easily by linking the groups into one common highlight
4318group, and give the color attributes only for that group.
4319
4320To set a link:
4321
4322 :hi[ghlight][!] [default] link {from-group} {to-group}
4323
4324To remove a link:
4325
4326 :hi[ghlight][!] [default] link {from-group} NONE
4327
4328Notes: *E414*
4329- If the {from-group} and/or {to-group} doesn't exist, it is created. You
4330 don't get an error message for a non-existing group.
4331- As soon as you use a ":highlight" command for a linked group, the link is
4332 removed.
4333- If there are already highlight settings for the {from-group}, the link is
4334 not made, unless the '!' is given. For a ":highlight link" command in a
4335 sourced file, you don't get an error message. This can be used to skip
4336 links for groups that already have settings.
4337
4338 *:hi-default* *:highlight-default*
4339The [default] argument is used for setting the default highlighting for a
4340group. If highlighting has already been specified for the group the command
4341will be ignored. Also when there is an existing link.
4342
4343Using [default] is especially useful to overrule the highlighting of a
4344specific syntax file. For example, the C syntax file contains: >
4345 :highlight default link cComment Comment
4346If you like Question highlighting for C comments, put this in your vimrc file: >
4347 :highlight link cComment Question
4348Without the "default" in the C syntax file, the highlighting would be
4349overruled when the syntax file is loaded.
4350
4351==============================================================================
435214. Cleaning up *:syn-clear* *E391*
4353
4354If you want to clear the syntax stuff for the current buffer, you can use this
4355command: >
4356 :syntax clear
4357
4358This command should be used when you want to switch off syntax highlighting,
4359or when you want to switch to using another syntax. It's normally not needed
4360in a syntax file itself, because syntax is cleared by the autocommands that
4361load the syntax file.
4362The command also deletes the "b:current_syntax" variable, since no syntax is
4363loaded after this command.
4364
4365If you want to disable syntax highlighting for all buffers, you need to remove
4366the autocommands that load the syntax files: >
4367 :syntax off
4368
4369What this command actually does, is executing the command >
4370 :source $VIMRUNTIME/syntax/nosyntax.vim
4371See the "nosyntax.vim" file for details. Note that for this to work
4372$VIMRUNTIME must be valid. See |$VIMRUNTIME|.
4373
4374To clean up specific syntax groups for the current buffer: >
4375 :syntax clear {group-name} ..
4376This removes all patterns and keywords for {group-name}.
4377
4378To clean up specific syntax group lists for the current buffer: >
4379 :syntax clear @{grouplist-name} ..
4380This sets {grouplist-name}'s contents to an empty list.
4381
4382 *:syntax-reset* *:syn-reset*
4383If you have changed the colors and messed them up, use this command to get the
4384defaults back: >
4385
4386 :syntax reset
4387
4388This doesn't change the colors for the 'highlight' option.
4389
4390Note that the syntax colors that you set in your vimrc file will also be reset
4391back to their Vim default.
4392Note that if you are using a color scheme, the colors defined by the color
4393scheme for syntax highlighting will be lost.
4394
4395What this actually does is: >
4396
4397 let g:syntax_cmd = "reset"
4398 runtime! syntax/syncolor.vim
4399
4400Note that this uses the 'runtimepath' option.
4401
4402 *syncolor*
4403If you want to use different colors for syntax highlighting, you can add a Vim
4404script file to set these colors. Put this file in a directory in
4405'runtimepath' which comes after $VIMRUNTIME, so that your settings overrule
4406the default colors. This way these colors will be used after the ":syntax
4407reset" command.
4408
4409For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: >
4410
4411 if &background == "light"
4412 highlight comment ctermfg=darkgreen guifg=darkgreen
4413 else
4414 highlight comment ctermfg=green guifg=green
4415 endif
4416
Bram Moolenaarc0197e22004-09-13 20:26:32 +00004417 *E679*
4418Do make sure this syncolor.vim script does not use a "syntax on", set the
4419'background' option or uses a "colorscheme" command, because it results in an
4420endless loop.
4421
Bram Moolenaar071d4272004-06-13 20:20:40 +00004422Note that when a color scheme is used, there might be some confusion whether
4423your defined colors are to be used or the colors from the scheme. This
4424depends on the color scheme file. See |:colorscheme|.
4425
4426 *syntax_cmd*
4427The "syntax_cmd" variable is set to one of these values when the
4428syntax/syncolor.vim files are loaded:
4429 "on" ":syntax on" command. Highlight colors are overruled but
4430 links are kept
4431 "enable" ":syntax enable" command. Only define colors for groups that
4432 don't have highlighting yet. Use ":syntax default".
4433 "reset" ":syntax reset" command or loading a color scheme. Define all
4434 the colors.
4435 "skip" Don't define colors. Used to skip the default settings when a
4436 syncolor.vim file earlier in 'runtimepath' has already set
4437 them.
4438
4439==============================================================================
444015. Highlighting tags *tag-highlight*
4441
4442If you want to highlight all the tags in your file, you can use the following
4443mappings.
4444
4445 <F11> -- Generate tags.vim file, and highlight tags.
4446 <F12> -- Just highlight tags based on existing tags.vim file.
4447>
4448 :map <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
4449 :map <F12> :so tags.vim<CR>
4450
4451WARNING: The longer the tags file, the slower this will be, and the more
4452memory Vim will consume.
4453
4454Only highlighting typedefs, unions and structs can be done too. For this you
4455must use Exuberant ctags (found at http://ctags.sf.net).
4456
4457Put these lines in your Makefile:
4458
4459# Make a highlight file for types. Requires Exuberant ctags and awk
4460types: types.vim
4461types.vim: *.[ch]
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004462 ctags --c-kinds=gstu -o- *.[ch] |\
Bram Moolenaar071d4272004-06-13 20:20:40 +00004463 awk 'BEGIN{printf("syntax keyword Type\t")}\
4464 {printf("%s ", $$1)}END{print ""}' > $@
4465
4466And put these lines in your .vimrc: >
4467
4468 " load the types.vim highlighting file, if it exists
4469 autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
4470 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
4471 autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname
4472 autocmd BufRead,BufNewFile *.[ch] endif
4473
4474==============================================================================
447516. Color xterms *xterm-color* *color-xterm*
4476
4477Most color xterms have only eight colors. If you don't get colors with the
4478default setup, it should work with these lines in your .vimrc: >
4479 :if &term =~ "xterm"
4480 : if has("terminfo")
4481 : set t_Co=8
4482 : set t_Sf=<Esc>[3%p1%dm
4483 : set t_Sb=<Esc>[4%p1%dm
4484 : else
4485 : set t_Co=8
4486 : set t_Sf=<Esc>[3%dm
4487 : set t_Sb=<Esc>[4%dm
4488 : endif
4489 :endif
4490< [<Esc> is a real escape, type CTRL-V <Esc>]
4491
4492You might want to change the first "if" to match the name of your terminal,
4493e.g. "dtterm" instead of "xterm".
4494
4495Note: Do these settings BEFORE doing ":syntax on". Otherwise the colors may
4496be wrong.
4497 *xiterm* *rxvt*
4498The above settings have been mentioned to work for xiterm and rxvt too.
4499But for using 16 colors in an rxvt these should work with terminfo: >
4500 :set t_AB=<Esc>[%?%p1%{8}%<%t25;%p1%{40}%+%e5;%p1%{32}%+%;%dm
4501 :set t_AF=<Esc>[%?%p1%{8}%<%t22;%p1%{30}%+%e1;%p1%{22}%+%;%dm
4502<
4503 *colortest.vim*
4504To test your color setup, a file has been included in the Vim distribution.
Bram Moolenaarf740b292006-02-16 22:11:02 +00004505To use it, execute this command: >
4506 :runtime syntax/colortest.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00004507
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004508Some versions of xterm (and other terminals, like the Linux console) can
Bram Moolenaar071d4272004-06-13 20:20:40 +00004509output lighter foreground colors, even though the number of colors is defined
4510at 8. Therefore Vim sets the "cterm=bold" attribute for light foreground
4511colors, when 't_Co' is 8.
4512
4513 *xfree-xterm*
4514To get 16 colors or more, get the newest xterm version (which should be
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004515included with XFree86 3.3 and later). You can also find the latest version
Bram Moolenaar071d4272004-06-13 20:20:40 +00004516at: >
4517 http://invisible-island.net/xterm/xterm.html
4518Here is a good way to configure it. This uses 88 colors and enables the
4519termcap-query feature, which allows Vim to ask the xterm how many colors it
4520supports. >
4521 ./configure --disable-bold-color --enable-88-color --enable-tcap-query
4522If you only get 8 colors, check the xterm compilation settings.
4523(Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
4524
4525This xterm should work with these lines in your .vimrc (for 16 colors): >
4526 :if has("terminfo")
4527 : set t_Co=16
4528 : set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
4529 : set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
4530 :else
4531 : set t_Co=16
4532 : set t_Sf=<Esc>[3%dm
4533 : set t_Sb=<Esc>[4%dm
4534 :endif
4535< [<Esc> is a real escape, type CTRL-V <Esc>]
4536
4537Without |+terminfo|, Vim will recognize these settings, and automatically
4538translate cterm colors of 8 and above to "<Esc>[9%dm" and "<Esc>[10%dm".
4539Colors above 16 are also translated automatically.
4540
4541For 256 colors this has been reported to work: >
4542
4543 :set t_AB=<Esc>[48;5;%dm
4544 :set t_AF=<Esc>[38;5;%dm
4545
4546Or just set the TERM environment variable to "xterm-color" or "xterm-16color"
4547and try if that works.
4548
4549You probably want to use these X resources (in your ~/.Xdefaults file):
4550 XTerm*color0: #000000
4551 XTerm*color1: #c00000
4552 XTerm*color2: #008000
4553 XTerm*color3: #808000
4554 XTerm*color4: #0000c0
4555 XTerm*color5: #c000c0
4556 XTerm*color6: #008080
4557 XTerm*color7: #c0c0c0
4558 XTerm*color8: #808080
4559 XTerm*color9: #ff6060
4560 XTerm*color10: #00ff00
4561 XTerm*color11: #ffff00
4562 XTerm*color12: #8080ff
4563 XTerm*color13: #ff40ff
4564 XTerm*color14: #00ffff
4565 XTerm*color15: #ffffff
4566 Xterm*cursorColor: Black
4567
4568[Note: The cursorColor is required to work around a bug, which changes the
4569cursor color to the color of the last drawn text. This has been fixed by a
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004570newer version of xterm, but not everybody is using it yet.]
Bram Moolenaar071d4272004-06-13 20:20:40 +00004571
4572To get these right away, reload the .Xdefaults file to the X Option database
4573Manager (you only need to do this when you just changed the .Xdefaults file): >
4574 xrdb -merge ~/.Xdefaults
4575<
4576 *xterm-blink* *xterm-blinking-cursor*
4577To make the cursor blink in an xterm, see tools/blink.c. Or use Thomas
4578Dickey's xterm above patchlevel 107 (see above for where to get it), with
4579these resources:
4580 XTerm*cursorBlink: on
4581 XTerm*cursorOnTime: 400
4582 XTerm*cursorOffTime: 250
4583 XTerm*cursorColor: White
4584
4585 *hpterm-color*
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004586These settings work (more or less) for an hpterm, which only supports 8
Bram Moolenaar071d4272004-06-13 20:20:40 +00004587foreground colors: >
4588 :if has("terminfo")
4589 : set t_Co=8
4590 : set t_Sf=<Esc>[&v%p1%dS
4591 : set t_Sb=<Esc>[&v7S
4592 :else
4593 : set t_Co=8
4594 : set t_Sf=<Esc>[&v%dS
4595 : set t_Sb=<Esc>[&v7S
4596 :endif
4597< [<Esc> is a real escape, type CTRL-V <Esc>]
4598
4599 *Eterm* *enlightened-terminal*
4600These settings have been reported to work for the Enlightened terminal
4601emulator, or Eterm. They might work for all xterm-like terminals that use the
4602bold attribute to get bright colors. Add an ":if" like above when needed. >
4603 :set t_Co=16
4604 :set t_AF=^[[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
4605 :set t_AB=^[[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m
4606<
4607 *TTpro-telnet*
4608These settings should work for TTpro telnet. Tera Term Pro is a freeware /
4609open-source program for MS-Windows. >
4610 set t_Co=16
4611 set t_AB=^[[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{32}%+5;%;%dm
4612 set t_AF=^[[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{22}%+1;%;%dm
4613Also make sure TTpro's Setup / Window / Full Color is enabled, and make sure
4614that Setup / Font / Enable Bold is NOT enabled.
4615(info provided by John Love-Jensen <eljay@Adobe.COM>)
4616
4617 vim:tw=78:sw=4:ts=8:ft=help:norl: