vimtricks.wiki Concise Vim tricks, one at a time.

How do I enable fuzzy matching for insert mode completion in Neovim 0.11?

Answer

set completeopt+=fuzzy

Explanation

Neovim 0.11 added fuzzy as a valid value for completeopt, enabling fuzzy matching in the insert-mode completion popup (<C-n> / <C-p>). Instead of requiring a prefix match, Vim now ranks completion candidates by how closely they match the typed characters anywhere in the string — like the fuzzy matching you would expect from a plugin.

How it works

Add fuzzy to your completeopt settings:

set completeopt=menu,menuone,noselect,fuzzy

Or in Lua:

vim.opt.completeopt = { 'menu', 'menuone', 'noselect', 'fuzzy' }
  • Without fuzzy: typing fob only matches completions starting with fob
  • With fuzzy: typing fob matches fooBar, findObjByName, etc.
  • Candidates are ranked by fuzzy score, not just alphabetically
  • Works with all native completion sources: buffer words (<C-n>), LSP (via vim.lsp.completion.enable()), file paths (<C-x><C-f>), and more

Example

With completeopt+=fuzzy active, start typing in insert mode:

local M = {}
function M.setup() end
function M.teardown() end

Typing <C-n> after td would fuzzy-match and surface teardown even though it does not start with td.

Tips

  • Requires Neovim 0.11 or later; does nothing in older versions
  • Pairs well with vim.lsp.completion.enable() (also Neovim 0.11) for a fully plugin-free LSP completion experience
  • Use :set completeopt? to inspect current value

Next

What is the difference between the inner word (iw) and inner WORD (iW) text objects in Vim?