Skip to main content
  1. Posts/

English Words Completion inside Neovim/Vim

··250 words·2 mins·
Nvim Vim
Table of Contents

Some words are hard to type, it is handy if Neovim can provide auto-completion for the words we are typing. We can achieve word completion in Neovim in two ways.

Native method
#

The first method is to use a dictionary file. The dictionary file is a text file which contains plain English words, usually one word a line. In the Neovim config file, add the following settings for dictionary option:

if has('unix')
    set dictionary+=/usr/share/dict/words
else
    set dictionary+=~/AppData/Local/nvim/words
endif

For Linux systems, the dictionary file is usually /usr/share/dict/words. For Windows, there is no dictionary file. But you can copy the Linux dict file and place it under ~/AppData/Local/nvim/.

Then start editing a file, type the first several characters of a word, then press , the completion items will be shown on a completion menu. Typing <CTRL-X><CTRL-K> is cumbersome. You can add the following setting to complete option:

set complete+=k

Now, in insert mode, you can press <CTRL-N> to start auto-completion and move selection to next word in the completion menu, while pressing <CTRL-P> will move the selection to the previous word.

Use deoplete for completion
#

The second method is to install deoplete-spell. If you have installed deoplete, the only setting you need is :set spell. Then you should be able to see the autocompletion menu when you start typing characters.

There is also a plugin called neco-look which uses the look command on Linux system to provide auto-completion. But it does not work natively on Windows.

References
#

Related

Sort lines based on a column in Vim/Nvim
··231 words·2 mins
Nvim Sorting Vim
A Beginner's Guide on Creating Your Own Text Objects from Scratch in Neovim/Vim
··1234 words·6 mins
Nvim Text-Object Vim
How to Insert Unicode Characters in Neovim/Vim
··697 words·4 mins
Nvim Unicode Vim