Skip to content

Commit 240cf2a

Browse files
ttaylorrgitster
authored andcommitted
contrib/git-jump/git-jump: jump to exact location
Take advantage of 'git-grep(1)''s new option, '--column' in order to teach Peff's 'git-jump' script how to jump to the correct column for any given match. 'git-grep(1)''s output is in the correct format for Vim's jump list, so no additional cleanup is necessary. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6653fec commit 240cf2a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

contrib/git-jump/README

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ git-jump will feed this to the editor:
2525
foo.c:2: printf("hello word!\n");
2626
-----------------------------------
2727

28+
Or, when running 'git jump grep', column numbers will also be emitted,
29+
e.g. `git jump grep "hello"` would return:
30+
31+
-----------------------------------
32+
foo.c:2:9: printf("hello word!\n");
33+
-----------------------------------
34+
2835
Obviously this trivial case isn't that interesting; you could just open
2936
`foo.c` yourself. But when you have many changes scattered across a
3037
project, you can use the editor's support to "jump" from point to point.
@@ -35,7 +42,8 @@ Git-jump can generate four types of interesting lists:
3542

3643
2. The beginning of any merge conflict markers.
3744

38-
3. Any grep matches.
45+
3. Any grep matches, including the column of the first match on a
46+
line.
3947

4048
4. Any whitespace errors detected by `git diff --check`.
4149

@@ -82,7 +90,7 @@ which does something similar to `git jump grep`. However, it is limited
8290
to positioning the cursor to the correct line in only the first file,
8391
leaving you to locate subsequent hits in that file or other files using
8492
the editor or pager. By contrast, git-jump provides the editor with a
85-
complete list of files and line numbers for each match.
93+
complete list of files, lines, and a column number for each match.
8694

8795

8896
Limitations

contrib/git-jump/git-jump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mode_merge() {
5252
# editor shows them to us in the status bar.
5353
mode_grep() {
5454
cmd=$(git config jump.grepCmd)
55-
test -n "$cmd" || cmd="git grep -n"
55+
test -n "$cmd" || cmd="git grep -n --column"
5656
$cmd "$@" |
5757
perl -pe '
5858
s/[ \t]+/ /g;

0 commit comments

Comments
 (0)