17

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?

Max Yankov
  • 12,551
  • 12
  • 67
  • 135

2 Answers2

30

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • 2
    No, I didn't do a Gdiff; just an ordinary editing of file with git. – Max Yankov Apr 24 '14 at 09:30
  • 1
    What do you then mean by "the fugitive knows"?! Does it really run a diff without `:Gdiff`? – Ingo Karkat Apr 24 '14 at 09:53
  • 1
    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! – Max Yankov Apr 24 '14 at 10:22
  • Any way to get similar (jumping to changed lines) functionality with `:Gblame` ? – 0xc0de Jun 04 '19 at 09:02
23

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).

Dhruva Sagar
  • 7,089
  • 1
  • 25
  • 34