How do I see where a normal-mode mapping was last defined in Vim?
Answer
:verbose nmap <lhs>
Explanation
When key behavior is inconsistent, the root cause is usually mapping precedence. :verbose nmap <lhs> shows the active normal-mode mapping and, crucially, the script and line that last set it. This is the fastest way to debug collisions between your config, plugin defaults, and plugin lazy-loading order.
How it works
:verboseasks Vim to include provenance metadata in command outputnmaplimits the query to normal-mode mappings<lhs>is the key sequence you are investigating (for example<leader>fforK)- The result includes
Last set from ..., which points to the file and line you need to edit
Example
Suppose K unexpectedly opens plugin docs instead of :help:
:verbose nmap K
Output might include:
n K * <Cmd>lua require('plugin').hover()<CR>
Last set from ~/.config/nvim/after/plugin/lsp.lua line 42
Now you know exactly which file overrode the mapping.
Tips
- Use
:verbose imap <lhs>or:verbose xmap <lhs>for other modes - If no mapping exists, Vim says so, which confirms you are hitting a built-in motion or command