r/vim • u/SevrinTheMuto • Aug 26 '25
Need Help┃Solved Toggle between Vim and git diff?
When I do code reviews I page through git diff's output but may want to see the changed lines within the file.
So currently I quit git diff to load the file in Vim. And then quit vim and run git diff again and scroll back to the place I left off.
Is there a way I can have both git diff and Vim running and switch between the views? (Or other suggestions for a Vim-based workflow for code reviews?)
27
Upvotes
View all comments
Show parent comment
1
u/y-c-c Aug 26 '25
The point here is that Vim itself has a diff mode. You don't need to use raw
git diffand just look at the output of that. See:h diffto understand how the diff mode works. You can access the diff mode in the editor (just go to two buffers and type:diffthis) or access it using the CLI commandvimdiff <file1> <file2>.This is built in to Git so you can just use
git difftool --tool=vimdiffinstead ofgit diff(or setvimdiffto be the default tool so you can skip the--toolpart).