Here's a simple syntax highlighting style for SMILES files. It supports three different colours for comments, the SMILES itself, and titles. If anyone has the necessary regexp-fu, it might be worth looking into highlighting different bracket levels in the SMILES string.
To use, save this file into vimfiles/syntax/smi.vim, and then use "set filetype=smi" to turn on the highlighting. To automatically do this for *.smi files, create a file vimfiles/ftdetect/smi.vim containing the line "autocmd BufRead,BufNewFile *.smi set filetype=smi".
I also looked into doing folding for such files, that is, to use any comment as a header and then fold the subsequent SMILES. This is a format I use for storing matched series, for example. It works (see foldexpr), but it's too slow for a large file, which defeats the purpose.
" Vim syntax file " Language: SMILES strings " Maintainer: Noel O'Boyle " Latest Revision: 16 June 2016 if exists("b:current_syntax") finish endif syn match smiTitle /\v\s+.*$/hs=s+1 syn match smiString "\v^\S*" nextgroup=smiTitle skipwhite syn match smiComment "\v^#.*$" let b:current_syntax = "smi" hi def link smiComment Comment hi def link smiString Identifier hi def link smiTitle Include
* As the Vim documentation says, apparently it's actually lexical highlighting, but everyone calls it syntax highlighting so...
Along these lines, I have some old (but still working!) vim syntax files for NWCHEM, Gaussian .com and PDB: https://gist.github.com/jarvist/2818256
ReplyDeleteNice. And I see that someone has taken your Gaussian syntax file and done some extra tweaks. http://www.chem.wilkes.edu/~trujillo/Scripts/vim/
ReplyDeleteThat's wonderful, always a fuzzy warm feeling when something you've made has been built on. Even if was originally just a horribly hacked together vim syntax file! Thanks for bringing it to my attention Noel.
ReplyDeleteWould be nice to implement in Notepad++ too!
ReplyDelete