Track your keymap usage to identify unused keymaps for cleanup.
- Neovim 0.10+
{
"username/unused.nvim",
priority = 10000, -- Load before other plugins
lazy = false,
config = true,
}Important: The priority = 10000 ensures the hook installs before other plugins define keymaps.
:Unused- Open picker showing all tracked keymaps (sorted by usage, unused first):Unused unused- Show only keymaps with zero uses:Unused reset- Reset all usage counts
<CR>- Jump to where the keymap is defined in your config
local unused = require("unused")
-- Get keymaps with zero uses
unused.get_unused()
-- Get all tracked keymaps with counts
unused.get_all()
-- Reset all counts
unused.reset_all()- Hooks
vim.keymap.setearly to capture where keymaps are defined - Uses
vim.on_keyto count keymap usage without modifying keymap behavior - Only tracks keymaps defined in your config (not plugins or defaults)
- Persists counts to
~/.local/share/nvim/unused.json
Currently tracks only user-defined keymaps (via vim.keymap.set). Plugin keymaps and Neovim defaults are not tracked in v1.