created 2003 · complexity intermediate · author Yakov Lerner · version 6.0
:scriptnames command can be used to list the scripts that Vim has loaded. This tip provides information on how to list scripts that Vim failed to load. In addition, a user command is provided to list loaded scripts in a scratch buffer which you can search and edit (convenient for use of
gf to edit scripts).
Listing loaded scripts
To see the file names of all scripts loaded (sourced) by Vim, including those loaded implicitly at startup, enter:
The list does not include "would-be scripts" (scripts that Vim tried to open but which failed without warning, perhaps because the script could not be found). To see the "would-be" scripts use the
-V option when starting Vim:
Use the following to show the system-dependent locations of configuration files (but not the location of system/personal plugins):
Listing to a scratch buffer
The following code (for your vimrc) defines the
:Scriptnames user command to list loaded scripts in a scratch buffer which you can search and edit. It is also useful to put the cursor on the name of a script, and type
gf ("goto file") to show that script.
:Scriptnames command takes an argument which is a pattern to match the names of scripts of interest. Lines which do not contain the given argument are removed from the list. For example, entering
:Scriptnames surround will list all scripts which contain "surround" in the path name of the script.
~/.vim/plugin/scriptnames.vim (Unix) or
$HOME/vimfiles/plugin/scriptnames.vim (Windows) containing the script below, then restart Vim.
" Execute 'cmd' while redirecting output. " Delete all lines that do not match regex 'filter' (if not empty). " Delete any blank lines. " Delete '<whitespace><number>:<whitespace>' from start of each line. " Display result in a scratch buffer. function! s:Filter_lines(cmd, filter) let save_more = &more set nomore redir => lines silent execute a:cmd redir END let &more = save_more new setlocal buftype=nofile bufhidden=hide noswapfile put =lines g/^\s*$/d %s/^\s*\d\+:\s*//e if !empty(a:filter) execute 'v/' . a:filter . '/d' endif 0 endfunction command! -nargs=? Scriptnames call s:Filter_lines('scriptnames', <q-args>)
The Headlights plugin (for gvim or MacVim) creates menus for installed plugins along with their files (and commands, mappings, abbreviations, etc).