Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do quick searching in NERDTree?

Is it possible to do searching in NERDTree window by the filenames and file content?

like image 533
yurko Avatar asked Nov 10 '12 10:11

yurko


People also ask

How do I switch between NERDTree tabs?

Ctrl + → arrow will switch to tab that is on the right of current tab.

How do I invoke NERDTree?

If you want to use NERDTree, you can open NERDTree (type :NERDTree ), navigate to your file, and then press t with cursor on the file name. This will open specific file in new tab. Also, while in NERDTree , you can hit ? . That will show you it's internal help with list of available commands.


2 Answers

You can do /foo like in any other normal Vim window but you are limited to the text currently displayed in NERDTree: you cannot search non-expanded subdirectories or non-listed files.

Assuming you are at the root of your project, you can do the following to search the word foo in JavaScript files across your project:

:vim foo **/*.js | copen 

Or the following if the "working directory" (:pwd) is not the root of your project:

:vim foo /path/to/project/**/* | copen 

Note the ** (:help starstar) that makes the search recursive.

If you want to open app/views/foobar.php for editing, you can do:

:e **/foo<tab> 

Well, there are many ways.

Accessing files/buffers or searching across a project are relatively straightforward with native commands but there are quite a lot of third party plugins to make it even faster and easier. Ctrl+P is my favorite file/buffer finder plugin but you should get comfortable with the basics before turning to plugins.

like image 150
romainl Avatar answered Sep 28 '22 03:09

romainl


Command-t in one of my favorite vim plugins, it's ruby based plugin above integration with FZF.

By using Comamnd-T and FZF you can do the search with an extremely fast "fuzzy" mechanism for:

  • Opening files and buffers
  • Jumping to tags and help
  • Running commands, or previous searches and commands
  • with a minimal number of keystrokes.

As you can see

enter image description here

I always search in command history by opening a new terminal and hit:

CTRL+R 

In addition to searching in all folders recursively by writing in any terminal tab:

fzf 

Also, you can write inside vim

:CommandT  

But Still, I am looking for a powerful vim plugin to search inside files content. especially in large folders. if I found one I will update this answer.

like image 25
HMagdy Avatar answered Sep 28 '22 03:09

HMagdy