Mercurial > vim
comparison runtime/doc/syntax.txt @ 2033:de5a43c5eedc
Update documentation files.
author | Bram Moolenaar <bram@zimbu.org> |
---|---|
date | Wed, 06 Jan 2010 20:52:26 +0100 |
parents | 5232b9862f23 |
children | b9e314fe473f |
comparison
equal
deleted
inserted
replaced
2032:592032e9e167 | 2033:de5a43c5eedc |
---|---|
1 *syntax.txt* For Vim version 7.2. Last change: 2008 Jul 22 | 1 *syntax.txt* For Vim version 7.2. Last change: 2009 Dec 19 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
111 :syntax on $VIMRUNTIME/syntax/syntax.vim | 111 :syntax on $VIMRUNTIME/syntax/syntax.vim |
112 :syntax manual $VIMRUNTIME/syntax/manual.vim | 112 :syntax manual $VIMRUNTIME/syntax/manual.vim |
113 :syntax off $VIMRUNTIME/syntax/nosyntax.vim | 113 :syntax off $VIMRUNTIME/syntax/nosyntax.vim |
114 Also see |syntax-loading|. | 114 Also see |syntax-loading|. |
115 | 115 |
116 NOTE: If displaying long lines is slow and switching off syntax highlighting | |
117 makes it fast, consider setting the 'synmaxcol' option to a lower value. | |
118 | |
116 ============================================================================== | 119 ============================================================================== |
117 2. Syntax files *:syn-files* | 120 2. Syntax files *:syn-files* |
118 | 121 |
119 The syntax and highlighting commands for one language are normally stored in | 122 The syntax and highlighting commands for one language are normally stored in |
120 a syntax file. The name convention is: "{name}.vim". Where {name} is the | 123 a syntax file. The name convention is: "{name}.vim". Where {name} is the |
196 version, follow the same steps as for |mysyntaxfile| above. Just make sure | 199 version, follow the same steps as for |mysyntaxfile| above. Just make sure |
197 that you write the syntax file in a directory that is early in 'runtimepath'. | 200 that you write the syntax file in a directory that is early in 'runtimepath'. |
198 Vim will only load the first syntax file found. | 201 Vim will only load the first syntax file found. |
199 | 202 |
200 | 203 |
201 NAMING CONVENTIONS | 204 NAMING CONVENTIONS *group-name* *{group-name}* *E669* *W18* |
202 *group-name* *{group-name}* *E669* *W18* | 205 |
206 A syntax group name is to be used for syntax items that match the same kind of | |
207 thing. These are then linked to a highlight group that specifies the color. | |
208 A syntax group name doesn't specify any color or attributes itself. | |
209 | |
203 The name for a highlight or syntax group must consist of ASCII letters, digits | 210 The name for a highlight or syntax group must consist of ASCII letters, digits |
204 and the underscore. As a regexp: "[a-zA-Z0-9_]*" | 211 and the underscore. As a regexp: "[a-zA-Z0-9_]*" |
205 | 212 |
206 To be able to allow each user to pick his favorite set of colors, there must | 213 To be able to allow each user to pick his favorite set of colors, there must |
207 be preferred names for highlight groups that are common for many languages. | 214 be preferred names for highlight groups that are common for many languages. |
377 Or use the ":TOhtml" user command. It is defined in a standard plugin. | 384 Or use the ":TOhtml" user command. It is defined in a standard plugin. |
378 ":TOhtml" also works with a range and in a Visual area: > | 385 ":TOhtml" also works with a range and in a Visual area: > |
379 | 386 |
380 :10,40TOhtml | 387 :10,40TOhtml |
381 | 388 |
382 After you save the resulting file, you can view it with any HTML viewer, such | 389 After you save the resulting file, you can view it with any browser. The |
383 as Netscape. The colors should be exactly the same as you see them in Vim. | 390 colors should be exactly the same as you see them in Vim. |
384 | 391 |
385 To restrict the conversion to a range of lines set "html_start_line" and | 392 To restrict the conversion to a range of lines set "html_start_line" and |
386 "html_end_line" to the first and last line to be converted. Example, using | 393 "html_end_line" to the first and last line to be converted. Example, using |
387 the last set Visual area: > | 394 the last set Visual area: > |
388 | 395 |
396 Force to omit the line numbers by using a zero value: > | 403 Force to omit the line numbers by using a zero value: > |
397 :let html_number_lines = 0 | 404 :let html_number_lines = 0 |
398 Go back to the default to use 'number' by deleting the variable: > | 405 Go back to the default to use 'number' by deleting the variable: > |
399 :unlet html_number_lines | 406 :unlet html_number_lines |
400 | 407 |
401 Closed folds are put in the HTML as they are displayed. If you don't want | |
402 this, use the |zR| command before invoking 2html, or use: > | |
403 :let html_ignore_folding = 1 | |
404 | |
405 By default, HTML optimized for old browsers is generated. If you prefer using | 408 By default, HTML optimized for old browsers is generated. If you prefer using |
406 cascading style sheets (CSS1) for the attributes (resulting in considerably | 409 cascading style sheets (CSS1) for the attributes (resulting in considerably |
407 shorter and valid HTML 4 file), use: > | 410 shorter and valid HTML 4 file), use: > |
408 :let html_use_css = 1 | 411 :let html_use_css = 1 |
412 | |
413 Closed folds are put in the HTML as they are displayed. If you don't want | |
414 this, use the |zR| command before invoking 2html, or use: > | |
415 :let html_ignore_folding = 1 | |
416 | |
417 You may want to generate HTML that includes all the data within the folds, and | |
418 allow the user to view the folded data similar to how they would in Vim. To | |
419 generate this dynamic fold information, use: > | |
420 :let html_dynamic_folds = 1 | |
421 | |
422 Using html_dynamic_folds will imply html_use_css, because it would be far too | |
423 difficult to do it for old browsers. However, html_ignore_folding overrides | |
424 html_dynamic_folds. | |
425 | |
426 Using html_dynamic_folds will default to generating a foldcolumn in the html | |
427 similar to Vim's foldcolumn, that will use javascript to open and close the | |
428 folds in the HTML document. The width of this foldcolumn starts at the current | |
429 setting of |'foldcolumn'| but grows to fit the greatest foldlevel in your | |
430 document. If you do not want to show a foldcolumn at all, use: > | |
431 :let html_no_foldcolumn = 1 | |
432 | |
433 Using this option, there will be no foldcolumn available to open the folds in | |
434 the HTML. For this reason, another option is provided: html_hover_unfold. | |
435 Enabling this option will use CSS 2.0 to allow a user to open a fold by | |
436 hovering the mouse pointer over it. Note that old browsers (notably Internet | |
437 Explorer 6) will not support this feature. Browser-specific markup for IE6 is | |
438 included to fall back to the normal CSS1 code so that the folds show up | |
439 correctly for this browser, but they will not be openable without a | |
440 foldcolumn. Note that using html_hover_unfold will allow modern browsers with | |
441 disabled javascript to view closed folds. To use this option, use: > | |
442 :let html_hover_unfold = 1 | |
443 | |
444 Setting html_no_foldcolumn with html_dynamic_folds will automatically set | |
445 html_hover_unfold, because otherwise the folds wouldn't be dynamic. | |
409 | 446 |
410 By default "<pre>" and "</pre>" is used around the text. This makes it show | 447 By default "<pre>" and "</pre>" is used around the text. This makes it show |
411 up as you see it in Vim, but without wrapping. If you prefer wrapping, at the | 448 up as you see it in Vim, but without wrapping. If you prefer wrapping, at the |
412 risk of making some things look a bit different, use: > | 449 risk of making some things look a bit different, use: > |
413 :let html_no_pre = 1 | 450 :let html_no_pre = 1 |
523 tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and | 560 tasm Turbo Assembly (with opcodes 80x86 up to Pentium, and |
524 MMX) | 561 MMX) |
525 pic PIC assembly (currently for PIC16F84) | 562 pic PIC assembly (currently for PIC16F84) |
526 | 563 |
527 The most flexible is to add a line in your assembly file containing: > | 564 The most flexible is to add a line in your assembly file containing: > |
528 :asmsyntax=nasm | 565 asmsyntax=nasm |
529 Replace "nasm" with the name of the real assembly syntax. This line must be | 566 Replace "nasm" with the name of the real assembly syntax. This line must be |
530 one of the first five lines in the file. | 567 one of the first five lines in the file. No non-white text must be |
568 immediately before or after this text. | |
531 | 569 |
532 The syntax type can always be overruled for a specific buffer by setting the | 570 The syntax type can always be overruled for a specific buffer by setting the |
533 b:asmsyntax variable: > | 571 b:asmsyntax variable: > |
534 :let b:asmsyntax = "nasm" | 572 :let b:asmsyntax = "nasm" |
535 | 573 |
2527 | 2565 |
2528 If you notice highlighting errors while scrolling backwards, which are fixed | 2566 If you notice highlighting errors while scrolling backwards, which are fixed |
2529 when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable | 2567 when redrawing with CTRL-L, try setting the "tcsh_minlines" internal variable |
2530 to a larger number: > | 2568 to a larger number: > |
2531 | 2569 |
2532 :let tcsh_minlines = 100 | 2570 :let tcsh_minlines = 1000 |
2533 | 2571 |
2534 This will make the syntax synchronization start 100 lines before the first | 2572 This will make the syntax synchronization start 1000 lines before the first |
2535 displayed line. The default value is 15. The disadvantage of using a larger | 2573 displayed line. If you set "tcsh_minlines" to "fromstart", then |
2536 number is that redrawing can become slow. | 2574 synchronization is done from the start of the file. The default value for |
2575 tcsh_minlines is 100. The disadvantage of using a larger number is that | |
2576 redrawing can become slow. | |
2537 | 2577 |
2538 | 2578 |
2539 TEX *tex.vim* *ft-tex-syntax* | 2579 TEX *tex.vim* *ft-tex-syntax* |
2540 | 2580 |
2541 *tex-folding* | 2581 *tex-folding* |
3412 - There must be no white space between the pattern and the character | 3452 - There must be no white space between the pattern and the character |
3413 offset(s). | 3453 offset(s). |
3414 - The highlighted area will never be outside of the matched text. | 3454 - The highlighted area will never be outside of the matched text. |
3415 - A negative offset for an end pattern may not always work, because the end | 3455 - A negative offset for an end pattern may not always work, because the end |
3416 pattern may be detected when the highlighting should already have stopped. | 3456 pattern may be detected when the highlighting should already have stopped. |
3417 - Until Vim 7.2 the offsets were counted in bytes instead of characters. This | 3457 - Before Vim 7.2 the offsets were counted in bytes instead of characters. |
3418 didn't work well for multi-byte characters. | 3458 This didn't work well for multi-byte characters, so it was changed with the |
3459 Vim 7.2 release. | |
3419 - The start of a match cannot be in a line other than where the pattern | 3460 - The start of a match cannot be in a line other than where the pattern |
3420 matched. This doesn't work: "a\nb"ms=e. You can make the highlighting | 3461 matched. This doesn't work: "a\nb"ms=e. You can make the highlighting |
3421 start in another line, this does work: "a\nb"hs=e. | 3462 start in another line, this does work: "a\nb"hs=e. |
3422 | 3463 |
3423 Example (match a comment but don't highlight the /* and */): > | 3464 Example (match a comment but don't highlight the /* and */): > |
3464 The patterns can include "\n" to match an end-of-line. Mostly this works as | 3505 The patterns can include "\n" to match an end-of-line. Mostly this works as |
3465 expected, but there are a few exceptions. | 3506 expected, but there are a few exceptions. |
3466 | 3507 |
3467 When using a start pattern with an offset, the start of the match is not | 3508 When using a start pattern with an offset, the start of the match is not |
3468 allowed to start in a following line. The highlighting can start in a | 3509 allowed to start in a following line. The highlighting can start in a |
3469 following line though. | 3510 following line though. Using the "\zs" item also requires that the start of |
3511 the match doesn't move to another line. | |
3470 | 3512 |
3471 The skip pattern can include the "\n", but the search for an end pattern will | 3513 The skip pattern can include the "\n", but the search for an end pattern will |
3472 continue in the first character of the next line, also when that character is | 3514 continue in the first character of the next line, also when that character is |
3473 matched by the skip pattern. This is because redrawing may start in any line | 3515 matched by the skip pattern. This is because redrawing may start in any line |
3474 halfway a region and there is no check if the skip pattern started in a | 3516 halfway a region and there is no check if the skip pattern started in a |
3830 | 3872 |
3831 *:colo* *:colorscheme* *E185* | 3873 *:colo* *:colorscheme* *E185* |
3832 :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath' | 3874 :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath' |
3833 for the file "colors/{name}.vim. The first one that | 3875 for the file "colors/{name}.vim. The first one that |
3834 is found is loaded. | 3876 is found is loaded. |
3835 To see the name of the currently active color scheme | 3877 To see the name of the currently active color scheme: > |
3836 (if there is one): > | |
3837 :echo g:colors_name | 3878 :echo g:colors_name |
3838 < Doesn't work recursively, thus you can't use | 3879 < When using the default colors you will get an E121 |
3880 error. | |
3881 Doesn't work recursively, thus you can't use | |
3839 ":colorscheme" in a color scheme script. | 3882 ":colorscheme" in a color scheme script. |
3840 After the color scheme has been loaded the | 3883 After the color scheme has been loaded the |
3841 |ColorScheme| autocommand event is triggered. | 3884 |ColorScheme| autocommand event is triggered. |
3842 For info about writing a colorscheme file: > | 3885 For info about writing a colorscheme file: > |
3843 :edit $VIMRUNTIME/colors/README.txt | 3886 :edit $VIMRUNTIME/colors/README.txt |
4030 highlight groups that depend on 'background' to change! This means | 4073 highlight groups that depend on 'background' to change! This means |
4031 you should set the colors for Normal first, before setting other | 4074 you should set the colors for Normal first, before setting other |
4032 colors. | 4075 colors. |
4033 When a colorscheme is being used, changing 'background' causes it to | 4076 When a colorscheme is being used, changing 'background' causes it to |
4034 be reloaded, which may reset all colors (including Normal). First | 4077 be reloaded, which may reset all colors (including Normal). First |
4035 delete the "colors_name" variable when you don't want this. | 4078 delete the "g:colors_name" variable when you don't want this. |
4036 | 4079 |
4037 When you have set "ctermfg" or "ctermbg" for the Normal group, Vim | 4080 When you have set "ctermfg" or "ctermbg" for the Normal group, Vim |
4038 needs to reset the color when exiting. This is done with the "op" | 4081 needs to reset the color when exiting. This is done with the "op" |
4039 termcap entry |t_op|. If this doesn't work correctly, try setting the | 4082 termcap entry |t_op|. If this doesn't work correctly, try setting the |
4040 't_op' option in your .vimrc. | 4083 't_op' option in your .vimrc. |