Is there a way to enable autocomplete for writing in English? For example, if I write giv, I want Vim to automatically suggest give, given, gives, giving, giveaway, etc.

In Emacs, this is easy to enable when using the company-mode package (source). How can I do this in Vim?


Yes, you can use the Ctrl+X, Ctrl+K sequence to initiate completion from keywords in a dictionary. See :help i_CTRL-X_CTRL-K for an entry point to configuring and using this feature.

Perhaps the best way to enable this feature is to enable spell checking, since Vim is able to use the spell checking dictionaries (typically shipped with the Vim runtimes) to complete keywords with the default setting. Typically all you need to do is issue a :set spell command to enable spell checking and that will unlock keyword completion with it.

An alternative is to set the 'dictionary' option to point to one or more files (such as /usr/share/dict/words on Linux and other Unix-like systems) containing lists of words to use for keyword completion.

You can also combine both options of spell checking dictionaries and word list files by including a special literal spell as part of the list of paths in the 'dictionary' setting. For example:

set dictionary=spell,/usr/share/dict/words

One more advantage of leveraging the spell checking system for dictionary keyword completion is that you have a handy way of adding new acceptable completion targets, by simply marking them as good words for the spell checking system, which you can easily do with the zg command.

  • Is there any way to enable as-you-type autocomplete without having to press CTRL-X CTRL-K every single time?
    – Flux
    Apr 19 '20 at 3:35
  • 1
    @Flux You will need a plug-in for as-you-type completion. YouCompleteMe is one such plug-in that does as-you-type completion, but unfortunately it doesn't support completion from a dictionary. You might want to look into SuperTab. While it doesn't trigger completion menu automatically, it definitely improves the completion interface...
    – filbranden
    Apr 19 '20 at 4:49
  • 2
    MUcomplete does the job github.com/lifepillar/vim-mucomplete
    – Tae
    Apr 19 '20 at 7:21
  • 1
    For word lists sorted by word frequency for use by Vim's dictionary completion: github.com/Konfekt/complete-common-words.vim
    – Flux
    Mar 4 at 16:01

You could use https://github.com/cwfoo/vim-text-omnicomplete. It is an omnicomplete plugin for English words, and it is automatically enabled in text files (*.txt, README). Advantages over Vim's dictionary completion:

  • It orders its suggestions by word frequency. More common words would be suggested before less common ones.
  • It is able to suggest matches based on the previous word. For example, if you have typed "annual", the plugin would suggest "meeting", "payroll", "report", etc. as possible candidates.

Disadvantage: if you are already using another omnicomplete plugin for the file you are editing, you probably cannot use this plugin at the same time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.