Lookup
Most of my writing inside the browser is done with the combination of the It’s All Text extension and Vim. During this writing, I use words whose meaning I know vaguely but don’t know the exact usage, and in such cases, I usually open a new browser window and look up the meaning of the word in an online dictionary. This process of looking up the dictionary meaning was getting rather tedious, so I wrote a small Vim plugin today to do this job with a simple command.
To use the plugin, first install
BeautifulSoup. Then, get my
lookup.vim script and
copy it to . See the new version’s installation instructions, it now uses John Goerzen’s dict client implementation in Python.~/.vim/plugin/.
Next time you use Vim, just place your cursor over any word and run :Lookup,
and you’ll see something like this:
Since, this is the only command starting with L on my Vim installation, I just
end up running :L. Of course, you can always create your own keyboard
shortcuts to make it easier.
Update: Based on the comments, I’ve updated the script to now use the DICT protocol and talks to some servers. This avoids screen-scraping, is much faster to use, allows me to now use both a dictionary and a thesaurus which is very very handy because I can see what other words I can use, and of course, doesn’t violate any TOS (which screen-scraping could amount to).



August 26th, 2007 at 5:59 am
By using wordnet, you can obviate internet connection and html scraping, http://nearfar.org/code/greclusters/dict.py
August 26th, 2007 at 7:54 am
Good one, trying it out.
August 26th, 2007 at 5:39 pm
And, if your client is *nix, you can ignore wordnet and all and simply use dict at the command line. In vim:
function! LookupDictionary() let theword = expand(“”) exec ‘:!dict ‘ . theword endfunction
” Look up a word using dict nnoremap :call LookupDictionary() inoremap :call LookupDictionary()
August 27th, 2007 at 1:16 am
[...] Swaroop C H, The Dreamer » Python: Lookup [...]
August 27th, 2007 at 1:01 pm
Cool. I will love to write similar plugin for GujaratiLexicon.com.
August 28th, 2007 at 10:46 am
This comment has just been written with “It’s All Text” and gvim, thanks for mentioning the former.
August 28th, 2007 at 8:23 pm
@Sridhar: Thanks, didn’t know about that.
@Michael: Nice idea, although I tend to be on Windows too. Perhaps, there are binaries for dict on gnuwin32.sf.net
@Kartik: Should be easy
@Abhijit, @Chris: Enjoy!
October 24th, 2007 at 1:03 am
Hi, I’ve just donwloaded your cool plugin, but I was unable to lookup words. Then I found out that the server indicated in the code is currently not working, so I have edited it to dict.org, and I also had to change moby-thesaurus to moby-thes, this way (I hope BBCode is on):
output += "\n".join([d.getdefstr() for d in conn.define('wn', word)]) # WordNet output += "\n\n" output += "\n".join([d.getdefstr() for d in conn.define('moby-thes', word)]) # Moby Thesaurus
It would be nice if you could update the plugin on the Vim website
October 24th, 2007 at 3:55 pm
@finferflu : Thanks for pointing that out, and I’ve updated the plugin on the vim website
October 24th, 2007 at 5:58 pm
Cool, thank you for your work