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

How do I find out which script or plugin defined a specific mapping or setting?

Answer

:verbose map <key> or :verbose set option?

Explanation

The :verbose prefix shows where a mapping, setting, command, or function was defined — which file and line number. This is invaluable for debugging configuration conflicts and understanding what your plugins are doing.

Trace mappings

:verbose nmap <leader>w
" Output: n  <leader>w    :w<CR>
"         Last set from ~/.vimrc line 42

:verbose imap <C-n>
" Shows which plugin or config defined <C-n> in insert mode

Trace settings

:verbose set tabstop?
" Output: tabstop=4
"         Last set from ~/.vim/after/ftplugin/go.vim line 3

:verbose set formatoptions?
" Shows which file last changed formatoptions

Trace commands and functions

:verbose command MyCommand
" Shows where :MyCommand was defined

:verbose function MyFunc
" Shows where the function was defined

Trace highlights

:verbose highlight Normal
" Shows where the Normal highlight group was last set

Debugging with verbose level

" Set verbose level to see autocommand execution
:set verbose=9

" Log all verbose output to a file
:set verbosefile=~/vim_debug.log

Tips

  • :verbose works with map, set, command, function, highlight, autocmd
  • Use :verbose map (no arguments) to list ALL mappings with their source files
  • This is the #1 debugging tool when a mapping doesn't work as expected
  • :scriptnames lists all sourced scripts in order — useful for understanding load order
  • When a plugin overrides your mapping, :verbose nmap <key> reveals the culprit immediately
  • Documented under :help :verbose

Next

How do I run the same command across all windows, buffers, or tabs?