Search code examples
vimnerdtreevim-plugin

How can I do quick searching in NERDTree?


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


Solution

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