How to use Vim to quickly see Mercurial or Git changes

11,786

Solution 1

Edit 2020-01-23: Searched quickly and FYI saw that there's another plugin that seems more VCS agnostic: https://github.com/mhinz/vim-signify


There's a new plugin that does this: vim-gitgutter. It puts the changes in the Vim gutter whenever you save the file. Here's what it looks like in action:

enter image description here

Solution 2

Have a look at Tim Pope's fugitive.vim plugin.

I'm a git purist and usually drop into the command line for git, but when I'm in vim I find that this does most of what I need to do and yet I can still call git commands directly.

Solution 3

Try vcscommand plugin, use :VCSVimDiff to view differencies with current revision (supports both hg and git, probably some other SCM systems as well) and internal :bdelete (:bd) (on opened buffer of course, not on already existing) to stop diffing. If you are using gentoo, it is available in the repository: app-vim/vcscommand.

Solution 4

one method is to do the following:

:!git diff

This will show the changes (to all files) in comparison to HEAD

to do a single file :!git diff path/to/file

this is a quick way of doing it without switching different apps nor installing any plugins (which isn't always easy to do on some systems that you don't have control over).

it wont give you 'inline' highlighting but should work ok.

another way to do it quickly is to do a :r !git diff take a look at the changes then type u to undo the addition. This works nicely too, esp if you want to yank some text from HEAD

Solution 5

There is a site on using git and vim together:

http://www.osnews.com/story/21556/Using_Git_with_Vim

I use the git.vim one, and every time I need a diff I can check it with \gd.

Share:
11,786
Kyle Heironimus
Author by

Kyle Heironimus

Ruby on Rails developer with experience in C, C++, embedded, and electrical engineering.

Updated on June 11, 2022

Comments

  • Kyle Heironimus
    Kyle Heironimus about 2 years

    As I'm editing a file in Vim, I would like to quickly highlight any changes I have made since my last commit, while still being able to edit the file. Is there anything that comes close to doing this?