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

How do I find out which file or plugin last changed a Vim option?

Answer

:verbose set {option}?

Explanation

Prefix any :set {option}? query with :verbose to see not only the current value of an option, but also the exact file path and line number where it was last modified. This is invaluable for debugging unexpected behaviour caused by plugins or ftplugin files overriding your settings.

How it works

  • :set {option}? prints the current value of the option
  • Prepending :verbose causes Vim to also print the source location (script path and line number) of the most recent assignment
  • If the option was set interactively (e.g. from the command line or vimrc without a script context), Vim reports Last set from command line or similar

Example

You notice 'expandtab' is unexpectedly on. Run:

:verbose set expandtab?

Output might be:

  expandtab
      Last set from ~/.vim/ftplugin/python.vim line 3

Now you know exactly which file to edit.

Also works for mappings:

:verbose nmap <leader>f

Tips

  • Works with any option: 'tabstop', 'filetype', 'foldmethod', etc.
  • Combine with :scriptnames to see all sourced scripts and find unfamiliar paths
  • In Neovim, :verbose set {option}? output is the same; use :checkhealth for broader diagnostics
  • You can abbreviate: :verb set et?

Next

How do I run a substitution across multiple files using Vim's argument list?