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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6653fec3bb
commit
240cf2a257
@ -25,6 +25,13 @@ git-jump will feed this to the editor:
|
|||||||
foo.c:2: printf("hello word!\n");
|
foo.c:2: printf("hello word!\n");
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
Or, when running 'git jump grep', column numbers will also be emitted,
|
||||||
|
e.g. `git jump grep "hello"` would return:
|
||||||
|
|
||||||
|
-----------------------------------
|
||||||
|
foo.c:2:9: printf("hello word!\n");
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
Obviously this trivial case isn't that interesting; you could just open
|
Obviously this trivial case isn't that interesting; you could just open
|
||||||
`foo.c` yourself. But when you have many changes scattered across a
|
`foo.c` yourself. But when you have many changes scattered across a
|
||||||
project, you can use the editor's support to "jump" from point to point.
|
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:
|
|||||||
|
|
||||||
2. The beginning of any merge conflict markers.
|
2. The beginning of any merge conflict markers.
|
||||||
|
|
||||||
3. Any grep matches.
|
3. Any grep matches, including the column of the first match on a
|
||||||
|
line.
|
||||||
|
|
||||||
4. Any whitespace errors detected by `git diff --check`.
|
4. Any whitespace errors detected by `git diff --check`.
|
||||||
|
|
||||||
@ -82,7 +90,7 @@ which does something similar to `git jump grep`. However, it is limited
|
|||||||
to positioning the cursor to the correct line in only the first file,
|
to positioning the cursor to the correct line in only the first file,
|
||||||
leaving you to locate subsequent hits in that file or other files using
|
leaving you to locate subsequent hits in that file or other files using
|
||||||
the editor or pager. By contrast, git-jump provides the editor with a
|
the editor or pager. By contrast, git-jump provides the editor with a
|
||||||
complete list of files and line numbers for each match.
|
complete list of files, lines, and a column number for each match.
|
||||||
|
|
||||||
|
|
||||||
Limitations
|
Limitations
|
||||||
|
@ -52,7 +52,7 @@ mode_merge() {
|
|||||||
# editor shows them to us in the status bar.
|
# editor shows them to us in the status bar.
|
||||||
mode_grep() {
|
mode_grep() {
|
||||||
cmd=$(git config jump.grepCmd)
|
cmd=$(git config jump.grepCmd)
|
||||||
test -n "$cmd" || cmd="git grep -n"
|
test -n "$cmd" || cmd="git grep -n --column"
|
||||||
$cmd "$@" |
|
$cmd "$@" |
|
||||||
perl -pe '
|
perl -pe '
|
||||||
s/[ \t]+/ /g;
|
s/[ \t]+/ /g;
|
||||||
|
Loading…
Reference in New Issue
Block a user