Is there a way to search for some text in a folder and to display search results in a separate buffer in Vim? (Like Sublime Text Ctrl + Shift + F
results)
No, you don't need any plugin. The default :vimgrep
(or :vim
) is all you need.
Search for foo
in every file in the current directory:
:vim foo * | cw
Search for foo
in every JavaScript file in the current directory:
:vim foo *.js | cw
Search for foo
in every JavaScript file in the current directory recursively:
:vim foo **/*.js | cw
Search for the current word in every file in the current directory:
:vim <C-r><C-w> * | cw
:vim <cword> * | cw
(edit: use :cw[indow]
instead of :copen
)
Sounds like you need ack.vim
:
This plugin is a front for the Perl module App::Ack. Ack can be used as a replacement for 99% of the uses of grep. This plugin will allow you to run ack from vim, and shows the results in a split window.
Usage:
:Ack [options] {pattern} [{directory}]
Search recursively in {directory} (which defaults to the current directory) for the {pattern}.
Files containing the search term will be listed in the split window, along with the line number of the occurrence, once for each occurrence. [Enter] on a line in this window will open the file, and place the cursor on the matching line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With