Jumping between changed lines in VIM with fugitive
Asked Answered
E

2

19

I have a huge file where I modified several lines, and saved it. The fugitive knows which lines are modified, and it would be very useful to just jump between them. Is there an existing hotkey for that, or can I map it somehow?

Elurd answered 24/4, 2014 at 8:18 Comment(0)
Q
31

If you mean you've done a :Gdiff to another revision or the index, you can use the built-in ]c and [c motions to jump to the next / previous start of a change, as Vim shows the changes in 'diff' mode.

Edit: Have a look at the gitgutter plugin; it shows the changes in the sign column, updates those automatically, and even overloads the mentioned ]c commands as you would like them to behave.

Quarter answered 24/4, 2014 at 8:59 Comment(4)
No, I didn't do a Gdiff; just an ordinary editing of file with git.Elurd
What do you then mean by "the fugitive knows"?! Does it really run a diff without :Gdiff?Quarter
It turns out I already installed gitgutter, but forgot about it, so I assumed that it was fugitive which was responsible for symbol column. Thanks for the link, it has this feature indeed!Elurd
Any way to get similar (jumping to changed lines) functionality with :Gblame ?Woodie
P
25

Even without fugitive, vim maintains a changelist for every document which you can see by invoking :changes. You can jump through the changelist using g; (go to older change), g, (go to newer change).

Pinette answered 24/4, 2014 at 11:33 Comment(4)
This solution is too simple. ;-)Insult
And it works with :Gblame, for which the accepted answer sadly doesn't.Woodie
Really usefull and this also works in VSCode with Vim pluginBrainbrainard
not working. I thought the op is asking how to jump the changes in diff mode.Sexagenarian

© 2022 - 2024 — McMap. All rights reserved.