docs:vim:syntax

syntax

First check the vim installation files, under the 'syntax' directory to see if you can find a sensible match for the type of file you have.

If vim has failed to auto-detect your filetype, you may specify the syntax with :set syntax=javascript. Filetype detection is enabled with :filetype on, and filetype plugin usage is enabled with :filetype plugin on.

If you find a syntax to use, but you wish to tweak something about it, you can create a syntax file to run 'after' vim has loaded the default file. Simply create a file in $VIMRUNTIME/after/syntax/ with the same name as the syntax file you are starting with. For example, to add folding to the Progress syntax, create $VIMRUNTIME/after/syntax/progress.vim.

This is an easy way to add customized folding to an existing language that didn't have it set up by default.

If you can't find a matching syntax file, you can create a new one. See :help syntax to understand how this is done. Create your syntax file at $VIMRUNTIME/syntax/newtype.vim.

Load your file into vim, then load your syntax like this:

:set syntax=newtype

You may also have vim automatically detect your new filetype, and set up the syntax for you. See :help new-filetype in vim for more information. It basically involves creating a file 'newtype.vim' in /ftdetect/ with this line:

au BufRead,BufNewFile *.newtype		set filetype=newtype
  • docs/vim/syntax.txt
  • Last modified: 2008/09/14 01:23
  • by billh