A Vim plugin for word lookup and thesaurus functionality, powered by the Datamuse API. Look up definitions, synonyms, antonyms, related words, and more.
- Definitions - Look up word definitions, parts of speech, and syllable counts
- Synonyms - Find synonyms via WordNet
- Antonyms - Find antonyms via WordNet
- Related Words - Discover semantically related words
- Word Replacement - Replace the original word directly from the results buffer
- Chained Lookups - Look up words from within the results buffer; replacement always targets the original word
- Visual Selection Replacement - Visually select text in the results buffer to use as replacement
- Tab Completion - Full command-line tab completion via argonaut.vim
- Vim 8.0+ (for
json_decode()) - argonaut.vim
curl(for HTTP requests)- Network access to
api.datamuse.com
Lexicon depends on argonaut.vim. Make sure to install both plugins.
Vundle:
Plugin 'cwshugg/argonaut.vim'
Plugin 'cwshugg/lexicon.vim'vim-plug:
Plug 'cwshugg/argonaut.vim'
Plug 'cwshugg/lexicon.vim'minpac:
call minpac#add('cwshugg/argonaut.vim')
call minpac#add('cwshugg/lexicon.vim')Manual:
cd ~/.vim/pack/plugins/start
git clone https://github.com/cwshugg/argonaut.vim.git
git clone https://github.com/cwshugg/lexicon.vim.git:Lexicon hello " Look up the word 'hello'
:Lexicon " Look up the word under the cursor
:Lexicon --word hello " Explicit word flag
:Lexicon -h " Show help| Command | Description |
|---|---|
:Lexicon [word] |
Look up a word (or the word under the cursor) |
:Lexicon --word WORD |
Explicitly specify the word to look up |
:Lexicon --synonyms |
Show only synonyms |
:Lexicon --antonyms |
Show only antonyms |
:Lexicon --definitions |
Show only definitions |
:Lexicon --related |
Show only related words |
:Lexicon --help |
Show the help menu |
:LexiconDictionary [word] |
Show only definitions (no thesaurus data) |
:LexiconThesaurus [word] |
Show only thesaurus data (no definitions) |
Multiple filter flags can be combined:
:Lexicon --synonyms --antonyms hello
:Lexicon -s -a helloAll flags have short forms: -w, -s, -a, -d, -r, -h.
Optional short aliases :L, :LD, and :LT are available by setting
let g:lexicon_define_short_commands = 1 in your .vimrc.
All options are configured via global variables in your .vimrc:
| Variable | Default | Description |
|---|---|---|
g:lexicon_max_results |
15 |
Max results per API query (1–100; out-of-range resets to 15) |
g:lexicon_timeout |
10 |
Curl request timeout in seconds |
g:lexicon_buffer_position |
'botright' |
Split position for the results buffer |
g:lexicon_buffer_height |
15 |
Height of the results buffer (in lines) |
g:lexicon_replace_key |
'<CR>' |
Key to trigger word replacement |
g:lexicon_close_on_replace |
1 |
Close results buffer after replacement |
g:lexicon_api_url |
'https://api.datamuse.com' |
Base URL for the Datamuse API |
g:lexicon_allow_insecure |
0 |
Allow non-HTTPS API requests (blocked by default) |
g:lexicon_define_short_commands |
0 |
Define the :L, :LD, :LT short aliases |
Example:
let g:lexicon_max_results = 20
let g:lexicon_buffer_height = 20
let g:lexicon_close_on_replace = 0
let g:lexicon_define_short_commands = 1When you run :Lexicon, a temporary results buffer opens as a split showing:
- Definitions - with part-of-speech tags and syllable count
- Synonyms - words with similar meanings
- Antonyms - words with opposite meanings
- Related Words - semantically similar words
Key mappings in the results buffer:
| Key | Action |
|---|---|
<Enter> |
Replace the original word with the word under the cursor (normal) or visual selection (visual) |
q |
Close the results buffer |
<Esc> |
Close the results buffer |
Word replacement is restricted to the Synonyms, Antonyms, and Related Words sections. Definitions and other non-word-list sections are not replaceable.
Case preservation: When replacing, the new word automatically matches the casing of the original word - ALL CAPS stays ALL CAPS, lowercase stays lowercase, and Title Case stays Title Case. This ensures replacements blend naturally into your prose.
Replacement always targets the word under your cursor when the command was invoked, even if a different word was specified as the lookup argument.
Only one results buffer can be open at a time. Running :Lexicon again will
replace the existing results buffer.
You can look up words from within the results buffer. Place the cursor on a
word in the results and run :Lexicon (or :LexiconThesaurus, etc.) again.
The buffer is updated in place — no new splits are created. Replacement always
targets the original word in your source buffer, no matter how many
chained lookups you perform.
See :h lexicon-chained for details.
The results buffer defines syntax highlight groups that you can customize in
your colorscheme or .vimrc. Groups include LexiconHeader, LexiconSection,
LexiconPOS, LexiconCursorEntry, LexiconFooter, and more. The
LexiconCursorEntry group highlights the thesaurus entry under the cursor
(linked to Title by default).
For the full list of groups and examples, see :h lexicon-highlighting.
For full documentation, run:
:h lexicon- Datamuse API - the free word-finding query engine that powers all lookups (no API key required)
- argonaut.vim - provides command-line argument parsing and tab completion