Search code examples
vimgrepnetrw

How do I grep in vim netrw?


How do I do a grep in netrw in Vim? ctrl-p can be used in this way, is there a similar plugin for grep?

E.g., when I'm in a directory, I want a list of files containing this or that keyword.


Solution

  • Netrw does have "that feature"; see :help netrw-star. You can do for instance :Explore */filepath or more generally use one of the patterns below:

    */filepath   files in current directory which satisfy filepath
    **/filepath  files in current directory or below which satisfy the
                file pattern
    *//pattern  files in the current directory which contain the
                pattern (vimgrep is used)
    **//pattern files in the current directory or below which contain
                the pattern (vimgrep is used)
    

    Use :Pexplore and :Nexplore to go to the previous/next matching file (and @: to repeat the chosen command); hit <cr> to enter the file.