Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search at vim 'scriptnames' command

Tags:

vim

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".

like image 267
geckos Avatar asked Dec 10 '16 13:12

geckos


People also ask

How do I search and edit a specific line in Vim?

You can search/edit here using regular vim commands. You start in Normal mode. Press Enter to execute a command. This approach lets you search across whole command not just beginning of line. Enter the first letters of your previous command and push <Up> arrow (or Ctrl+p).

How can I see the file names of all VIM 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).

How do I search forward in vim/vi?

To search forward, use the command: Replace pattern with the item (s) you want to find. For example, to search for all instances of the pattern "root", you would: 1. Press Esc to make sure Vim/Vi is in normal mode. 2. Type the command:

How do I search for a specific character in vimrc?

Searching for all characters as normal text Place the following in your vimrc : command! -nargs=1 SS let @/ = '\V'.escape (<q-args>, '\') to define a new command SS which allows easy searching for text which includes characters that normally have a special meaning in a search pattern.


2 Answers

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.

like image 133
Sato Katsura Avatar answered Oct 20 '22 22:10

Sato Katsura


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.

like image 32
Luc Hermitte Avatar answered Oct 20 '22 22:10

Luc Hermitte