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

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

Answer

:verbose set {option}?

Explanation

:verbose set {option}? shows the current value of an option and reports exactly which file set it last — the full path and line number. This is the definitive debugging tool when an option behaves unexpectedly and you cannot find where it is being changed.

How it works

  • :set {option}? prints the current value of {option} (the ? suffix queries without changing)
  • :verbose prefix adds provenance information: the file path and line number of the last set call
  • Works for any option: boolean, string, or number
  • :verbose setlocal {option}? checks the buffer-local value
  • :verbose setglobal {option}? checks the global value

Example

Your tabstop seems wrong in some files. Run:

:verbose set tabstop?

Output:

tabstop=2
      Last set from ~/.vim/ftplugin/javascript.vim line 3

Now you know exactly which file is overriding your vimrc setting.

Tips

  • Use :verbose map {key} to find where a key mapping was defined — same provenance approach for mappings
  • :verbose autocmd {event} lists all autocmds for an event with their source files
  • For a full diagnostic overview, :scriptnames lists every script file loaded in the current session in load order
  • :set all displays the current value of every option at once — useful for a broad audit before targeting :verbose set

Next

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