1VGREP(1)(vgrep)                                                VGREP(1)(vgrep)
2
3
4

NAME

6       vgrep -- a user-friendly pager for grep
7
8

SYNOPSIS

10       vgrep [OPTION...] PATTERNS [FILE...]
11
12
13       vgrep [OPTION...] -s [COMMAND][context] [SELECTORS]
14
15

DESCRIPTION

17       vgrep is a pager for grep, git-grep, ripgrep and similar grep implemen‐
18       tations, and allows for opening the indexed file locations in  a  user-
19       specified editor such as vim or emacs.
20
21
22       vgrep  is  inspired by the ancient cgvg scripts but extended to perform
23       further operations such as listing statistics of  files  and  directory
24       trees or showing the context lines before and after the matches.
25
26
27       vgrep runs on Linux, Windows and Mac OS.
28
29
30       Note:  vgrep is used to perform textual searches. On a technical level,
31       vgrep serves as a front-end to grep or git-grep when invoking vgrep in‐
32       side a git tree and uses less for displaying the results. All non-vgrep
33       flags and arguments will be passed down to grep. Results  of  the  last
34       search  are cached, so running vgrep without a new query will load pre‐
35       vious results and operate on them.
36
37
38       By default, the output will be written to less to make  browsing  large
39       amounts of data more comfortable. vgrep --no-less will write to stdout.
40
41

Opening Matches

43       vgrep can open the indexed file locations in an editor specified by the
44       EDITOR environment variable. Opening one of the file locations from the
45       previous example may look as follows:
46
47
48              # export EDITOR=gedit
49              # vgrep --show 4
50
51
52
53       The default editor of vgrep is vim with the default flag to open a file
54       at a specific line being + followed by the line number. If your  editor
55       of choice hits the rare case of a different syntax, use the EDITORLINE‐
56       FLAG environment variable to adjust. For example, a kate user  may  set
57       the environment to EDITOR="kate" and EDITORLINEFLAG="-l".
58
59
60       Note  that  vgrep does not allow for searching and opening files at the
61       same time. For instance, vgrep --show=files text should be split in two
62       commands: vgrep text and vgrep --show=files.
63
64
65   IDE Support
66       Note  that  if you run vgrep inside a terminal of VSCode or Goland, the
67       format of listed files changes to "$PATH:$LINE" to  allow  for  opening
68       the matches in the editor via a simple mouse click.
69
70

Interactive Shell

72       Once vgreped, you can perform certain operations on the results such as
73       limiting the range of indexed matches, listing matching files  and  di‐
74       rectories and more.
75
76
77       Enter  a  vgrep  command: ?  vgrep command help: command[context lines]
78       [selectors]
79                selectors: '3' (single), '1,2,6' (multi), '1-8' (range), 'all'
80                 commands: print, show, context, tree, delete,  keep,  refine,
81       files, grep, quit, ?
82
83
84       vgrep  commands  can  be passed directly to the --show/-s flag, for in‐
85       stance as --show c5 1-10 to show the five context lines  of  the  first
86       ten  matched lines. Furthermore, the commands can be executed in an in‐
87       teractive shell via the --interactive/-i flag. Running vgrep --interac‐
88       tive  will  enter the shell directly, vgrep --show 1 --interactive will
89       first open the first matched line in the editor and enter the  interac‐
90       tive shell after.
91
92

COMMANDS

94print,p  -  Limit  the range of matched lines to be printed. p
95                1-12,20 prints the first 12 lines and the 20th line.
96
97show,s - Open the selectors in an user-specified  editor  (re‐
98                quires selectors).
99
100context,c  -  Print  the  context  lines  before and after the
101                matched lines. c10 3-9 prints 10 context lines of the matching
102                lines  3  to  9.  Unless specified, vgrep will print 5 context
103                lines.
104
105tree,t - Print the number of matches for each directory in the
106                tree.
107
108delete,d  - Remove lines at selected indices from the results,
109                for the duration of the  interactive  shell  (requires  selec‐
110                tors).
111
112keep,k - Keep only lines at selected indices from the results,
113                for the duration of the  interactive  shell  (requires  selec‐
114                tors).
115
116refine,r  -  Keep only lines matching the provided regexp pat‐
117                tern from the results, for the  duration  of  the  interactive
118                shell (requires a regexp string).
119
120files,f  -  Print  the  number of matches for each file in the
121                tree.
122
123grep,g - Start a new search without  leaving  the  interactive
124                shell  (requires arguments for a vgrep search). For example, g
125                -i "foo bar" dir/ will trigger a case-insensitive  search  for
126                foo bar in the files under dir. The cache will be updated with
127                the results from the new search.
128
129quit,q - Exit the interactive shell.
130
131? - Show the help for vgrep commands.
132
133
134

Examples

136       Print the number of matches for earch directory in the tree:
137
138
139              $ vgrep -stree
140              Matches Directory
141                37690
142                  876 .
143                   21 docs
144                    5 hack
145                   88 internal
146                   15 internal/ansi
147                   73 internal/colwriter
148                   76 test
149                    3 test/search_files
150                37500 vendor
151
152
153
154       Show one context line before and after each match:
155
156
157              $ vgrep -sc1
158              --- 0 .cirrus.yml ------------------------------------------------
159              5   GOPROXY: https://proxy.golang.org
160              6   CODECOV_TOKEN: ENCRYPTED[64481ea00b08c4703bf350a2ad3d5a6fd7a00269576784b2943cce62604798e88f532e19fb66859fa68f43dbd4a0df15]
161              7
162              --- 1 .goreleaser.yml ---------------------------------------------
163              1 before:
164              2   hooks:
165              --- 2 .goreleaser.yml ---------------------------------------------
166              15     amd64: x86_64
167              16   format: binary
168              17 checksum:
169
170
171
172
173pages                                 man                      VGREP(1)(vgrep)
Impressum