[lammps-users] Vim syntax

Hi Steve and lammps-users,

I've attached a modified Vim syntax highlighting file for lammps scripts (the current one is located at tools/vim/lammps.vim). I added some more keywords, including the new "elif" from the 19 Nov patch and the "nthreads" keyword from Axel's lammps-icms. It also includes the underscore in variable names between braces (e.g. "${variable_name}").

lammps.vim (2.36 KB)

Thanks - I'll update the distribution.

Steve

Just posted a 25Nov10 patch with these upgrades.

Thanks,
Steve

Pretty nice, except for some reason, I lose all syntax highlighting (except comment lines are blue) if any line is a comment line (starts with #).

Aidan

aidan,

what version of vim do you have?

the attached version incorporates sam's changes
and a few more from me. it works fine with vim 7.3.29

but for that the install instructions have to be a bit different:

mkdir -p ~/.vim/syntax
cp lammps.vim ~/.vim/syntax/lammps.vim

create/edit ~/.vim/filetype.vim to contain

" vim syntax highlight customizations
if exists("did_load_filetypes")
  finish
endif

augroup filetypedetect
  au! BufRead,BufNewFile *.pdb setfiletype none
  au! BufRead,BufNewFile *.psf setfiletype none

  au! BufRead,BufNewFile *.cu setfiletype c
  au! BufRead,BufNewFile in.* setfiletype lammps
augroup END

cheers,
    axel.

lammps.vim (2.56 KB)

I have 7.2 and your method works. Thanks!

Just checked it in both instructions. They should both handle in.* and *.lmp.

Since I am not really a vi person, I created an emacs lisp file (attached) to do similar syntax highlighting in emacs. It will be in tools/emacs shortly. Just insert or load it into your emacs init file. If anyone wants to take a stab at improving my attempts to define regexp variables, feel free.

lammps.el (4.86 KB)