Disclaimer: I am not a native speaker, so please forgive me for a large number of mistakes on the site

Search recursively in vim/neovim without 3d party tools


Both Vim and Neovim have build-in command for searching in files called vimgrep. The main advantage of using vimgrep is that it’s available on all platforms and by using vimgrep you can freely use vim/Neovim on all platforms, including Windows.

For example, you want to search for vim string across all files in a directory. This is what you should do:

  1. :cd /path/to/directory. This command changes current directory, similar to cd command in a terminal.
  2. :vimgrep vim **/*.html. This command searches for string “vim” across all files in a current directory with “html” extension. To search across all files, use :vimgrep vim **/*
  3. :copen Open “quickfix window” with a list of matches. Now you can move through matches and open corresponding match by pressing Enter.

You can also move between matches with :cnext and :cprevious commands (even without opening a quickfix window).