vim (on most systems these days
vi is actually a symlink for
vim) uses syntax files to define the coloring schemes for the various languages it can deal with. You have not specified which OS you use but on my LMDE system, these are found in
When you open a file using
vim, it will first try and figure out what type of file it is. As explained in the official documentation:
Upon loading a file, Vim finds the relevant syntax file as follows:
Loading the file triggers the BufReadPost autocommands.
+- If there is a match with one of the autocommands from |synload-3|
| (known file types) or |synload-4| (user's file types), the 'filetype'
| option is set to the file type.
+- The autocommand at |synload-5| is triggered. If the file type was not
| found yet, then scripts.vim is searched for in 'runtimepath'. This
| should always load $VIMRUNTIME/scripts.vim, which does the following.
| +- Source the user's optional file, from the *myscriptsfile*
| | variable. This is for backwards compatibility with Vim 5.x only.
| +- If the file type is still unknown, check the contents of the file,
| again with checks like "getline(1) =~ pattern" as to whether the
| file type can be recognized, and set 'filetype'.
+- When the file type was determined and 'filetype' was set, this
| triggers the FileType autocommand |synload-6| above. It sets
| 'syntax' to the determined file type.
+- When the 'syntax' option was set above, this triggers an autocommand
| from |synload-1| (and |synload-2|). This find the main syntax file in
| 'runtimepath', with this command:
| runtime! syntax/<name>.vim
+- Any other user installed FileType or Syntax autocommands are
triggered. This can be used to change the highlighting for a specific
vim uses some tricks to parse and guess the file type and then will load the appropriate syntax file. The file that defines the syntax for configuration files is