[ncl-talk] [vim for ncl] sharing a short script to create ncl.dic

Packard Chan packard.chan at gmail.com
Sat Apr 22 15:04:23 MDT 2017


Hi all,

I am using vim editor for NCL, and I appreciated the tips in
https://www.ncl.ucar.edu/Applications/editor.shtml#vim. I also appreciated
that the ncl3.vim file is updated promptly after release of the new version
of NCL. However, I noticed that ncl.dic has not been updated for 4 years.

Another problem with the current ncl.dic is that some keywords are not
showing up correctly with my version of vim (7.2). For example, if I type
in "xy", then Ctrl+n, the keyword "xyCoordData" is trimmed to "xyCo" and
several words from "xyCoordDataSpec" to "xyLineDashSegLenF" are missing. I
noticed that my version of vim imposed a 510-byte limit on the maximum line
length for the dictionary file (see :help 'dictionary' in vim). I believe
this explains the problem seen in
https://www.ncl.ucar.edu/Support/talk_archives/2011/1828.html.

Now, this is my solution:

#!/bin/sh
# produce ncl3.dic from downloaded ncl3.vim

#wget http://www.ncl.ucar.edu/Applications/Files/ncl.dic
#mv -i ncl.dic ~/.vim/dictionary/
#wget http://www.ncl.ucar.edu/Applications/Files/ncl3.vim  # updated 2 days
after release of 6.4.0
#mv -i ncl3.vim ~/.vim/syntax/

sed -n '/^syn keyword nclKeyword/p' ~/.vim/syntax/ncl3.vim > dic3b.ncl
sed -n '/^syn keyword nclBoolean/p' ~/.vim/syntax/ncl3.vim >> dic3b.ncl
sed -n '/nclKeyword/d;/nclBoolean/d;/^syn keyword/p' ~/.vim/syntax/ncl3.vim
>> dic3b.ncl
sed -i 's/syn keyword [^ ]* \+\b/\n/' dic3b.ncl

t_update=`sed -n '/^" Updated/s/" Updated //p' ~/.vim/syntax/ncl3.vim`
head -n 5 ~/.vim/dictionary/ncl.dic |sed "s/\(^.* Updated:
\+\b\).*$/\1$t_update/;s/\(^.* Author: \+\b\).*$/\1Packard Chan\n\" Based
on previous version by Prince K Xavier, and ncl3.vim by Carl Schreck/" >
~/.vim/dictionary/ncl3.dic
sed '1d' dic3b.ncl |fold -w 500 -s >> ~/.vim/dictionary/ncl3.dic
rm dic3b.ncl

This script puts the dictionary file in ~/.vim/dictionary/ncl3.dic. Make
sure you update your vimrc with this new dictionary file location.

Any comments and suggestions are welcomed.

Cheers,
Packard

Packard Chan
Ph.D. candidate
Department of Earth and Planetary Sciences
Harvard University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170422/40f7bd30/attachment.html 


More information about the ncl-talk mailing list