Retyping long identifiers or boilerplate text wastes time. Completion suggestions improve speed and reduce typos.
In Insert mode, Vim provides keyword completion from the current buffer and loaded files.
Completion commands in Insert mode:
| Key | Action |
|---|---|
<C-n> | Next match |
<C-p> | Previous match |
<C-x><C-l> | Line completion |
<C-x><C-f> | Filename completion |
Workflow:
- Type the start of a word
- Press
<C-n>or<C-p>to cycle through suggestions - Accept with right arrow or completion key
- Continue typing or press
<C-n>for more options
- Completion is keyword-based from open buffers
- Searches all loaded buffers, not just current
<C-n>/<C-p>cycle through matches- Works with dictionaries, thesaurus, and more via plugins
- Need at least one charactertyped before completion works
- Dictionary completion via
'dictionary'option - LSP completion is separate (see LSP wiki for language-aware)
- Language Server Protocol — Language-aware completion (vs basic word completion)
- Vim Modes — Completion in Insert mode
- Survival Commands — Insert mode basics
- Repetition — Can repeat insertions