How do I restrict keyword completion to current buffer, windows, buffers, and tags for predictable results?
Answer
:set complete=.,w,b,t
Explanation
Default keyword completion can feel noisy in large projects because Vim may scan extra sources you do not care about in the moment. The complete option controls exactly where <C-n> and <C-p> pull candidates from. Tightening it to open-text sources plus tags gives faster, more relevant completion with less random vocabulary bleed.
How it works
.searches the current bufferwincludes buffers visible in other windowsbincludes loaded bufferstadds tag-based completion from your tags files
By explicitly setting complete=.,w,b,t, you exclude slower or noisier sources (like include-file scanning or unloaded buffers), which keeps completion deterministic during refactors and large multi-file sessions.
Example
Project contains many generated files and vendor code.
Default completion offers irrelevant identifiers.
Apply:
:set complete=.,w,b,t
Now <C-n> prioritizes terms from currently active editing context and tags, reducing accidental completions from distant files.
Tips
- Add
uif you also want unloaded buffers searched - Temporarily inspect current value with
:set complete? - Pair with
:set wildmenuand tag generation for stronger symbol completion workflows