Vim’s autocomplete functionality is triggered from
Insert mode.
Trigger Autocompletion
Vim’s autocompletion can be triggered from Insert mode with the and
chords, which select the previous and next items in the word list,
respectively.
The and commands both invoke generic keyword autocompletion.
There are several variant forms of autocompletion, all of which are prefixed
with the chord.
Command Type of Completion
Generic keywords
Current buffer keywords
Included file keywords
<C-]> tags file keywords
Dictionary lookup
Whole line completion
Filename completion
Omni-completion
We can end autocompletion by pressing ,
which dismisses the pop-up menu and restores the
text in front of the cursor to the partial word
that was typed before autocomplete was invoked.
Refine the word list as you type
Try pressing . That’s two separate commands: followed
immediately by (although would work just as well). The first
command invokes autocomplete, summons the pop-up menu, and selects
the first item in the word list. The second command selects the previous item
in the word list, taking us back to where we started but without dismissing
the pop-up menu. Now we can continue to type, and Vim will filter the word
list in real time.
This trick works just as well with the other variants of autocompletion. For
example, we could type to perform live filtering on omni auto-
completion, or to do the same with filename completion.
Understand the source of keywords
Generic keyword autocompletion compiles its word list from a handful of sources.
We can be more specific about which sources we want to use to build a word
list.