blob: 4e6f92d9f3472a3905c9db63860474be8fb34f88 [file] [log] [blame]
Bram Moolenaar30b65812012-07-12 22:01:11 +02001*syntax.txt* For Vim version 7.3. Last change: 2012 Jun 13
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Syntax highlighting *syntax* *syntax-highlighting* *coloring*
8
9Syntax highlighting enables Vim to show parts of the text in another font or
10color. Those parts can be specific keywords or text matching a pattern. Vim
11doesn't parse the whole file (to keep it fast), so the highlighting has its
12limitations. Lexical highlighting might be a better name, but since everybody
13calls it syntax highlighting we'll stick with that.
14
15Vim supports syntax highlighting on all terminals. But since most ordinary
16terminals have very limited highlighting possibilities, it works best in the
17GUI version, gvim.
18
19In the User Manual:
20|usr_06.txt| introduces syntax highlighting.
21|usr_44.txt| introduces writing a syntax file.
22
231. Quick start |:syn-qstart|
242. Syntax files |:syn-files|
253. Syntax loading procedure |syntax-loading|
264. Syntax file remarks |:syn-file-remarks|
275. Defining a syntax |:syn-define|
286. :syntax arguments |:syn-arguments|
297. Syntax patterns |:syn-pattern|
308. Syntax clusters |:syn-cluster|
319. Including syntax files |:syn-include|
3210. Synchronizing |:syn-sync|
3311. Listing syntax items |:syntax|
3412. Highlight command |:highlight|
3513. Linking groups |:highlight-link|
3614. Cleaning up |:syn-clear|
3715. Highlighting tags |tag-highlight|
Bram Moolenaar860cae12010-06-05 23:22:07 +02003816. Window-local syntax |:ownsyntax|
3917. Color xterms |xterm-color|
Bram Moolenaar071d4272004-06-13 20:20:40 +000040
41{Vi does not have any of these commands}
42
43Syntax highlighting is not available when the |+syntax| feature has been
44disabled at compile time.
45
46==============================================================================
471. Quick start *:syn-qstart*
48
49 *:syn-enable* *:syntax-enable*
50This command switches on syntax highlighting: >
51
52 :syntax enable
53
54What this command actually does is to execute the command >
55 :source $VIMRUNTIME/syntax/syntax.vim
56
57If the VIM environment variable is not set, Vim will try to find
58the path in another way (see |$VIMRUNTIME|). Usually this works just
59fine. If it doesn't, try setting the VIM environment variable to the
60directory where the Vim stuff is located. For example, if your syntax files
61are in the "/usr/vim/vim50/syntax" directory, set $VIMRUNTIME to
62"/usr/vim/vim50". You must do this in the shell, before starting Vim.
63
64 *:syn-on* *:syntax-on*
65The ":syntax enable" command will keep your current color settings. This
66allows using ":highlight" commands to set your preferred colors before or
67after using this command. If you want Vim to overrule your settings with the
68defaults, use: >
69 :syntax on
70<
71 *:hi-normal* *:highlight-normal*
72If you are running in the GUI, you can get white text on a black background
73with: >
74 :highlight Normal guibg=Black guifg=White
75For a color terminal see |:hi-normal-cterm|.
76For setting up your own colors syntax highlighting see |syncolor|.
77
78NOTE: The syntax files on MS-DOS and Windows have lines that end in <CR><NL>.
79The files for Unix end in <NL>. This means you should use the right type of
80file for your system. Although on MS-DOS and Windows the right format is
81automatically selected if the 'fileformats' option is not empty.
82
83NOTE: When using reverse video ("gvim -fg white -bg black"), the default value
84of 'background' will not be set until the GUI window is opened, which is after
Bram Moolenaar910f66f2006-04-05 20:41:53 +000085reading the |gvimrc|. This will cause the wrong default highlighting to be
Bram Moolenaar071d4272004-06-13 20:20:40 +000086used. To set the default value of 'background' before switching on
Bram Moolenaar910f66f2006-04-05 20:41:53 +000087highlighting, include the ":gui" command in the |gvimrc|: >
Bram Moolenaar071d4272004-06-13 20:20:40 +000088
89 :gui " open window and set default for 'background'
90 :syntax on " start highlighting, use 'background' to set colors
91
Bram Moolenaar910f66f2006-04-05 20:41:53 +000092NOTE: Using ":gui" in the |gvimrc| means that "gvim -f" won't start in the
Bram Moolenaar071d4272004-06-13 20:20:40 +000093foreground! Use ":gui -f" then.
94
Bram Moolenaar09092152010-08-08 16:38:42 +020095 *g:syntax_on*
96You can toggle the syntax on/off with this command: >
97 :if exists("g:syntax_on") | syntax off | else | syntax enable | endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000098
99To put this into a mapping, you can use: >
Bram Moolenaar09092152010-08-08 16:38:42 +0200100 :map <F7> :if exists("g:syntax_on") <Bar>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101 \ syntax off <Bar>
102 \ else <Bar>
103 \ syntax enable <Bar>
104 \ endif <CR>
105[using the |<>| notation, type this literally]
106
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000107Details:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108The ":syntax" commands are implemented by sourcing a file. To see exactly how
109this works, look in the file:
110 command file ~
111 :syntax enable $VIMRUNTIME/syntax/syntax.vim
112 :syntax on $VIMRUNTIME/syntax/syntax.vim
113 :syntax manual $VIMRUNTIME/syntax/manual.vim
114 :syntax off $VIMRUNTIME/syntax/nosyntax.vim
115Also see |syntax-loading|.
116
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100117NOTE: If displaying long lines is slow and switching off syntax highlighting
118makes it fast, consider setting the 'synmaxcol' option to a lower value.
119
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120==============================================================================
1212. Syntax files *:syn-files*
122
123The syntax and highlighting commands for one language are normally stored in
124a syntax file. The name convention is: "{name}.vim". Where {name} is the
125name of the language, or an abbreviation (to fit the name in 8.3 characters,
126a requirement in case the file is used on a DOS filesystem).
127Examples:
128 c.vim perl.vim java.vim html.vim
129 cpp.vim sh.vim csh.vim
130
131The syntax file can contain any Ex commands, just like a vimrc file. But
132the idea is that only commands for a specific language are included. When a
133language is a superset of another language, it may include the other one,
134for example, the cpp.vim file could include the c.vim file: >
135 :so $VIMRUNTIME/syntax/c.vim
136
137The .vim files are normally loaded with an autocommand. For example: >
138 :au Syntax c runtime! syntax/c.vim
139 :au Syntax cpp runtime! syntax/cpp.vim
140These commands are normally in the file $VIMRUNTIME/syntax/synload.vim.
141
142
143MAKING YOUR OWN SYNTAX FILES *mysyntaxfile*
144
145When you create your own syntax files, and you want to have Vim use these
146automatically with ":syntax enable", do this:
147
1481. Create your user runtime directory. You would normally use the first item
149 of the 'runtimepath' option. Example for Unix: >
150 mkdir ~/.vim
151
1522. Create a directory in there called "syntax". For Unix: >
153 mkdir ~/.vim/syntax
154
1553. Write the Vim syntax file. Or download one from the internet. Then write
156 it in your syntax directory. For example, for the "mine" syntax: >
157 :w ~/.vim/syntax/mine.vim
158
159Now you can start using your syntax file manually: >
160 :set syntax=mine
161You don't have to exit Vim to use this.
162
163If you also want Vim to detect the type of file, see |new-filetype|.
164
165If you are setting up a system with many users and you don't want each user
166to add the same syntax file, you can use another directory from 'runtimepath'.
167
168
169ADDING TO AN EXISTING SYNTAX FILE *mysyntaxfile-add*
170
171If you are mostly satisfied with an existing syntax file, but would like to
172add a few items or change the highlighting, follow these steps:
173
1741. Create your user directory from 'runtimepath', see above.
175
1762. Create a directory in there called "after/syntax". For Unix: >
177 mkdir ~/.vim/after
178 mkdir ~/.vim/after/syntax
179
1803. Write a Vim script that contains the commands you want to use. For
181 example, to change the colors for the C syntax: >
182 highlight cComment ctermfg=Green guifg=Green
183
1844. Write that file in the "after/syntax" directory. Use the name of the
185 syntax, with ".vim" added. For our C syntax: >
186 :w ~/.vim/after/syntax/c.vim
187
188That's it. The next time you edit a C file the Comment color will be
189different. You don't even have to restart Vim.
190
Bram Moolenaar5313dcb2005-02-22 08:56:13 +0000191If you have multiple files, you can use the filetype as the directory name.
192All the "*.vim" files in this directory will be used, for example:
193 ~/.vim/after/syntax/c/one.vim
194 ~/.vim/after/syntax/c/two.vim
195
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196
197REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
198
199If you don't like a distributed syntax file, or you have downloaded a new
200version, follow the same steps as for |mysyntaxfile| above. Just make sure
201that you write the syntax file in a directory that is early in 'runtimepath'.
Bram Moolenaar61d35bd2012-03-28 20:51:51 +0200202Vim will only load the first syntax file found, assuming that it sets
203b:current_syntax.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000204
205
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100206NAMING CONVENTIONS *group-name* *{group-name}* *E669* *W18*
207
208A syntax group name is to be used for syntax items that match the same kind of
209thing. These are then linked to a highlight group that specifies the color.
210A syntax group name doesn't specify any color or attributes itself.
211
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212The name for a highlight or syntax group must consist of ASCII letters, digits
213and the underscore. As a regexp: "[a-zA-Z0-9_]*"
214
215To be able to allow each user to pick his favorite set of colors, there must
216be preferred names for highlight groups that are common for many languages.
217These are the suggested group names (if syntax highlighting works properly
218you can see the actual color, except for "Ignore"):
219
220 *Comment any comment
221
222 *Constant any constant
223 String a string constant: "this is a string"
224 Character a character constant: 'c', '\n'
225 Number a number constant: 234, 0xff
226 Boolean a boolean constant: TRUE, false
227 Float a floating point constant: 2.3e10
228
229 *Identifier any variable name
230 Function function name (also: methods for classes)
231
232 *Statement any statement
233 Conditional if, then, else, endif, switch, etc.
234 Repeat for, do, while, etc.
235 Label case, default, etc.
236 Operator "sizeof", "+", "*", etc.
237 Keyword any other keyword
238 Exception try, catch, throw
239
240 *PreProc generic Preprocessor
241 Include preprocessor #include
242 Define preprocessor #define
243 Macro same as Define
244 PreCondit preprocessor #if, #else, #endif, etc.
245
246 *Type int, long, char, etc.
247 StorageClass static, register, volatile, etc.
248 Structure struct, union, enum, etc.
249 Typedef A typedef
250
251 *Special any special symbol
252 SpecialChar special character in a constant
253 Tag you can use CTRL-] on this
254 Delimiter character that needs attention
255 SpecialComment special things inside a comment
256 Debug debugging statements
257
258 *Underlined text that stands out, HTML links
259
Bram Moolenaar4f99eae2010-07-24 15:56:43 +0200260 *Ignore left blank, hidden |hl-Ignore|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261
262 *Error any erroneous construct
263
264 *Todo anything that needs extra attention; mostly the
265 keywords TODO FIXME and XXX
266
267The names marked with * are the preferred groups; the others are minor groups.
268For the preferred groups, the "syntax.vim" file contains default highlighting.
269The minor groups are linked to the preferred groups, so they get the same
270highlighting. You can override these defaults by using ":highlight" commands
271after sourcing the "syntax.vim" file.
272
273Note that highlight group names are not case sensitive. "String" and "string"
274can be used for the same group.
275
276The following names are reserved and cannot be used as a group name:
277 NONE ALL ALLBUT contains contained
278
Bram Moolenaar4f99eae2010-07-24 15:56:43 +0200279 *hl-Ignore*
280When using the Ignore group, you may also consider using the conceal
281mechanism. See |conceal|.
282
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283==============================================================================
2843. Syntax loading procedure *syntax-loading*
285
286This explains the details that happen when the command ":syntax enable" is
287issued. When Vim initializes itself, it finds out where the runtime files are
288located. This is used here as the variable |$VIMRUNTIME|.
289
290":syntax enable" and ":syntax on" do the following:
291
292 Source $VIMRUNTIME/syntax/syntax.vim
293 |
294 +- Clear out any old syntax by sourcing $VIMRUNTIME/syntax/nosyntax.vim
295 |
296 +- Source first syntax/synload.vim in 'runtimepath'
297 | |
298 | +- Setup the colors for syntax highlighting. If a color scheme is
299 | | defined it is loaded again with ":colors {name}". Otherwise
300 | | ":runtime! syntax/syncolor.vim" is used. ":syntax on" overrules
301 | | existing colors, ":syntax enable" only sets groups that weren't
302 | | set yet.
303 | |
304 | +- Set up syntax autocmds to load the appropriate syntax file when
305 | | the 'syntax' option is set. *synload-1*
306 | |
307 | +- Source the user's optional file, from the |mysyntaxfile| variable.
308 | This is for backwards compatibility with Vim 5.x only. *synload-2*
309 |
310 +- Do ":filetype on", which does ":runtime! filetype.vim". It loads any
311 | filetype.vim files found. It should always Source
312 | $VIMRUNTIME/filetype.vim, which does the following.
313 | |
314 | +- Install autocmds based on suffix to set the 'filetype' option
315 | | This is where the connection between file name and file type is
316 | | made for known file types. *synload-3*
317 | |
318 | +- Source the user's optional file, from the *myfiletypefile*
319 | | variable. This is for backwards compatibility with Vim 5.x only.
320 | | *synload-4*
321 | |
322 | +- Install one autocommand which sources scripts.vim when no file
323 | | type was detected yet. *synload-5*
324 | |
325 | +- Source $VIMRUNTIME/menu.vim, to setup the Syntax menu. |menu.vim|
326 |
327 +- Install a FileType autocommand to set the 'syntax' option when a file
328 | type has been detected. *synload-6*
329 |
330 +- Execute syntax autocommands to start syntax highlighting for each
331 already loaded buffer.
332
333
334Upon loading a file, Vim finds the relevant syntax file as follows:
335
336 Loading the file triggers the BufReadPost autocommands.
337 |
338 +- If there is a match with one of the autocommands from |synload-3|
339 | (known file types) or |synload-4| (user's file types), the 'filetype'
340 | option is set to the file type.
341 |
342 +- The autocommand at |synload-5| is triggered. If the file type was not
343 | found yet, then scripts.vim is searched for in 'runtimepath'. This
344 | should always load $VIMRUNTIME/scripts.vim, which does the following.
345 | |
346 | +- Source the user's optional file, from the *myscriptsfile*
347 | | variable. This is for backwards compatibility with Vim 5.x only.
348 | |
349 | +- If the file type is still unknown, check the contents of the file,
350 | again with checks like "getline(1) =~ pattern" as to whether the
351 | file type can be recognized, and set 'filetype'.
352 |
353 +- When the file type was determined and 'filetype' was set, this
354 | triggers the FileType autocommand |synload-6| above. It sets
355 | 'syntax' to the determined file type.
356 |
357 +- When the 'syntax' option was set above, this triggers an autocommand
358 | from |synload-1| (and |synload-2|). This find the main syntax file in
359 | 'runtimepath', with this command:
360 | runtime! syntax/<name>.vim
361 |
362 +- Any other user installed FileType or Syntax autocommands are
363 triggered. This can be used to change the highlighting for a specific
364 syntax.
365
366==============================================================================
3674. Syntax file remarks *:syn-file-remarks*
368
369 *b:current_syntax-variable*
370Vim stores the name of the syntax that has been loaded in the
371"b:current_syntax" variable. You can use this if you want to load other
372settings, depending on which syntax is active. Example: >
373 :au BufReadPost * if b:current_syntax == "csh"
374 :au BufReadPost * do-some-things
375 :au BufReadPost * endif
376
377
3782HTML *2html.vim* *convert-to-HTML*
379
380This is not a syntax file itself, but a script that converts the current
381window into HTML. Vim opens a new window in which it builds the HTML file.
382
383You are not supposed to set the 'filetype' or 'syntax' option to "2html"!
384Source the script to convert the current file: >
385
386 :runtime! syntax/2html.vim
387<
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388 *:TOhtml*
389Or use the ":TOhtml" user command. It is defined in a standard plugin.
390":TOhtml" also works with a range and in a Visual area: >
391
392 :10,40TOhtml
393
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100394Warning: This can be slow! The script must process every character of every
395line. Because it can take a long time, by default a progress bar is displayed
396in the statusline for each major step in the conversion process. If you don't
397like seeing this progress bar, you can disable it and get a very minor speed
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200398improvement with: >
399
400 let g:html_no_progress = 1
401
Bram Moolenaarb02cbe32010-07-11 22:38:52 +0200402":TOhtml" has another special feature: if the window is in diff mode, it will
403generate HTML that shows all the related windows. This can be disabled by
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200404setting the g:html_diff_one_file variable: >
Bram Moolenaarb02cbe32010-07-11 22:38:52 +0200405
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200406 let g:html_diff_one_file = 1
Bram Moolenaarb02cbe32010-07-11 22:38:52 +0200407
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100408After you save the resulting file, you can view it with any browser. The
409colors should be exactly the same as you see them in Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000410
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200411To restrict the conversion to a range of lines, use a range with the |:TOhtml|
412command, or set "g:html_start_line" and "g:html_end_line" to the first and
413last line to be converted. Example, using the last set Visual area: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200415 :let g:html_start_line = line("'<")
416 :let g:html_end_line = line("'>")
Bram Moolenaar071d4272004-06-13 20:20:40 +0000417
418The lines are numbered according to 'number' option and the Number
419highlighting. You can force lines to be numbered in the HTML output by
420setting "html_number_lines" to non-zero value: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200421 :let g:html_number_lines = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000422Force to omit the line numbers by using a zero value: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200423 :let g:html_number_lines = 0
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424Go back to the default to use 'number' by deleting the variable: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200425 :unlet g:html_number_lines
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426
Bram Moolenaar076e8b22010-08-05 21:54:00 +0200427By default, valid HTML 4.01 using cascading style sheets (CSS1) is generated.
428If you need to generate markup for really old browsers or some other user
429agent that lacks basic CSS support, use: >
430 :let g:html_use_css = 0
Bram Moolenaar071d4272004-06-13 20:20:40 +0000431
Bram Moolenaar7510fe72010-07-25 12:46:44 +0200432Concealed text is removed from the HTML and replaced with the appropriate
Bram Moolenaarfa0ff9a2010-07-25 16:05:19 +0200433character from |:syn-cchar| or 'listchars' depending on the current value of
Bram Moolenaar7510fe72010-07-25 12:46:44 +0200434'conceallevel'. If you always want to display all text in your document,
Bram Moolenaar8ada2cc2010-07-29 20:43:36 +0200435either set 'conceallevel' to zero before invoking 2html, or use: >
Bram Moolenaar7510fe72010-07-25 12:46:44 +0200436 :let g:html_ignore_conceal = 1
437
438Similarly, closed folds are put in the HTML as they are displayed. If you
439don't want this, use the |zR| command before invoking 2html, or use: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200440 :let g:html_ignore_folding = 1
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100441
442You may want to generate HTML that includes all the data within the folds, and
443allow the user to view the folded data similar to how they would in Vim. To
444generate this dynamic fold information, use: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200445 :let g:html_dynamic_folds = 1
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100446
447Using html_dynamic_folds will imply html_use_css, because it would be far too
448difficult to do it for old browsers. However, html_ignore_folding overrides
449html_dynamic_folds.
450
451Using html_dynamic_folds will default to generating a foldcolumn in the html
452similar to Vim's foldcolumn, that will use javascript to open and close the
453folds in the HTML document. The width of this foldcolumn starts at the current
454setting of |'foldcolumn'| but grows to fit the greatest foldlevel in your
455document. If you do not want to show a foldcolumn at all, use: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200456 :let g:html_no_foldcolumn = 1
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100457
458Using this option, there will be no foldcolumn available to open the folds in
459the HTML. For this reason, another option is provided: html_hover_unfold.
460Enabling this option will use CSS 2.0 to allow a user to open a fold by
461hovering the mouse pointer over it. Note that old browsers (notably Internet
462Explorer 6) will not support this feature. Browser-specific markup for IE6 is
463included to fall back to the normal CSS1 code so that the folds show up
464correctly for this browser, but they will not be openable without a
465foldcolumn. Note that using html_hover_unfold will allow modern browsers with
466disabled javascript to view closed folds. To use this option, use: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200467 :let g:html_hover_unfold = 1
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100468
469Setting html_no_foldcolumn with html_dynamic_folds will automatically set
470html_hover_unfold, because otherwise the folds wouldn't be dynamic.
471
Bram Moolenaar8e5af3e2011-04-28 19:02:44 +0200472By default "<pre>" and "</pre>" are used around the text. When 'wrap' is set
473in the window being converted, the CSS 2.0 "white-space:pre-wrap" value is
474used to wrap the text. You can explicitly enable the wrapping with: >
475 :let g:html_pre_wrap = 1
476or disable with >
477 :let g:html_pre_wrap = 0
478This generates HTML that looks very close to the Vim window, but unfortunately
479there can be minor differences such as the lack of a 'showbreak' option in in
480the HTML, or where line breaks can occur.
481
482Another way to obtain text wrapping in the HTML, at the risk of making some
483things look even more different, is to use: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200484 :let g:html_no_pre = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000485This will use <br> at the end of each line and use "&nbsp;" for repeated
Bram Moolenaar8e5af3e2011-04-28 19:02:44 +0200486spaces. Doing it this way is more compatible with old browsers, but modern
487browsers support the "white-space" method.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000488
Bram Moolenaar8e5af3e2011-04-28 19:02:44 +0200489If you do stick with the default "<pre>" tags, <Tab> characters in the text
490are included in the generated output if they will have no effect on the
491appearance of the text and it looks like they are in the document
492intentionally. This allows for the HTML output to be copied and pasted from a
493browser without losing the actual whitespace used in the document.
Bram Moolenaar2a8a3ec2011-01-08 16:06:37 +0100494
495Specifically, <Tab> characters will be included if the 'tabstop' option is set
496to the default of 8, 'expandtab' is not set, and if neither the foldcolumn nor
497the line numbers are included in the HTML output (see options above). When any
498of these conditions are not met, any <Tab> characters in the text are expanded
499to the appropriate number of spaces in the HTML output.
500
501When "<pre>" is included, you can force |:TOhtml| to keep the tabs even if the
502other conditions are not met with: >
503 :let g:html_expand_tabs = 0
504Note that this can easily break text alignment and indentation in the HTML.
505
506Force tabs to be expanded even when they would be kept using: >
507 :let g:html_expand_tabs = 1
508
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100509For diff mode on a single file (with g:html_diff_one_file) a sequence of more
510than 3 filler lines is displayed as three lines with the middle line
511mentioning the total number of inserted lines. If you prefer to see all the
512inserted lines as with the side-by-side diff, use: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200513 :let g:html_whole_filler = 1
Bram Moolenaar47136d72004-10-12 20:02:24 +0000514And to go back to displaying up to three lines again: >
Bram Moolenaar349b2fb2010-07-16 20:35:36 +0200515 :unlet g:html_whole_filler
Bram Moolenaar8e5af3e2011-04-28 19:02:44 +0200516
517For most buffers, TOhtml uses the current value of 'fileencoding' if set, or
518'encoding' if not, to determine the charset and 'fileencoding' of the HTML
519file. 'encoding' is always used for certain 'buftype' values. In general, this
520works for the encodings mentioned specifically by name in |encoding-names|,
521but TOhtml will only automatically use those encodings which are widely
522supported. However, you can override this to support specific encodings that
523may not be automatically detected by default.
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100524
525To overrule all automatic charset detection, set g:html_use_encoding to the
526name of the charset to be used. TOhtml will try to determine the appropriate
527'fileencoding' setting from the charset, but you may need to set it manually
528if TOhtml cannot determine the encoding. It is recommended to set this
529variable to something widely supported, like UTF-8, for anything you will be
530hosting on a webserver: >
531 :let g:html_use_encoding = "UTF-8"
532You can also use this option to omit the line that specifies the charset
533entirely, by setting g:html_use_encoding to an empty string: >
534 :let g:html_use_encoding = ""
535To go back to the automatic mechanism, delete the g:html_use_encoding
536variable: >
537 :unlet g:html_use_encoding
538
539If you specify a charset with g:html_use_encoding for which TOhtml cannot
540automatically detect the corresponding 'fileencoding' setting, you can use
541g:html_encoding_override to allow TOhtml to detect the correct encoding.
542This is a dictionary of charset-encoding pairs that will replace existing
543pairs automatically detected by TOhtml, or supplement with new pairs. For
544example, to allow TOhtml to detect the HTML charset "windows-1252" properly as
545the encoding "8bit-cp1252", use: >
546 :let g:html_encoding_override = {'windows-1252': '8bit-cp1252'}
547<
548The g:html_charset_override is similar, it allows TOhtml to detect the HTML
549charset for any 'fileencoding' or 'encoding' which is not detected
550automatically. You can also use it to override specific existing
551encoding-charset pairs. For example, TOhtml will by default use UTF-8 for all
552Unicode/UCS encodings. To use UTF-16 and UTF-32 instead, use: >
553 :let g:html_charset_override = {'ucs-4': 'UTF-32', 'utf-16': 'UTF-16'}
554
555Note that documents encoded in either UTF-32 or UTF-16 have known
556compatibility problems with at least one major browser.
557
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558 *convert-to-XML* *convert-to-XHTML*
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100559If you do not like plain HTML, an alternative is to have the script generate
560XHTML (XML compliant HTML). To do this set the "html_use_xhtml" variable: >
Bram Moolenaar076e8b22010-08-05 21:54:00 +0200561 :let g:html_use_xhtml = 1
562
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100563Any of the on/off options listed above can be enabled or disabled by setting
564them explicitly to the desired value, or restored to their default by removing
565the variable using |:unlet|.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566
567Remarks:
Bram Moolenaar076e8b22010-08-05 21:54:00 +0200568- Some truly ancient browsers may not show the background colors.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569- From most browsers you can also print the file (in color)!
Bram Moolenaar166af9b2010-11-16 20:34:40 +0100570- This version of TOhtml may work with older versions of Vim, but some
571 features such as conceal support will not function, and the colors may be
572 incorrect for an old Vim without GUI support compiled in.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573
574Here is an example how to run the script over all .c and .h files from a
575Unix shell: >
576 for f in *.[ch]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done
577<
578
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000579ABEL *abel.vim* *ft-abel-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580
581ABEL highlighting provides some user-defined options. To enable them, assign
582any value to the respective variable. Example: >
583 :let abel_obsolete_ok=1
584To disable them use ":unlet". Example: >
585 :unlet abel_obsolete_ok
586
587Variable Highlight ~
588abel_obsolete_ok obsolete keywords are statements, not errors
589abel_cpp_comments_illegal do not interpret '//' as inline comment leader
590
591
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000592ADA
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000594See |ft-ada-syntax|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000595
596
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000597ANT *ant.vim* *ft-ant-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598
599The ant syntax file provides syntax highlighting for javascript and python
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000600by default. Syntax highlighting for other script languages can be installed
Bram Moolenaar071d4272004-06-13 20:20:40 +0000601by the function AntSyntaxScript(), which takes the tag name as first argument
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000602and the script syntax file name as second argument. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000603
604 :call AntSyntaxScript('perl', 'perl.vim')
605
606will install syntax perl highlighting for the following ant code >
607
608 <script language = 'perl'><![CDATA[
609 # everything inside is highlighted as perl
610 ]]></script>
611
612See |mysyntaxfile-add| for installing script languages permanently.
613
614
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000615APACHE *apache.vim* *ft-apache-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000616
617The apache syntax file provides syntax highlighting depending on Apache HTTP
618server version, by default for 1.3.x. Set "apache_version" to Apache version
619(as a string) to get highlighting for another version. Example: >
620
621 :let apache_version = "2.0"
622<
623
624 *asm.vim* *asmh8300.vim* *nasm.vim* *masm.vim* *asm68k*
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000625ASSEMBLY *ft-asm-syntax* *ft-asmh8300-syntax* *ft-nasm-syntax*
626 *ft-masm-syntax* *ft-asm68k-syntax* *fasm.vim*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627
628Files matching "*.i" could be Progress or Assembly. If the automatic detection
629doesn't work for you, or you don't edit Progress at all, use this in your
630startup vimrc: >
631 :let filetype_i = "asm"
632Replace "asm" with the type of assembly you use.
633
634There are many types of assembly languages that all use the same file name
635extensions. Therefore you will have to select the type yourself, or add a
636line in the assembly file that Vim will recognize. Currently these syntax
637files are included:
638 asm GNU assembly (the default)
639 asm68k Motorola 680x0 assembly
640 asmh8300 Hitachi H-8300 version of GNU assembly
641 ia64 Intel Itanium 64
642 fasm Flat assembly (http://flatassembler.net)
643 masm Microsoft assembly (probably works for any 80x86)
644 nasm Netwide assembly
645 tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and
646 MMX)
647 pic PIC assembly (currently for PIC16F84)
648
649The most flexible is to add a line in your assembly file containing: >
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100650 asmsyntax=nasm
Bram Moolenaar071d4272004-06-13 20:20:40 +0000651Replace "nasm" with the name of the real assembly syntax. This line must be
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100652one of the first five lines in the file. No non-white text must be
Bram Moolenaar30b65812012-07-12 22:01:11 +0200653immediately before or after this text. Note that specifying asmsyntax=foo is
654equivalent to setting ft=foo in a |modeline|, and that in case of a conflict
655between the two settings the one from the modeline will take precedence (in
656particular, if you have ft=asm in the modeline, you will get the GNU syntax
657highlighting regardless of what is specified as asmsyntax).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658
659The syntax type can always be overruled for a specific buffer by setting the
660b:asmsyntax variable: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000661 :let b:asmsyntax = "nasm"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662
663If b:asmsyntax is not set, either automatically or by hand, then the value of
664the global variable asmsyntax is used. This can be seen as a default assembly
665language: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000666 :let asmsyntax = "nasm"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000667
668As a last resort, if nothing is defined, the "asm" syntax is used.
669
670
671Netwide assembler (nasm.vim) optional highlighting ~
672
673To enable a feature: >
674 :let {variable}=1|set syntax=nasm
675To disable a feature: >
676 :unlet {variable} |set syntax=nasm
677
678Variable Highlight ~
679nasm_loose_syntax unofficial parser allowed syntax not as Error
680 (parser dependent; not recommended)
681nasm_ctx_outside_macro contexts outside macro not as Error
682nasm_no_warn potentially risky syntax not as ToDo
683
684
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000685ASPPERL and ASPVBS *ft-aspperl-syntax* *ft-aspvbs-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000686
687*.asp and *.asa files could be either Perl or Visual Basic script. Since it's
688hard to detect this you can set two global variables to tell Vim what you are
689using. For Perl script use: >
690 :let g:filetype_asa = "aspperl"
691 :let g:filetype_asp = "aspperl"
692For Visual Basic use: >
693 :let g:filetype_asa = "aspvbs"
694 :let g:filetype_asp = "aspvbs"
695
696
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000697BAAN *baan.vim* *baan-syntax*
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000698
699The baan.vim gives syntax support for BaanC of release BaanIV upto SSA ERP LN
700for both 3 GL and 4 GL programming. Large number of standard defines/constants
701are supported.
702
703Some special violation of coding standards will be signalled when one specify
704in ones |.vimrc|: >
705 let baan_code_stds=1
706
707*baan-folding*
708
709Syntax folding can be enabled at various levels through the variables
710mentioned below (Set those in your |.vimrc|). The more complex folding on
711source blocks and SQL can be CPU intensive.
712
713To allow any folding and enable folding at function level use: >
714 let baan_fold=1
715Folding can be enabled at source block level as if, while, for ,... The
716indentation preceding the begin/end keywords has to match (spaces are not
717considered equal to a tab). >
718 let baan_fold_block=1
719Folding can be enabled for embedded SQL blocks as SELECT, SELECTDO,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000720SELECTEMPTY, ... The indentation preceding the begin/end keywords has to
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000721match (spaces are not considered equal to a tab). >
722 let baan_fold_sql=1
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000723Note: Block folding can result in many small folds. It is suggested to |:set|
Bram Moolenaarf193fff2006-04-27 00:02:13 +0000724the options 'foldminlines' and 'foldnestmax' in |.vimrc| or use |:setlocal| in
725.../after/syntax/baan.vim (see |after-directory|). Eg: >
726 set foldminlines=5
727 set foldnestmax=6
728
729
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000730BASIC *basic.vim* *vb.vim* *ft-basic-syntax* *ft-vb-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000731
732Both Visual Basic and "normal" basic use the extension ".bas". To detect
733which one should be used, Vim checks for the string "VB_Name" in the first
734five lines of the file. If it is not found, filetype will be "basic",
735otherwise "vb". Files with the ".frm" extension will always be seen as Visual
736Basic.
737
738
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000739C *c.vim* *ft-c-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000740
741A few things in C highlighting are optional. To enable them assign any value
742to the respective variable. Example: >
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000743 :let c_comment_strings = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000744To disable them use ":unlet". Example: >
745 :unlet c_comment_strings
746
747Variable Highlight ~
748c_gnu GNU gcc specific items
749c_comment_strings strings and numbers inside a comment
750c_space_errors trailing white space and spaces before a <Tab>
751c_no_trail_space_error ... but no trailing spaces
752c_no_tab_space_error ... but no spaces before a <Tab>
753c_no_bracket_error don't highlight {}; inside [] as errors
Bram Moolenaar677ee682005-01-27 14:41:15 +0000754c_no_curly_error don't highlight {}; inside [] and () as errors;
755 except { and } in first column
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000756c_curly_error highlight a missing }; this forces syncing from the
757 start of the file, can be slow
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758c_no_ansi don't do standard ANSI types and constants
759c_ansi_typedefs ... but do standard ANSI types
760c_ansi_constants ... but do standard ANSI constants
761c_no_utf don't highlight \u and \U in strings
Bram Moolenaar61d35bd2012-03-28 20:51:51 +0200762c_syntax_for_h for *.h files use C syntax instead of C++ and use objc
763 syntax instead of objcpp
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764c_no_if0 don't highlight "#if 0" blocks as comments
765c_no_cformat don't highlight %-formats in strings
766c_no_c99 don't highlight C99 standard items
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100767c_no_c11 don't highlight C11 standard items
Bram Moolenaar071d4272004-06-13 20:20:40 +0000768
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000769When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will
770become a fold. If you don't want comments to become a fold use: >
771 :let c_no_comment_fold = 1
Bram Moolenaarf9393ef2006-04-24 19:47:27 +0000772"#if 0" blocks are also folded, unless: >
773 :let c_no_if0_fold = 1
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000774
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775If you notice highlighting errors while scrolling backwards, which are fixed
776when redrawing with CTRL-L, try setting the "c_minlines" internal variable
777to a larger number: >
778 :let c_minlines = 100
779This will make the syntax synchronization start 100 lines before the first
780displayed line. The default value is 50 (15 when c_no_if0 is set). The
781disadvantage of using a larger number is that redrawing can become slow.
782
783When using the "#if 0" / "#endif" comment highlighting, notice that this only
784works when the "#if 0" is within "c_minlines" from the top of the window. If
785you have a long "#if 0" construct it will not be highlighted correctly.
786
787To match extra items in comments, use the cCommentGroup cluster.
788Example: >
789 :au Syntax c call MyCadd()
790 :function MyCadd()
791 : syn keyword cMyItem contained Ni
792 : syn cluster cCommentGroup add=cMyItem
793 : hi link cMyItem Title
794 :endfun
795
796ANSI constants will be highlighted with the "cConstant" group. This includes
797"NULL", "SIG_IGN" and others. But not "TRUE", for example, because this is
798not in the ANSI standard. If you find this confusing, remove the cConstant
799highlighting: >
800 :hi link cConstant NONE
801
802If you see '{' and '}' highlighted as an error where they are OK, reset the
803highlighting for cErrInParen and cErrInBracket.
804
805If you want to use folding in your C files, you can add these lines in a file
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200806in the "after" directory in 'runtimepath'. For Unix this would be
Bram Moolenaar071d4272004-06-13 20:20:40 +0000807~/.vim/after/syntax/c.vim. >
Bram Moolenaar071d4272004-06-13 20:20:40 +0000808 syn sync fromstart
809 set foldmethod=syntax
810
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000811CH *ch.vim* *ft-ch-syntax*
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000812
813C/C++ interpreter. Ch has similar syntax highlighting to C and builds upon
814the C syntax file. See |c.vim| for all the settings that are available for C.
815
816By setting a variable you can tell Vim to use Ch syntax for *.h files, instead
817of C or C++: >
818 :let ch_syntax_for_h = 1
819
Bram Moolenaar071d4272004-06-13 20:20:40 +0000820
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000821CHILL *chill.vim* *ft-chill-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000822
823Chill syntax highlighting is similar to C. See |c.vim| for all the settings
824that are available. Additionally there is:
825
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826chill_space_errors like c_space_errors
827chill_comment_string like c_comment_strings
828chill_minlines like c_minlines
829
830
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000831CHANGELOG *changelog.vim* *ft-changelog-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000832
833ChangeLog supports highlighting spaces at the start of a line.
834If you do not like this, add following line to your .vimrc: >
835 let g:changelog_spacing_errors = 0
836This works the next time you edit a changelog file. You can also use
837"b:changelog_spacing_errors" to set this per buffer (before loading the syntax
838file).
839
840You can change the highlighting used, e.g., to flag the spaces as an error: >
841 :hi link ChangelogError Error
842Or to avoid the highlighting: >
843 :hi link ChangelogError NONE
844This works immediately.
845
846
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000847COBOL *cobol.vim* *ft-cobol-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000848
849COBOL highlighting has different needs for legacy code than it does for fresh
850development. This is due to differences in what is being done (maintenance
851versus development) and other factors. To enable legacy code highlighting,
852add this line to your .vimrc: >
853 :let cobol_legacy_code = 1
854To disable it again, use this: >
855 :unlet cobol_legacy_code
856
857
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000858COLD FUSION *coldfusion.vim* *ft-coldfusion-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000859
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000860The ColdFusion has its own version of HTML comments. To turn on ColdFusion
Bram Moolenaar071d4272004-06-13 20:20:40 +0000861comment highlighting, add the following line to your startup file: >
862
863 :let html_wrong_comments = 1
864
865The ColdFusion syntax file is based on the HTML syntax file.
866
867
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000868CSH *csh.vim* *ft-csh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000869
870This covers the shell named "csh". Note that on some systems tcsh is actually
871used.
872
873Detecting whether a file is csh or tcsh is notoriously hard. Some systems
874symlink /bin/csh to /bin/tcsh, making it almost impossible to distinguish
875between csh and tcsh. In case VIM guesses wrong you can set the
Bram Moolenaar97293012011-07-18 19:40:27 +0200876"filetype_csh" variable. For using csh: *g:filetype_csh*
877>
878 :let g:filetype_csh = "csh"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000879
880For using tcsh: >
881
Bram Moolenaar97293012011-07-18 19:40:27 +0200882 :let g:filetype_csh = "tcsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000883
884Any script with a tcsh extension or a standard tcsh filename (.tcshrc,
885tcsh.tcshrc, tcsh.login) will have filetype tcsh. All other tcsh/csh scripts
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000886will be classified as tcsh, UNLESS the "filetype_csh" variable exists. If the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000887"filetype_csh" variable exists, the filetype will be set to the value of the
888variable.
889
890
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000891CYNLIB *cynlib.vim* *ft-cynlib-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000892
893Cynlib files are C++ files that use the Cynlib class library to enable
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000894hardware modelling and simulation using C++. Typically Cynlib files have a .cc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000895or a .cpp extension, which makes it very difficult to distinguish them from a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000896normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000897line to your .vimrc file: >
898
899 :let cynlib_cyntax_for_cc=1
900
901Similarly for cpp files (this extension is only usually used in Windows) >
902
903 :let cynlib_cyntax_for_cpp=1
904
905To disable these again, use this: >
906
907 :unlet cynlib_cyntax_for_cc
908 :unlet cynlib_cyntax_for_cpp
909<
910
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000911CWEB *cweb.vim* *ft-cweb-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000912
913Files matching "*.w" could be Progress or cweb. If the automatic detection
914doesn't work for you, or you don't edit Progress at all, use this in your
915startup vimrc: >
916 :let filetype_w = "cweb"
917
918
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000919DESKTOP *desktop.vim* *ft-desktop-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920
921Primary goal of this syntax file is to highlight .desktop and .directory files
Bram Moolenaara17d4c12010-05-30 18:30:36 +0200922according to freedesktop.org standard:
923http://standards.freedesktop.org/desktop-entry-spec/latest/
Bram Moolenaar071d4272004-06-13 20:20:40 +0000924But actually almost none implements this standard fully. Thus it will
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000925highlight all Unix ini files. But you can force strict highlighting according
Bram Moolenaar071d4272004-06-13 20:20:40 +0000926to standard by placing this in your vimrc file: >
927 :let enforce_freedesktop_standard = 1
928
929
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000930DIRCOLORS *dircolors.vim* *ft-dircolors-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000931
932The dircolors utility highlighting definition has one option. It exists to
933provide compatibility with the Slackware GNU/Linux distributions version of
934the command. It adds a few keywords that are generally ignored by most
935versions. On Slackware systems, however, the utility accepts the keywords and
936uses them for processing. To enable the Slackware keywords add the following
937line to your startup file: >
938 let dircolors_is_slackware = 1
939
940
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000941DOCBOOK *docbk.vim* *ft-docbk-syntax* *docbook*
Bram Moolenaar81af9252010-12-10 20:35:50 +0100942DOCBOOK XML *docbkxml.vim* *ft-docbkxml-syntax*
943DOCBOOK SGML *docbksgml.vim* *ft-docbksgml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000944
945There are two types of DocBook files: SGML and XML. To specify what type you
946are using the "b:docbk_type" variable should be set. Vim does this for you
947automatically if it can recognize the type. When Vim can't guess it the type
948defaults to XML.
949You can set the type manually: >
950 :let docbk_type = "sgml"
951or: >
952 :let docbk_type = "xml"
953You need to do this before loading the syntax file, which is complicated.
954Simpler is setting the filetype to "docbkxml" or "docbksgml": >
955 :set filetype=docbksgml
956or: >
957 :set filetype=docbkxml
958
959
Bram Moolenaarda2303d2005-08-30 21:55:26 +0000960DOSBATCH *dosbatch.vim* *ft-dosbatch-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961
962There is one option with highlighting DOS batch files. This covers new
963extensions to the Command Interpreter introduced with Windows 2000 and
964is controlled by the variable dosbatch_cmdextversion. For Windows NT
965this should have the value 1, and for Windows 2000 it should be 2.
966Select the version you want with the following line: >
967
Bram Moolenaar8299df92004-07-10 09:47:34 +0000968 :let dosbatch_cmdextversion = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000969
970If this variable is not defined it defaults to a value of 2 to support
971Windows 2000.
972
Bram Moolenaar8299df92004-07-10 09:47:34 +0000973A second option covers whether *.btm files should be detected as type
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000974"dosbatch" (MS-DOS batch files) or type "btm" (4DOS batch files). The latter
975is used by default. You may select the former with the following line: >
Bram Moolenaar8299df92004-07-10 09:47:34 +0000976
977 :let g:dosbatch_syntax_for_btm = 1
978
979If this variable is undefined or zero, btm syntax is selected.
980
981
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000982DOXYGEN *doxygen.vim* *doxygen-syntax*
983
984Doxygen generates code documentation using a special documentation format
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000985(similar to Javadoc). This syntax script adds doxygen highlighting to c, cpp,
986idl and php files, and should also work with java.
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000987
Bram Moolenaar25394022007-05-10 19:06:20 +0000988There are a few of ways to turn on doxygen formatting. It can be done
989explicitly or in a modeline by appending '.doxygen' to the syntax of the file.
990Example: >
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000991 :set syntax=c.doxygen
992or >
993 // vim:syntax=c.doxygen
994
Bram Moolenaar5dc62522012-02-13 00:05:22 +0100995It can also be done automatically for C, C++, C#, IDL and PHP files by setting
996the global or buffer-local variable load_doxygen_syntax. This is done by
997adding the following to your .vimrc. >
Bram Moolenaar8cacf352006-04-15 20:27:24 +0000998 :let g:load_doxygen_syntax=1
999
Bram Moolenaar06b5d512010-05-22 15:37:44 +02001000There are a couple of variables that have an effect on syntax highlighting, and
Bram Moolenaar8cacf352006-04-15 20:27:24 +00001001are to do with non-standard highlighting options.
1002
1003Variable Default Effect ~
1004g:doxygen_enhanced_color
1005g:doxygen_enhanced_colour 0 Use non-standard highlighting for
1006 doxygen comments.
1007
1008doxygen_my_rendering 0 Disable rendering of HTML bold, italic
1009 and html_my_rendering underline.
1010
1011doxygen_javadoc_autobrief 1 Set to 0 to disable javadoc autobrief
1012 colour highlighting.
1013
1014doxygen_end_punctuation '[.]' Set to regexp match for the ending
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00001015 punctuation of brief
Bram Moolenaar8cacf352006-04-15 20:27:24 +00001016
1017There are also some hilight groups worth mentioning as they can be useful in
1018configuration.
1019
1020Highlight Effect ~
1021doxygenErrorComment The colour of an end-comment when missing
1022 punctuation in a code, verbatim or dot section
1023doxygenLinkError The colour of an end-comment when missing the
1024 \endlink from a \link section.
1025
Bram Moolenaar071d4272004-06-13 20:20:40 +00001026
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001027DTD *dtd.vim* *ft-dtd-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001029The DTD syntax highlighting is case sensitive by default. To disable
Bram Moolenaar071d4272004-06-13 20:20:40 +00001030case-sensitive highlighting, add the following line to your startup file: >
1031
1032 :let dtd_ignore_case=1
1033
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001034The DTD syntax file will highlight unknown tags as errors. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035this is annoying, it can be turned off by setting: >
1036
1037 :let dtd_no_tag_errors=1
1038
1039before sourcing the dtd.vim syntax file.
1040Parameter entity names are highlighted in the definition using the
1041'Type' highlighting group and 'Comment' for punctuation and '%'.
1042Parameter entity instances are highlighted using the 'Constant'
1043highlighting group and the 'Type' highlighting group for the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001044delimiters % and ;. This can be turned off by setting: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045
1046 :let dtd_no_param_entities=1
1047
1048The DTD syntax file is also included by xml.vim to highlight included dtd's.
1049
1050
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001051EIFFEL *eiffel.vim* *ft-eiffel-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052
1053While Eiffel is not case-sensitive, its style guidelines are, and the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001054syntax highlighting file encourages their use. This also allows to
1055highlight class names differently. If you want to disable case-sensitive
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056highlighting, add the following line to your startup file: >
1057
1058 :let eiffel_ignore_case=1
1059
1060Case still matters for class names and TODO marks in comments.
1061
1062Conversely, for even stricter checks, add one of the following lines: >
1063
1064 :let eiffel_strict=1
1065 :let eiffel_pedantic=1
1066
1067Setting eiffel_strict will only catch improper capitalization for the
1068five predefined words "Current", "Void", "Result", "Precursor", and
1069"NONE", to warn against their accidental use as feature or class names.
1070
1071Setting eiffel_pedantic will enforce adherence to the Eiffel style
1072guidelines fairly rigorously (like arbitrary mixes of upper- and
1073lowercase letters as well as outdated ways to capitalize keywords).
1074
1075If you want to use the lower-case version of "Current", "Void",
1076"Result", and "Precursor", you can use >
1077
1078 :let eiffel_lower_case_predef=1
1079
1080instead of completely turning case-sensitive highlighting off.
1081
1082Support for ISE's proposed new creation syntax that is already
1083experimentally handled by some compilers can be enabled by: >
1084
1085 :let eiffel_ise=1
1086
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001087Finally, some vendors support hexadecimal constants. To handle them, add >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001088
1089 :let eiffel_hex_constants=1
1090
1091to your startup file.
1092
1093
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001094ERLANG *erlang.vim* *ft-erlang-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095
1096The erlang highlighting supports Erlang (ERicsson LANGuage).
1097Erlang is case sensitive and default extension is ".erl".
1098
1099If you want to disable keywords highlighting, put in your .vimrc: >
1100 :let erlang_keywords = 1
1101If you want to disable built-in-functions highlighting, put in your
1102.vimrc file: >
1103 :let erlang_functions = 1
1104If you want to disable special characters highlighting, put in
1105your .vimrc: >
1106 :let erlang_characters = 1
1107
1108
Bram Moolenaard68071d2006-05-02 22:08:30 +00001109FLEXWIKI *flexwiki.vim* *ft-flexwiki-syntax*
1110
1111FlexWiki is an ASP.NET-based wiki package available at http://www.flexwiki.com
Bram Moolenaar446beb42011-05-10 17:18:44 +02001112NOTE: this site currently doesn't work, on Wikipedia is mentioned that
1113development stopped in 2009.
Bram Moolenaard68071d2006-05-02 22:08:30 +00001114
1115Syntax highlighting is available for the most common elements of FlexWiki
1116syntax. The associated ftplugin script sets some buffer-local options to make
1117editing FlexWiki pages more convenient. FlexWiki considers a newline as the
1118start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length),
1119'wrap' (wrap long lines instead of using horizontal scrolling), 'linebreak'
1120(to wrap at a character in 'breakat' instead of at the last char on screen),
1121and so on. It also includes some keymaps that are disabled by default.
1122
1123If you want to enable the keymaps that make "j" and "k" and the cursor keys
1124move up and down by display lines, add this to your .vimrc: >
1125 :let flexwiki_maps = 1
1126
1127
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001128FORM *form.vim* *ft-form-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129
1130The coloring scheme for syntax elements in the FORM file uses the default
1131modes Conditional, Number, Statement, Comment, PreProc, Type, and String,
Bram Moolenaardd2a0d82007-05-12 15:07:00 +00001132following the language specifications in 'Symbolic Manipulation with FORM' by
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133J.A.M. Vermaseren, CAN, Netherlands, 1991.
1134
1135If you want include your own changes to the default colors, you have to
1136redefine the following syntax groups:
1137
1138 - formConditional
1139 - formNumber
1140 - formStatement
1141 - formHeaderStatement
1142 - formComment
1143 - formPreProc
1144 - formDirective
1145 - formType
1146 - formString
1147
1148Note that the form.vim syntax file implements FORM preprocessor commands and
1149directives per default in the same syntax group.
1150
1151A predefined enhanced color mode for FORM is available to distinguish between
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001152header statements and statements in the body of a FORM program. To activate
Bram Moolenaar071d4272004-06-13 20:20:40 +00001153this mode define the following variable in your vimrc file >
1154
1155 :let form_enhanced_color=1
1156
1157The enhanced mode also takes advantage of additional color features for a dark
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001158gvim display. Here, statements are colored LightYellow instead of Yellow, and
Bram Moolenaar071d4272004-06-13 20:20:40 +00001159conditionals are LightBlue for better distinction.
1160
1161
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001162FORTRAN *fortran.vim* *ft-fortran-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001163
1164Default highlighting and dialect ~
Bram Moolenaar6ee8d892012-01-10 14:55:01 +01001165Highlighting appropriate for Fortran 2008 is used by default. This choice
1166should be appropriate for most users most of the time because Fortran 2008 is
1167almost a superset of previous versions (Fortran 2003, 95, 90, and 77).
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168
1169Fortran source code form ~
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001170Fortran code can be in either fixed or free source form. Note that the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171syntax highlighting will not be correct if the form is incorrectly set.
1172
1173When you create a new fortran file, the syntax script assumes fixed source
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001174form. If you always use free source form, then >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 :let fortran_free_source=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001176in your .vimrc prior to the :syntax on command. If you always use fixed source
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177form, then >
1178 :let fortran_fixed_source=1
1179in your .vimrc prior to the :syntax on command.
1180
1181If the form of the source code depends upon the file extension, then it is
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001182most convenient to set fortran_free_source 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 free source form and the
1185rest in fixed source form, add the following code to your ftplugin file >
1186 let s:extfname = expand("%:e")
1187 if s:extfname ==? "f90"
1188 let fortran_free_source=1
1189 unlet! fortran_fixed_source
1190 else
1191 let fortran_fixed_source=1
1192 unlet! fortran_free_source
1193 endif
1194Note that this will work only if the "filetype plugin indent on" command
1195precedes the "syntax on" command in your .vimrc file.
1196
1197When you edit an existing fortran file, the syntax script will assume free
1198source form if the fortran_free_source variable has been set, and assumes
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001199fixed source form if the fortran_fixed_source variable has been set. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200neither of these variables have been set, the syntax script attempts to
1201determine which source form has been used by examining the first five columns
Bram Moolenaar910f66f2006-04-05 20:41:53 +00001202of the first 250 lines of your file. If no signs of free source form are
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001203detected, then the file is assumed to be in fixed source form. The algorithm
1204should work in the vast majority of cases. In some cases, such as a file that
Bram Moolenaar910f66f2006-04-05 20:41:53 +00001205begins with 250 or more full-line comments, the script may incorrectly decide
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001206that the fortran code is in fixed form. If that happens, just add a
Bram Moolenaar071d4272004-06-13 20:20:40 +00001207non-comment statement beginning anywhere in the first five columns of the
1208first twenty five lines, save (:w) and then reload (:e!) the file.
1209
1210Tabs in fortran files ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001211Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212fixed format fortran source code which requires fixed column boundaries.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001213Therefore, tabs are marked as errors. Nevertheless, some programmers like
1214using tabs. If your fortran files contain tabs, then you should set the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215variable fortran_have_tabs in your .vimrc with a command such as >
1216 :let fortran_have_tabs=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001217placed prior to the :syntax on command. Unfortunately, the use of tabs will
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218mean that the syntax file will not be able to detect incorrect margins.
1219
1220Syntax folding of fortran files ~
1221If you wish to use foldmethod=syntax, then you must first set the variable
1222fortran_fold with a command such as >
1223 :let fortran_fold=1
1224to instruct the syntax script to define fold regions for program units, that
1225is main programs starting with a program statement, subroutines, function
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001226subprograms, block data subprograms, interface blocks, and modules. If you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001227also set the variable fortran_fold_conditionals with a command such as >
1228 :let fortran_fold_conditionals=1
1229then fold regions will also be defined for do loops, if blocks, and select
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001230case constructs. If you also set the variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00001231fortran_fold_multilinecomments with a command such as >
1232 :let fortran_fold_multilinecomments=1
1233then fold regions will also be defined for three or more consecutive comment
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001234lines. Note that defining fold regions can be slow for large files.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001235
1236If fortran_fold, and possibly fortran_fold_conditionals and/or
1237fortran_fold_multilinecomments, have been set, then vim will fold your file if
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001238you set foldmethod=syntax. Comments or blank lines placed between two program
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239units are not folded because they are seen as not belonging to any program
1240unit.
1241
1242More precise fortran syntax ~
1243If you set the variable fortran_more_precise with a command such as >
1244 :let fortran_more_precise=1
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001245then the syntax coloring will be more precise but slower. In particular,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001246statement labels used in do, goto and arithmetic if statements will be
1247recognized, as will construct names at the end of a do, if, select or forall
1248construct.
1249
1250Non-default fortran dialects ~
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001251The syntax script supports two Fortran dialects: f08 and F. You will probably
1252find the default highlighting (f08) satisfactory. A few legacy constructs
1253deleted or declared obsolescent in the 2008 standard are highlighted as todo
1254items.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001255
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001256If you use F, the advantage of setting the dialect appropriately is that
1257other legacy features excluded from F will be highlighted as todo items and
1258that free source form will be assumed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001260The dialect can be selected in various ways. If all your fortran files use
1261the same dialect, set the global variable fortran_dialect in your .vimrc prior
1262to your syntax on statement. The case-sensitive, permissible values of
1263fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
1264ignored.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001266If the dialect depends upon the file extension, then it is most convenient to
1267set a buffer-local variable in a ftplugin file. For more information on
1268ftplugin files, see |ftplugin|. For example, if all your fortran files with
1269an .f90 extension are written in the F subset, your ftplugin file should
1270contain the code >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271 let s:extfname = expand("%:e")
1272 if s:extfname ==? "f90"
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001273 let b:fortran_dialect="F"
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 else
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001275 unlet! b:fortran_dialect
Bram Moolenaar071d4272004-06-13 20:20:40 +00001276 endif
1277Note that this will work only if the "filetype plugin indent on" command
1278precedes the "syntax on" command in your .vimrc file.
1279
1280Finer control is necessary if the file extension does not uniquely identify
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001281the dialect. You can override the default dialect, on a file-by-file basis,
1282by including a comment with the directive "fortran_dialect=xx" (where xx=F or
1283f08) in one of the first three lines in your file. For example, your older .f
1284files may be legacy code but your newer ones may be F codes, and you would
1285identify the latter by including in the first three lines of those files a
1286Fortran comment of the form >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 ! fortran_dialect=F
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001288
1289For previous versions of the syntax, you may have set fortran_dialect to the
1290now-obsolete values "f77", "f90", "f95", or "elf". Such settings will be
1291silently handled as "f08". Users of "elf" may wish to experiment with "F"
1292instead.
1293
1294The syntax/fortran.vim script contains embedded comments that tell you how to
1295comment and/or uncomment some lines to (a) activate recognition of some
1296non-standard, vendor-supplied intrinsics and (b) to prevent features deleted
1297or declared obsolescent in the 2008 standard from being highlighted as todo
1298items.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001299
1300Limitations ~
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001301Parenthesis checking does not catch too few closing parentheses. Hollerith
1302strings are not recognized. Some keywords may be highlighted incorrectly
Bram Moolenaar071d4272004-06-13 20:20:40 +00001303because Fortran90 has no reserved words.
1304
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001305For further information related to fortran, see |ft-fortran-indent| and
1306|ft-fortran-plugin|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001307
1308
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001309FVWM CONFIGURATION FILES *fvwm.vim* *ft-fvwm-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001310
1311In order for Vim to recognize Fvwm configuration files that do not match
1312the patterns *fvwmrc* or *fvwm2rc* , you must put additional patterns
1313appropriate to your system in your myfiletypes.vim file. For these
1314patterns, you must set the variable "b:fvwm_version" to the major version
1315number of Fvwm, and the 'filetype' option to fvwm.
1316
1317For example, to make Vim identify all files in /etc/X11/fvwm2/
1318as Fvwm2 configuration files, add the following: >
1319
1320 :au! BufNewFile,BufRead /etc/X11/fvwm2/* let b:fvwm_version = 2 |
1321 \ set filetype=fvwm
1322
1323If you'd like Vim to highlight all valid color names, tell it where to
1324find the color database (rgb.txt) on your system. Do this by setting
1325"rgb_file" to its location. Assuming your color database is located
1326in /usr/X11/lib/X11/, you should add the line >
1327
1328 :let rgb_file = "/usr/X11/lib/X11/rgb.txt"
1329
1330to your .vimrc file.
1331
1332
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001333GSP *gsp.vim* *ft-gsp-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001334
1335The default coloring style for GSP pages is defined by |html.vim|, and
1336the coloring for java code (within java tags or inline between backticks)
1337is defined by |java.vim|. The following HTML groups defined in |html.vim|
1338are redefined to incorporate and highlight inline java code:
1339
1340 htmlString
1341 htmlValue
1342 htmlEndTag
1343 htmlTag
1344 htmlTagN
1345
1346Highlighting should look fine most of the places where you'd see inline
1347java code, but in some special cases it may not. To add another HTML
1348group where you will have inline java code where it does not highlight
1349correctly, just copy the line you want from |html.vim| and add gspJava
1350to the contains clause.
1351
1352The backticks for inline java are highlighted according to the htmlError
1353group to make them easier to see.
1354
1355
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001356GROFF *groff.vim* *ft-groff-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357
1358The groff syntax file is a wrapper for |nroff.vim|, see the notes
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001359under that heading for examples of use and configuration. The purpose
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360of this wrapper is to set up groff syntax extensions by setting the
1361filetype from a |modeline| or in a personal filetype definitions file
1362(see |filetype.txt|).
1363
1364
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001365HASKELL *haskell.vim* *lhaskell.vim* *ft-haskell-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001366
1367The Haskell syntax files support plain Haskell code as well as literate
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001368Haskell code, the latter in both Bird style and TeX style. The Haskell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369syntax highlighting will also highlight C preprocessor directives.
1370
1371If you want to highlight delimiter characters (useful if you have a
1372light-coloured background), add to your .vimrc: >
1373 :let hs_highlight_delimiters = 1
1374To treat True and False as keywords as opposed to ordinary identifiers,
1375add: >
1376 :let hs_highlight_boolean = 1
1377To also treat the names of primitive types as keywords: >
1378 :let hs_highlight_types = 1
1379And to treat the names of even more relatively common types as keywords: >
1380 :let hs_highlight_more_types = 1
1381If you want to highlight the names of debugging functions, put in
1382your .vimrc: >
1383 :let hs_highlight_debug = 1
1384
1385The Haskell syntax highlighting also highlights C preprocessor
1386directives, and flags lines that start with # but are not valid
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001387directives as erroneous. This interferes with Haskell's syntax for
1388operators, as they may start with #. If you want to highlight those
Bram Moolenaar071d4272004-06-13 20:20:40 +00001389as operators as opposed to errors, put in your .vimrc: >
1390 :let hs_allow_hash_operator = 1
1391
1392The syntax highlighting for literate Haskell code will try to
1393automatically guess whether your literate Haskell code contains
1394TeX markup or not, and correspondingly highlight TeX constructs
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001395or nothing at all. You can override this globally by putting
Bram Moolenaar071d4272004-06-13 20:20:40 +00001396in your .vimrc >
1397 :let lhs_markup = none
1398for no highlighting at all, or >
1399 :let lhs_markup = tex
1400to force the highlighting to always try to highlight TeX markup.
1401For more flexibility, you may also use buffer local versions of
1402this variable, so e.g. >
1403 :let b:lhs_markup = tex
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001404will force TeX highlighting for a particular buffer. It has to be
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405set before turning syntax highlighting on for the buffer or
1406loading a file.
1407
1408
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001409HTML *html.vim* *ft-html-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410
1411The coloring scheme for tags in the HTML file works as follows.
1412
1413The <> of opening tags are colored differently than the </> of a closing tag.
1414This is on purpose! For opening tags the 'Function' color is used, while for
1415closing tags the 'Type' color is used (See syntax.vim to check how those are
1416defined for you)
1417
1418Known tag names are colored the same way as statements in C. Unknown tag
1419names are colored with the same color as the <> or </> respectively which
1420makes it easy to spot errors
1421
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001422Note that the same is true for argument (or attribute) names. Known attribute
Bram Moolenaar071d4272004-06-13 20:20:40 +00001423names are colored differently than unknown ones.
1424
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001425Some HTML tags are used to change the rendering of text. The following tags
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426are recognized by the html.vim syntax coloring file and change the way normal
1427text is shown: <B> <I> <U> <EM> <STRONG> (<EM> is used as an alias for <I>,
1428while <STRONG> as an alias for <B>), <H1> - <H6>, <HEAD>, <TITLE> and <A>, but
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001429only if used as a link (that is, it must include a href as in
Bram Moolenaar25394022007-05-10 19:06:20 +00001430<A href="somefile.html">).
Bram Moolenaar071d4272004-06-13 20:20:40 +00001431
1432If you want to change how such text is rendered, you must redefine the
1433following syntax groups:
1434
1435 - htmlBold
1436 - htmlBoldUnderline
1437 - htmlBoldUnderlineItalic
1438 - htmlUnderline
1439 - htmlUnderlineItalic
1440 - htmlItalic
1441 - htmlTitle for titles
1442 - htmlH1 - htmlH6 for headings
1443
1444To make this redefinition work you must redefine them all with the exception
1445of the last two (htmlTitle and htmlH[1-6], which are optional) and define the
1446following variable in your vimrc (this is due to the order in which the files
1447are read during initialization) >
1448 :let html_my_rendering=1
1449
1450If you'd like to see an example download mysyntax.vim at
1451http://www.fleiner.com/vim/download.html
1452
1453You can also disable this rendering by adding the following line to your
1454vimrc file: >
1455 :let html_no_rendering=1
1456
1457HTML comments are rather special (see an HTML reference document for the
1458details), and the syntax coloring scheme will highlight all errors.
1459However, if you prefer to use the wrong style (starts with <!-- and
1460ends with --!>) you can define >
1461 :let html_wrong_comments=1
1462
1463JavaScript and Visual Basic embedded inside HTML documents are highlighted as
1464'Special' with statements, comments, strings and so on colored as in standard
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001465programming languages. Note that only JavaScript and Visual Basic are currently
Bram Moolenaar071d4272004-06-13 20:20:40 +00001466supported, no other scripting language has been added yet.
1467
1468Embedded and inlined cascading style sheets (CSS) are highlighted too.
1469
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001470There are several html preprocessor languages out there. html.vim has been
1471written such that it should be trivial to include it. To do so add the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001472following two lines to the syntax coloring file for that language
1473(the example comes from the asp.vim file):
1474
1475 runtime! syntax/html.vim
1476 syn cluster htmlPreproc add=asp
1477
1478Now you just need to make sure that you add all regions that contain
1479the preprocessor language to the cluster htmlPreproc.
1480
1481
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001482HTML/OS (by Aestiva) *htmlos.vim* *ft-htmlos-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001483
1484The coloring scheme for HTML/OS works as follows:
1485
1486Functions and variable names are the same color by default, because VIM
1487doesn't specify different colors for Functions and Identifiers. To change
1488this (which is recommended if you want function names to be recognizable in a
1489different color) you need to add the following line to either your ~/.vimrc: >
1490 :hi Function term=underline cterm=bold ctermfg=LightGray
1491
1492Of course, the ctermfg can be a different color if you choose.
1493
1494Another issues that HTML/OS runs into is that there is no special filetype to
1495signify that it is a file with HTML/OS coding. You can change this by opening
1496a file and turning on HTML/OS syntax by doing the following: >
1497 :set syntax=htmlos
1498
1499Lastly, it should be noted that the opening and closing characters to begin a
1500block of HTML/OS code can either be << or [[ and >> or ]], respectively.
1501
1502
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001503IA64 *ia64.vim* *intel-itanium* *ft-ia64-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001504
1505Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
1506how to recognize this filetype.
1507
1508To have *.inc files be recognized as IA64, add this to your .vimrc file: >
1509 :let g:filetype_inc = "ia64"
1510
1511
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001512INFORM *inform.vim* *ft-inform-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001513
1514Inform highlighting includes symbols provided by the Inform Library, as
1515most programs make extensive use of it. If do not wish Library symbols
1516to be highlighted add this to your vim startup: >
1517 :let inform_highlight_simple=1
1518
1519By default it is assumed that Inform programs are Z-machine targeted,
1520and highlights Z-machine assembly language symbols appropriately. If
1521you intend your program to be targeted to a Glulx/Glk environment you
1522need to add this to your startup sequence: >
1523 :let inform_highlight_glulx=1
1524
1525This will highlight Glulx opcodes instead, and also adds glk() to the
1526set of highlighted system functions.
1527
1528The Inform compiler will flag certain obsolete keywords as errors when
1529it encounters them. These keywords are normally highlighted as errors
1530by Vim. To prevent such error highlighting, you must add this to your
1531startup sequence: >
1532 :let inform_suppress_obsolete=1
1533
1534By default, the language features highlighted conform to Compiler
1535version 6.30 and Library version 6.11. If you are using an older
1536Inform development environment, you may with to add this to your
1537startup sequence: >
1538 :let inform_highlight_old=1
1539
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001540IDL *idl.vim* *idl-syntax*
1541
1542IDL (Interface Definition Language) files are used to define RPC calls. In
1543Microsoft land, this is also used for defining COM interfaces and calls.
1544
1545IDL's structure is simple enough to permit a full grammar based approach to
1546rather than using a few heuristics. The result is large and somewhat
Bram Moolenaar25394022007-05-10 19:06:20 +00001547repetitive but seems to work.
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001548
1549There are some Microsoft extensions to idl files that are here. Some of them
1550are disabled by defining idl_no_ms_extensions.
1551
1552The more complex of the extensions are disabled by defining idl_no_extensions.
1553
1554Variable Effect ~
1555
1556idl_no_ms_extensions Disable some of the Microsoft specific
1557 extensions
1558idl_no_extensions Disable complex extensions
1559idlsyntax_showerror Show IDL errors (can be rather intrusive, but
1560 quite helpful)
1561idlsyntax_showerror_soft Use softer colours by default for errors
1562
Bram Moolenaar071d4272004-06-13 20:20:40 +00001563
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001564JAVA *java.vim* *ft-java-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001565
1566The java.vim syntax highlighting file offers several options:
1567
1568In Java 1.0.2 it was never possible to have braces inside parens, so this was
1569flagged as an error. Since Java 1.1 this is possible (with anonymous
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001570classes), and therefore is no longer marked as an error. If you prefer the old
Bram Moolenaar071d4272004-06-13 20:20:40 +00001571way, put the following line into your vim startup file: >
1572 :let java_mark_braces_in_parens_as_errors=1
1573
1574All identifiers in java.lang.* are always visible in all classes. To
1575highlight them use: >
1576 :let java_highlight_java_lang_ids=1
1577
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001578You can also highlight identifiers of most standard Java packages if you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001579download the javaid.vim script at http://www.fleiner.com/vim/download.html.
1580If you prefer to only highlight identifiers of a certain package, say java.io
1581use the following: >
1582 :let java_highlight_java_io=1
1583Check the javaid.vim file for a list of all the packages that are supported.
1584
1585Function names are not highlighted, as the way to find functions depends on
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001586how you write Java code. The syntax file knows two possible ways to highlight
Bram Moolenaar071d4272004-06-13 20:20:40 +00001587functions:
1588
1589If you write function declarations that are always indented by either
1590a tab, 8 spaces or 2 spaces you may want to set >
1591 :let java_highlight_functions="indent"
1592However, if you follow the Java guidelines about how functions and classes are
1593supposed to be named (with respect to upper and lowercase), use >
1594 :let java_highlight_functions="style"
1595If both options do not work for you, but you would still want function
1596declarations to be highlighted create your own definitions by changing the
1597definitions in java.vim or by creating your own java.vim which includes the
1598original one and then adds the code to highlight functions.
1599
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001600In Java 1.1 the functions System.out.println() and System.err.println() should
Bram Moolenaared203462004-06-16 11:19:22 +00001601only be used for debugging. Therefore it is possible to highlight debugging
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001602statements differently. To do this you must add the following definition in
Bram Moolenaar071d4272004-06-13 20:20:40 +00001603your startup file: >
1604 :let java_highlight_debug=1
1605The result will be that those statements are highlighted as 'Special'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001606characters. If you prefer to have them highlighted differently you must define
Bram Moolenaar071d4272004-06-13 20:20:40 +00001607new highlightings for the following groups.:
1608 Debug, DebugSpecial, DebugString, DebugBoolean, DebugType
1609which are used for the statement itself, special characters used in debug
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001610strings, strings, boolean constants and types (this, super) respectively. I
Bram Moolenaar071d4272004-06-13 20:20:40 +00001611have opted to chose another background for those statements.
1612
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001613Javadoc is a program that takes special comments out of Java program files and
1614creates HTML pages. The standard configuration will highlight this HTML code
1615similarly to HTML files (see |html.vim|). You can even add Javascript
1616and CSS inside this code (see below). There are four differences however:
Bram Moolenaar071d4272004-06-13 20:20:40 +00001617 1. The title (all characters up to the first '.' which is followed by
1618 some white space or up to the first '@') is colored differently (to change
1619 the color change the group CommentTitle).
1620 2. The text is colored as 'Comment'.
1621 3. HTML comments are colored as 'Special'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001622 4. The special Javadoc tags (@see, @param, ...) are highlighted as specials
Bram Moolenaar071d4272004-06-13 20:20:40 +00001623 and the argument (for @see, @param, @exception) as Function.
1624To turn this feature off add the following line to your startup file: >
1625 :let java_ignore_javadoc=1
1626
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001627If you use the special Javadoc comment highlighting described above you
1628can also turn on special highlighting for Javascript, visual basic
1629scripts and embedded CSS (stylesheets). This makes only sense if you
1630actually have Javadoc comments that include either Javascript or embedded
1631CSS. The options to use are >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001632 :let java_javascript=1
1633 :let java_css=1
1634 :let java_vb=1
1635
1636In order to highlight nested parens with different colors define colors
1637for javaParen, javaParen1 and javaParen2, for example with >
1638 :hi link javaParen Comment
1639or >
1640 :hi javaParen ctermfg=blue guifg=#0000ff
1641
1642If you notice highlighting errors while scrolling backwards, which are fixed
1643when redrawing with CTRL-L, try setting the "java_minlines" internal variable
1644to a larger number: >
1645 :let java_minlines = 50
1646This will make the syntax synchronization start 50 lines before the first
1647displayed line. The default value is 10. The disadvantage of using a larger
1648number is that redrawing can become slow.
1649
1650
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001651LACE *lace.vim* *ft-lace-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001652
1653Lace (Language for Assembly of Classes in Eiffel) is case insensitive, but the
1654style guide lines are not. If you prefer case insensitive highlighting, just
1655define the vim variable 'lace_case_insensitive' in your startup file: >
1656 :let lace_case_insensitive=1
1657
1658
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001659LEX *lex.vim* *ft-lex-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001660
1661Lex uses brute-force synchronizing as the "^%%$" section delimiter
1662gives no clue as to what section follows. Consequently, the value for >
1663 :syn sync minlines=300
1664may be changed by the user if s/he is experiencing synchronization
1665difficulties (such as may happen with large lex files).
1666
1667
Bram Moolenaar6fc45b52010-07-25 17:42:45 +02001668LIFELINES *lifelines.vim* *ft-lifelines-syntax*
1669
1670To highlight deprecated functions as errors, add in your .vimrc: >
1671
1672 :let g:lifelines_deprecated = 1
1673<
1674
Bram Moolenaara5fac542005-10-12 20:58:49 +00001675LISP *lisp.vim* *ft-lisp-syntax*
1676
1677The lisp syntax highlighting provides two options: >
1678
1679 g:lisp_instring : if it exists, then "(...)" strings are highlighted
1680 as if the contents of the string were lisp.
1681 Useful for AutoLisp.
1682 g:lisp_rainbow : if it exists and is nonzero, then differing levels
1683 of parenthesization will receive different
1684 highlighting.
1685<
1686The g:lisp_rainbow option provides 10 levels of individual colorization for
1687the parentheses and backquoted parentheses. Because of the quantity of
1688colorization levels, unlike non-rainbow highlighting, the rainbow mode
1689specifies its highlighting using ctermfg and guifg, thereby bypassing the
1690usual colorscheme control using standard highlighting groups. The actual
1691highlighting used depends on the dark/bright setting (see |'bg'|).
1692
1693
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001694LITE *lite.vim* *ft-lite-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695
1696There are two options for the lite syntax highlighting.
1697
1698If you like SQL syntax highlighting inside Strings, use this: >
1699
1700 :let lite_sql_query = 1
1701
1702For syncing, minlines defaults to 100. If you prefer another value, you can
1703set "lite_minlines" to the value you desire. Example: >
1704
1705 :let lite_minlines = 200
1706
1707
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001708LPC *lpc.vim* *ft-lpc-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001709
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001710LPC stands for a simple, memory-efficient language: Lars Pensj| C. The
Bram Moolenaar071d4272004-06-13 20:20:40 +00001711file name of LPC is usually *.c. Recognizing these files as LPC would bother
1712users writing only C programs. If you want to use LPC syntax in Vim, you
1713should set a variable in your .vimrc file: >
1714
1715 :let lpc_syntax_for_c = 1
1716
1717If it doesn't work properly for some particular C or LPC files, use a
1718modeline. For a LPC file:
1719
1720 // vim:set ft=lpc:
1721
1722For a C file that is recognized as LPC:
1723
1724 // vim:set ft=c:
1725
1726If you don't want to set the variable, use the modeline in EVERY LPC file.
1727
1728There are several implementations for LPC, we intend to support most widely
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001729used ones. Here the default LPC syntax is for MudOS series, for MudOS v22
Bram Moolenaar071d4272004-06-13 20:20:40 +00001730and before, you should turn off the sensible modifiers, and this will also
1731asserts the new efuns after v22 to be invalid, don't set this variable when
1732you are using the latest version of MudOS: >
1733
1734 :let lpc_pre_v22 = 1
1735
1736For LpMud 3.2 series of LPC: >
1737
1738 :let lpc_compat_32 = 1
1739
1740For LPC4 series of LPC: >
1741
1742 :let lpc_use_lpc4_syntax = 1
1743
1744For uLPC series of LPC:
1745uLPC has been developed to Pike, so you should use Pike syntax
1746instead, and the name of your source file should be *.pike
1747
1748
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001749LUA *lua.vim* *ft-lua-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001750
Bram Moolenaar5dc62522012-02-13 00:05:22 +01001751The Lua syntax file can be used for versions 4.0, 5.0, 5.1 and 5.2 (5.2 is
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001752the default). You can select one of these versions using the global variables
1753lua_version and lua_subversion. For example, to activate Lua
Bram Moolenaar5dc62522012-02-13 00:05:22 +010017545.1 syntax highlighting, set the variables like this:
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00001755
1756 :let lua_version = 5
1757 :let lua_subversion = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758
1759
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001760MAIL *mail.vim* *ft-mail.vim*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761
1762Vim highlights all the standard elements of an email (headers, signatures,
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001763quoted text and URLs / email addresses). In keeping with standard conventions,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764signatures begin in a line containing only "--" followed optionally by
1765whitespaces and end with a newline.
1766
1767Vim treats lines beginning with ']', '}', '|', '>' or a word followed by '>'
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001768as quoted text. However Vim highlights headers and signatures in quoted text
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769only if the text is quoted with '>' (optionally followed by one space).
1770
1771By default mail.vim synchronises syntax to 100 lines before the first
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001772displayed line. If you have a slow machine, and generally deal with emails
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773with short headers, you can change this to a smaller value: >
1774
1775 :let mail_minlines = 30
1776
1777
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001778MAKE *make.vim* *ft-make-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001779
1780In makefiles, commands are usually highlighted to make it easy for you to spot
1781errors. However, this may be too much coloring for you. You can turn this
1782feature off by using: >
1783
1784 :let make_no_commands = 1
1785
1786
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001787MAPLE *maple.vim* *ft-maple-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001788
1789Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
1790supports many packages of functions which are selectively loaded by the user.
1791The standard set of packages' functions as supplied in Maple V release 4 may be
1792highlighted at the user's discretion. Users may place in their .vimrc file: >
1793
1794 :let mvpkg_all= 1
1795
1796to get all package functions highlighted, or users may select any subset by
1797choosing a variable/package from the table below and setting that variable to
17981, also in their .vimrc file (prior to sourcing
1799$VIMRUNTIME/syntax/syntax.vim).
1800
1801 Table of Maple V Package Function Selectors >
1802 mv_DEtools mv_genfunc mv_networks mv_process
1803 mv_Galois mv_geometry mv_numapprox mv_simplex
1804 mv_GaussInt mv_grobner mv_numtheory mv_stats
1805 mv_LREtools mv_group mv_orthopoly mv_student
1806 mv_combinat mv_inttrans mv_padic mv_sumtools
1807 mv_combstruct mv_liesymm mv_plots mv_tensor
1808 mv_difforms mv_linalg mv_plottools mv_totorder
1809 mv_finance mv_logic mv_powseries
1810
1811
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001812MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
Bram Moolenaar34cdc3e2005-05-18 22:24:46 +00001813
1814Empty *.m files will automatically be presumed to be Matlab files unless you
1815have the following in your .vimrc: >
1816
1817 let filetype_m = "mma"
1818
1819
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001820MOO *moo.vim* *ft-moo-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001821
1822If you use C-style comments inside expressions and find it mangles your
1823highlighting, you may want to use extended (slow!) matches for C-style
1824comments: >
1825
1826 :let moo_extended_cstyle_comments = 1
1827
1828To disable highlighting of pronoun substitution patterns inside strings: >
1829
1830 :let moo_no_pronoun_sub = 1
1831
1832To disable highlighting of the regular expression operator '%|', and matching
1833'%(' and '%)' inside strings: >
1834
1835 :let moo_no_regexp = 1
1836
1837Unmatched double quotes can be recognized and highlighted as errors: >
1838
1839 :let moo_unmatched_quotes = 1
1840
1841To highlight builtin properties (.name, .location, .programmer etc.): >
1842
1843 :let moo_builtin_properties = 1
1844
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001845Unknown builtin functions can be recognized and highlighted as errors. If you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846use this option, add your own extensions to the mooKnownBuiltinFunction group.
1847To enable this option: >
1848
1849 :let moo_unknown_builtin_functions = 1
1850
1851An example of adding sprintf() to the list of known builtin functions: >
1852
1853 :syn keyword mooKnownBuiltinFunction sprintf contained
1854
1855
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001856MSQL *msql.vim* *ft-msql-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857
1858There are two options for the msql syntax highlighting.
1859
1860If you like SQL syntax highlighting inside Strings, use this: >
1861
1862 :let msql_sql_query = 1
1863
1864For syncing, minlines defaults to 100. If you prefer another value, you can
1865set "msql_minlines" to the value you desire. Example: >
1866
1867 :let msql_minlines = 200
1868
1869
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001870NCF *ncf.vim* *ft-ncf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871
1872There is one option for NCF syntax highlighting.
1873
1874If you want to have unrecognized (by ncf.vim) statements highlighted as
1875errors, use this: >
1876
1877 :let ncf_highlight_unknowns = 1
1878
1879If you don't want to highlight these errors, leave it unset.
1880
1881
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001882NROFF *nroff.vim* *ft-nroff-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001883
1884The nroff syntax file works with AT&T n/troff out of the box. You need to
1885activate the GNU groff extra features included in the syntax file before you
1886can use them.
1887
1888For example, Linux and BSD distributions use groff as their default text
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001889processing package. In order to activate the extra syntax highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +00001890features for groff, add the following option to your start-up files: >
1891
1892 :let b:nroff_is_groff = 1
1893
1894Groff is different from the old AT&T n/troff that you may still find in
1895Solaris. Groff macro and request names can be longer than 2 characters and
1896there are extensions to the language primitives. For example, in AT&T troff
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001897you access the year as a 2-digit number with the request \(yr. In groff you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001898can use the same request, recognized for compatibility, or you can use groff's
1899native syntax, \[yr]. Furthermore, you can use a 4-digit year directly:
1900\[year]. Macro requests can be longer than 2 characters, for example, GNU mm
1901accepts the requests ".VERBON" and ".VERBOFF" for creating verbatim
1902environments.
1903
1904In order to obtain the best formatted output g/troff can give you, you should
1905follow a few simple rules about spacing and punctuation.
1906
19071. Do not leave empty spaces at the end of lines.
1908
19092. Leave one space and one space only after an end-of-sentence period,
1910 exclamation mark, etc.
1911
19123. For reasons stated below, it is best to follow all period marks with a
1913 carriage return.
1914
1915The reason behind these unusual tips is that g/n/troff have a line breaking
1916algorithm that can be easily upset if you don't follow the rules given above.
1917
1918Unlike TeX, troff fills text line-by-line, not paragraph-by-paragraph and,
1919furthermore, it does not have a concept of glue or stretch, all horizontal and
1920vertical space input will be output as is.
1921
1922Therefore, you should be careful about not using more space between sentences
1923than you intend to have in your final document. For this reason, the common
1924practice is to insert a carriage return immediately after all punctuation
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001925marks. If you want to have "even" text in your final processed output, you
Bram Moolenaar071d4272004-06-13 20:20:40 +00001926need to maintaining regular spacing in the input text. To mark both trailing
1927spaces and two or more spaces after a punctuation as an error, use: >
1928
1929 :let nroff_space_errors = 1
1930
1931Another technique to detect extra spacing and other errors that will interfere
1932with the correct typesetting of your file, is to define an eye-catching
1933highlighting definition for the syntax groups "nroffDefinition" and
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001934"nroffDefSpecial" in your configuration files. For example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00001935
1936 hi def nroffDefinition term=italic cterm=italic gui=reverse
1937 hi def nroffDefSpecial term=italic,bold cterm=italic,bold
1938 \ gui=reverse,bold
1939
1940If you want to navigate preprocessor entries in your source file as easily as
1941with section markers, you can activate the following option in your .vimrc
1942file: >
1943
1944 let b:preprocs_as_sections = 1
1945
Bram Moolenaar69a7cb42004-06-20 12:51:53 +00001946As well, the syntax file adds an extra paragraph marker for the extended
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947paragraph macro (.XP) in the ms package.
1948
1949Finally, there is a |groff.vim| syntax file that can be used for enabling
1950groff syntax highlighting either on a file basis or globally by default.
1951
1952
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001953OCAML *ocaml.vim* *ft-ocaml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954
1955The OCaml syntax file handles files having the following prefixes: .ml,
1956.mli, .mll and .mly. By setting the following variable >
1957
1958 :let ocaml_revised = 1
1959
1960you can switch from standard OCaml-syntax to revised syntax as supported
1961by the camlp4 preprocessor. Setting the variable >
1962
1963 :let ocaml_noend_error = 1
1964
1965prevents highlighting of "end" as error, which is useful when sources
1966contain very long structures that Vim does not synchronize anymore.
1967
1968
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001969PAPP *papp.vim* *ft-papp-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001970
1971The PApp syntax file handles .papp files and, to a lesser extend, .pxml
1972and .pxsl files which are all a mixture of perl/xml/html/other using xml
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001973as the top-level file format. By default everything inside phtml or pxml
1974sections is treated as a string with embedded preprocessor commands. If
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975you set the variable: >
1976
1977 :let papp_include_html=1
1978
1979in your startup file it will try to syntax-hilight html code inside phtml
1980sections, but this is relatively slow and much too colourful to be able to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001981edit sensibly. ;)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982
1983The newest version of the papp.vim syntax file can usually be found at
1984http://papp.plan9.de.
1985
1986
Bram Moolenaarda2303d2005-08-30 21:55:26 +00001987PASCAL *pascal.vim* *ft-pascal-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988
1989Files matching "*.p" could be Progress or Pascal. If the automatic detection
1990doesn't work for you, or you don't edit Progress at all, use this in your
1991startup vimrc: >
1992
1993 :let filetype_p = "pascal"
1994
1995The Pascal syntax file has been extended to take into account some extensions
1996provided by Turbo Pascal, Free Pascal Compiler and GNU Pascal Compiler.
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00001997Delphi keywords are also supported. By default, Turbo Pascal 7.0 features are
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998enabled. If you prefer to stick with the standard Pascal keywords, add the
1999following line to your startup file: >
2000
2001 :let pascal_traditional=1
2002
2003To switch on Delphi specific constructions (such as one-line comments,
2004keywords, etc): >
2005
2006 :let pascal_delphi=1
2007
2008
2009The option pascal_symbol_operator controls whether symbol operators such as +,
2010*, .., etc. are displayed using the Operator color or not. To colorize symbol
2011operators, add the following line to your startup file: >
2012
2013 :let pascal_symbol_operator=1
2014
2015Some functions are highlighted by default. To switch it off: >
2016
2017 :let pascal_no_functions=1
2018
Bram Moolenaar996343d2010-07-04 22:20:21 +02002019Furthermore, there are specific variables for some compilers. Besides
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020pascal_delphi, there are pascal_gpc and pascal_fpc. Default extensions try to
2021match Turbo Pascal. >
2022
2023 :let pascal_gpc=1
2024
2025or >
2026
2027 :let pascal_fpc=1
2028
2029To ensure that strings are defined on a single line, you can define the
2030pascal_one_line_string variable. >
2031
2032 :let pascal_one_line_string=1
2033
2034If you dislike <Tab> chars, you can set the pascal_no_tabs variable. Tabs
2035will be highlighted as Error. >
2036
2037 :let pascal_no_tabs=1
2038
2039
2040
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002041PERL *perl.vim* *ft-perl-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042
2043There are a number of possible options to the perl syntax highlighting.
2044
2045If you use POD files or POD segments, you might: >
2046
2047 :let perl_include_pod = 1
2048
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002049The reduce the complexity of parsing (and increase performance) you can switch
2050off two elements in the parsing of variable names and contents. >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002051
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002052To handle package references in variable and function names not differently
2053from the rest of the name (like 'PkgName::' in '$PkgName::VarName'): >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002054
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002055 :let perl_no_scope_in_variables = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002056
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002057(In Vim 6.x it was the other way around: "perl_want_scope_in_variables"
2058enabled it.)
2059
2060If you do not want complex things like '@{${"foo"}}' to be parsed: >
2061
2062 :let perl_no_extended_vars = 1
2063
Bram Moolenaar3fdfa4a2004-10-07 21:02:47 +00002064(In Vim 6.x it was the other way around: "perl_extended_vars" enabled it.)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002065
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002066The coloring strings can be changed. By default strings and qq friends will be
2067highlighted like the first line. If you set the variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00002068perl_string_as_statement, it will be highlighted as in the second line.
2069
2070 "hello world!"; qq|hello world|;
2071 ^^^^^^^^^^^^^^NN^^^^^^^^^^^^^^^N (unlet perl_string_as_statement)
2072 S^^^^^^^^^^^^SNNSSS^^^^^^^^^^^SN (let perl_string_as_statement)
2073
2074(^ = perlString, S = perlStatement, N = None at all)
2075
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002076The syncing has 3 options. The first two switch off some triggering of
Bram Moolenaar071d4272004-06-13 20:20:40 +00002077synchronization and should only be needed in case it fails to work properly.
2078If while scrolling all of a sudden the whole screen changes color completely
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002079then you should try and switch off one of those. Let me know if you can figure
Bram Moolenaar071d4272004-06-13 20:20:40 +00002080out the line that causes the mistake.
2081
2082One triggers on "^\s*sub\s*" and the other on "^[$@%]" more or less. >
2083
2084 :let perl_no_sync_on_sub
2085 :let perl_no_sync_on_global_var
2086
2087Below you can set the maximum distance VIM should look for starting points for
2088its attempts in syntax highlighting. >
2089
2090 :let perl_sync_dist = 100
2091
2092If you want to use folding with perl, set perl_fold: >
2093
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002094 :let perl_fold = 1
2095
2096If you want to fold blocks in if statements, etc. as well set the following: >
2097
2098 :let perl_fold_blocks = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002099
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00002100To avoid folding packages or subs when perl_fold is let, let the appropriate
2101variable(s): >
2102
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002103 :unlet perl_nofold_packages
2104 :unlet perl_nofold_subs
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00002105
2106
Bram Moolenaar071d4272004-06-13 20:20:40 +00002107
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002108PHP3 and PHP4 *php.vim* *php3.vim* *ft-php-syntax* *ft-php3-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002109
2110[note: previously this was called "php3", but since it now also supports php4
2111it has been renamed to "php"]
2112
2113There are the following options for the php syntax highlighting.
2114
2115If you like SQL syntax highlighting inside Strings: >
2116
2117 let php_sql_query = 1
2118
2119For highlighting the Baselib methods: >
2120
2121 let php_baselib = 1
2122
2123Enable HTML syntax highlighting inside strings: >
2124
2125 let php_htmlInStrings = 1
2126
2127Using the old colorstyle: >
2128
2129 let php_oldStyle = 1
2130
2131Enable highlighting ASP-style short tags: >
2132
2133 let php_asp_tags = 1
2134
2135Disable short tags: >
2136
2137 let php_noShortTags = 1
2138
2139For highlighting parent error ] or ): >
2140
2141 let php_parent_error_close = 1
2142
2143For skipping an php end tag, if there exists an open ( or [ without a closing
2144one: >
2145
2146 let php_parent_error_open = 1
2147
2148Enable folding for classes and functions: >
2149
2150 let php_folding = 1
2151
2152Selecting syncing method: >
2153
2154 let php_sync_method = x
2155
2156x = -1 to sync by search (default),
2157x > 0 to sync at least x lines backwards,
2158x = 0 to sync from start.
2159
2160
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00002161PLAINTEX *plaintex.vim* *ft-plaintex-syntax*
2162
2163TeX is a typesetting language, and plaintex is the file type for the "plain"
2164variant of TeX. If you never want your *.tex files recognized as plain TeX,
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002165see |ft-tex-plugin|.
Bram Moolenaard2cec5b2006-03-28 21:08:56 +00002166
2167This syntax file has the option >
2168
2169 let g:plaintex_delimiters = 1
2170
2171if you want to highlight brackets "[]" and braces "{}".
2172
2173
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002174PPWIZARD *ppwiz.vim* *ft-ppwiz-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175
2176PPWizard is a preprocessor for HTML and OS/2 INF files
2177
2178This syntax file has the options:
2179
2180- ppwiz_highlight_defs : determines highlighting mode for PPWizard's
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002181 definitions. Possible values are
Bram Moolenaar071d4272004-06-13 20:20:40 +00002182
2183 ppwiz_highlight_defs = 1 : PPWizard #define statements retain the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002184 colors of their contents (e.g. PPWizard macros and variables)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002185
2186 ppwiz_highlight_defs = 2 : preprocessor #define and #evaluate
2187 statements are shown in a single color with the exception of line
2188 continuation symbols
2189
2190 The default setting for ppwiz_highlight_defs is 1.
2191
2192- ppwiz_with_html : If the value is 1 (the default), highlight literal
2193 HTML code; if 0, treat HTML code like ordinary text.
2194
2195
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002196PHTML *phtml.vim* *ft-phtml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002197
2198There are two options for the phtml syntax highlighting.
2199
2200If you like SQL syntax highlighting inside Strings, use this: >
2201
2202 :let phtml_sql_query = 1
2203
2204For syncing, minlines defaults to 100. If you prefer another value, you can
2205set "phtml_minlines" to the value you desire. Example: >
2206
2207 :let phtml_minlines = 200
2208
2209
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002210POSTSCRIPT *postscr.vim* *ft-postscr-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002211
2212There are several options when it comes to highlighting PostScript.
2213
2214First which version of the PostScript language to highlight. There are
2215currently three defined language versions, or levels. Level 1 is the original
2216and base version, and includes all extensions prior to the release of level 2.
2217Level 2 is the most common version around, and includes its own set of
2218extensions prior to the release of level 3. Level 3 is currently the highest
2219level supported. You select which level of the PostScript language you want
2220highlighted by defining the postscr_level variable as follows: >
2221
2222 :let postscr_level=2
2223
2224If this variable is not defined it defaults to 2 (level 2) since this is
2225the most prevalent version currently.
2226
2227Note, not all PS interpreters will support all language features for a
2228particular language level. In particular the %!PS-Adobe-3.0 at the start of
2229PS files does NOT mean the PostScript present is level 3 PostScript!
2230
2231If you are working with Display PostScript, you can include highlighting of
2232Display PS language features by defining the postscr_display variable as
2233follows: >
2234
2235 :let postscr_display=1
2236
2237If you are working with Ghostscript, you can include highlighting of
2238Ghostscript specific language features by defining the variable
2239postscr_ghostscript as follows: >
2240
2241 :let postscr_ghostscript=1
2242
2243PostScript is a large language, with many predefined elements. While it
2244useful to have all these elements highlighted, on slower machines this can
2245cause Vim to slow down. In an attempt to be machine friendly font names and
2246character encodings are not highlighted by default. Unless you are working
2247explicitly with either of these this should be ok. If you want them to be
2248highlighted you should set one or both of the following variables: >
2249
2250 :let postscr_fonts=1
2251 :let postscr_encodings=1
2252
2253There is a stylistic option to the highlighting of and, or, and not. In
2254PostScript the function of these operators depends on the types of their
2255operands - if the operands are booleans then they are the logical operators,
2256if they are integers then they are binary operators. As binary and logical
2257operators can be highlighted differently they have to be highlighted one way
2258or the other. By default they are treated as logical operators. They can be
2259highlighted as binary operators by defining the variable
2260postscr_andornot_binary as follows: >
2261
2262 :let postscr_andornot_binary=1
2263<
2264
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002265 *ptcap.vim* *ft-printcap-syntax*
2266PRINTCAP + TERMCAP *ft-ptcap-syntax* *ft-termcap-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267
2268This syntax file applies to the printcap and termcap databases.
2269
2270In order for Vim to recognize printcap/termcap files that do not match
2271the patterns *printcap*, or *termcap*, you must put additional patterns
2272appropriate to your system in your |myfiletypefile| file. For these
2273patterns, you must set the variable "b:ptcap_type" to either "print" or
2274"term", and then the 'filetype' option to ptcap.
2275
2276For example, to make Vim identify all files in /etc/termcaps/ as termcap
2277files, add the following: >
2278
2279 :au BufNewFile,BufRead /etc/termcaps/* let b:ptcap_type = "term" |
2280 \ set filetype=ptcap
2281
2282If you notice highlighting errors while scrolling backwards, which
2283are fixed when redrawing with CTRL-L, try setting the "ptcap_minlines"
2284internal variable to a larger number: >
2285
2286 :let ptcap_minlines = 50
2287
2288(The default is 20 lines.)
2289
2290
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002291PROGRESS *progress.vim* *ft-progress-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292
2293Files matching "*.w" could be Progress or cweb. If the automatic detection
2294doesn't work for you, or you don't edit cweb at all, use this in your
2295startup vimrc: >
2296 :let filetype_w = "progress"
2297The same happens for "*.i", which could be assembly, and "*.p", which could be
2298Pascal. Use this if you don't use assembly and Pascal: >
2299 :let filetype_i = "progress"
2300 :let filetype_p = "progress"
2301
2302
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002303PYTHON *python.vim* *ft-python-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304
2305There are four options to control Python syntax highlighting.
2306
2307For highlighted numbers: >
2308 :let python_highlight_numbers = 1
2309
2310For highlighted builtin functions: >
2311 :let python_highlight_builtins = 1
2312
2313For highlighted standard exceptions: >
2314 :let python_highlight_exceptions = 1
2315
Bram Moolenaar4a748032010-09-30 21:47:56 +02002316For highlighted trailing whitespace and mix of spaces and tabs: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 :let python_highlight_space_errors = 1
2318
2319If you want all possible Python highlighting (the same as setting the
2320preceding three options): >
2321 :let python_highlight_all = 1
2322
2323
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002324QUAKE *quake.vim* *ft-quake-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325
2326The Quake syntax definition should work for most any FPS (First Person
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002327Shooter) based on one of the Quake engines. However, the command names vary
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328a bit between the three games (Quake, Quake 2, and Quake 3 Arena) so the
2329syntax definition checks for the existence of three global variables to allow
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002330users to specify what commands are legal in their files. The three variables
Bram Moolenaar071d4272004-06-13 20:20:40 +00002331can be set for the following effects:
2332
2333set to highlight commands only available in Quake: >
2334 :let quake_is_quake1 = 1
2335
2336set to highlight commands only available in Quake 2: >
2337 :let quake_is_quake2 = 1
2338
2339set to highlight commands only available in Quake 3 Arena: >
2340 :let quake_is_quake3 = 1
2341
2342Any combination of these three variables is legal, but might highlight more
2343commands than are actually available to you by the game.
2344
2345
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002346READLINE *readline.vim* *ft-readline-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002347
2348The readline library is primarily used by the BASH shell, which adds quite a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002349few commands and options to the ones already available. To highlight these
Bram Moolenaar071d4272004-06-13 20:20:40 +00002350items as well you can add the following to your |vimrc| or just type it in the
2351command line before loading a file with the readline syntax: >
2352 let readline_has_bash = 1
2353
2354This will add highlighting for the commands that BASH (version 2.05a and
2355later, and part earlier) adds.
2356
2357
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002358REXX *rexx.vim* *ft-rexx-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359
2360If you notice highlighting errors while scrolling backwards, which are fixed
2361when redrawing with CTRL-L, try setting the "rexx_minlines" internal variable
2362to a larger number: >
2363 :let rexx_minlines = 50
2364This will make the syntax synchronization start 50 lines before the first
2365displayed line. The default value is 10. The disadvantage of using a larger
2366number is that redrawing can become slow.
2367
Bram Moolenaar97293012011-07-18 19:40:27 +02002368Vim tries to guess what type a ".r" file is. If it can't be detected (from
2369comment lines), the default is "r". To make the default rexx add this line to
2370your .vimrc: *g:filetype_r*
2371>
2372 :let g:filetype_r = "r"
2373
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002375RUBY *ruby.vim* *ft-ruby-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002377There are a number of options to the Ruby syntax highlighting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378
2379By default, the "end" keyword is colorized according to the opening statement
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002380of the block it closes. While useful, this feature can be expensive; if you
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381experience slow redrawing (or you are on a terminal with poor color support)
2382you may want to turn it off by defining the "ruby_no_expensive" variable: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002383
Bram Moolenaar071d4272004-06-13 20:20:40 +00002384 :let ruby_no_expensive = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002385<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386In this case the same color will be used for all control keywords.
2387
2388If you do want this feature enabled, but notice highlighting errors while
2389scrolling backwards, which are fixed when redrawing with CTRL-L, try setting
2390the "ruby_minlines" variable to a value larger than 50: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002391
Bram Moolenaar071d4272004-06-13 20:20:40 +00002392 :let ruby_minlines = 100
Bram Moolenaar25394022007-05-10 19:06:20 +00002393<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394Ideally, this value should be a number of lines large enough to embrace your
2395largest class or module.
2396
Bram Moolenaar25394022007-05-10 19:06:20 +00002397Highlighting of special identifiers can be disabled by removing the
2398rubyIdentifier highlighting: >
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002399
Bram Moolenaar25394022007-05-10 19:06:20 +00002400 :hi link rubyIdentifier NONE
2401<
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402This will prevent highlighting of special identifiers like "ConstantName",
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002403"$global_var", "@@class_var", "@instance_var", "| block_param |", and
2404":symbol".
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002406Significant methods of Kernel, Module and Object are highlighted by default.
2407This can be disabled by defining "ruby_no_special_methods": >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002409 :let ruby_no_special_methods = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002410<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002411This will prevent highlighting of important methods such as "require", "attr",
2412"private", "raise" and "proc".
2413
Bram Moolenaar25394022007-05-10 19:06:20 +00002414Ruby operators can be highlighted. This is enabled by defining
2415"ruby_operators": >
2416
2417 :let ruby_operators = 1
2418<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002419Whitespace errors can be highlighted by defining "ruby_space_errors": >
2420
2421 :let ruby_space_errors = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002422<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002423This will highlight trailing whitespace and tabs preceded by a space character
2424as errors. This can be refined by defining "ruby_no_trail_space_error" and
2425"ruby_no_tab_space_error" which will ignore trailing whitespace and tabs after
2426spaces respectively.
2427
2428Folding can be enabled by defining "ruby_fold": >
2429
2430 :let ruby_fold = 1
Bram Moolenaar25394022007-05-10 19:06:20 +00002431<
Bram Moolenaar943d2b52005-12-02 00:50:49 +00002432This will set the 'foldmethod' option to "syntax" and allow folding of
2433classes, modules, methods, code blocks, heredocs and comments.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002434
Bram Moolenaar25394022007-05-10 19:06:20 +00002435Folding of multiline comments can be disabled by defining
2436"ruby_no_comment_fold": >
2437
2438 :let ruby_no_comment_fold = 1
2439<
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002440
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002441SCHEME *scheme.vim* *ft-scheme-syntax*
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002442
2443By default only R5RS keywords are highlighted and properly indented.
2444
2445MzScheme-specific stuff will be used if b:is_mzscheme or g:is_mzscheme
2446variables are defined.
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00002447
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002448Also scheme.vim supports keywords of the Chicken Scheme->C compiler. Define
2449b:is_chicken or g:is_chicken, if you need them.
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002450
2451
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002452SDL *sdl.vim* *ft-sdl-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453
2454The SDL highlighting probably misses a few keywords, but SDL has so many
2455of them it's almost impossibly to cope.
2456
2457The new standard, SDL-2000, specifies that all identifiers are
2458case-sensitive (which was not so before), and that all keywords can be
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002459used either completely lowercase or completely uppercase. To have the
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460highlighting reflect this, you can set the following variable: >
2461 :let sdl_2000=1
2462
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002463This also sets many new keywords. If you want to disable the old
Bram Moolenaar071d4272004-06-13 20:20:40 +00002464keywords, which is probably a good idea, use: >
2465 :let SDL_no_96=1
2466
2467
2468The indentation is probably also incomplete, but right now I am very
2469satisfied with it for my own projects.
2470
2471
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002472SED *sed.vim* *ft-sed-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473
2474To make tabs stand out from regular blanks (accomplished by using Todo
2475highlighting on the tabs), define "highlight_sedtabs" by putting >
2476
2477 :let highlight_sedtabs = 1
2478
2479in the vimrc file. (This special highlighting only applies for tabs
2480inside search patterns, replacement texts, addresses or text included
2481by an Append/Change/Insert command.) If you enable this option, it is
2482also a good idea to set the tab width to one character; by doing that,
2483you can easily count the number of tabs in a string.
2484
2485Bugs:
2486
2487 The transform command (y) is treated exactly like the substitute
2488 command. This means that, as far as this syntax file is concerned,
2489 transform accepts the same flags as substitute, which is wrong.
2490 (Transform accepts no flags.) I tolerate this bug because the
2491 involved commands need very complex treatment (95 patterns, one for
2492 each plausible pattern delimiter).
2493
2494
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002495SGML *sgml.vim* *ft-sgml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496
2497The coloring scheme for tags in the SGML file works as follows.
2498
2499The <> of opening tags are colored differently than the </> of a closing tag.
2500This is on purpose! For opening tags the 'Function' color is used, while for
2501closing tags the 'Type' color is used (See syntax.vim to check how those are
2502defined for you)
2503
2504Known tag names are colored the same way as statements in C. Unknown tag
2505names are not colored which makes it easy to spot errors.
2506
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002507Note that the same is true for argument (or attribute) names. Known attribute
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508names are colored differently than unknown ones.
2509
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002510Some SGML tags are used to change the rendering of text. The following tags
Bram Moolenaar071d4272004-06-13 20:20:40 +00002511are recognized by the sgml.vim syntax coloring file and change the way normal
2512text is shown: <varname> <emphasis> <command> <function> <literal>
2513<replaceable> <ulink> and <link>.
2514
2515If you want to change how such text is rendered, you must redefine the
2516following syntax groups:
2517
2518 - sgmlBold
2519 - sgmlBoldItalic
2520 - sgmlUnderline
2521 - sgmlItalic
2522 - sgmlLink for links
2523
2524To make this redefinition work you must redefine them all and define the
2525following variable in your vimrc (this is due to the order in which the files
2526are read during initialization) >
2527 let sgml_my_rendering=1
2528
2529You can also disable this rendering by adding the following line to your
2530vimrc file: >
2531 let sgml_no_rendering=1
2532
2533(Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>)
2534
2535
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002536SH *sh.vim* *ft-sh-syntax* *ft-bash-syntax* *ft-ksh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002538This covers the "normal" Unix (Bourne) sh, bash and the Korn shell.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539
2540Vim attempts to determine which shell type is in use by specifying that
2541various filenames are of specific types: >
2542
2543 ksh : .kshrc* *.ksh
2544 bash: .bashrc* bashrc bash.bashrc .bash_profile* *.bash
2545<
2546If none of these cases pertain, then the first line of the file is examined
2547(ex. /bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype,
2548then that shelltype is used. However some files (ex. .profile) are known to
2549be shell files but the type is not apparent. Furthermore, on many systems
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002550sh is symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002551
2552One may specify a global default by instantiating one of the following three
2553variables in your <.vimrc>:
2554
2555 ksh: >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002556 let g:is_kornshell = 1
2557< posix: (using this is the same as setting is_kornshell to 1) >
2558 let g:is_posix = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002559< bash: >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002560 let g:is_bash = 1
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002561< sh: (default) Bourne shell >
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002562 let g:is_sh = 1
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002564If there's no "#! ..." line, and the user hasn't availed himself/herself of a
2565default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002566the Bourne shell syntax. No need to quote RFCs or market penetration
2567statistics in error reports, please -- just select the default version of the
2568sh your system uses in your <.vimrc>.
Bram Moolenaar910f66f2006-04-05 20:41:53 +00002569
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002570The syntax/sh.vim file provides several levels of syntax-based folding: >
2571
2572 let g:sh_fold_enabled= 0 (default, no syntax folding)
2573 let g:sh_fold_enabled= 1 (enable function folding)
2574 let g:sh_fold_enabled= 2 (enable heredoc folding)
2575 let g:sh_fold_enabled= 4 (enable if/do/for folding)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576>
2577then various syntax items (HereDocuments and function bodies) become
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002578syntax-foldable (see |:syn-fold|). You also may add these together
2579to get multiple types of folding: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002580
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002581 let g:sh_fold_enabled= 3 (enables function and heredoc folding)
2582
2583If you notice highlighting errors while scrolling backwards which are fixed
2584when one redraws with CTRL-L, try setting the "sh_minlines" internal variable
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585to a larger number. Example: >
2586
2587 let sh_minlines = 500
2588
2589This will make syntax synchronization start 500 lines before the first
2590displayed line. The default value is 200. The disadvantage of using a larger
2591number is that redrawing can become slow.
2592
2593If you don't have much to synchronize on, displaying can be very slow. To
2594reduce this, the "sh_maxlines" internal variable can be set. Example: >
2595
2596 let sh_maxlines = 100
2597<
2598The default is to use the twice sh_minlines. Set it to a smaller number to
2599speed up displaying. The disadvantage is that highlight errors may appear.
2600
Bram Moolenaard960d762011-09-21 19:22:10 +02002601 *g:sh_isk* *g:sh_noisk*
2602The shell languages appear to let "." be part of words, commands, etc;
2603consequently it should be in the isk for sh.vim. As of v116 of syntax/sh.vim,
2604syntax/sh.vim will append the "." to |'iskeyword'| by default; you may control
2605this behavior with: >
2606 let g:sh_isk = '..whatever characters you want as part of iskeyword'
2607 let g:sh_noisk= 1 " otherwise, if this exists, the isk will NOT chg
2608<
2609 *sh-embed* *sh-awk*
2610 Sh: EMBEDDING LANGUAGES~
Bram Moolenaar071d4272004-06-13 20:20:40 +00002611
Bram Moolenaard960d762011-09-21 19:22:10 +02002612You may wish to embed languages into sh. I'll give an example courtesy of
2613Lorance Stinson on how to do this with awk as an example. Put the following
2614file into $HOME/.vim/after/syntax/sh/awkembed.vim: >
2615
2616 " AWK Embedding: {{{1
2617 " ==============
2618 " Shamelessly ripped from aspperl.vim by Aaron Hope.
2619 if exists("b:current_syntax")
2620 unlet b:current_syntax
2621 endif
2622 syn include @AWKScript syntax/awk.vim
2623 syn region AWKScriptCode matchgroup=AWKCommand start=+[=\\]\@<!'+ skip=+\\'+ end=+'+ contains=@AWKScript contained
2624 syn region AWKScriptEmbedded matchgroup=AWKCommand start=+\<awk\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1 contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
2625 syn cluster shCommandSubList add=AWKScriptEmbedded
2626 hi def link AWKCommand Type
2627<
2628This code will then let the awk code in the single quotes: >
2629 awk '...awk code here...'
2630be highlighted using the awk highlighting syntax. Clearly this may be
2631extended to other languages.
2632
2633
2634SPEEDUP *spup.vim* *ft-spup-syntax*
2635(AspenTech plant simulator)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636
2637The Speedup syntax file has some options:
2638
2639- strict_subsections : If this variable is defined, only keywords for
2640 sections and subsections will be highlighted as statements but not
2641 other keywords (like WITHIN in the OPERATION section).
2642
2643- highlight_types : Definition of this variable causes stream types
2644 like temperature or pressure to be highlighted as Type, not as a
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002645 plain Identifier. Included are the types that are usually found in
Bram Moolenaar071d4272004-06-13 20:20:40 +00002646 the DECLARE section; if you defined own types, you have to include
2647 them in the syntax file.
2648
2649- oneline_comments : this value ranges from 1 to 3 and determines the
2650 highlighting of # style comments.
2651
2652 oneline_comments = 1 : allow normal Speedup code after an even
2653 number of #s.
2654
2655 oneline_comments = 2 : show code starting with the second # as
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002656 error. This is the default setting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657
2658 oneline_comments = 3 : show the whole line as error if it contains
2659 more than one #.
2660
2661Since especially OPERATION sections tend to become very large due to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002662PRESETting variables, syncing may be critical. If your computer is
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663fast enough, you can increase minlines and/or maxlines near the end of
2664the syntax file.
2665
2666
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002667SQL *sql.vim* *ft-sql-syntax*
2668 *sqlinformix.vim* *ft-sqlinformix-syntax*
Bram Moolenaar1056d982006-03-09 22:37:52 +00002669 *sqlanywhere.vim* *ft-sqlanywhere-syntax*
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002670
Bram Moolenaar1056d982006-03-09 22:37:52 +00002671While there is an ANSI standard for SQL, most database engines add their own
2672custom extensions. Vim currently supports the Oracle and Informix dialects of
2673SQL. Vim assumes "*.sql" files are Oracle SQL by default.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002674
Bram Moolenaar1056d982006-03-09 22:37:52 +00002675Vim currently has SQL support for a variety of different vendors via syntax
2676scripts. You can change Vim's default from Oracle to any of the current SQL
2677supported types. You can also easily alter the SQL dialect being used on a
2678buffer by buffer basis.
2679
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002680For more detailed instructions see |ft_sql.txt|.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00002681
2682
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002683TCSH *tcsh.vim* *ft-tcsh-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684
2685This covers the shell named "tcsh". It is a superset of csh. See |csh.vim|
2686for how the filetype is detected.
2687
2688Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002689is set. If you want VIM to assume that no backslash quote constructs exist add
Bram Moolenaar071d4272004-06-13 20:20:40 +00002690this line to your .vimrc: >
2691
2692 :let tcsh_backslash_quote = 0
2693
2694If you notice highlighting errors while scrolling backwards, which are fixed
2695when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable
2696to a larger number: >
2697
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01002698 :let tcsh_minlines = 1000
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01002700This will make the syntax synchronization start 1000 lines before the first
2701displayed line. If you set "tcsh_minlines" to "fromstart", then
2702synchronization is done from the start of the file. The default value for
2703tcsh_minlines is 100. The disadvantage of using a larger number is that
2704redrawing can become slow.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002705
2706
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002707TEX *tex.vim* *ft-tex-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002708
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002709 *tex-folding*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002710 Tex: Want Syntax Folding? ~
Bram Moolenaar488c6512005-08-11 20:09:58 +00002711
2712As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
2713sections, subsections, etc are supported. Put >
2714 let g:tex_fold_enabled=1
2715in your <.vimrc>, and :set fdm=syntax. I suggest doing the latter via a
2716modeline at the end of your LaTeX file: >
2717 % vim: fdm=syntax
Bram Moolenaard960d762011-09-21 19:22:10 +02002718If your system becomes too slow, then you might wish to look into >
Bram Moolenaar15146672011-10-20 22:22:38 +02002719 http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
Bram Moolenaar488c6512005-08-11 20:09:58 +00002720<
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002721 *tex-nospell*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002722 Tex: Don't Want Spell Checking In Comments? ~
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002723
2724Some folks like to include things like source code in comments and so would
2725prefer that spell checking be disabled in comments in LaTeX files. To do
2726this, put the following in your <.vimrc>: >
2727 let g:tex_comment_nospell= 1
Bram Moolenaard38b0552012-04-25 19:07:41 +02002728The comment lines >
2729 % nospell{
2730 ...
2731 % nospell}
2732will suppress spell checking between them. These comment lines spelling
2733control are known to be fragile; for example, don't include any of the section
2734commands (\part, \chapter, \section, \paragraph, etc) inside nospell blocks
2735or interleave environments (such as math) across nospell blocks.
Bram Moolenaar74cbdf02010-08-04 23:03:17 +02002736 *tex-verb*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002737 Tex: Want Spell Checking in Verbatim Zones?~
Bram Moolenaar74cbdf02010-08-04 23:03:17 +02002738
2739Often verbatim regions are used for things like source code; seldom does
2740one want source code spell-checked. However, for those of you who do
2741want your verbatim zones spell-checked, put the following in your <.vimrc>: >
2742 let g:tex_verbspell= 1
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002743<
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002744 *tex-runon*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002745 Tex: Run-on Comments or MathZones ~
Bram Moolenaar071d4272004-06-13 20:20:40 +00002746
Bram Moolenaar488c6512005-08-11 20:09:58 +00002747The <syntax/tex.vim> highlighting supports TeX, LaTeX, and some AmsTeX. The
2748highlighting supports three primary zones/regions: normal, texZone, and
2749texMathZone. Although considerable effort has been made to have these zones
2750terminate properly, zones delineated by $..$ and $$..$$ cannot be synchronized
2751as there's no difference between start and end patterns. Consequently, a
Bram Moolenaar071d4272004-06-13 20:20:40 +00002752special "TeX comment" has been provided >
2753 %stopzone
2754which will forcibly terminate the highlighting of either a texZone or a
2755texMathZone.
2756
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002757 *tex-slow*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002758 Tex: Slow Syntax Highlighting? ~
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759
2760If you have a slow computer, you may wish to reduce the values for >
2761 :syn sync maxlines=200
2762 :syn sync minlines=50
2763(especially the latter). If your computer is fast, you may wish to
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002764increase them. This primarily affects synchronizing (i.e. just what group,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002765if any, is the text at the top of the screen supposed to be in?).
2766
Bram Moolenaard960d762011-09-21 19:22:10 +02002767Another cause of slow highlighting is due to syntax-driven folding; see
2768|tex-folding| for a way around this.
2769
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002770 *tex-morecommands* *tex-package*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002771 Tex: Want To Highlight More Commands? ~
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002772
2773LaTeX is a programmable language, and so there are thousands of packages full
2774of specialized LaTeX commands, syntax, and fonts. If you're using such a
2775package you'll often wish that the distributed syntax/tex.vim would support
2776it. However, clearly this is impractical. So please consider using the
2777techniques in |mysyntaxfile-add| to extend or modify the highlighting provided
Bram Moolenaarb6b046b2011-12-30 13:11:27 +01002778by syntax/tex.vim. Please consider uploading any extensions that you write,
2779which typically would go in $HOME/after/syntax/tex/[pkgname].vim, to
2780http://vim.sf.net/.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002781
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002782 *tex-error*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002783 Tex: Excessive Error Highlighting? ~
Bram Moolenaar071d4272004-06-13 20:20:40 +00002784
2785The <tex.vim> supports lexical error checking of various sorts. Thus,
2786although the error checking is ofttimes very useful, it can indicate
2787errors where none actually are. If this proves to be a problem for you,
2788you may put in your <.vimrc> the following statement: >
2789 let tex_no_error=1
Bram Moolenaar488c6512005-08-11 20:09:58 +00002790and all error checking by <syntax/tex.vim> will be suppressed.
Bram Moolenaar071d4272004-06-13 20:20:40 +00002791
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002792 *tex-math*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002793 Tex: Need a new Math Group? ~
Bram Moolenaar071d4272004-06-13 20:20:40 +00002794
2795If you want to include a new math group in your LaTeX, the following
2796code shows you an example as to how you might do so: >
Bram Moolenaar488c6512005-08-11 20:09:58 +00002797 call TexNewMathZone(sfx,mathzone,starform)
2798You'll want to provide the new math group with a unique suffix
2799(currently, A-L and V-Z are taken by <syntax/tex.vim> itself).
2800As an example, consider how eqnarray is set up by <syntax/tex.vim>: >
2801 call TexNewMathZone("D","eqnarray",1)
2802You'll need to change "mathzone" to the name of your new math group,
2803and then to the call to it in .vim/after/syntax/tex.vim.
2804The "starform" variable, if true, implies that your new math group
2805has a starred form (ie. eqnarray*).
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002807 *tex-style*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002808 Tex: Starting a New Style? ~
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809
2810One may use "\makeatletter" in *.tex files, thereby making the use of "@" in
2811commands available. However, since the *.tex file doesn't have one of the
2812following suffices: sty cls clo dtx ltx, the syntax highlighting will flag
2813such use of @ as an error. To solve this: >
2814
2815 :let b:tex_stylish = 1
2816 :set ft=tex
2817
2818Putting "let g:tex_stylish=1" into your <.vimrc> will make <syntax/tex.vim>
2819always accept such use of @.
2820
Bram Moolenaar611df5b2010-07-26 22:51:56 +02002821 *tex-cchar* *tex-cole* *tex-conceal*
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002822 Tex: Taking Advantage of Conceal Mode~
Bram Moolenaar611df5b2010-07-26 22:51:56 +02002823
Bram Moolenaar477db062010-07-28 18:17:41 +02002824If you have |'conceallevel'| set to 2 and if your encoding is utf-8, then a
2825number of character sequences can be translated into appropriate utf-8 glyphs,
2826including various accented characters, Greek characters in MathZones, and
2827superscripts and subscripts in MathZones. Not all characters can be made into
2828superscripts or subscripts; the constraint is due to what utf-8 supports.
2829In fact, only a few characters are supported as subscripts.
2830
2831One way to use this is to have vertically split windows (see |CTRL-W_v|); one
2832with |'conceallevel'| at 0 and the other at 2; and both using |'scrollbind'|.
Bram Moolenaar611df5b2010-07-26 22:51:56 +02002833
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002834 *g:tex_conceal*
2835 Tex: Selective Conceal Mode~
2836
2837You may selectively use conceal mode by setting g:tex_conceal in your
2838<.vimrc>. By default it is set to "admgs" to enable conceal for the
2839following sets of characters: >
2840
2841 a = accents/ligatures
Bram Moolenaard38b0552012-04-25 19:07:41 +02002842 b = bold and italic
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02002843 d = delimiters
2844 m = math symbols
2845 g = Greek
2846 s = superscripts/subscripts
2847<
2848By leaving one or more of these out, the associated conceal-character
2849substitution will not be made.
2850
Bram Moolenaar5b435d62012-04-05 17:33:26 +02002851 *g:tex_isk*
2852 Tex: Controlling What's In A Keyword~
2853
2854(La)Tex keywords normally use the characters 0-9,a-z,A-Z,192-255 only
2855but the "_" is the only one that causes problems. So, by default,
Bram Moolenaar53bfca22012-04-13 23:04:47 +02002856syntax/tex.vim overrides the usual |'iskeyword'| setting (using |:setlocal|)
Bram Moolenaar5b435d62012-04-05 17:33:26 +02002857with one that works for LaTeX.
2858
2859However, one may override this iskeyword re-setting by setting the
2860variable, g:tex_isk, in one's .vimrc to whatever one wishes and
2861it will be used instead.
2862
Bram Moolenaar071d4272004-06-13 20:20:40 +00002863
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002864TF *tf.vim* *ft-tf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002865
2866There is one option for the tf syntax highlighting.
2867
2868For syncing, minlines defaults to 100. If you prefer another value, you can
2869set "tf_minlines" to the value you desire. Example: >
2870
2871 :let tf_minlines = your choice
2872
2873
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002874VIM *vim.vim* *ft-vim-syntax*
2875 *g:vimsyn_minlines* *g:vimsyn_maxlines*
Bram Moolenaar996343d2010-07-04 22:20:21 +02002876There is a trade-off between more accurate syntax highlighting versus screen
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002877updating speed. To improve accuracy, you may wish to increase the
2878g:vimsyn_minlines variable. The g:vimsyn_maxlines variable may be used to
2879improve screen updating rates (see |:syn-sync| for more on this). >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002881 g:vimsyn_minlines : used to set synchronization minlines
2882 g:vimsyn_maxlines : used to set synchronization maxlines
2883<
2884 (g:vim_minlines and g:vim_maxlines are deprecated variants of
2885 these two options)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002886
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002887 *g:vimsyn_embed*
2888The g:vimsyn_embed option allows users to select what, if any, types of
2889embedded script highlighting they wish to have. >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002890
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002891 g:vimsyn_embed == 0 : don't embed any scripts
2892 g:vimsyn_embed =~ 'm' : embed mzscheme (but only if vim supports it)
2893 g:vimsyn_embed =~ 'p' : embed perl (but only if vim supports it)
2894 g:vimsyn_embed =~ 'P' : embed python (but only if vim supports it)
2895 g:vimsyn_embed =~ 'r' : embed ruby (but only if vim supports it)
2896 g:vimsyn_embed =~ 't' : embed tcl (but only if vim supports it)
2897<
2898By default, g:vimsyn_embed is "mpPr"; ie. syntax/vim.vim will support
2899highlighting mzscheme, perl, python, and ruby by default. Vim's has("tcl")
2900test appears to hang vim when tcl is not truly available. Thus, by default,
2901tcl is not supported for embedding (but those of you who like tcl embedded in
2902their vim syntax highlighting can simply include it in the g:vimembedscript
2903option).
2904 *g:vimsyn_folding*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002905
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002906Some folding is now supported with syntax/vim.vim: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002907
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002908 g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding
2909 g:vimsyn_folding =~ 'a' : augroups
2910 g:vimsyn_folding =~ 'f' : fold functions
2911 g:vimsyn_folding =~ 'm' : fold mzscheme script
2912 g:vimsyn_folding =~ 'p' : fold perl script
2913 g:vimsyn_folding =~ 'P' : fold python script
2914 g:vimsyn_folding =~ 'r' : fold ruby script
2915 g:vimsyn_folding =~ 't' : fold tcl script
Bram Moolenaar30b65812012-07-12 22:01:11 +02002916<
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002917 *g:vimsyn_noerror*
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002918Not all error highlighting that syntax/vim.vim does may be correct; VimL is a
2919difficult language to highlight correctly. A way to suppress error
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002920highlighting is to put the following line in your |vimrc|: >
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002921
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002922 let g:vimsyn_noerror = 1
2923<
Bram Moolenaar437df8f2006-04-27 21:47:44 +00002924
Bram Moolenaar071d4272004-06-13 20:20:40 +00002925
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002926XF86CONFIG *xf86conf.vim* *ft-xf86conf-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002927
2928The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both
2929variants are supported. Automatic detection is used, but is far from perfect.
2930You may need to specify the version manually. Set the variable
2931xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
2932your .vimrc. Example: >
2933 :let xf86conf_xfree86_version=3
2934When using a mix of versions, set the b:xf86conf_xfree86_version variable.
2935
2936Note that spaces and underscores in option names are not supported. Use
2937"SyncOnGreen" instead of "__s yn con gr_e_e_n" if you want the option name
2938highlighted.
2939
2940
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002941XML *xml.vim* *ft-xml-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002942
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002943Xml namespaces are highlighted by default. This can be inhibited by
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944setting a global variable: >
2945
2946 :let g:xml_namespace_transparent=1
2947<
2948 *xml-folding*
2949The xml syntax file provides syntax |folding| (see |:syn-fold|) between
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00002950start and end tags. This can be turned on by >
Bram Moolenaar071d4272004-06-13 20:20:40 +00002951
2952 :let g:xml_syntax_folding = 1
2953 :set foldmethod=syntax
2954
2955Note: syntax folding might slow down syntax highlighting significantly,
2956especially for large files.
2957
2958
Bram Moolenaarda2303d2005-08-30 21:55:26 +00002959X Pixmaps (XPM) *xpm.vim* *ft-xpm-syntax*
Bram Moolenaar071d4272004-06-13 20:20:40 +00002960
2961xpm.vim creates its syntax items dynamically based upon the contents of the
2962XPM file. Thus if you make changes e.g. in the color specification strings,
2963you have to source it again e.g. with ":set syn=xpm".
2964
2965To copy a pixel with one of the colors, yank a "pixel" with "yl" and insert it
2966somewhere else with "P".
2967
2968Do you want to draw with the mouse? Try the following: >
2969 :function! GetPixel()
Bram Moolenaar61660ea2006-04-07 21:40:07 +00002970 : let c = getline(".")[col(".") - 1]
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971 : echo c
2972 : exe "noremap <LeftMouse> <LeftMouse>r".c
2973 : exe "noremap <LeftDrag> <LeftMouse>r".c
2974 :endfunction
2975 :noremap <RightMouse> <LeftMouse>:call GetPixel()<CR>
2976 :set guicursor=n:hor20 " to see the color beneath the cursor
2977This turns the right button into a pipette and the left button into a pen.
2978It will work with XPM files that have one character per pixel only and you
2979must not click outside of the pixel strings, but feel free to improve it.
2980
2981It will look much better with a font in a quadratic cell size, e.g. for X: >
2982 :set guifont=-*-clean-medium-r-*-*-8-*-*-*-*-80-*
2983
2984==============================================================================
29855. Defining a syntax *:syn-define* *E410*
2986
2987Vim understands three types of syntax items:
2988
Bram Moolenaarce0842a2005-07-18 21:58:11 +000029891. Keyword
Bram Moolenaar071d4272004-06-13 20:20:40 +00002990 It can only contain keyword characters, according to the 'iskeyword'
2991 option. It cannot contain other syntax items. It will only match with a
2992 complete word (there are no keyword characters before or after the match).
2993 The keyword "if" would match in "if(a=b)", but not in "ifdef x", because
2994 "(" is not a keyword character and "d" is.
2995
Bram Moolenaarce0842a2005-07-18 21:58:11 +000029962. Match
Bram Moolenaar071d4272004-06-13 20:20:40 +00002997 This is a match with a single regexp pattern.
2998
Bram Moolenaarce0842a2005-07-18 21:58:11 +000029993. Region
Bram Moolenaar071d4272004-06-13 20:20:40 +00003000 This starts at a match of the "start" regexp pattern and ends with a match
3001 with the "end" regexp pattern. Any other text can appear in between. A
3002 "skip" regexp pattern can be used to avoid matching the "end" pattern.
3003
3004Several syntax ITEMs can be put into one syntax GROUP. For a syntax group
3005you can give highlighting attributes. For example, you could have an item
3006to define a "/* .. */" comment and another one that defines a "// .." comment,
3007and put them both in the "Comment" group. You can then specify that a
3008"Comment" will be in bold font and have a blue color. You are free to make
3009one highlight group for one syntax item, or put all items into one group.
3010This depends on how you want to specify your highlighting attributes. Putting
3011each item in its own group results in having to specify the highlighting
3012for a lot of groups.
3013
3014Note that a syntax group and a highlight group are similar. For a highlight
3015group you will have given highlight attributes. These attributes will be used
3016for the syntax group with the same name.
3017
3018In case more than one item matches at the same position, the one that was
3019defined LAST wins. Thus you can override previously defined syntax items by
3020using an item that matches the same text. But a keyword always goes before a
3021match or region. And a keyword with matching case always goes before a
3022keyword with ignoring case.
3023
3024
3025PRIORITY *:syn-priority*
3026
3027When several syntax items may match, these rules are used:
3028
30291. When multiple Match or Region items start in the same position, the item
3030 defined last has priority.
30312. A Keyword has priority over Match and Region items.
30323. An item that starts in an earlier position has priority over items that
3033 start in later positions.
3034
3035
3036DEFINING CASE *:syn-case* *E390*
3037
Bram Moolenaarce0842a2005-07-18 21:58:11 +00003038:sy[ntax] case [match | ignore]
Bram Moolenaar071d4272004-06-13 20:20:40 +00003039 This defines if the following ":syntax" commands will work with
3040 matching case, when using "match", or with ignoring case, when using
3041 "ignore". Note that any items before this are not affected, and all
3042 items until the next ":syntax case" command are affected.
3043
3044
Bram Moolenaarce0842a2005-07-18 21:58:11 +00003045SPELL CHECKING *:syn-spell*
3046
3047:sy[ntax] spell [toplevel | notoplevel | default]
3048 This defines where spell checking is to be done for text that is not
3049 in a syntax item:
3050
3051 toplevel: Text is spell checked.
3052 notoplevel: Text is not spell checked.
3053 default: When there is a @Spell cluster no spell checking.
3054
3055 For text in syntax items use the @Spell and @NoSpell clusters
3056 |spell-syntax|. When there is no @Spell and no @NoSpell cluster then
3057 spell checking is done for "default" and "toplevel".
3058
3059 To activate spell checking the 'spell' option must be set.
3060
3061
Bram Moolenaar071d4272004-06-13 20:20:40 +00003062DEFINING KEYWORDS *:syn-keyword*
3063
3064:sy[ntax] keyword {group-name} [{options}] {keyword} .. [{options}]
3065
3066 This defines a number of keywords.
3067
3068 {group-name} Is a syntax group name such as "Comment".
3069 [{options}] See |:syn-arguments| below.
3070 {keyword} .. Is a list of keywords which are part of this group.
3071
3072 Example: >
3073 :syntax keyword Type int long char
3074<
3075 The {options} can be given anywhere in the line. They will apply to
3076 all keywords given, also for options that come after a keyword.
3077 These examples do exactly the same: >
3078 :syntax keyword Type contained int long char
3079 :syntax keyword Type int long contained char
3080 :syntax keyword Type int long char contained
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003081< *E789*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003082 When you have a keyword with an optional tail, like Ex commands in
3083 Vim, you can put the optional characters inside [], to define all the
3084 variations at once: >
3085 :syntax keyword vimCommand ab[breviate] n[ext]
3086<
3087 Don't forget that a keyword can only be recognized if all the
3088 characters are included in the 'iskeyword' option. If one character
3089 isn't, the keyword will never be recognized.
3090 Multi-byte characters can also be used. These do not have to be in
3091 'iskeyword'.
3092
3093 A keyword always has higher priority than a match or region, the
3094 keyword is used if more than one item matches. Keywords do not nest
3095 and a keyword can't contain anything else.
3096
3097 Note that when you have a keyword that is the same as an option (even
3098 one that isn't allowed here), you can not use it. Use a match
3099 instead.
3100
3101 The maximum length of a keyword is 80 characters.
3102
3103 The same keyword can be defined multiple times, when its containment
3104 differs. For example, you can define the keyword once not contained
3105 and use one highlight group, and once contained, and use a different
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00003106 highlight group. Example: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00003107 :syn keyword vimCommand tag
3108 :syn keyword vimSetting contained tag
3109< When finding "tag" outside of any syntax item, the "vimCommand"
3110 highlight group is used. When finding "tag" in a syntax item that
3111 contains "vimSetting", the "vimSetting" group is used.
3112
3113
3114DEFINING MATCHES *:syn-match*
3115
3116:sy[ntax] match {group-name} [{options}] [excludenl] {pattern} [{options}]
3117
3118 This defines one match.
3119
3120 {group-name} A syntax group name such as "Comment".
3121 [{options}] See |:syn-arguments| below.
3122 [excludenl] Don't make a pattern with the end-of-line "$"
3123 extend a containing match or region. Must be
3124 given before the pattern. |:syn-excludenl|
3125 {pattern} The search pattern that defines the match.
3126 See |:syn-pattern| below.
3127 Note that the pattern may match more than one
3128 line, which makes the match depend on where
3129 Vim starts searching for the pattern. You
3130 need to make sure syncing takes care of this.
3131
3132 Example (match a character constant): >
3133 :syntax match Character /'.'/hs=s+1,he=e-1
3134<
3135
3136DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
3137 *E398* *E399*
3138:sy[ntax] region {group-name} [{options}]
3139 [matchgroup={group-name}]
3140 [keepend]
3141 [extend]
3142 [excludenl]
3143 start={start_pattern} ..
3144 [skip={skip_pattern}]
3145 end={end_pattern} ..
3146 [{options}]
3147
3148 This defines one region. It may span several lines.
3149
3150 {group-name} A syntax group name such as "Comment".
3151 [{options}] See |:syn-arguments| below.
3152 [matchgroup={group-name}] The syntax group to use for the following
3153 start or end pattern matches only. Not used
3154 for the text in between the matched start and
3155 end patterns. Use NONE to reset to not using
3156 a different group for the start or end match.
3157 See |:syn-matchgroup|.
3158 keepend Don't allow contained matches to go past a
3159 match with the end pattern. See
3160 |:syn-keepend|.
3161 extend Override a "keepend" for an item this region
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00003162 is contained in. See |:syn-extend|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 excludenl Don't make a pattern with the end-of-line "$"
3164 extend a containing match or item. Only
3165 useful for end patterns. Must be given before
3166 the patterns it applies to. |:syn-excludenl|
3167 start={start_pattern} The search pattern that defines the start of
3168 the region. See |:syn-pattern| below.
3169 skip={skip_pattern} The search pattern that defines text inside
3170 the region where not to look for the end
3171 pattern. See |:syn-pattern| below.
3172 end={end_pattern} The search pattern that defines the end of
3173 the region. See |:syn-pattern| below.
3174
3175 Example: >
3176 :syntax region String start=+"+ skip=+\\"+ end=+"+
3177<
3178 The start/skip/end patterns and the options can be given in any order.
3179 There can be zero or one skip pattern. There must be one or more
3180 start and end patterns. This means that you can omit the skip
3181 pattern, but you must give at least one start and one end pattern. It
3182 is allowed to have white space before and after the equal sign
3183 (although it mostly looks better without white space).
3184
3185 When more than one start pattern is given, a match with one of these
3186 is sufficient. This means there is an OR relation between the start
3187 patterns. The last one that matches is used. The same is true for
3188 the end patterns.
3189
3190 The search for the end pattern starts right after the start pattern.
3191 Offsets are not used for this. This implies that the match for the
3192 end pattern will never overlap with the start pattern.
3193
3194 The skip and end pattern can match across line breaks, but since the
3195 search for the pattern can start in any line it often does not do what
3196 you want. The skip pattern doesn't avoid a match of an end pattern in
3197 the next line. Use single-line patterns to avoid trouble.
3198
3199 Note: The decision to start a region is only based on a matching start
3200 pattern. There is no check for a matching end pattern. This does NOT
3201 work: >
3202 :syn region First start="(" end=":"
3203 :syn region Second start="(" end=";"
3204< The Second always matches before the First (last defined pattern has
3205 higher priority). The Second region then continues until the next
3206 ';', no matter if there is a ':' before it. Using a match does work: >
3207 :syn match First "(\_.\{-}:"
3208 :syn match Second "(\_.\{-};"
3209< This pattern matches any character or line break with "\_." and
3210 repeats that with "\{-}" (repeat as few as possible).
3211
3212 *:syn-keepend*
3213 By default, a contained match can obscure a match for the end pattern.
3214 This is useful for nesting. For example, a region that starts with
3215 "{" and ends with "}", can contain another region. An encountered "}"
3216 will then end the contained region, but not the outer region:
3217 { starts outer "{}" region
3218 { starts contained "{}" region
3219 } ends contained "{}" region
3220 } ends outer "{} region
3221 If you don't want this, the "keepend" argument will make the matching
3222 of an end pattern of the outer region also end any contained item.
3223 This makes it impossible to nest the same region, but allows for
3224 contained items to highlight parts of the end pattern, without causing
3225 that to skip the match with the end pattern. Example: >
3226 :syn match vimComment +"[^"]\+$+
3227 :syn region vimCommand start="set" end="$" contains=vimComment keepend
3228< The "keepend" makes the vimCommand always end at the end of the line,
3229 even though the contained vimComment includes a match with the <EOL>.
3230
3231 When "keepend" is not used, a match with an end pattern is retried
3232 after each contained match. When "keepend" is included, the first
3233 encountered match with an end pattern is used, truncating any
3234 contained matches.
3235 *:syn-extend*
3236 The "keepend" behavior can be changed by using the "extend" argument.
3237 When an item with "extend" is contained in an item that uses
3238 "keepend", the "keepend" is ignored and the containing region will be
3239 extended.
3240 This can be used to have some contained items extend a region while
3241 others don't. Example: >
3242
3243 :syn region htmlRef start=+<a>+ end=+</a>+ keepend contains=htmlItem,htmlScript
3244 :syn match htmlItem +<[^>]*>+ contained
3245 :syn region htmlScript start=+<script+ end=+</script[^>]*>+ contained extend
3246
3247< Here the htmlItem item does not make the htmlRef item continue
3248 further, it is only used to highlight the <> items. The htmlScript
3249 item does extend the htmlRef item.
3250
3251 Another example: >
3252 :syn region xmlFold start="<a>" end="</a>" fold transparent keepend extend
3253< This defines a region with "keepend", so that its end cannot be
3254 changed by contained items, like when the "</a>" is matched to
3255 highlight it differently. But when the xmlFold region is nested (it
3256 includes itself), the "extend" applies, so that the "</a>" of a nested
3257 region only ends that region, and not the one it is contained in.
3258
3259 *:syn-excludenl*
3260 When a pattern for a match or end pattern of a region includes a '$'
3261 to match the end-of-line, it will make a region item that it is
3262 contained in continue on the next line. For example, a match with
3263 "\\$" (backslash at the end of the line) can make a region continue
3264 that would normally stop at the end of the line. This is the default
3265 behavior. If this is not wanted, there are two ways to avoid it:
3266 1. Use "keepend" for the containing item. This will keep all
3267 contained matches from extending the match or region. It can be
3268 used when all contained items must not extend the containing item.
3269 2. Use "excludenl" in the contained item. This will keep that match
3270 from extending the containing match or region. It can be used if
3271 only some contained items must not extend the containing item.
3272 "excludenl" must be given before the pattern it applies to.
3273
3274 *:syn-matchgroup*
3275 "matchgroup" can be used to highlight the start and/or end pattern
3276 differently than the body of the region. Example: >
3277 :syntax region String matchgroup=Quote start=+"+ skip=+\\"+ end=+"+
3278< This will highlight the quotes with the "Quote" group, and the text in
3279 between with the "String" group.
3280 The "matchgroup" is used for all start and end patterns that follow,
3281 until the next "matchgroup". Use "matchgroup=NONE" to go back to not
3282 using a matchgroup.
3283
3284 In a start or end pattern that is highlighted with "matchgroup" the
3285 contained items of the region are not used. This can be used to avoid
3286 that a contained item matches in the start or end pattern match. When
3287 using "transparent", this does not apply to a start or end pattern
3288 match that is highlighted with "matchgroup".
3289
3290 Here is an example, which highlights three levels of parentheses in
3291 different colors: >
3292 :sy region par1 matchgroup=par1 start=/(/ end=/)/ contains=par2
3293 :sy region par2 matchgroup=par2 start=/(/ end=/)/ contains=par3 contained
3294 :sy region par3 matchgroup=par3 start=/(/ end=/)/ contains=par1 contained
3295 :hi par1 ctermfg=red guifg=red
3296 :hi par2 ctermfg=blue guifg=blue
3297 :hi par3 ctermfg=darkgreen guifg=darkgreen
Bram Moolenaaradc21822011-04-01 18:03:16 +02003298<
3299 *E849*
3300The maximum number of syntax groups is 19999.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003301
3302==============================================================================
33036. :syntax arguments *:syn-arguments*
3304
3305The :syntax commands that define syntax items take a number of arguments.
3306The common ones are explained here. The arguments may be given in any order
3307and may be mixed with patterns.
3308
3309Not all commands accept all arguments. This table shows which arguments
3310can not be used for all commands:
Bram Moolenaar09092152010-08-08 16:38:42 +02003311 *E395*
Bram Moolenaar860cae12010-06-05 23:22:07 +02003312 contains oneline fold display extend concealends~
3313:syntax keyword - - - - - -
3314:syntax match yes - yes yes yes -
3315:syntax region yes yes yes yes yes yes
Bram Moolenaar071d4272004-06-13 20:20:40 +00003316
3317These arguments can be used for all three commands:
Bram Moolenaar860cae12010-06-05 23:22:07 +02003318 conceal
3319 cchar
Bram Moolenaar071d4272004-06-13 20:20:40 +00003320 contained
3321 containedin
3322 nextgroup
3323 transparent
3324 skipwhite
3325 skipnl
3326 skipempty
3327
Bram Moolenaar860cae12010-06-05 23:22:07 +02003328conceal *conceal* *:syn-conceal*
3329
3330When the "conceal" argument is given, the item is marked as concealable.
Bram Moolenaar370df582010-06-22 05:16:38 +02003331Whether or not it is actually concealed depends on the value of the
Bram Moolenaarf5963f72010-07-23 22:10:27 +02003332'conceallevel' option. The 'concealcursor' option is used to decide whether
3333concealable items in the current line are displayed unconcealed to be able to
3334edit the line.
Bram Moolenaar860cae12010-06-05 23:22:07 +02003335
3336concealends *:syn-concealends*
3337
3338When the "concealends" argument is given, the start and end matches of
3339the region, but not the contents of the region, are marked as concealable.
3340Whether or not they are actually concealed depends on the setting on the
3341'conceallevel' option. The ends of a region can only be concealed separately
3342in this way when they have their own highlighting via "matchgroup"
3343
3344cchar *:syn-cchar*
Bram Moolenaard58e9292011-02-09 17:07:58 +01003345 *E844*
Bram Moolenaar860cae12010-06-05 23:22:07 +02003346The "cchar" argument defines the character shown in place of the item
3347when it is concealed (setting "cchar" only makes sense when the conceal
3348argument is given.) If "cchar" is not set then the default conceal
Bram Moolenaard58e9292011-02-09 17:07:58 +01003349character defined in the 'listchars' option is used. The character cannot be
3350a control character such as Tab. Example: >
Bram Moolenaar860cae12010-06-05 23:22:07 +02003351 :syntax match Entity "&amp;" conceal cchar=&
Bram Moolenaar9028b102010-07-11 16:58:51 +02003352See |hl-Conceal| for highlighting.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003353
3354contained *:syn-contained*
3355
3356When the "contained" argument is given, this item will not be recognized at
3357the top level, but only when it is mentioned in the "contains" field of
3358another match. Example: >
3359 :syntax keyword Todo TODO contained
3360 :syntax match Comment "//.*" contains=Todo
3361
3362
3363display *:syn-display*
3364
3365If the "display" argument is given, this item will be skipped when the
3366detected highlighting will not be displayed. This will speed up highlighting,
3367by skipping this item when only finding the syntax state for the text that is
3368to be displayed.
3369
3370Generally, you can use "display" for match and region items that meet these
3371conditions:
3372- The item does not continue past the end of a line. Example for C: A region
3373 for a "/*" comment can't contain "display", because it continues on the next
3374 line.
3375- The item does not contain items that continue past the end of the line or
3376 make it continue on the next line.
3377- The item does not change the size of any item it is contained in. Example
3378 for C: A match with "\\$" in a preprocessor match can't have "display",
3379 because it may make that preprocessor match shorter.
3380- The item does not allow other items to match that didn't match otherwise,
3381 and that item may extend the match too far. Example for C: A match for a
3382 "//" comment can't use "display", because a "/*" inside that comment would
3383 match then and start a comment which extends past the end of the line.
3384
3385Examples, for the C language, where "display" can be used:
3386- match with a number
3387- match with a label
3388
3389
3390transparent *:syn-transparent*
3391
3392If the "transparent" argument is given, this item will not be highlighted
3393itself, but will take the highlighting of the item it is contained in. This
3394is useful for syntax items that don't need any highlighting but are used
3395only to skip over a part of the text.
3396
3397The "contains=" argument is also inherited from the item it is contained in,
3398unless a "contains" argument is given for the transparent item itself. To
3399avoid that unwanted items are contained, use "contains=NONE". Example, which
3400highlights words in strings, but makes an exception for "vim": >
3401 :syn match myString /'[^']*'/ contains=myWord,myVim
3402 :syn match myWord /\<[a-z]*\>/ contained
3403 :syn match myVim /\<vim\>/ transparent contained contains=NONE
3404 :hi link myString String
3405 :hi link myWord Comment
3406Since the "myVim" match comes after "myWord" it is the preferred match (last
3407match in the same position overrules an earlier one). The "transparent"
3408argument makes the "myVim" match use the same highlighting as "myString". But
3409it does not contain anything. If the "contains=NONE" argument would be left
3410out, then "myVim" would use the contains argument from myString and allow
3411"myWord" to be contained, which will be highlighted as a Constant. This
3412happens because a contained match doesn't match inside itself in the same
3413position, thus the "myVim" match doesn't overrule the "myWord" match here.
3414
3415When you look at the colored text, it is like looking at layers of contained
3416items. The contained item is on top of the item it is contained in, thus you
3417see the contained item. When a contained item is transparent, you can look
3418through, thus you see the item it is contained in. In a picture:
3419
3420 look from here
3421
3422 | | | | | |
3423 V V V V V V
3424
3425 xxxx yyy more contained items
3426 .................... contained item (transparent)
3427 ============================= first item
3428
3429The 'x', 'y' and '=' represent a highlighted syntax item. The '.' represent a
3430transparent group.
3431
3432What you see is:
3433
3434 =======xxxx=======yyy========
3435
3436Thus you look through the transparent "....".
3437
3438
3439oneline *:syn-oneline*
3440
3441The "oneline" argument indicates that the region does not cross a line
3442boundary. It must match completely in the current line. However, when the
3443region has a contained item that does cross a line boundary, it continues on
3444the next line anyway. A contained item can be used to recognize a line
3445continuation pattern. But the "end" pattern must still match in the first
3446line, otherwise the region doesn't even start.
3447
3448When the start pattern includes a "\n" to match an end-of-line, the end
3449pattern must be found in the same line as where the start pattern ends. The
3450end pattern may also include an end-of-line. Thus the "oneline" argument
3451means that the end of the start pattern and the start of the end pattern must
3452be within one line. This can't be changed by a skip pattern that matches a
3453line break.
3454
3455
3456fold *:syn-fold*
3457
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003458The "fold" argument makes the fold level increase by one for this item.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003459Example: >
3460 :syn region myFold start="{" end="}" transparent fold
3461 :syn sync fromstart
3462 :set foldmethod=syntax
3463This will make each {} block form one fold.
3464
3465The fold will start on the line where the item starts, and end where the item
3466ends. If the start and end are within the same line, there is no fold.
3467The 'foldnestmax' option limits the nesting of syntax folds.
3468{not available when Vim was compiled without |+folding| feature}
3469
3470
3471 *:syn-contains* *E405* *E406* *E407* *E408* *E409*
3472contains={groupname},..
3473
3474The "contains" argument is followed by a list of syntax group names. These
3475groups will be allowed to begin inside the item (they may extend past the
3476containing group's end). This allows for recursive nesting of matches and
3477regions. If there is no "contains" argument, no groups will be contained in
3478this item. The group names do not need to be defined before they can be used
3479here.
3480
3481contains=ALL
3482 If the only item in the contains list is "ALL", then all
3483 groups will be accepted inside the item.
3484
3485contains=ALLBUT,{group-name},..
3486 If the first item in the contains list is "ALLBUT", then all
3487 groups will be accepted inside the item, except the ones that
3488 are listed. Example: >
3489 :syntax region Block start="{" end="}" ... contains=ALLBUT,Function
3490
3491contains=TOP
3492 If the first item in the contains list is "TOP", then all
3493 groups will be accepted that don't have the "contained"
3494 argument.
3495contains=TOP,{group-name},..
3496 Like "TOP", but excluding the groups that are listed.
3497
3498contains=CONTAINED
3499 If the first item in the contains list is "CONTAINED", then
3500 all groups will be accepted that have the "contained"
3501 argument.
3502contains=CONTAINED,{group-name},..
3503 Like "CONTAINED", but excluding the groups that are
3504 listed.
3505
3506
3507The {group-name} in the "contains" list can be a pattern. All group names
3508that match the pattern will be included (or excluded, if "ALLBUT" is used).
3509The pattern cannot contain white space or a ','. Example: >
3510 ... contains=Comment.*,Keyw[0-3]
3511The matching will be done at moment the syntax command is executed. Groups
3512that are defined later will not be matched. Also, if the current syntax
3513command defines a new group, it is not matched. Be careful: When putting
3514syntax commands in a file you can't rely on groups NOT being defined, because
3515the file may have been sourced before, and ":syn clear" doesn't remove the
3516group names.
3517
3518The contained groups will also match in the start and end patterns of a
3519region. If this is not wanted, the "matchgroup" argument can be used
3520|:syn-matchgroup|. The "ms=" and "me=" offsets can be used to change the
3521region where contained items do match. Note that this may also limit the
3522area that is highlighted
3523
3524
3525containedin={groupname}... *:syn-containedin*
3526
3527The "containedin" argument is followed by a list of syntax group names. The
3528item will be allowed to begin inside these groups. This works as if the
3529containing item has a "contains=" argument that includes this item.
3530
3531The {groupname}... can be used just like for "contains", as explained above.
3532
3533This is useful when adding a syntax item afterwards. An item can be told to
3534be included inside an already existing item, without changing the definition
3535of that item. For example, to highlight a word in a C comment after loading
3536the C syntax: >
3537 :syn keyword myword HELP containedin=cComment contained
3538Note that "contained" is also used, to avoid that the item matches at the top
3539level.
3540
3541Matches for "containedin" are added to the other places where the item can
3542appear. A "contains" argument may also be added as usual. Don't forget that
3543keywords never contain another item, thus adding them to "containedin" won't
3544work.
3545
3546
3547nextgroup={groupname},.. *:syn-nextgroup*
3548
3549The "nextgroup" argument is followed by a list of syntax group names,
3550separated by commas (just like with "contains", so you can also use patterns).
3551
3552If the "nextgroup" argument is given, the mentioned syntax groups will be
3553tried for a match, after the match or region ends. If none of the groups have
3554a match, highlighting continues normally. If there is a match, this group
3555will be used, even when it is not mentioned in the "contains" field of the
3556current group. This is like giving the mentioned group priority over all
3557other groups. Example: >
3558 :syntax match ccFoobar "Foo.\{-}Bar" contains=ccFoo
3559 :syntax match ccFoo "Foo" contained nextgroup=ccFiller
3560 :syntax region ccFiller start="." matchgroup=ccBar end="Bar" contained
3561
3562This will highlight "Foo" and "Bar" differently, and only when there is a
3563"Bar" after "Foo". In the text line below, "f" shows where ccFoo is used for
3564highlighting, and "bbb" where ccBar is used. >
3565
3566 Foo asdfasd Bar asdf Foo asdf Bar asdf
3567 fff bbb fff bbb
3568
3569Note the use of ".\{-}" to skip as little as possible until the next Bar.
3570when ".*" would be used, the "asdf" in between "Bar" and "Foo" would be
3571highlighted according to the "ccFoobar" group, because the ccFooBar match
3572would include the first "Foo" and the last "Bar" in the line (see |pattern|).
3573
3574
3575skipwhite *:syn-skipwhite*
3576skipnl *:syn-skipnl*
3577skipempty *:syn-skipempty*
3578
3579These arguments are only used in combination with "nextgroup". They can be
3580used to allow the next group to match after skipping some text:
Bram Moolenaardd2a0d82007-05-12 15:07:00 +00003581 skipwhite skip over space and tab characters
Bram Moolenaar071d4272004-06-13 20:20:40 +00003582 skipnl skip over the end of a line
3583 skipempty skip over empty lines (implies a "skipnl")
3584
3585When "skipwhite" is present, the white space is only skipped if there is no
3586next group that matches the white space.
3587
3588When "skipnl" is present, the match with nextgroup may be found in the next
3589line. This only happens when the current item ends at the end of the current
3590line! When "skipnl" is not present, the nextgroup will only be found after
3591the current item in the same line.
3592
3593When skipping text while looking for a next group, the matches for other
3594groups are ignored. Only when no next group matches, other items are tried
3595for a match again. This means that matching a next group and skipping white
3596space and <EOL>s has a higher priority than other items.
3597
3598Example: >
3599 :syn match ifstart "\<if.*" nextgroup=ifline skipwhite skipempty
3600 :syn match ifline "[^ \t].*" nextgroup=ifline skipwhite skipempty contained
3601 :syn match ifline "endif" contained
3602Note that the "[^ \t].*" match matches all non-white text. Thus it would also
3603match "endif". Therefore the "endif" match is put last, so that it takes
3604precedence.
3605Note that this example doesn't work for nested "if"s. You need to add
3606"contains" arguments to make that work (omitted for simplicity of the
3607example).
3608
Bram Moolenaar860cae12010-06-05 23:22:07 +02003609IMPLICIT CONCEAL *:syn-conceal-implicit*
3610
3611:sy[ntax] conceal [on|off]
3612 This defines if the following ":syntax" commands will define keywords,
3613 matches or regions with the "conceal" flag set. After ":syn conceal
3614 on", all subsequent ":syn keyword", ":syn match" or ":syn region"
3615 defined will have the "conceal" flag set implicitly. ":syn conceal
3616 off" returns to the normal state where the "conceal" flag must be
3617 given explicitly.
3618
Bram Moolenaar071d4272004-06-13 20:20:40 +00003619==============================================================================
36207. Syntax patterns *:syn-pattern* *E401* *E402*
3621
3622In the syntax commands, a pattern must be surrounded by two identical
3623characters. This is like it works for the ":s" command. The most common to
3624use is the double quote. But if the pattern contains a double quote, you can
3625use another character that is not used in the pattern. Examples: >
3626 :syntax region Comment start="/\*" end="\*/"
3627 :syntax region String start=+"+ end=+"+ skip=+\\"+
3628
3629See |pattern| for the explanation of what a pattern is. Syntax patterns are
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003630always interpreted like the 'magic' option is set, no matter what the actual
Bram Moolenaar071d4272004-06-13 20:20:40 +00003631value of 'magic' is. And the patterns are interpreted like the 'l' flag is
3632not included in 'cpoptions'. This was done to make syntax files portable and
3633independent of 'compatible' and 'magic' settings.
3634
3635Try to avoid patterns that can match an empty string, such as "[a-z]*".
3636This slows down the highlighting a lot, because it matches everywhere.
3637
3638 *:syn-pattern-offset*
3639The pattern can be followed by a character offset. This can be used to
3640change the highlighted part, and to change the text area included in the
3641match or region (which only matters when trying to match other items). Both
3642are relative to the matched pattern. The character offset for a skip
3643pattern can be used to tell where to continue looking for an end pattern.
3644
3645The offset takes the form of "{what}={offset}"
3646The {what} can be one of seven strings:
3647
3648ms Match Start offset for the start of the matched text
3649me Match End offset for the end of the matched text
3650hs Highlight Start offset for where the highlighting starts
3651he Highlight End offset for where the highlighting ends
3652rs Region Start offset for where the body of a region starts
3653re Region End offset for where the body of a region ends
3654lc Leading Context offset past "leading context" of pattern
3655
3656The {offset} can be:
3657
3658s start of the matched pattern
3659s+{nr} start of the matched pattern plus {nr} chars to the right
3660s-{nr} start of the matched pattern plus {nr} chars to the left
3661e end of the matched pattern
3662e+{nr} end of the matched pattern plus {nr} chars to the right
3663e-{nr} end of the matched pattern plus {nr} chars to the left
3664{nr} (for "lc" only): start matching {nr} chars to the left
3665
3666Examples: "ms=s+1", "hs=e-2", "lc=3".
3667
3668Although all offsets are accepted after any pattern, they are not always
3669meaningful. This table shows which offsets are actually used:
3670
3671 ms me hs he rs re lc ~
3672match item yes yes yes yes - - yes
3673region item start yes - yes - yes - yes
3674region item skip - yes - - - - yes
3675region item end - yes - yes - yes yes
3676
3677Offsets can be concatenated, with a ',' in between. Example: >
3678 :syn match String /"[^"]*"/hs=s+1,he=e-1
3679<
3680 some "string" text
3681 ^^^^^^ highlighted
3682
3683Notes:
3684- There must be no white space between the pattern and the character
3685 offset(s).
3686- The highlighted area will never be outside of the matched text.
3687- A negative offset for an end pattern may not always work, because the end
3688 pattern may be detected when the highlighting should already have stopped.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003689- Before Vim 7.2 the offsets were counted in bytes instead of characters.
3690 This didn't work well for multi-byte characters, so it was changed with the
3691 Vim 7.2 release.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003692- The start of a match cannot be in a line other than where the pattern
3693 matched. This doesn't work: "a\nb"ms=e. You can make the highlighting
3694 start in another line, this does work: "a\nb"hs=e.
3695
3696Example (match a comment but don't highlight the /* and */): >
3697 :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1
3698<
3699 /* this is a comment */
3700 ^^^^^^^^^^^^^^^^^^^ highlighted
3701
3702A more complicated Example: >
3703 :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
3704<
3705 abcfoostringbarabc
3706 mmmmmmmmmmm match
Bram Moolenaar4770d092006-01-12 23:22:24 +00003707 sssrrreee highlight start/region/end ("Foo", "Exa" and "Bar")
Bram Moolenaar071d4272004-06-13 20:20:40 +00003708
3709Leading context *:syn-lc* *:syn-leading* *:syn-context*
3710
3711Note: This is an obsolete feature, only included for backwards compatibility
3712with previous Vim versions. It's now recommended to use the |/\@<=| construct
3713in the pattern.
3714
3715The "lc" offset specifies leading context -- a part of the pattern that must
3716be present, but is not considered part of the match. An offset of "lc=n" will
3717cause Vim to step back n columns before attempting the pattern match, allowing
3718characters which have already been matched in previous patterns to also be
3719used as leading context for this match. This can be used, for instance, to
3720specify that an "escaping" character must not precede the match: >
3721
3722 :syn match ZNoBackslash "[^\\]z"ms=s+1
3723 :syn match WNoBackslash "[^\\]w"lc=1
3724 :syn match Underline "_\+"
3725<
3726 ___zzzz ___wwww
3727 ^^^ ^^^ matches Underline
3728 ^ ^ matches ZNoBackslash
3729 ^^^^ matches WNoBackslash
3730
3731The "ms" offset is automatically set to the same value as the "lc" offset,
3732unless you set "ms" explicitly.
3733
3734
3735Multi-line patterns *:syn-multi-line*
3736
3737The patterns can include "\n" to match an end-of-line. Mostly this works as
3738expected, but there are a few exceptions.
3739
3740When using a start pattern with an offset, the start of the match is not
3741allowed to start in a following line. The highlighting can start in a
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01003742following line though. Using the "\zs" item also requires that the start of
3743the match doesn't move to another line.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003744
3745The skip pattern can include the "\n", but the search for an end pattern will
3746continue in the first character of the next line, also when that character is
3747matched by the skip pattern. This is because redrawing may start in any line
3748halfway a region and there is no check if the skip pattern started in a
3749previous line. For example, if the skip pattern is "a\nb" and an end pattern
3750is "b", the end pattern does match in the second line of this: >
3751 x x a
3752 b x x
3753Generally this means that the skip pattern should not match any characters
3754after the "\n".
3755
3756
3757External matches *:syn-ext-match*
3758
3759These extra regular expression items are available in region patterns:
3760
3761 */\z(* */\z(\)* *E50* *E52*
3762 \z(\) Marks the sub-expression as "external", meaning that it is can
3763 be accessed from another pattern match. Currently only usable
3764 in defining a syntax region start pattern.
3765
3766 */\z1* */\z2* */\z3* */\z4* */\z5*
3767 \z1 ... \z9 */\z6* */\z7* */\z8* */\z9* *E66* *E67*
3768 Matches the same string that was matched by the corresponding
3769 sub-expression in a previous start pattern match.
3770
3771Sometimes the start and end patterns of a region need to share a common
3772sub-expression. A common example is the "here" document in Perl and many Unix
3773shells. This effect can be achieved with the "\z" special regular expression
3774items, which marks a sub-expression as "external", in the sense that it can be
3775referenced from outside the pattern in which it is defined. The here-document
3776example, for instance, can be done like this: >
3777 :syn region hereDoc start="<<\z(\I\i*\)" end="^\z1$"
3778
3779As can be seen here, the \z actually does double duty. In the start pattern,
3780it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it
3781changes the \1 back-reference into an external reference referring to the
3782first external sub-expression in the start pattern. External references can
3783also be used in skip patterns: >
3784 :syn region foo start="start \(\I\i*\)" skip="not end \z1" end="end \z1"
3785
3786Note that normal and external sub-expressions are completely orthogonal and
3787indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied
3788to the string "aabb", then \1 will refer to "bb" and \z1 will refer to "aa".
3789Note also that external sub-expressions cannot be accessed as back-references
3790within the same pattern like normal sub-expressions. If you want to use one
3791sub-expression as both a normal and an external sub-expression, you can nest
3792the two, as in "\(\z(...\)\)".
3793
3794Note that only matches within a single line can be used. Multi-line matches
3795cannot be referred to.
3796
3797==============================================================================
37988. Syntax clusters *:syn-cluster* *E400*
3799
3800:sy[ntax] cluster {cluster-name} [contains={group-name}..]
3801 [add={group-name}..]
3802 [remove={group-name}..]
3803
3804This command allows you to cluster a list of syntax groups together under a
3805single name.
3806
3807 contains={group-name}..
3808 The cluster is set to the specified list of groups.
3809 add={group-name}..
3810 The specified groups are added to the cluster.
3811 remove={group-name}..
3812 The specified groups are removed from the cluster.
3813
Bram Moolenaar8c8de832008-06-24 22:58:06 +00003814A cluster so defined may be referred to in a contains=.., containedin=..,
3815nextgroup=.., add=.. or remove=.. list with a "@" prefix. You can also use
3816this notation to implicitly declare a cluster before specifying its contents.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003817
3818Example: >
3819 :syntax match Thing "# [^#]\+ #" contains=@ThingMembers
3820 :syntax cluster ThingMembers contains=ThingMember1,ThingMember2
3821
3822As the previous example suggests, modifications to a cluster are effectively
3823retroactive; the membership of the cluster is checked at the last minute, so
3824to speak: >
3825 :syntax keyword A aaa
3826 :syntax keyword B bbb
3827 :syntax cluster AandB contains=A
3828 :syntax match Stuff "( aaa bbb )" contains=@AandB
3829 :syntax cluster AandB add=B " now both keywords are matched in Stuff
3830
3831This also has implications for nested clusters: >
3832 :syntax keyword A aaa
3833 :syntax keyword B bbb
3834 :syntax cluster SmallGroup contains=B
3835 :syntax cluster BigGroup contains=A,@SmallGroup
3836 :syntax match Stuff "( aaa bbb )" contains=@BigGroup
3837 :syntax cluster BigGroup remove=B " no effect, since B isn't in BigGroup
3838 :syntax cluster SmallGroup remove=B " now bbb isn't matched within Stuff
Bram Moolenaaradc21822011-04-01 18:03:16 +02003839<
3840 *E848*
3841The maximum number of clusters is 9767.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003842
3843==============================================================================
38449. Including syntax files *:syn-include* *E397*
3845
3846It is often useful for one language's syntax file to include a syntax file for
3847a related language. Depending on the exact relationship, this can be done in
3848two different ways:
3849
3850 - If top-level syntax items in the included syntax file are to be
3851 allowed at the top level in the including syntax, you can simply use
3852 the |:runtime| command: >
3853
3854 " In cpp.vim:
3855 :runtime! syntax/c.vim
3856 :unlet b:current_syntax
3857
3858< - If top-level syntax items in the included syntax file are to be
3859 contained within a region in the including syntax, you can use the
3860 ":syntax include" command:
3861
3862:sy[ntax] include [@{grouplist-name}] {file-name}
3863
3864 All syntax items declared in the included file will have the
3865 "contained" flag added. In addition, if a group list is specified,
3866 all top-level syntax items in the included file will be added to
3867 that list. >
3868
3869 " In perl.vim:
3870 :syntax include @Pod <sfile>:p:h/pod.vim
3871 :syntax region perlPOD start="^=head" end="^=cut" contains=@Pod
3872<
3873 When {file-name} is an absolute path (starts with "/", "c:", "$VAR"
3874 or "<sfile>") that file is sourced. When it is a relative path
3875 (e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'.
3876 All matching files are loaded. Using a relative path is
3877 recommended, because it allows a user to replace the included file
3878 with his own version, without replacing the file that does the ":syn
3879 include".
3880
Bram Moolenaaradc21822011-04-01 18:03:16 +02003881 *E847*
3882The maximum number of includes is 999.
3883
Bram Moolenaar071d4272004-06-13 20:20:40 +00003884==============================================================================
388510. Synchronizing *:syn-sync* *E403* *E404*
3886
3887Vim wants to be able to start redrawing in any position in the document. To
3888make this possible it needs to know the syntax state at the position where
3889redrawing starts.
3890
3891:sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
3892
3893There are four ways to synchronize:
38941. Always parse from the start of the file.
3895 |:syn-sync-first|
38962. Based on C-style comments. Vim understands how C-comments work and can
3897 figure out if the current line starts inside or outside a comment.
3898 |:syn-sync-second|
38993. Jumping back a certain number of lines and start parsing there.
3900 |:syn-sync-third|
39014. Searching backwards in the text for a pattern to sync on.
3902 |:syn-sync-fourth|
3903
3904 *:syn-sync-maxlines* *:syn-sync-minlines*
3905For the last three methods, the line range where the parsing can start is
3906limited by "minlines" and "maxlines".
3907
3908If the "minlines={N}" argument is given, the parsing always starts at least
3909that many lines backwards. This can be used if the parsing may take a few
3910lines before it's correct, or when it's not possible to use syncing.
3911
3912If the "maxlines={N}" argument is given, the number of lines that are searched
3913for a comment or syncing pattern is restricted to N lines backwards (after
3914adding "minlines"). This is useful if you have few things to sync on and a
3915slow machine. Example: >
3916 :syntax sync ccomment maxlines=500
3917<
3918 *:syn-sync-linebreaks*
3919When using a pattern that matches multiple lines, a change in one line may
3920cause a pattern to no longer match in a previous line. This means has to
3921start above where the change was made. How many lines can be specified with
3922the "linebreaks" argument. For example, when a pattern may include one line
3923break use this: >
3924 :syntax sync linebreaks=1
3925The result is that redrawing always starts at least one line before where a
3926change was made. The default value for "linebreaks" is zero. Usually the
3927value for "minlines" is bigger than "linebreaks".
3928
3929
3930First syncing method: *:syn-sync-first*
3931>
3932 :syntax sync fromstart
3933
3934The file will be parsed from the start. This makes syntax highlighting
3935accurate, but can be slow for long files. Vim caches previously parsed text,
3936so that it's only slow when parsing the text for the first time. However,
Bram Moolenaarf1568ec2011-12-14 21:17:39 +01003937when making changes some part of the text needs to be parsed again (worst
Bram Moolenaar071d4272004-06-13 20:20:40 +00003938case: to the end of the file).
3939
3940Using "fromstart" is equivalent to using "minlines" with a very large number.
3941
3942
3943Second syncing method: *:syn-sync-second* *:syn-sync-ccomment*
3944
3945For the second method, only the "ccomment" argument needs to be given.
3946Example: >
3947 :syntax sync ccomment
3948
3949When Vim finds that the line where displaying starts is inside a C-style
3950comment, the last region syntax item with the group-name "Comment" will be
3951used. This requires that there is a region with the group-name "Comment"!
3952An alternate group name can be specified, for example: >
3953 :syntax sync ccomment javaComment
3954This means that the last item specified with "syn region javaComment" will be
3955used for the detected C comment region. This only works properly if that
3956region does have a start pattern "\/*" and an end pattern "*\/".
3957
3958The "maxlines" argument can be used to restrict the search to a number of
3959lines. The "minlines" argument can be used to at least start a number of
3960lines back (e.g., for when there is some construct that only takes a few
3961lines, but it hard to sync on).
3962
3963Note: Syncing on a C comment doesn't work properly when strings are used
3964that cross a line and contain a "*/". Since letting strings cross a line
3965is a bad programming habit (many compilers give a warning message), and the
3966chance of a "*/" appearing inside a comment is very small, this restriction
3967is hardly ever noticed.
3968
3969
3970Third syncing method: *:syn-sync-third*
3971
3972For the third method, only the "minlines={N}" argument needs to be given.
3973Vim will subtract {N} from the line number and start parsing there. This
3974means {N} extra lines need to be parsed, which makes this method a bit slower.
3975Example: >
3976 :syntax sync minlines=50
3977
3978"lines" is equivalent to "minlines" (used by older versions).
3979
3980
3981Fourth syncing method: *:syn-sync-fourth*
3982
3983The idea is to synchronize on the end of a few specific regions, called a
3984sync pattern. Only regions can cross lines, so when we find the end of some
3985region, we might be able to know in which syntax item we are. The search
3986starts in the line just above the one where redrawing starts. From there
3987the search continues backwards in the file.
3988
3989This works just like the non-syncing syntax items. You can use contained
3990matches, nextgroup, etc. But there are a few differences:
3991- Keywords cannot be used.
3992- The syntax items with the "sync" keyword form a completely separated group
3993 of syntax items. You can't mix syncing groups and non-syncing groups.
3994- The matching works backwards in the buffer (line by line), instead of
3995 forwards.
3996- A line continuation pattern can be given. It is used to decide which group
3997 of lines need to be searched like they were one line. This means that the
3998 search for a match with the specified items starts in the first of the
3999 consecutive that contain the continuation pattern.
4000- When using "nextgroup" or "contains", this only works within one line (or
4001 group of continued lines).
4002- When using a region, it must start and end in the same line (or group of
4003 continued lines). Otherwise the end is assumed to be at the end of the
4004 line (or group of continued lines).
4005- When a match with a sync pattern is found, the rest of the line (or group of
4006 continued lines) is searched for another match. The last match is used.
4007 This is used when a line can contain both the start end the end of a region
4008 (e.g., in a C-comment like /* this */, the last "*/" is used).
4009
4010There are two ways how a match with a sync pattern can be used:
40111. Parsing for highlighting starts where redrawing starts (and where the
4012 search for the sync pattern started). The syntax group that is expected
4013 to be valid there must be specified. This works well when the regions
4014 that cross lines cannot contain other regions.
40152. Parsing for highlighting continues just after the match. The syntax group
4016 that is expected to be present just after the match must be specified.
4017 This can be used when the previous method doesn't work well. It's much
4018 slower, because more text needs to be parsed.
4019Both types of sync patterns can be used at the same time.
4020
4021Besides the sync patterns, other matches and regions can be specified, to
4022avoid finding unwanted matches.
4023
4024[The reason that the sync patterns are given separately, is that mostly the
4025search for the sync point can be much simpler than figuring out the
4026highlighting. The reduced number of patterns means it will go (much)
4027faster.]
4028
4029 *syn-sync-grouphere* *E393* *E394*
4030 :syntax sync match {sync-group-name} grouphere {group-name} "pattern" ..
4031
4032 Define a match that is used for syncing. {group-name} is the
4033 name of a syntax group that follows just after the match. Parsing
4034 of the text for highlighting starts just after the match. A region
4035 must exist for this {group-name}. The first one defined will be used.
4036 "NONE" can be used for when there is no syntax group after the match.
4037
4038 *syn-sync-groupthere*
4039 :syntax sync match {sync-group-name} groupthere {group-name} "pattern" ..
4040
4041 Like "grouphere", but {group-name} is the name of a syntax group that
4042 is to be used at the start of the line where searching for the sync
4043 point started. The text between the match and the start of the sync
4044 pattern searching is assumed not to change the syntax highlighting.
4045 For example, in C you could search backwards for "/*" and "*/". If
4046 "/*" is found first, you know that you are inside a comment, so the
4047 "groupthere" is "cComment". If "*/" is found first, you know that you
4048 are not in a comment, so the "groupthere" is "NONE". (in practice
4049 it's a bit more complicated, because the "/*" and "*/" could appear
4050 inside a string. That's left as an exercise to the reader...).
4051
4052 :syntax sync match ..
4053 :syntax sync region ..
4054
4055 Without a "groupthere" argument. Define a region or match that is
4056 skipped while searching for a sync point.
4057
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00004058 *syn-sync-linecont*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059 :syntax sync linecont {pattern}
4060
4061 When {pattern} matches in a line, it is considered to continue in
4062 the next line. This means that the search for a sync point will
4063 consider the lines to be concatenated.
4064
4065If the "maxlines={N}" argument is given too, the number of lines that are
4066searched for a match is restricted to N. This is useful if you have very
4067few things to sync on and a slow machine. Example: >
4068 :syntax sync maxlines=100
4069
4070You can clear all sync settings with: >
4071 :syntax sync clear
4072
4073You can clear specific sync patterns with: >
4074 :syntax sync clear {sync-group-name} ..
4075
4076==============================================================================
407711. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
4078
Bram Moolenaar482aaeb2005-09-29 18:26:07 +00004079This command lists all the syntax items: >
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080
4081 :sy[ntax] [list]
4082
4083To show the syntax items for one syntax group: >
4084
4085 :sy[ntax] list {group-name}
4086
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +02004087To list the syntax groups in one cluster: *E392* >
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088
4089 :sy[ntax] list @{cluster-name}
4090
4091See above for other arguments for the ":syntax" command.
4092
4093Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
4094is mostly used, because it looks better.
4095
4096==============================================================================
409712. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
4098
4099There are three types of highlight groups:
4100- The ones used for specific languages. For these the name starts with the
4101 name of the language. Many of these don't have any attributes, but are
4102 linked to a group of the second type.
4103- The ones used for all syntax languages.
4104- The ones used for the 'highlight' option.
4105 *hitest.vim*
4106You can see all the groups currently active with this command: >
4107 :so $VIMRUNTIME/syntax/hitest.vim
4108This will open a new window containing all highlight group names, displayed
4109in their own color.
4110
4111 *:colo* *:colorscheme* *E185*
Bram Moolenaar00a927d2010-05-14 23:24:24 +02004112:colo[rscheme] Output the name of the currently active color scheme.
4113 This is basically the same as >
4114 :echo g:colors_name
4115< In case g:colors_name has not been defined :colo will
4116 output "default". When compiled without the |+eval|
4117 feature it will output "unknown".
4118
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
4120 for the file "colors/{name}.vim. The first one that
4121 is found is loaded.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01004122 To see the name of the currently active color scheme: >
Bram Moolenaar00a927d2010-05-14 23:24:24 +02004123 :colo
4124< The name is also stored in the g:colors_name variable.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01004125 Doesn't work recursively, thus you can't use
Bram Moolenaar071d4272004-06-13 20:20:40 +00004126 ":colorscheme" in a color scheme script.
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00004127 After the color scheme has been loaded the
4128 |ColorScheme| autocommand event is triggered.
Bram Moolenaard4755bb2004-09-02 19:12:26 +00004129 For info about writing a colorscheme file: >
4130 :edit $VIMRUNTIME/colors/README.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131
4132:hi[ghlight] List all the current highlight groups that have
4133 attributes set.
4134
4135:hi[ghlight] {group-name}
4136 List one highlight group.
4137
4138:hi[ghlight] clear Reset all highlighting to the defaults. Removes all
4139 highlighting for groups added by the user!
4140 Uses the current value of 'background' to decide which
4141 default colors to use.
4142
4143:hi[ghlight] clear {group-name}
4144:hi[ghlight] {group-name} NONE
4145 Disable the highlighting for one highlight group. It
4146 is _not_ set back to the default colors.
4147
4148:hi[ghlight] [default] {group-name} {key}={arg} ..
4149 Add a highlight group, or change the highlighting for
4150 an existing group.
4151 See |highlight-args| for the {key}={arg} arguments.
4152 See |:highlight-default| for the optional [default]
4153 argument.
4154
4155Normally a highlight group is added once when starting up. This sets the
4156default values for the highlighting. After that, you can use additional
4157highlight commands to change the arguments that you want to set to non-default
4158values. The value "NONE" can be used to switch the value off or go back to
4159the default value.
4160
4161A simple way to change colors is with the |:colorscheme| command. This loads
4162a file with ":highlight" commands such as this: >
4163
4164 :hi Comment gui=bold
4165
4166Note that all settings that are not included remain the same, only the
4167specified field is used, and settings are merged with previous ones. So, the
4168result is like this single command has been used: >
4169 :hi Comment term=bold ctermfg=Cyan guifg=#80a0ff gui=bold
4170<
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00004171 *:highlight-verbose*
Bram Moolenaar661b1822005-07-28 22:36:45 +00004172When listing a highlight group and 'verbose' is non-zero, the listing will
4173also tell where it was last set. Example: >
4174 :verbose hi Comment
4175< Comment xxx term=bold ctermfg=4 guifg=Blue ~
Bram Moolenaarc9b4b052006-04-30 18:54:39 +00004176 Last set from /home/mool/vim/vim7/runtime/syntax/syncolor.vim ~
Bram Moolenaar661b1822005-07-28 22:36:45 +00004177
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00004178When ":hi clear" is used then the script where this command is used will be
4179mentioned for the default values. See |:verbose-cmd| for more information.
Bram Moolenaar661b1822005-07-28 22:36:45 +00004180
Bram Moolenaar071d4272004-06-13 20:20:40 +00004181 *highlight-args* *E416* *E417* *E423*
4182There are three types of terminals for highlighting:
4183term a normal terminal (vt100, xterm)
4184cterm a color terminal (MS-DOS console, color-xterm, these have the "Co"
4185 termcap entry)
4186gui the GUI
4187
4188For each type the highlighting can be given. This makes it possible to use
4189the same syntax file on all terminals, and use the optimal highlighting.
4190
41911. highlight arguments for normal terminals
4192
Bram Moolenaar75c50c42005-06-04 22:06:24 +00004193 *bold* *underline* *undercurl*
4194 *inverse* *italic* *standout*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004195term={attr-list} *attr-list* *highlight-term* *E418*
4196 attr-list is a comma separated list (without spaces) of the
4197 following items (in any order):
4198 bold
4199 underline
Bram Moolenaar5409c052005-03-18 20:27:04 +00004200 undercurl not always available
Bram Moolenaar071d4272004-06-13 20:20:40 +00004201 reverse
4202 inverse same as reverse
4203 italic
4204 standout
4205 NONE no attributes used (used to reset it)
4206
4207 Note that "bold" can be used here and by using a bold font. They
4208 have the same effect.
Bram Moolenaar5409c052005-03-18 20:27:04 +00004209 "undercurl" is a curly underline. When "undercurl" is not possible
4210 then "underline" is used. In general "undercurl" is only available in
Bram Moolenaar910f66f2006-04-05 20:41:53 +00004211 the GUI. The color is set with |highlight-guisp|.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212
4213start={term-list} *highlight-start* *E422*
4214stop={term-list} *term-list* *highlight-stop*
4215 These lists of terminal codes can be used to get
4216 non-standard attributes on a terminal.
4217
4218 The escape sequence specified with the "start" argument
4219 is written before the characters in the highlighted
4220 area. It can be anything that you want to send to the
4221 terminal to highlight this area. The escape sequence
4222 specified with the "stop" argument is written after the
4223 highlighted area. This should undo the "start" argument.
4224 Otherwise the screen will look messed up.
4225
4226 The {term-list} can have two forms:
4227
4228 1. A string with escape sequences.
4229 This is any string of characters, except that it can't start with
4230 "t_" and blanks are not allowed. The <> notation is recognized
4231 here, so you can use things like "<Esc>" and "<Space>". Example:
4232 start=<Esc>[27h;<Esc>[<Space>r;
4233
4234 2. A list of terminal codes.
4235 Each terminal code has the form "t_xx", where "xx" is the name of
4236 the termcap entry. The codes have to be separated with commas.
4237 White space is not allowed. Example:
4238 start=t_C1,t_BL
4239 The terminal codes must exist for this to work.
4240
4241
42422. highlight arguments for color terminals
4243
4244cterm={attr-list} *highlight-cterm*
4245 See above for the description of {attr-list} |attr-list|.
4246 The "cterm" argument is likely to be different from "term", when
4247 colors are used. For example, in a normal terminal comments could
4248 be underlined, in a color terminal they can be made Blue.
4249 Note: Many terminals (e.g., DOS console) can't mix these attributes
4250 with coloring. Use only one of "cterm=" OR "ctermfg=" OR "ctermbg=".
4251
4252ctermfg={color-nr} *highlight-ctermfg* *E421*
4253ctermbg={color-nr} *highlight-ctermbg*
4254 The {color-nr} argument is a color number. Its range is zero to
4255 (not including) the number given by the termcap entry "Co".
4256 The actual color with this number depends on the type of terminal
4257 and its settings. Sometimes the color also depends on the settings of
4258 "cterm". For example, on some systems "cterm=bold ctermfg=3" gives
4259 another color, on others you just get color 3.
4260
4261 For an xterm this depends on your resources, and is a bit
4262 unpredictable. See your xterm documentation for the defaults. The
4263 colors for a color-xterm can be changed from the .Xdefaults file.
4264 Unfortunately this means that it's not possible to get the same colors
4265 for each user. See |xterm-color| for info about color xterms.
4266
4267 The MSDOS standard colors are fixed (in a console window), so these
4268 have been used for the names. But the meaning of color names in X11
4269 are fixed, so these color settings have been used, to make the
4270 highlighting settings portable (complicated, isn't it?). The
4271 following names are recognized, with the color number used:
4272
4273 *cterm-colors*
4274 NR-16 NR-8 COLOR NAME ~
4275 0 0 Black
4276 1 4 DarkBlue
4277 2 2 DarkGreen
4278 3 6 DarkCyan
4279 4 1 DarkRed
4280 5 5 DarkMagenta
4281 6 3 Brown, DarkYellow
4282 7 7 LightGray, LightGrey, Gray, Grey
4283 8 0* DarkGray, DarkGrey
4284 9 4* Blue, LightBlue
4285 10 2* Green, LightGreen
4286 11 6* Cyan, LightCyan
4287 12 1* Red, LightRed
4288 13 5* Magenta, LightMagenta
4289 14 3* Yellow, LightYellow
4290 15 7* White
4291
4292 The number under "NR-16" is used for 16-color terminals ('t_Co'
4293 greater than or equal to 16). The number under "NR-8" is used for
4294 8-color terminals ('t_Co' less than 16). The '*' indicates that the
4295 bold attribute is set for ctermfg. In many 8-color terminals (e.g.,
4296 "linux"), this causes the bright colors to appear. This doesn't work
4297 for background colors! Without the '*' the bold attribute is removed.
4298 If you want to set the bold attribute in a different way, put a
4299 "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument. Or use
4300 a number instead of a color name.
4301
4302 The case of the color names is ignored.
4303 Note that for 16 color ansi style terminals (including xterms), the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004304 numbers in the NR-8 column is used. Here '*' means 'add 8' so that Blue
Bram Moolenaar071d4272004-06-13 20:20:40 +00004305 is 12, DarkGray is 8 etc.
4306
4307 Note that for some color terminals these names may result in the wrong
4308 colors!
4309
4310 *:hi-normal-cterm*
4311 When setting the "ctermfg" or "ctermbg" colors for the Normal group,
4312 these will become the colors used for the non-highlighted text.
4313 Example: >
4314 :highlight Normal ctermfg=grey ctermbg=darkblue
4315< When setting the "ctermbg" color for the Normal group, the
4316 'background' option will be adjusted automatically. This causes the
4317 highlight groups that depend on 'background' to change! This means
4318 you should set the colors for Normal first, before setting other
4319 colors.
4320 When a colorscheme is being used, changing 'background' causes it to
4321 be reloaded, which may reset all colors (including Normal). First
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +01004322 delete the "g:colors_name" variable when you don't want this.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004323
4324 When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
4325 needs to reset the color when exiting. This is done with the "op"
4326 termcap entry |t_op|. If this doesn't work correctly, try setting the
4327 't_op' option in your .vimrc.
4328 *E419* *E420*
4329 When Vim knows the normal foreground and background colors, "fg" and
4330 "bg" can be used as color names. This only works after setting the
4331 colors for the Normal group and for the MS-DOS console. Example, for
4332 reverse video: >
4333 :highlight Visual ctermfg=bg ctermbg=fg
4334< Note that the colors are used that are valid at the moment this
4335 command are given. If the Normal group colors are changed later, the
4336 "fg" and "bg" colors will not be adjusted.
4337
4338
43393. highlight arguments for the GUI
4340
4341gui={attr-list} *highlight-gui*
4342 These give the attributes to use in the GUI mode.
4343 See |attr-list| for a description.
4344 Note that "bold" can be used here and by using a bold font. They
4345 have the same effect.
4346 Note that the attributes are ignored for the "Normal" group.
4347
4348font={font-name} *highlight-font*
4349 font-name is the name of a font, as it is used on the system Vim
4350 runs on. For X11 this is a complicated name, for example: >
4351 font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
4352<
4353 The font-name "NONE" can be used to revert to the default font.
4354 When setting the font for the "Normal" group, this becomes the default
4355 font (until the 'guifont' option is changed; the last one set is
4356 used).
4357 The following only works with Motif and Athena, not with other GUIs:
4358 When setting the font for the "Menu" group, the menus will be changed.
4359 When setting the font for the "Tooltip" group, the tooltips will be
4360 changed.
4361 All fonts used, except for Menu and Tooltip, should be of the same
4362 character size as the default font! Otherwise redrawing problems will
4363 occur.
4364
4365guifg={color-name} *highlight-guifg*
4366guibg={color-name} *highlight-guibg*
Bram Moolenaar5409c052005-03-18 20:27:04 +00004367guisp={color-name} *highlight-guisp*
4368 These give the foreground (guifg), background (guibg) and special
Bram Moolenaar7df351e2006-01-23 22:30:28 +00004369 (guisp) color to use in the GUI. "guisp" is used for undercurl.
4370 There are a few special names:
Bram Moolenaar071d4272004-06-13 20:20:40 +00004371 NONE no color (transparent)
4372 bg use normal background color
4373 background use normal background color
4374 fg use normal foreground color
4375 foreground use normal foreground color
4376 To use a color name with an embedded space or other special character,
4377 put it in single quotes. The single quote cannot be used then.
4378 Example: >
4379 :hi comment guifg='salmon pink'
4380<
4381 *gui-colors*
4382 Suggested color names (these are available on most systems):
4383 Red LightRed DarkRed
4384 Green LightGreen DarkGreen SeaGreen
4385 Blue LightBlue DarkBlue SlateBlue
4386 Cyan LightCyan DarkCyan
4387 Magenta LightMagenta DarkMagenta
4388 Yellow LightYellow Brown DarkYellow
4389 Gray LightGray DarkGray
4390 Black White
4391 Orange Purple Violet
4392
4393 In the Win32 GUI version, additional system colors are available. See
4394 |win32-colors|.
4395
4396 You can also specify a color by its Red, Green and Blue values.
4397 The format is "#rrggbb", where
4398 "rr" is the Red value
Bram Moolenaar071d4272004-06-13 20:20:40 +00004399 "gg" is the Green value
Bram Moolenaar5409c052005-03-18 20:27:04 +00004400 "bb" is the Blue value
Bram Moolenaar071d4272004-06-13 20:20:40 +00004401 All values are hexadecimal, range from "00" to "ff". Examples: >
4402 :highlight Comment guifg=#11f0c3 guibg=#ff00ff
4403<
4404 *highlight-groups* *highlight-default*
4405These are the default highlighting groups. These groups are used by the
4406'highlight' option default. Note that the highlighting depends on the value
4407of 'background'. You can see the current settings with the ":highlight"
4408command.
Bram Moolenaar1a384422010-07-14 19:53:30 +02004409 *hl-ColorColumn*
4410ColorColumn used for the columns set with 'colorcolumn'
Bram Moolenaar860cae12010-06-05 23:22:07 +02004411 *hl-Conceal*
4412Conceal placeholder characters substituted for concealed
4413 text (see 'conceallevel')
Bram Moolenaar071d4272004-06-13 20:20:40 +00004414 *hl-Cursor*
4415Cursor the character under the cursor
4416 *hl-CursorIM*
4417CursorIM like Cursor, but used when in IME mode |CursorIM|
Bram Moolenaar5316eee2006-03-12 22:11:10 +00004418 *hl-CursorColumn*
4419CursorColumn the screen column that the cursor is in when 'cursorcolumn' is
4420 set
4421 *hl-CursorLine*
4422CursorLine the screen line that the cursor is in when 'cursorline' is
4423 set
Bram Moolenaar071d4272004-06-13 20:20:40 +00004424 *hl-Directory*
4425Directory directory names (and other special names in listings)
4426 *hl-DiffAdd*
4427DiffAdd diff mode: Added line |diff.txt|
4428 *hl-DiffChange*
4429DiffChange diff mode: Changed line |diff.txt|
4430 *hl-DiffDelete*
4431DiffDelete diff mode: Deleted line |diff.txt|
4432 *hl-DiffText*
4433DiffText diff mode: Changed text within a changed line |diff.txt|
4434 *hl-ErrorMsg*
4435ErrorMsg error messages on the command line
4436 *hl-VertSplit*
4437VertSplit the column separating vertically split windows
4438 *hl-Folded*
4439Folded line used for closed folds
4440 *hl-FoldColumn*
4441FoldColumn 'foldcolumn'
4442 *hl-SignColumn*
4443SignColumn column where |signs| are displayed
4444 *hl-IncSearch*
4445IncSearch 'incsearch' highlighting; also used for the text replaced with
4446 ":s///c"
4447 *hl-LineNr*
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00004448LineNr Line number for ":number" and ":#" commands, and when 'number'
Bram Moolenaar64486672010-05-16 15:46:46 +02004449 or 'relativenumber' option is set.
Bram Moolenaar61d35bd2012-03-28 20:51:51 +02004450 *hl-CursorLineNr*
4451CursorLineNr Like LineNr when 'cursorline' is set for the cursor line.
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00004452 *hl-MatchParen*
4453MatchParen The character under the cursor or just before it, if it
4454 is a paired bracket, and its match. |pi_paren.txt|
4455
Bram Moolenaar071d4272004-06-13 20:20:40 +00004456 *hl-ModeMsg*
4457ModeMsg 'showmode' message (e.g., "-- INSERT --")
4458 *hl-MoreMsg*
4459MoreMsg |more-prompt|
4460 *hl-NonText*
4461NonText '~' and '@' at the end of the window, characters from
4462 'showbreak' and other characters that do not really exist in
4463 the text (e.g., ">" displayed when a double-wide character
4464 doesn't fit at the end of the line).
4465 *hl-Normal*
4466Normal normal text
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00004467 *hl-Pmenu*
4468Pmenu Popup menu: normal item.
4469 *hl-PmenuSel*
4470PmenuSel Popup menu: selected item.
4471 *hl-PmenuSbar*
4472PmenuSbar Popup menu: scrollbar.
4473 *hl-PmenuThumb*
4474PmenuThumb Popup menu: Thumb of the scrollbar.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004475 *hl-Question*
4476Question |hit-enter| prompt and yes/no questions
4477 *hl-Search*
4478Search Last search pattern highlighting (see 'hlsearch').
4479 Also used for highlighting the current line in the quickfix
4480 window and similar items that need to stand out.
4481 *hl-SpecialKey*
4482SpecialKey Meta and special keys listed with ":map", also for text used
4483 to show unprintable characters in the text, 'listchars'.
4484 Generally: text that is displayed differently from what it
4485 really is.
Bram Moolenaar217ad922005-03-20 22:37:15 +00004486 *hl-SpellBad*
4487SpellBad Word that is not recognized by the spellchecker. |spell|
4488 This will be combined with the highlighting used otherwise.
Bram Moolenaar53180ce2005-07-05 21:48:14 +00004489 *hl-SpellCap*
4490SpellCap Word that should start with a capital. |spell|
4491 This will be combined with the highlighting used otherwise.
Bram Moolenaar217ad922005-03-20 22:37:15 +00004492 *hl-SpellLocal*
4493SpellLocal Word that is recognized by the spellchecker as one that is
4494 used in another region. |spell|
4495 This will be combined with the highlighting used otherwise.
4496 *hl-SpellRare*
4497SpellRare Word that is recognized by the spellchecker as one that is
4498 hardly ever used. |spell|
4499 This will be combined with the highlighting used otherwise.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004500 *hl-StatusLine*
4501StatusLine status line of current window
4502 *hl-StatusLineNC*
4503StatusLineNC status lines of not-current windows
4504 Note: if this is equal to "StatusLine" Vim will use "^^^" in
4505 the status line of the current window.
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004506 *hl-TabLine*
4507TabLine tab pages line, not active tab page label
4508 *hl-TabLineFill*
4509TabLineFill tab pages line, where there are no labels
4510 *hl-TabLineSel*
4511TabLineSel tab pages line, active tab page label
Bram Moolenaar071d4272004-06-13 20:20:40 +00004512 *hl-Title*
4513Title titles for output from ":set all", ":autocmd" etc.
4514 *hl-Visual*
4515Visual Visual mode selection
4516 *hl-VisualNOS*
4517VisualNOS Visual mode selection when vim is "Not Owning the Selection".
4518 Only X11 Gui's |gui-x11| and |xterm-clipboard| supports this.
4519 *hl-WarningMsg*
4520WarningMsg warning messages
4521 *hl-WildMenu*
4522WildMenu current match in 'wildmenu' completion
4523
Bram Moolenaarf75a9632005-09-13 21:20:47 +00004524 *hl-User1* *hl-User1..9* *hl-User9*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004525The 'statusline' syntax allows the use of 9 different highlights in the
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004526statusline and ruler (via 'rulerformat'). The names are User1 to User9.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004527
Bram Moolenaar8c8de832008-06-24 22:58:06 +00004528For the GUI you can use the following groups to set the colors for the menu,
Bram Moolenaar071d4272004-06-13 20:20:40 +00004529scrollbars and tooltips. They don't have defaults. This doesn't work for the
4530Win32 GUI. Only three highlight arguments have any effect here: font, guibg,
4531and guifg.
4532
4533 *hl-Menu*
4534Menu Current font, background and foreground colors of the menus.
4535 Also used for the toolbar.
4536 Applicable highlight arguments: font, guibg, guifg.
4537
4538 NOTE: For Motif and Athena the font argument actually
4539 specifies a fontset at all times, no matter if 'guifontset' is
4540 empty, and as such it is tied to the current |:language| when
4541 set.
4542
4543 *hl-Scrollbar*
4544Scrollbar Current background and foreground of the main window's
4545 scrollbars.
4546 Applicable highlight arguments: guibg, guifg.
4547
4548 *hl-Tooltip*
4549Tooltip Current font, background and foreground of the tooltips.
4550 Applicable highlight arguments: font, guibg, guifg.
4551
4552 NOTE: For Motif and Athena the font argument actually
4553 specifies a fontset at all times, no matter if 'guifontset' is
4554 empty, and as such it is tied to the current |:language| when
4555 set.
4556
4557==============================================================================
455813. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
4559
4560When you want to use the same highlighting for several syntax groups, you
4561can do this more easily by linking the groups into one common highlight
4562group, and give the color attributes only for that group.
4563
4564To set a link:
4565
4566 :hi[ghlight][!] [default] link {from-group} {to-group}
4567
4568To remove a link:
4569
4570 :hi[ghlight][!] [default] link {from-group} NONE
4571
4572Notes: *E414*
4573- If the {from-group} and/or {to-group} doesn't exist, it is created. You
4574 don't get an error message for a non-existing group.
4575- As soon as you use a ":highlight" command for a linked group, the link is
4576 removed.
4577- If there are already highlight settings for the {from-group}, the link is
4578 not made, unless the '!' is given. For a ":highlight link" command in a
4579 sourced file, you don't get an error message. This can be used to skip
4580 links for groups that already have settings.
4581
4582 *:hi-default* *:highlight-default*
4583The [default] argument is used for setting the default highlighting for a
4584group. If highlighting has already been specified for the group the command
4585will be ignored. Also when there is an existing link.
4586
4587Using [default] is especially useful to overrule the highlighting of a
4588specific syntax file. For example, the C syntax file contains: >
4589 :highlight default link cComment Comment
4590If you like Question highlighting for C comments, put this in your vimrc file: >
4591 :highlight link cComment Question
4592Without the "default" in the C syntax file, the highlighting would be
4593overruled when the syntax file is loaded.
4594
4595==============================================================================
459614. Cleaning up *:syn-clear* *E391*
4597
4598If you want to clear the syntax stuff for the current buffer, you can use this
4599command: >
4600 :syntax clear
4601
4602This command should be used when you want to switch off syntax highlighting,
4603or when you want to switch to using another syntax. It's normally not needed
4604in a syntax file itself, because syntax is cleared by the autocommands that
4605load the syntax file.
4606The command also deletes the "b:current_syntax" variable, since no syntax is
4607loaded after this command.
4608
4609If you want to disable syntax highlighting for all buffers, you need to remove
4610the autocommands that load the syntax files: >
4611 :syntax off
4612
4613What this command actually does, is executing the command >
4614 :source $VIMRUNTIME/syntax/nosyntax.vim
4615See the "nosyntax.vim" file for details. Note that for this to work
4616$VIMRUNTIME must be valid. See |$VIMRUNTIME|.
4617
4618To clean up specific syntax groups for the current buffer: >
4619 :syntax clear {group-name} ..
4620This removes all patterns and keywords for {group-name}.
4621
4622To clean up specific syntax group lists for the current buffer: >
4623 :syntax clear @{grouplist-name} ..
4624This sets {grouplist-name}'s contents to an empty list.
4625
4626 *:syntax-reset* *:syn-reset*
4627If you have changed the colors and messed them up, use this command to get the
4628defaults back: >
4629
4630 :syntax reset
4631
4632This doesn't change the colors for the 'highlight' option.
4633
4634Note that the syntax colors that you set in your vimrc file will also be reset
4635back to their Vim default.
4636Note that if you are using a color scheme, the colors defined by the color
4637scheme for syntax highlighting will be lost.
4638
4639What this actually does is: >
4640
4641 let g:syntax_cmd = "reset"
4642 runtime! syntax/syncolor.vim
4643
4644Note that this uses the 'runtimepath' option.
4645
4646 *syncolor*
4647If you want to use different colors for syntax highlighting, you can add a Vim
4648script file to set these colors. Put this file in a directory in
4649'runtimepath' which comes after $VIMRUNTIME, so that your settings overrule
4650the default colors. This way these colors will be used after the ":syntax
4651reset" command.
4652
4653For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: >
4654
4655 if &background == "light"
4656 highlight comment ctermfg=darkgreen guifg=darkgreen
4657 else
4658 highlight comment ctermfg=green guifg=green
4659 endif
4660
Bram Moolenaarc0197e22004-09-13 20:26:32 +00004661 *E679*
4662Do make sure this syncolor.vim script does not use a "syntax on", set the
4663'background' option or uses a "colorscheme" command, because it results in an
4664endless loop.
4665
Bram Moolenaar071d4272004-06-13 20:20:40 +00004666Note that when a color scheme is used, there might be some confusion whether
4667your defined colors are to be used or the colors from the scheme. This
4668depends on the color scheme file. See |:colorscheme|.
4669
4670 *syntax_cmd*
4671The "syntax_cmd" variable is set to one of these values when the
4672syntax/syncolor.vim files are loaded:
4673 "on" ":syntax on" command. Highlight colors are overruled but
4674 links are kept
4675 "enable" ":syntax enable" command. Only define colors for groups that
4676 don't have highlighting yet. Use ":syntax default".
4677 "reset" ":syntax reset" command or loading a color scheme. Define all
4678 the colors.
4679 "skip" Don't define colors. Used to skip the default settings when a
4680 syncolor.vim file earlier in 'runtimepath' has already set
4681 them.
4682
4683==============================================================================
468415. Highlighting tags *tag-highlight*
4685
4686If you want to highlight all the tags in your file, you can use the following
4687mappings.
4688
4689 <F11> -- Generate tags.vim file, and highlight tags.
4690 <F12> -- Just highlight tags based on existing tags.vim file.
4691>
4692 :map <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
4693 :map <F12> :so tags.vim<CR>
4694
4695WARNING: The longer the tags file, the slower this will be, and the more
4696memory Vim will consume.
4697
4698Only highlighting typedefs, unions and structs can be done too. For this you
4699must use Exuberant ctags (found at http://ctags.sf.net).
4700
4701Put these lines in your Makefile:
4702
4703# Make a highlight file for types. Requires Exuberant ctags and awk
4704types: types.vim
4705types.vim: *.[ch]
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004706 ctags --c-kinds=gstu -o- *.[ch] |\
Bram Moolenaar071d4272004-06-13 20:20:40 +00004707 awk 'BEGIN{printf("syntax keyword Type\t")}\
4708 {printf("%s ", $$1)}END{print ""}' > $@
4709
4710And put these lines in your .vimrc: >
4711
4712 " load the types.vim highlighting file, if it exists
4713 autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
4714 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
4715 autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname
4716 autocmd BufRead,BufNewFile *.[ch] endif
4717
4718==============================================================================
Bram Moolenaar860cae12010-06-05 23:22:07 +0200471916. Window-local syntax *:ownsyntax*
4720
4721Normally all windows on a buffer share the same syntax settings. It is
4722possible, however, to set a particular window on a file to have its own
4723private syntax setting. A possible example would be to edit LaTeX source
4724with conventional highlighting in one window, while seeing the same source
4725highlighted differently (so as to hide control sequences and indicate bold,
4726italic etc regions) in another. The 'scrollbind' option is useful here.
4727
4728To set the current window to have the syntax "foo", separately from all other
4729windows on the buffer: >
4730 :ownsyntax foo
Bram Moolenaardebe25a2010-06-06 17:41:24 +02004731< *w:current_syntax*
4732This will set the "w:current_syntax" variable to "foo". The value of
4733"b:current_syntax" does not change. This is implemented by saving and
4734restoring "b:current_syntax", since the syntax files do set
4735"b:current_syntax". The value set by the syntax file is assigned to
4736"w:current_syntax".
Bram Moolenaar860cae12010-06-05 23:22:07 +02004737
4738Once a window has its own syntax, syntax commands executed from other windows
4739on the same buffer (including :syntax clear) have no effect. Conversely,
4740syntax commands executed from that window do not effect other windows on the
4741same buffer.
4742
Bram Moolenaardebe25a2010-06-06 17:41:24 +02004743A window with its own syntax reverts to normal behavior when another buffer
4744is loaded into that window or the file is reloaded.
4745When splitting the window, the new window will use the original syntax.
Bram Moolenaar860cae12010-06-05 23:22:07 +02004746
4747==============================================================================
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +0200474817. Color xterms *xterm-color* *color-xterm*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004749
4750Most color xterms have only eight colors. If you don't get colors with the
4751default setup, it should work with these lines in your .vimrc: >
4752 :if &term =~ "xterm"
4753 : if has("terminfo")
4754 : set t_Co=8
4755 : set t_Sf=<Esc>[3%p1%dm
4756 : set t_Sb=<Esc>[4%p1%dm
4757 : else
4758 : set t_Co=8
4759 : set t_Sf=<Esc>[3%dm
4760 : set t_Sb=<Esc>[4%dm
4761 : endif
4762 :endif
4763< [<Esc> is a real escape, type CTRL-V <Esc>]
4764
4765You might want to change the first "if" to match the name of your terminal,
4766e.g. "dtterm" instead of "xterm".
4767
4768Note: Do these settings BEFORE doing ":syntax on". Otherwise the colors may
4769be wrong.
4770 *xiterm* *rxvt*
4771The above settings have been mentioned to work for xiterm and rxvt too.
4772But for using 16 colors in an rxvt these should work with terminfo: >
4773 :set t_AB=<Esc>[%?%p1%{8}%<%t25;%p1%{40}%+%e5;%p1%{32}%+%;%dm
4774 :set t_AF=<Esc>[%?%p1%{8}%<%t22;%p1%{30}%+%e1;%p1%{22}%+%;%dm
4775<
4776 *colortest.vim*
4777To test your color setup, a file has been included in the Vim distribution.
Bram Moolenaarf740b292006-02-16 22:11:02 +00004778To use it, execute this command: >
4779 :runtime syntax/colortest.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00004780
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004781Some versions of xterm (and other terminals, like the Linux console) can
Bram Moolenaar071d4272004-06-13 20:20:40 +00004782output lighter foreground colors, even though the number of colors is defined
4783at 8. Therefore Vim sets the "cterm=bold" attribute for light foreground
4784colors, when 't_Co' is 8.
4785
4786 *xfree-xterm*
4787To get 16 colors or more, get the newest xterm version (which should be
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +00004788included with XFree86 3.3 and later). You can also find the latest version
Bram Moolenaar071d4272004-06-13 20:20:40 +00004789at: >
4790 http://invisible-island.net/xterm/xterm.html
4791Here is a good way to configure it. This uses 88 colors and enables the
4792termcap-query feature, which allows Vim to ask the xterm how many colors it
4793supports. >
4794 ./configure --disable-bold-color --enable-88-color --enable-tcap-query
4795If you only get 8 colors, check the xterm compilation settings.
4796(Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
4797
4798This xterm should work with these lines in your .vimrc (for 16 colors): >
4799 :if has("terminfo")
4800 : set t_Co=16
4801 : set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
4802 : set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
4803 :else
4804 : set t_Co=16
4805 : set t_Sf=<Esc>[3%dm
4806 : set t_Sb=<Esc>[4%dm
4807 :endif
4808< [<Esc> is a real escape, type CTRL-V <Esc>]
4809
4810Without |+terminfo|, Vim will recognize these settings, and automatically
4811translate cterm colors of 8 and above to "<Esc>[9%dm" and "<Esc>[10%dm".
4812Colors above 16 are also translated automatically.
4813
4814For 256 colors this has been reported to work: >
4815
4816 :set t_AB=<Esc>[48;5;%dm
4817 :set t_AF=<Esc>[38;5;%dm
4818
4819Or just set the TERM environment variable to "xterm-color" or "xterm-16color"
4820and try if that works.
4821
4822You probably want to use these X resources (in your ~/.Xdefaults file):
4823 XTerm*color0: #000000
4824 XTerm*color1: #c00000
4825 XTerm*color2: #008000
4826 XTerm*color3: #808000
4827 XTerm*color4: #0000c0
4828 XTerm*color5: #c000c0
4829 XTerm*color6: #008080
4830 XTerm*color7: #c0c0c0
4831 XTerm*color8: #808080
4832 XTerm*color9: #ff6060
4833 XTerm*color10: #00ff00
4834 XTerm*color11: #ffff00
4835 XTerm*color12: #8080ff
4836 XTerm*color13: #ff40ff
4837 XTerm*color14: #00ffff
4838 XTerm*color15: #ffffff
4839 Xterm*cursorColor: Black
4840
4841[Note: The cursorColor is required to work around a bug, which changes the
4842cursor color to the color of the last drawn text. This has been fixed by a
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004843newer version of xterm, but not everybody is using it yet.]
Bram Moolenaar071d4272004-06-13 20:20:40 +00004844
4845To get these right away, reload the .Xdefaults file to the X Option database
4846Manager (you only need to do this when you just changed the .Xdefaults file): >
4847 xrdb -merge ~/.Xdefaults
4848<
4849 *xterm-blink* *xterm-blinking-cursor*
4850To make the cursor blink in an xterm, see tools/blink.c. Or use Thomas
4851Dickey's xterm above patchlevel 107 (see above for where to get it), with
4852these resources:
4853 XTerm*cursorBlink: on
4854 XTerm*cursorOnTime: 400
4855 XTerm*cursorOffTime: 250
4856 XTerm*cursorColor: White
4857
4858 *hpterm-color*
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00004859These settings work (more or less) for an hpterm, which only supports 8
Bram Moolenaar071d4272004-06-13 20:20:40 +00004860foreground colors: >
4861 :if has("terminfo")
4862 : set t_Co=8
4863 : set t_Sf=<Esc>[&v%p1%dS
4864 : set t_Sb=<Esc>[&v7S
4865 :else
4866 : set t_Co=8
4867 : set t_Sf=<Esc>[&v%dS
4868 : set t_Sb=<Esc>[&v7S
4869 :endif
4870< [<Esc> is a real escape, type CTRL-V <Esc>]
4871
4872 *Eterm* *enlightened-terminal*
4873These settings have been reported to work for the Enlightened terminal
4874emulator, or Eterm. They might work for all xterm-like terminals that use the
4875bold attribute to get bright colors. Add an ":if" like above when needed. >
4876 :set t_Co=16
4877 :set t_AF=^[[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
4878 :set t_AB=^[[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m
4879<
4880 *TTpro-telnet*
4881These settings should work for TTpro telnet. Tera Term Pro is a freeware /
4882open-source program for MS-Windows. >
4883 set t_Co=16
4884 set t_AB=^[[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{32}%+5;%;%dm
4885 set t_AF=^[[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{22}%+1;%;%dm
4886Also make sure TTpro's Setup / Window / Full Color is enabled, and make sure
4887that Setup / Font / Enable Bold is NOT enabled.
4888(info provided by John Love-Jensen <eljay@Adobe.COM>)
4889
4890 vim:tw=78:sw=4:ts=8:ft=help:norl: