CHARMM Development Project
Just sharing with the community.

Include in ${HOME}/.vimrc file

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
Posted By: rmv Re: Syntax highlighting for CHARMM in vim editor - 10/15/08 09:20 PM
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

Attached File
19237-charmm-vim.txt  (894 downloads)
NICE! Thanks a lot
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
A better version of syntax highlighting file, including features like case-insensitivity, new color scheme, and more Charmm commands...

Attached File  (683 downloads)
Apologies, I think I made a mistake in the original posting.

Line "syn region CursorLine start ..."
should read
syn region CursorLine start="-\s*\([!].*\)\=$" end="\<" contains=Comment

It is possible that it worked with the version of vim I used at the time.

I took the liberty of modifying the latest posted version accordingly.


Attached File  (634 downloads)
© CHARMM forums