Vimgrep is a tool with Vim, which is similar to the use of grep. For example, to find word in the current directory, use the following:
If you want to recursively look up all the subordinate directories, then use the
In addition, if you want to use a shortcut to find the letter under the current cursor, you only need to add the following code to the VIMRC:
1 2 3 4 5 6 |
"The settings for the search map Ft:call search_word () <CR>:copen<CR> function Search_word () Let w = expand (" < Cword > ")" Grasp the word execute "vimgrep" at the current cursor position. W. "*" Endfunction |
The results found by Vimgrep are generated into the Quickfix, as shown in the following figure:
There are a lot of commands for Quickfix as with have said, but I tend to find I only use a small subset of them:
: Copen ' Open the Quickfix window
: CCL ' close it
: CW ' Open it if there are ' errors ', close it otherwise (Some people prefer this)
: CN "Go to" next error in the window
: cnf "Go to" the "the" the "the" the "the" NEX T file
Get Quickfix List I type Ctrl + W
You can also use:cc 2 (or no other number) to jump to, in this case, the second error in the Quickfix window. Navigating WITH:CN,: CC 4, etc would put the "cursor on" in question.