1

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?

1

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.

| improve this answer | |
  • Is there any way to enable as-you-type autocomplete without having to press CTRL-X CTRL-K every single time? – Flux Apr 19 at 3:35
  • @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 at 4:49
  • 2
    MUcomplete does the job github.com/lifepillar/vim-mucomplete – Tae Apr 19 at 7:21

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.