Archived post: posted sometime between 2016 and 2022.

Vim: Find in Files, The Basics

Find in files is also known as find all and as multi-file search: it searches across multiple files.

First , open vim at the current directory (or at a specific file).

C:\temp> vim .     

Second , run vimgrep to find the word "foobar" within all files.

:vimgrep /foobar/ **/*

That vim command will do the following:

  1. find all the files that contain the word "foobar"
  2. add those files to the quickfix list
  3. jump to the first instance of the word "foobar"

Third , open the quickfix list to view the files.

:copen

Fourth , within the quickfix list, use the j k keys to select a file, then press enter to open it.

Finally , close the quickfix list.

:cclose

That's enough to get started.