comparison runtime/doc/syntax.txt @ 28933:57c9377b9c62

Update runtime files. Commit: https://github.com/vim/vim/commit/2d8ed0203aedd5f6c22efa99394a3677c17c7a7a Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 21 13:08:16 2022 +0100 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Sat, 21 May 2022 14:15:05 +0200
parents cd68a630f0d0
children f8e9d5023bf6
comparison
equal deleted inserted replaced
28932:6382d2a4be3a 28933:57c9377b9c62
1 *syntax.txt* For Vim version 8.2. Last change: 2022 May 06 1 *syntax.txt* For Vim version 8.2. Last change: 2022 May 20
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
30 8. Syntax patterns |:syn-pattern| 30 8. Syntax patterns |:syn-pattern|
31 9. Syntax clusters |:syn-cluster| 31 9. Syntax clusters |:syn-cluster|
32 10. Including syntax files |:syn-include| 32 10. Including syntax files |:syn-include|
33 11. Synchronizing |:syn-sync| 33 11. Synchronizing |:syn-sync|
34 12. Listing syntax items |:syntax| 34 12. Listing syntax items |:syntax|
35 13. Highlight command |:highlight| 35 13. Colorschemes |color-schemes|
36 14. Linking groups |:highlight-link| 36 14. Highlight command |:highlight|
37 15. Cleaning up |:syn-clear| 37 15. Linking groups |:highlight-link|
38 16. Highlighting tags |tag-highlight| 38 16. Cleaning up |:syn-clear|
39 17. Window-local syntax |:ownsyntax| 39 17. Highlighting tags |tag-highlight|
40 18. Color xterms |xterm-color| 40 18. Window-local syntax |:ownsyntax|
41 19. When syntax is slow |:syntime| 41 19. Color xterms |xterm-color|
42 20. When syntax is slow |:syntime|
42 43
43 {Vi does not have any of these commands} 44 {Vi does not have any of these commands}
44 45
45 Syntax highlighting is not available when the |+syntax| feature has been 46 Syntax highlighting is not available when the |+syntax| feature has been
46 disabled at compile time. 47 disabled at compile time.
1509 The coloring scheme for syntax elements in the FORM file uses the default 1510 The coloring scheme for syntax elements in the FORM file uses the default
1510 modes Conditional, Number, Statement, Comment, PreProc, Type, and String, 1511 modes Conditional, Number, Statement, Comment, PreProc, Type, and String,
1511 following the language specifications in 'Symbolic Manipulation with FORM' by 1512 following the language specifications in 'Symbolic Manipulation with FORM' by
1512 J.A.M. Vermaseren, CAN, Netherlands, 1991. 1513 J.A.M. Vermaseren, CAN, Netherlands, 1991.
1513 1514
1514 If you want include your own changes to the default colors, you have to 1515 If you want to include your own changes to the default colors, you have to
1515 redefine the following syntax groups: 1516 redefine the following syntax groups:
1516 1517
1517 - formConditional 1518 - formConditional
1518 - formNumber 1519 - formNumber
1519 - formStatement 1520 - formStatement
4843 4844
4844 Note that the ":syntax" command can be abbreviated to ":sy", although ":syn" 4845 Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
4845 is mostly used, because it looks better. 4846 is mostly used, because it looks better.
4846 4847
4847 ============================================================================== 4848 ==============================================================================
4848 13. Highlight command *:highlight* *:hi* *E28* *E411* *E415* 4849 13. Colorschemes *color-schemes*
4850
4851 In the next section you can find information about indivisual highlight groups
4852 and how to specify colors for them. Most likely you want to just select a set
4853 of colors by using the `:colorscheme` command, for example: >
4854
4855 colorscheme pablo
4856 <
4857 *:colo* *:colorscheme* *E185*
4858 :colo[rscheme] Output the name of the currently active color scheme.
4859 This is basically the same as >
4860 :echo g:colors_name
4861 < In case g:colors_name has not been defined :colo will
4862 output "default". When compiled without the |+eval|
4863 feature it will output "unknown".
4864
4865 :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
4866 for the file "colors/{name}.vim". The first one that
4867 is found is loaded.
4868 Also searches all plugins in 'packpath', first below
4869 "start" and then under "opt".
4870
4871 Doesn't work recursively, thus you can't use
4872 ":colorscheme" in a color scheme script.
4873
4874 You have two options for customizing a color scheme. For changing the
4875 appearance of specific colors, you can redefine a color name before loading
4876 the scheme. The desert scheme uses the khaki color for the cursor. To use a
4877 darker variation of the same color: >
4878
4879 let v:colornames['khaki'] = '#bdb76b'
4880 colorscheme desert
4881 <
4882 For further customization, such as changing |:highlight-link| associations,
4883 use another name, e.g. "~/.vim/colors/mine.vim", and use `:runtime` to load
4884 the original color scheme: >
4885 runtime colors/evening.vim
4886 hi Statement ctermfg=Blue guifg=Blue
4887
4888 Before the color scheme will be loaded all default color list scripts
4889 (`colors/lists/default.vim`) will be executed and then the |ColorSchemePre|
4890 autocommand event is triggered. After the color scheme has been loaded the
4891 |ColorScheme| autocommand event is triggered.
4892
4893 If a color scheme is almost right, you can add modifications on top of it by
4894 using the |ColorScheme| autocommand. For example, to remove the background
4895 color (can make it transparent in some terminals): >
4896 augroup my_colorschemes
4897 au!
4898 au Colorscheme pablo hi Normal ctermbg=NONE
4899 augroup END
4900
4901 If you make a lot of changes it might be better to copy the distributed
4902 colorscheme to your home directory and change it: >
4903 :!cp $VIMRUNTIME/colors/pablo.vim ~/.vim/colors
4904 :edit ~/.vim/colors/pablo.vim
4905
4906 With Vim 9.0 the collection of color schemes was updated and made work in many
4907 different terminals. One change was to often define the Normal highlight
4908 group to make sure the colors work well. In case you prefer the old version,
4909 you can find them here:
4910 https://github.com/vim/colorschemes/blob/master/legacy_colors/
4911
4912 For info about writing a color scheme file: >
4913 :edit $VIMRUNTIME/colors/README.txt
4914
4915
4916 ==============================================================================
4917 14. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
4849 4918
4850 There are three types of highlight groups: 4919 There are three types of highlight groups:
4851 - The ones used for specific languages. For these the name starts with the 4920 - The ones used for specific languages. For these the name starts with the
4852 name of the language. Many of these don't have any attributes, but are 4921 name of the language. Many of these don't have any attributes, but are
4853 linked to a group of the second type. 4922 linked to a group of the second type.
4856 *hitest.vim* 4925 *hitest.vim*
4857 You can see all the groups currently active with this command: > 4926 You can see all the groups currently active with this command: >
4858 :so $VIMRUNTIME/syntax/hitest.vim 4927 :so $VIMRUNTIME/syntax/hitest.vim
4859 This will open a new window containing all highlight group names, displayed 4928 This will open a new window containing all highlight group names, displayed
4860 in their own color. 4929 in their own color.
4861
4862 *:colo* *:colorscheme* *E185*
4863 :colo[rscheme] Output the name of the currently active color scheme.
4864 This is basically the same as >
4865 :echo g:colors_name
4866 < In case g:colors_name has not been defined :colo will
4867 output "default". When compiled without the |+eval|
4868 feature it will output "unknown".
4869
4870 :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
4871 for the file "colors/{name}.vim". The first one that
4872 is found is loaded.
4873 Also searches all plugins in 'packpath', first below
4874 "start" and then under "opt".
4875
4876 Doesn't work recursively, thus you can't use
4877 ":colorscheme" in a color scheme script.
4878
4879 You have two options for customizing a color scheme.
4880 For changing the appearance of specific colors, you
4881 can redefine a color name before loading the scheme.
4882 The desert scheme uses the khaki color for the cursor.
4883 To use a darker variation of the same color: >
4884
4885 let v:colornames['khaki'] = '#bdb76b'
4886 colorscheme desert
4887 <
4888 For further customization, such as changing
4889 |:highlight-link| associations, use another name, e.g.
4890 "~/.vim/colors/mine.vim", and use `:runtime` to load
4891 the original color scheme: >
4892 runtime colors/evening.vim
4893 hi Statement ctermfg=Blue guifg=Blue
4894
4895 < Before the color scheme will be loaded all default
4896 color list scripts (`colors/lists/default.vim`) will
4897 be executed and then the |ColorSchemePre| autocommand
4898 event is triggered. After the color scheme has been
4899 loaded the |ColorScheme| autocommand event is
4900 triggered.
4901 For info about writing a color scheme file: >
4902 :edit $VIMRUNTIME/colors/README.txt
4903 4930
4904 :hi[ghlight] List all the current highlight groups that have 4931 :hi[ghlight] List all the current highlight groups that have
4905 attributes set. 4932 attributes set.
4906 4933
4907 :hi[ghlight] {group-name} 4934 :hi[ghlight] {group-name}
5204 "gg" is the Green value 5231 "gg" is the Green value
5205 "bb" is the Blue value 5232 "bb" is the Blue value
5206 All values are hexadecimal, range from "00" to "ff". Examples: > 5233 All values are hexadecimal, range from "00" to "ff". Examples: >
5207 :highlight Comment guifg=#11f0c3 guibg=#ff00ff 5234 :highlight Comment guifg=#11f0c3 guibg=#ff00ff
5208 < 5235 <
5209 If you are authoring a color scheme and use the same hexademical value 5236 If you are authoring a color scheme and use the same hexadecimal value
5210 repeatedly, you can define a name for it in |v:colornames|. For 5237 repeatedly, you can define a name for it in |v:colornames|. For
5211 example: > 5238 example: >
5212 5239
5213 # provide a default value for this color but allow the user to 5240 # provide a default value for this color but allow the user to
5214 # override it. 5241 # override it.
5414 specifies a fontset at all times, no matter if 'guifontset' is 5441 specifies a fontset at all times, no matter if 'guifontset' is
5415 empty, and as such it is tied to the current |:language| when 5442 empty, and as such it is tied to the current |:language| when
5416 set. 5443 set.
5417 5444
5418 ============================================================================== 5445 ==============================================================================
5419 14. Linking groups *:hi-link* *:highlight-link* *E412* *E413* 5446 15. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
5420 5447
5421 When you want to use the same highlighting for several syntax groups, you 5448 When you want to use the same highlighting for several syntax groups, you
5422 can do this more easily by linking the groups into one common highlight 5449 can do this more easily by linking the groups into one common highlight
5423 group, and give the color attributes only for that group. 5450 group, and give the color attributes only for that group.
5424 5451
5458 another color scheme, put a command like this in the 5485 another color scheme, put a command like this in the
5459 "after/syntax/{filetype}.vim" file: > 5486 "after/syntax/{filetype}.vim" file: >
5460 highlight! default link cComment Question 5487 highlight! default link cComment Question
5461 5488
5462 ============================================================================== 5489 ==============================================================================
5463 15. Cleaning up *:syn-clear* *E391* 5490 16. Cleaning up *:syn-clear* *E391*
5464 5491
5465 If you want to clear the syntax stuff for the current buffer, you can use this 5492 If you want to clear the syntax stuff for the current buffer, you can use this
5466 command: > 5493 command: >
5467 :syntax clear 5494 :syntax clear
5468 5495
5550 "skip" Don't define colors. Used to skip the default settings when a 5577 "skip" Don't define colors. Used to skip the default settings when a
5551 syncolor.vim file earlier in 'runtimepath' has already set 5578 syncolor.vim file earlier in 'runtimepath' has already set
5552 them. 5579 them.
5553 5580
5554 ============================================================================== 5581 ==============================================================================
5555 16. Highlighting tags *tag-highlight* 5582 17. Highlighting tags *tag-highlight*
5556 5583
5557 If you want to highlight all the tags in your file, you can use the following 5584 If you want to highlight all the tags in your file, you can use the following
5558 mappings. 5585 mappings.
5559 5586
5560 <F11> -- Generate tags.vim file, and highlight tags. 5587 <F11> -- Generate tags.vim file, and highlight tags.
5586 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname) 5613 autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
5587 autocmd BufRead,BufNewFile *.[ch] exe 'so ' .. fname 5614 autocmd BufRead,BufNewFile *.[ch] exe 'so ' .. fname
5588 autocmd BufRead,BufNewFile *.[ch] endif 5615 autocmd BufRead,BufNewFile *.[ch] endif
5589 5616
5590 ============================================================================== 5617 ==============================================================================
5591 17. Window-local syntax *:ownsyntax* 5618 18. Window-local syntax *:ownsyntax*
5592 5619
5593 Normally all windows on a buffer share the same syntax settings. It is 5620 Normally all windows on a buffer share the same syntax settings. It is
5594 possible, however, to set a particular window on a file to have its own 5621 possible, however, to set a particular window on a file to have its own
5595 private syntax setting. A possible example would be to edit LaTeX source 5622 private syntax setting. A possible example would be to edit LaTeX source
5596 with conventional highlighting in one window, while seeing the same source 5623 with conventional highlighting in one window, while seeing the same source
5616 A window with its own syntax reverts to normal behavior when another buffer 5643 A window with its own syntax reverts to normal behavior when another buffer
5617 is loaded into that window or the file is reloaded. 5644 is loaded into that window or the file is reloaded.
5618 When splitting the window, the new window will use the original syntax. 5645 When splitting the window, the new window will use the original syntax.
5619 5646
5620 ============================================================================== 5647 ==============================================================================
5621 18. Color xterms *xterm-color* *color-xterm* 5648 19. Color xterms *xterm-color* *color-xterm*
5622 5649
5623 Most color xterms have only eight colors. If you don't get colors with the 5650 Most color xterms have only eight colors. If you don't get colors with the
5624 default setup, it should work with these lines in your .vimrc: > 5651 default setup, it should work with these lines in your .vimrc: >
5625 :if &term =~ "xterm" 5652 :if &term =~ "xterm"
5626 : if has("terminfo") 5653 : if has("terminfo")
5760 that Setup / Font / Enable Bold is NOT enabled. 5787 that Setup / Font / Enable Bold is NOT enabled.
5761 (info provided by John Love-Jensen <eljay@Adobe.COM>) 5788 (info provided by John Love-Jensen <eljay@Adobe.COM>)
5762 5789
5763 5790
5764 ============================================================================== 5791 ==============================================================================
5765 19. When syntax is slow *:syntime* 5792 20. When syntax is slow *:syntime*
5766 5793
5767 This is aimed at authors of a syntax file. 5794 This is aimed at authors of a syntax file.
5768 5795
5769 If your syntax causes redrawing to be slow, here are a few hints on making it 5796 If your syntax causes redrawing to be slow, here are a few hints on making it
5770 faster. To see slowness switch on some features that usually interfere, such 5797 faster. To see slowness switch on some features that usually interfere, such