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

How do I navigate between diagnostics with filtering by severity in Neovim 0.10+?

Answer

vim.diagnostic.jump()

Explanation

Neovim 0.10 introduced vim.diagnostic.jump(), a unified replacement for the older goto_next() / goto_prev() pair. It accepts a count argument for direction, supports severity filtering, and can show a floating diagnostic window on arrival — all in one call.

How it works

vim.diagnostic.jump({count, severity, float, ...}):

  • count = 1 — jump to the next diagnostic; count = -1 for the previous one
  • severity — limit to a specific severity level (e.g., vim.diagnostic.severity.ERROR)
  • float = true — automatically open a floating window showing the diagnostic after jumping
  • wrap = false — stop at the first/last diagnostic instead of wrapping around

Example: Severity-aware navigation mappings

-- Navigate any diagnostic
vim.keymap.set('n', ']d', function()
  vim.diagnostic.jump({ count = 1, float = true })
end)
vim.keymap.set('n', '[d', function()
  vim.diagnostic.jump({ count = -1, float = true })
end)

-- Navigate errors only
vim.keymap.set('n', ']e', function()
  vim.diagnostic.jump({
    count = 1,
    severity = vim.diagnostic.severity.ERROR,
    float = true,
  })
end)
vim.keymap.set('n', '[e', function()
  vim.diagnostic.jump({
    count = -1,
    severity = vim.diagnostic.severity.ERROR,
    float = true,
  })
end)

Tips

  • Prefer vim.diagnostic.jump() over the deprecated goto_next()/goto_prev() in new configs
  • Use vim.diagnostic.severity.WARN to skip errors and jump only to warnings
  • Combine with vim.diagnostic.open_float() if you want a separate mapping to inspect the diagnostic under the cursor
  • Check your Neovim version with :lua print(vim.version().minor)vim.diagnostic.jump() requires 0.10+

Next

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