Syntax script
Create a file ~/.vim/syntax/simple.vim
with the following contents:
" Quit when a syntax file was already loaded.
if exists('b:current_syntax') | finish| endif
syntax match simpleVar "\k\+" nextgroup=simpleAssignment
syntax match simpleAssignment "=" contained nextgroup=simpleValue
syntax match simpleValue ".*" contained
hi def link simpleVar Identifier
hi def link simpleAssignment Statement
hi def link simpleValue String
let b:current_syntax = 'simple'
That matches the three syntax elements, and provides default colors. One doesn't generally define explicit colors, but instead links to default highlighting groups defined by your colorscheme. You can list all via :hi
. For tweaking, read :help :syntax
and :help usr_44.txt
, and have a look at the syntax scripts that ship with Vim.
Filetype detection
So far, you have to manually :set syntax=simple
to active. To do this automatically, you have to teach Vim about your new filetype.
Create a file ~/.vim/ftdetect/simple.vim
with the following contents:
autocmd BufNewFile,BufRead *.simple setf simple
This assumes that the files can be identified via the file name (cp. :help autocmd-patterns
). You can also detect based on the path (file location), or even the contents. :help new-filetype
has details.