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

How do I find out which file or plugin defined a particular key mapping?

Answer

:verbose map {key}

Explanation

:verbose map {key} shows the definition of a mapping and the file where it was last set. This is essential for debugging unexpected key behavior — when a key does something you did not expect, :verbose map tells you exactly which plugin or config file is responsible.

How it works

:verbose nmap <C-p>

Output:

n  <C-p>         :Files<CR>
        Last set from ~/.vim/plugged/fzf.vim/plugin/fzf.vim line 42

Now you know <C-p> was mapped by fzf.vim.

Variants by mode

Command Shows mappings for
:verbose map {key} Normal + Visual + Operator-pending
:verbose nmap {key} Normal mode only
:verbose imap {key} Insert mode only
:verbose vmap {key} Visual + Select mode
:verbose map ALL mappings (no key = list all)

Example debugging workflow

  1. Press a key and get unexpected behavior
  2. :verbose nmap <key> to see what it is mapped to and where
  3. Go to the source file to understand or change it
  4. Or override it in your ~/.vimrc (loaded last, so it wins)

Tips

  • :verbose set {option}? works too — shows where an option was last set (covered in another trick)
  • :verbose prefix works with :command, :autocmd, :highlight, and :function as well
  • :map without :verbose shows the mapping but not its source file
  • Use :filter /pattern/ map to search mappings by pattern: :filter /fzf/ map shows all fzf-related mappings

Next

How do I run a search and replace only within a visually selected region?