geckos
geckos

Reputation: 6299

How to search at vim 'scriptnames' command

The vim 'scriptnames' command output all scripts loaded. The problem is that I can't find any practical way to filter/search/find on it. I want to look for some script without having to do this by "eye brute force".

Upvotes: 7

Views: 1016

Answers (2)

Luc Hermitte
Luc Hermitte

Reputation: 32966

Instead of :redir, we have execute() with recent versions of vim.

Thus, you can play with :echo filter(split(execute('scritnames'), "\n"), 'v:val =~ "somepattern") or :new+put=execute(':scriptnames')+search in the buffer as you would have explored a log life.

Upvotes: 1

Sato Katsura
Sato Katsura

Reputation: 3086

There is no such thing as a script command, there are only scriptencoding and scriptnames (which can be abbreviated as scr, according to :h :scr). I presume you're looking for scriptnames.

With Vim 8 you can filter the results of most commands with :filter:

:filter /pattern/ scriptnames

(cf. :h :filter).

With older versions of Vim you can redirect all messages to a file before running :scriptnames, then cancel the redirection:

:redir >file
:scriptnames
:redir END

(cf. :h :redir). Alternatively, you can redirect messages to a register, then paste the contents of the register to a buffer:

:redir @a
:scriptnames
:redir END
:new
"aP

Finally, Tim Pope's plugin scriptease adds a command :Scriptnames that runs :scriptnames and loads the results into a quickfix list.

Upvotes: 12

Related Questions