Previous Thread
Next Thread
Print Thread
Joined: Oct 2008
Posts: 3
M
Forum Member
OP Offline
Forum Member
M
Joined: Oct 2008
Posts: 3
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

Joined: Sep 2003
Posts: 8,621
Likes: 24
rmv Online Content
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 8,621
Likes: 24
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 Images
19237-charmm-vim.txt (0 Bytes, 895 downloads)
Last edited by rmv; 11/14/08 01:28 AM.
Joined: Jul 2008
Posts: 12
T
Forum Member
Offline
Forum Member
T
Joined: Jul 2008
Posts: 12
NICE! Thanks a lot

Joined: Sep 2003
Posts: 8,621
Likes: 24
rmv Online Content
Forum Member
Online Content
Forum Member
Joined: Sep 2003
Posts: 8,621
Likes: 24
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

Joined: Oct 2008
Posts: 55
Forum Member
Offline
Forum Member
Joined: Oct 2008
Posts: 55
A better version of syntax highlighting file, including features like case-insensitivity, new color scheme, and more Charmm commands...

Attached Images
20384-charmm.zip (0 Bytes, 683 downloads)
Last edited by Zhiguo; 02/13/09 02:30 PM.
Joined: Oct 2008
Posts: 3
M
Forum Member
OP Offline
Forum Member
M
Joined: Oct 2008
Posts: 3
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.

A.

Attached Images
vim_syntax.zip (1.81 KB, 634 downloads)

Moderated by  lennart, rmv 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5
(Release build 20201027)
Responsive Width:

PHP: 7.3.31-1~deb10u1 Page Time: 0.007s Queries: 29 (0.004s) Memory: 0.7559 MB (Peak: 0.8312 MB) Data Comp: Off Server Time: 2022-11-27 15:17:57 UTC
Valid HTML 5 and Valid CSS