comparison runtime/doc/syntax.txt @ 15194:8b334e4cb97f

Update runtime files. commit https://github.com/vim/vim/commit/9d87a37ee9d87f5bdbc779bc940d5f1e6f055d0a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 18 21:41:50 2018 +0100 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Tue, 18 Dec 2018 21:45:08 +0100
parents d9d97b8afe0d
children 97b40b4c6911
comparison
equal deleted inserted replaced
15193:0154f020f97e 15194:8b334e4cb97f
1 *syntax.txt* For Vim version 8.1. Last change: 2018 Apr 30 1 *syntax.txt* For Vim version 8.1. Last change: 2018 Dec 14
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
21 |usr_44.txt| introduces writing a syntax file. 21 |usr_44.txt| introduces writing a syntax file.
22 22
23 1. Quick start |:syn-qstart| 23 1. Quick start |:syn-qstart|
24 2. Syntax files |:syn-files| 24 2. Syntax files |:syn-files|
25 3. Syntax loading procedure |syntax-loading| 25 3. Syntax loading procedure |syntax-loading|
26 4. Syntax file remarks |:syn-file-remarks| 26 4. Converting to HTML |2html.vim|
27 5. Defining a syntax |:syn-define| 27 5. Syntax file remarks |:syn-file-remarks|
28 6. :syntax arguments |:syn-arguments| 28 6. Defining a syntax |:syn-define|
29 7. Syntax patterns |:syn-pattern| 29 7. :syntax arguments |:syn-arguments|
30 8. Syntax clusters |:syn-cluster| 30 8. Syntax patterns |:syn-pattern|
31 9. Including syntax files |:syn-include| 31 9. Syntax clusters |:syn-cluster|
32 10. Synchronizing |:syn-sync| 32 10. Including syntax files |:syn-include|
33 11. Listing syntax items |:syntax| 33 11. Synchronizing |:syn-sync|
34 12. Highlight command |:highlight| 34 12. Listing syntax items |:syntax|
35 13. Linking groups |:highlight-link| 35 13. Highlight command |:highlight|
36 14. Cleaning up |:syn-clear| 36 14. Linking groups |:highlight-link|
37 15. Highlighting tags |tag-highlight| 37 15. Cleaning up |:syn-clear|
38 16. Window-local syntax |:ownsyntax| 38 16. Highlighting tags |tag-highlight|
39 17. Color xterms |xterm-color| 39 17. Window-local syntax |:ownsyntax|
40 18. When syntax is slow |:syntime| 40 18. Color xterms |xterm-color|
41 19. When syntax is slow |:syntime|
41 42
42 {Vi does not have any of these commands} 43 {Vi does not have any of these commands}
43 44
44 Syntax highlighting is not available when the |+syntax| feature has been 45 Syntax highlighting is not available when the |+syntax| feature has been
45 disabled at compile time. 46 disabled at compile time.
366 +- Any other user installed FileType or Syntax autocommands are 367 +- Any other user installed FileType or Syntax autocommands are
367 triggered. This can be used to change the highlighting for a specific 368 triggered. This can be used to change the highlighting for a specific
368 syntax. 369 syntax.
369 370
370 ============================================================================== 371 ==============================================================================
371 4. Syntax file remarks *:syn-file-remarks* 372 4. Conversion to HTML *2html.vim* *convert-to-HTML*
372 373
373 *b:current_syntax-variable* 374 2html is not a syntax file itself, but a script that converts the current
374 Vim stores the name of the syntax that has been loaded in the
375 "b:current_syntax" variable. You can use this if you want to load other
376 settings, depending on which syntax is active. Example: >
377 :au BufReadPost * if b:current_syntax == "csh"
378 :au BufReadPost * do-some-things
379 :au BufReadPost * endif
380
381
382 2HTML *2html.vim* *convert-to-HTML*
383
384 This is not a syntax file itself, but a script that converts the current
385 window into HTML. Vim opens a new window in which it builds the HTML file. 375 window into HTML. Vim opens a new window in which it builds the HTML file.
386 376
387 After you save the resulting file, you can view it with any browser. The 377 After you save the resulting file, you can view it with any browser. The
388 colors should be exactly the same as you see them in Vim. With 378 colors should be exactly the same as you see them in Vim. With
389 |g:html_line_ids| you can jump to specific lines by adding (for example) #L123 379 |g:html_line_ids| you can jump to specific lines by adding (for example) #L123
771 When 0, generate standard HTML 4.01 (strict when possible). 761 When 0, generate standard HTML 4.01 (strict when possible).
772 When 1, generate XHTML 1.0 instead (XML compliant HTML). 762 When 1, generate XHTML 1.0 instead (XML compliant HTML).
773 > 763 >
774 :let g:html_use_xhtml = 1 764 :let g:html_use_xhtml = 1
775 < 765 <
766 ==============================================================================
767 5. Syntax file remarks *:syn-file-remarks*
768
769 *b:current_syntax-variable*
770 Vim stores the name of the syntax that has been loaded in the
771 "b:current_syntax" variable. You can use this if you want to load other
772 settings, depending on which syntax is active. Example: >
773 :au BufReadPost * if b:current_syntax == "csh"
774 :au BufReadPost * do-some-things
775 :au BufReadPost * endif
776
777
776 778
777 ABEL *abel.vim* *ft-abel-syntax* 779 ABEL *abel.vim* *ft-abel-syntax*
778 780
779 ABEL highlighting provides some user-defined options. To enable them, assign 781 ABEL highlighting provides some user-defined options. To enable them, assign
780 any value to the respective variable. Example: > 782 any value to the respective variable. Example: >
3482 The syntax script for zsh allows for syntax-based folding: > 3484 The syntax script for zsh allows for syntax-based folding: >
3483 3485
3484 :let g:zsh_fold_enable = 1 3486 :let g:zsh_fold_enable = 1
3485 3487
3486 ============================================================================== 3488 ==============================================================================
3487 5. Defining a syntax *:syn-define* *E410* 3489 6. Defining a syntax *:syn-define* *E410*
3488 3490
3489 Vim understands three types of syntax items: 3491 Vim understands three types of syntax items:
3490 3492
3491 1. Keyword 3493 1. Keyword
3492 It can only contain keyword characters, according to the 'iskeyword' 3494 It can only contain keyword characters, according to the 'iskeyword'
3841 < 3843 <
3842 *E849* 3844 *E849*
3843 The maximum number of syntax groups is 19999. 3845 The maximum number of syntax groups is 19999.
3844 3846
3845 ============================================================================== 3847 ==============================================================================
3846 6. :syntax arguments *:syn-arguments* 3848 7. :syntax arguments *:syn-arguments*
3847 3849
3848 The :syntax commands that define syntax items take a number of arguments. 3850 The :syntax commands that define syntax items take a number of arguments.
3849 The common ones are explained here. The arguments may be given in any order 3851 The common ones are explained here. The arguments may be given in any order
3850 and may be mixed with patterns. 3852 and may be mixed with patterns.
3851 3853
4162 4164
4163 :sy[ntax] conceal 4165 :sy[ntax] conceal
4164 Show either "syntax conceal on" or "syntax conceal off" (translated). 4166 Show either "syntax conceal on" or "syntax conceal off" (translated).
4165 4167
4166 ============================================================================== 4168 ==============================================================================
4167 7. Syntax patterns *:syn-pattern* *E401* *E402* 4169 8. Syntax patterns *:syn-pattern* *E401* *E402*
4168 4170
4169 In the syntax commands, a pattern must be surrounded by two identical 4171 In the syntax commands, a pattern must be surrounded by two identical
4170 characters. This is like it works for the ":s" command. The most common to 4172 characters. This is like it works for the ":s" command. The most common to
4171 use is the double quote. But if the pattern contains a double quote, you can 4173 use is the double quote. But if the pattern contains a double quote, you can
4172 use another character that is not used in the pattern. Examples: > 4174 use another character that is not used in the pattern. Examples: >
4340 4342
4341 Note that only matches within a single line can be used. Multi-line matches 4343 Note that only matches within a single line can be used. Multi-line matches
4342 cannot be referred to. 4344 cannot be referred to.
4343 4345
4344 ============================================================================== 4346 ==============================================================================
4345 8. Syntax clusters *:syn-cluster* *E400* 4347 9. Syntax clusters *:syn-cluster* *E400*
4346 4348
4347 :sy[ntax] cluster {cluster-name} [contains={group-name}..] 4349 :sy[ntax] cluster {cluster-name} [contains={group-name}..]
4348 [add={group-name}..] 4350 [add={group-name}..]
4349 [remove={group-name}..] 4351 [remove={group-name}..]
4350 4352
4386 < 4388 <
4387 *E848* 4389 *E848*
4388 The maximum number of clusters is 9767. 4390 The maximum number of clusters is 9767.
4389 4391
4390 ============================================================================== 4392 ==============================================================================
4391 9. Including syntax files *:syn-include* *E397* 4393 10. Including syntax files *:syn-include* *E397*
4392 4394
4393 It is often useful for one language's syntax file to include a syntax file for 4395 It is often useful for one language's syntax file to include a syntax file for
4394 a related language. Depending on the exact relationship, this can be done in 4396 a related language. Depending on the exact relationship, this can be done in
4395 two different ways: 4397 two different ways:
4396 4398
4427 4429
4428 *E847* 4430 *E847*
4429 The maximum number of includes is 999. 4431 The maximum number of includes is 999.
4430 4432
4431 ============================================================================== 4433 ==============================================================================
4432 10. Synchronizing *:syn-sync* *E403* *E404* 4434 11. Synchronizing *:syn-sync* *E403* *E404*
4433 4435
4434 Vim wants to be able to start redrawing in any position in the document. To 4436 Vim wants to be able to start redrawing in any position in the document. To
4435 make this possible it needs to know the syntax state at the position where 4437 make this possible it needs to know the syntax state at the position where
4436 redrawing starts. 4438 redrawing starts.
4437 4439
4619 4621
4620 You can clear specific sync patterns with: > 4622 You can clear specific sync patterns with: >
4621 :syntax sync clear {sync-group-name} .. 4623 :syntax sync clear {sync-group-name} ..
4622 4624
4623 ============================================================================== 4625 ==============================================================================
4624 11. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list* 4626 12. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
4625 4627
4626 This command lists all the syntax items: > 4628 This command lists all the syntax items: >
4627 4629
4628 :sy[ntax] [list] 4630 :sy[ntax] [list]
4629 4631
4639 4641
4640 Note that the ":syntax" command can be abbreviated to ":sy", although ":syn" 4642 Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
4641 is mostly used, because it looks better. 4643 is mostly used, because it looks better.
4642 4644
4643 ============================================================================== 4645 ==============================================================================
4644 12. Highlight command *:highlight* *:hi* *E28* *E411* *E415* 4646 13. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
4645 4647
4646 There are three types of highlight groups: 4648 There are three types of highlight groups:
4647 - The ones used for specific languages. For these the name starts with the 4649 - The ones used for specific languages. For these the name starts with the
4648 name of the language. Many of these don't have any attributes, but are 4650 name of the language. Many of these don't have any attributes, but are
4649 linked to a group of the second type. 4651 linked to a group of the second type.
5132 specifies a fontset at all times, no matter if 'guifontset' is 5134 specifies a fontset at all times, no matter if 'guifontset' is
5133 empty, and as such it is tied to the current |:language| when 5135 empty, and as such it is tied to the current |:language| when
5134 set. 5136 set.
5135 5137
5136 ============================================================================== 5138 ==============================================================================
5137 13. Linking groups *:hi-link* *:highlight-link* *E412* *E413* 5139 14. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
5138 5140
5139 When you want to use the same highlighting for several syntax groups, you 5141 When you want to use the same highlighting for several syntax groups, you
5140 can do this more easily by linking the groups into one common highlight 5142 can do this more easily by linking the groups into one common highlight
5141 group, and give the color attributes only for that group. 5143 group, and give the color attributes only for that group.
5142 5144
5170 :highlight link cComment Question 5172 :highlight link cComment Question
5171 Without the "default" in the C syntax file, the highlighting would be 5173 Without the "default" in the C syntax file, the highlighting would be
5172 overruled when the syntax file is loaded. 5174 overruled when the syntax file is loaded.
5173 5175
5174 ============================================================================== 5176 ==============================================================================
5175 14. Cleaning up *:syn-clear* *E391* 5177 15. Cleaning up *:syn-clear* *E391*
5176 5178
5177 If you want to clear the syntax stuff for the current buffer, you can use this 5179 If you want to clear the syntax stuff for the current buffer, you can use this
5178 command: > 5180 command: >
5179 :syntax clear 5181 :syntax clear
5180 5182
5261 "skip" Don't define colors. Used to skip the default settings when a 5263 "skip" Don't define colors. Used to skip the default settings when a
5262 syncolor.vim file earlier in 'runtimepath' has already set 5264 syncolor.vim file earlier in 'runtimepath' has already set
5263 them. 5265 them.
5264 5266
5265 ============================================================================== 5267 ==============================================================================
5266 15. Highlighting tags *tag-highlight* 5268 16. Highlighting tags *tag-highlight*
5267 5269
5268 If you want to highlight all the tags in your file, you can use the following 5270 If you want to highlight all the tags in your file, you can use the following
5269 mappings. 5271 mappings.
5270 5272
5271 <F11> -- Generate tags.vim file, and highlight tags. 5273 <F11> -- Generate tags.vim file, and highlight tags.
5296 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname) 5298 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
5297 autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname 5299 autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname
5298 autocmd BufRead,BufNewFile *.[ch] endif 5300 autocmd BufRead,BufNewFile *.[ch] endif
5299 5301
5300 ============================================================================== 5302 ==============================================================================
5301 16. Window-local syntax *:ownsyntax* 5303 17. Window-local syntax *:ownsyntax*
5302 5304
5303 Normally all windows on a buffer share the same syntax settings. It is 5305 Normally all windows on a buffer share the same syntax settings. It is
5304 possible, however, to set a particular window on a file to have its own 5306 possible, however, to set a particular window on a file to have its own
5305 private syntax setting. A possible example would be to edit LaTeX source 5307 private syntax setting. A possible example would be to edit LaTeX source
5306 with conventional highlighting in one window, while seeing the same source 5308 with conventional highlighting in one window, while seeing the same source
5326 A window with its own syntax reverts to normal behavior when another buffer 5328 A window with its own syntax reverts to normal behavior when another buffer
5327 is loaded into that window or the file is reloaded. 5329 is loaded into that window or the file is reloaded.
5328 When splitting the window, the new window will use the original syntax. 5330 When splitting the window, the new window will use the original syntax.
5329 5331
5330 ============================================================================== 5332 ==============================================================================
5331 17. Color xterms *xterm-color* *color-xterm* 5333 18. Color xterms *xterm-color* *color-xterm*
5332 5334
5333 Most color xterms have only eight colors. If you don't get colors with the 5335 Most color xterms have only eight colors. If you don't get colors with the
5334 default setup, it should work with these lines in your .vimrc: > 5336 default setup, it should work with these lines in your .vimrc: >
5335 :if &term =~ "xterm" 5337 :if &term =~ "xterm"
5336 : if has("terminfo") 5338 : if has("terminfo")
5470 that Setup / Font / Enable Bold is NOT enabled. 5472 that Setup / Font / Enable Bold is NOT enabled.
5471 (info provided by John Love-Jensen <eljay@Adobe.COM>) 5473 (info provided by John Love-Jensen <eljay@Adobe.COM>)
5472 5474
5473 5475
5474 ============================================================================== 5476 ==============================================================================
5475 18. When syntax is slow *:syntime* 5477 19. When syntax is slow *:syntime*
5476 5478
5477 This is aimed at authors of a syntax file. 5479 This is aimed at authors of a syntax file.
5478 5480
5479 If your syntax causes redrawing to be slow, here are a few hints on making it 5481 If your syntax causes redrawing to be slow, here are a few hints on making it
5480 faster. To see slowness switch on some features that usually interfere, such 5482 faster. To see slowness switch on some features that usually interfere, such