October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 110 | Customize the grep Program |
Vim’s :grep command is a wrapper for the external grep program. We can customize the way that Vim delegates this task by manipulating two settings: ‘grepprg’ and ‘grepformat’. First we’ll examine the defaults, and then we’ll see how tweaking them allows us to outsource the search task to any other suitable program.
The ‘grepprg’ setting specifies what to run in the shell when Vim’s :grep command is executed ('grepprg'ⓘ). The ‘grepformat’ setting tells Vim how to parse the output returned by the :grep command (see 'grepformat'ⓘ). On Unix systems, the defaults are these:
| | grepprg="grep -n $* /dev/null" |
| | grepformat="%f:%l:%m,%f:%l%m,%f %l%m" |
The $* symbol used in the ‘grepprg’ ...