2

I can figure out which script changed a vim setting the last time with

:verbose set errorformat?

However, sometimes a setting is modified/appended several times and I want to see all scripts who touched this setting not only the last one.

Right now, I am aware of following means:

  1. start vim in verbose mode with

    $ vim -V15vim.log demo.tex
    

    and then grep vim.log for the setting (in full and abbreviated form) I am interested in.

  2. Grep in vim or on the commandline the directories ~/.vim and $VIMRUNTIME.

Apparently, the event OptionSet is deactivated on startup.

Is there a more polished way similar to :verbose set efm??

Related wiki page:

1

Put vimgrep matches in files from :scriptnames into the quickfix list

Using :scriptnames allows to consider

  • only files which have actually been sourced
  • and then you can grep for the full and abbreviated option name (regex pattern)

Steps

  1. vim demo.tex or
    do whatever you need to do to get to the point where you want to find out how you ended up with the current setting.

  2. Run :Scriptnames from vim-scriptease. This populates the quickfix list with results from :scriptnames.

  3. Fill arglist from quickfixlist (Is there a better solution?)

    :argdelete * " if necessary
    :for f in map(getqflist(), {i, v -> bufname(v.bufnr)}) | exe('argadd '.f) | endfor
    
  4. Search with vimgrep all entries in arglist

    :vim /\<errorformat\>\|\<efm\>/ ##
    

Now one can cycle through likely candidates.

Step 3 and 4 can be combined and avoids to use the arglist:

:exe('vimgrep /\<errorformat\>\|\<efm\>/ '.join(map(getqflist(), {i, v -> bufname(v.bufnr)})))

However, if you want to try different regex pattern, you might find it better to keep them separated.

If you wish to see a list of files to get a first overview which script is involved, you could run

:for f in uniq(sort(map(getqflist(), {i, v -> bufname(v.bufnr)})))| echo f | endfor

In my case I get for /\<errorformat\>\|\<efm\>/:

/Users/hotschke/.vim/pack/lervag/start/vimtex/autoload/vimtex/qf/latexlog.vim
/Users/hotschke/.vim/pack/tpope/start/dispatch/autoload/dispatch.vim
/Users/hotschke/.vim/pack/tpope/start/fugitive/autoload/fugitive.vim
/Users/hotschke/.vim/pack/tpope/start/projectionist/autoload/projectionist.vim

However, this is not perfect and it would be better to have something similar for $ vim -V15vim.log. But extracting the match and the corresponding file from the log file is more complicated (mostly due to autoloaded functions).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.