au BufRead,BufNewFile *.inp set filetype=charmm au! Syntax charmm source $HOME/.vim/syntax/charmm.vim
Create syntax directory mkdir -p .vim/syntax/
Create file ${HOME}/.vim/syntax/charmm.vim with the following content
"AM: BEGIN OF .vim/syntax/charmm.vim syn sync clear syn sync fromstart
syn match Comment "[!].*$" "floating point number, with dot, optional exponent syn match cFloat "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" "floating point number, starting with a dot, optional exponent syn match cFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" "floating point number, without dot, with exponent syn match cFloat "\d\+e[-+]\=\d\+[fl]\=\>" syn match cNumber "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" syn match cNumber "\<[-+]\=\d\+\>" highlight def link cNumber Constant highlight def link cFloat Constant
syn match Title "^\*.*$" syn keyword Identifier if label stream calc goto incr stop syn region Special start="sele" end="end"
syn match Statement "^\s*dyna\w*\>" syn match Statement "^\s*coor\w*\>" syn match Statement "^\s*mini\w*\>"
syn match charmmParameter "[@?]\h\+" syn match charmmParameter "[@?][{]\h\+[}]" highlight def link charmmParameter ModeMsg
syn region CursorLine start="\<-\>\s*\([!].*\)\=$" end="\<" contains=Comment
let b:current_syntax = "charmm" "AM: END OF .vim/syntax/charmm.vim
A very nice template. I've taken the liberty of using the main command parser (charmm/charmm_main.src) to add an expanded list of primary commands as 'Statement' words, and expanded the list of 'Identifier' words. I also added files with an extension of .str (my convention for stream files) via the following one-line addition to my .vimrc
au BufRead,BufNewFile *.str set filetype=charmm
The revised 'charmm.vim' syntax file is attached as plain text.
An alternative to adding the above line is to change the line for '.inp' to add another extension
au BufRead,BufNewFile *.inp,*.str set filetype=charmm
As a bonus for those who use vim to browse or edit CHARMM source code, adding the following line to your ~/.vimrc file will add fortran syntax highlighting for .src and .fcm files:
au BufRead,BufNewFile *.src,*.fcm set filetype=fortran