Biological/Medical Dictionary in Vim

Creating Medical and Chemical Dictionaries for Vim

So, it’s come to the point in my Ph.D where I need to spell check. The problem is that a large number of the technical words I use aren’t in the default dictionary now provided by vim.

Time to add some!

This is actually quite easy to do, originally I tried compiling dictionaries as vim .spl files but this proved less simple thanj I had hoped. In the end I found a simple way of doing this using vim’s .add files.

Note: This assumes you’re using some form of English dictionary as base. Vim uses language (ignoring location) when loading the files so replace “en” with your language’s abbreviation.

In the ~/.vim/spell/ folder, any words you add to your dictionary using the “zg" command in vim get added to a file here called en.utf-8.add. I’ve simply added any extra words I wanted in my dictionary a .add file in this folder.

Firstly grab the medical dictionary for open office from here (chemical dictionary here) and extract the contents using your archive manager of choice. You specifically need the .aff and .dic files for vim to compile them into a dictionary.

Once you’ve got both of these it’s a simple command to combine them all into one new file:

cd ~/.vim/spell/
mv en.utf-8.add en.utf-8.temp
cat ~/.vim/spell/en.utf-8.temp ~/path/en_US_OpenMedSpel.dic ~/path/ChemDictOOo.dic > ~/.vim/spell/en.utf-8.add

Lastly, you need to compile the en.utf-8.add file into the en.utf-8.add.spl file that vim will load. Load up vim and run…

:mkspell! en.utf-8.add

Test you got this right by opening your en.utf-8.add file and turning spell on (:set spell). Hopefully none of the words should be glowing red!

 

Edit: Thanks to MarshaG63 for pointing out some errors I had.

Advertisements
    • MarshaG63
    • October 3rd, 2013

    I tried the above commands and in the mv command you need “~/.vim>.” I only need the openmedpsell words and left the chemdoc part off, but when I tried to mkspell the file “en.utf-8.add” was not found.
    Any idea what I need to do?

    MDG

    • Joe
    • October 3rd, 2013

    Aha, right, looks like I wasn’t paying enough attention when I wrote this. You need to do:

    :mkspell technical.utf-8.add

    …or whatever you named the file at the end of the cat command.

    Hope that helps.

    (I’ve fixed the cat command so it now outputs back to en.utf8.add and fixed the mv line. Thanks for pointing those out!)

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: