Home Explore Blog CI



neovim

71th chunk of `runtime/doc/syntax.txt`
0001deee14364ad3143a16fd9dba713b3caa1f22501f1f2a0000000100000e5f

"after/syntax/{filetype}.vim" file: >
    highlight! default link cComment Question

==============================================================================
15. Cleaning up						*:syn-clear* *E391*

If you want to clear the syntax stuff for the current buffer, you can use this
command: >
  :syntax clear

This command should be used when you want to switch off syntax highlighting,
or when you want to switch to using another syntax.  It's normally not needed
in a syntax file itself, because syntax is cleared by the autocommands that
load the syntax file.
The command also deletes the "b:current_syntax" variable, since no syntax is
loaded after this command.

To clean up specific syntax groups for the current buffer: >
  :syntax clear {group-name} ..
This removes all patterns and keywords for {group-name}.

To clean up specific syntax group lists for the current buffer: >
  :syntax clear @{grouplist-name} ..
This sets {grouplist-name}'s contents to an empty list.

						*:syntax-off* *:syn-off*
If you want to disable syntax highlighting for all buffers, you need to remove
the autocommands that load the syntax files: >
  :syntax off

What this command actually does, is executing the command >
  :source $VIMRUNTIME/syntax/nosyntax.vim
See the "nosyntax.vim" file for details.  Note that for this to work
$VIMRUNTIME must be valid.  See |$VIMRUNTIME|.

						*:syntax-reset* *:syn-reset*
If you have changed the colors and messed them up, use this command to get the
defaults back: >

  :syntax reset

It is a bit of a wrong name, since it does not reset any syntax items, it only
affects the highlighting.

Note that the syntax colors that you set in your vimrc file will also be reset
back to their Vim default.
Note that if you are using a color scheme, the colors defined by the color
scheme for syntax highlighting will be lost.

Note that when a color scheme is used, there might be some confusion whether
your defined colors are to be used or the colors from the scheme.  This
depends on the color scheme file.  See |:colorscheme|.

==============================================================================
16. Highlighting tags					*tag-highlight*

If you want to highlight all the tags in your file, you can use the following
mappings.

	<F11>	-- Generate tags.vim file, and highlight tags.
	<F12>	-- Just highlight tags based on existing tags.vim file.
>
  :map <F11>  :sp tags<CR>:%s/^\([^	:]*:\)\=\([^	]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
  :map <F12>  :so tags.vim<CR>

WARNING: The longer the tags file, the slower this will be, and the more
memory Vim will consume.

Only highlighting typedefs, unions and structs can be done too.  For this you
must use Universal Ctags (https://ctags.io) or Exuberant ctags.

Put these lines in your Makefile: >

    # Make a highlight file for types.  Requires Universal/Exuberant ctags and awk
    types: types.vim
    types.vim: *.[ch]
	    ctags --c-kinds=gstu -o- *.[ch] |\
		    awk 'BEGIN{printf("syntax keyword Type\t")}\
			    {printf("%s ", $$1)}END{print ""}' > $@

And put these lines in your vimrc: >

   " load the types.vim highlighting file, if it exists
   autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') .. '/types.vim'
   autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
   autocmd BufRead,BufNewFile *.[ch]   exe 'so ' .. fname
   autocmd BufRead,BufNewFile *.[ch] endif

==============================================================================
17. Window-local syntax				*:ownsyntax*

Normally all windows on a buffer share the same syntax settings. It is
possible, however, to set a particular window on a file to have its

Title: Vim Syntax Highlighting: Clearing Syntax, Resetting Colors, Highlighting Tags, and Window-Local Syntax
Summary
This section describes how to use the ':syntax clear' command to remove syntax highlighting or switch to a different syntax, and ':syntax off' to disable syntax for all buffers. It also explains how to reset the default colors with ':syntax reset'. Further, it covers highlighting tags in a file using mappings and generating a 'tags.vim' file, as well as highlighting typedefs, unions, and structs using Universal Ctags or Exuberant Ctags. Finally, it introduces the concept of window-local syntax, where each window on a file can have its own syntax settings.