Gvim

vimdiff allows you to diff and merge two files in vim. Start it with either of the following commands:

You can also use gvim, in which case substitute 'vim' for 'gvim' in the above commands.

If you are already in vim (editing [file1]), use the following command to do a vertical diff between the current file and another.

If you want to use the --remote-tab or --remote-tab-silent switch to open the diff in a new tab in the existing window, you need to start the diff via a command rather than via a switch:

Note that you will need to escape any spaces in [file2].

GUI executable gvim##.zip gvim82.zip This is the 'normal' GUI version. OLE GUI executable gvim##ole.zip gvim82ole.zip A GUI version with OLE support. This offers a few extra features, such as integration with Visual Developer Studio. But it uses quite a bit more memory. The GVim Portable Launcher allows you to run GVim from a removable drive whose letter changes as you move it to another computer. The program can be entirely self-contained on the drive and then used on any Microsoft Windows computer. Figure: Screenshot. Last updated 15-Jul-2008 15:53:43 CEST. Changing the location of gVim swap and backup files. When editing a file in gVim a backup file is created after saving changes to a newly opened file. It is a copy of the file before changing the file. It is named the same as the file with a at the end. This creates a lot of clutter in your directories.

Gvim

Scrolling

If you want to simply change the font size in a running GVim instance, type::set guifont=. A window should pop up letting you set font size as well as pick a new font if desired. You can then ask Vim to print the line you would need to add to your /.gvimrc to make the change permanent.

To get both files scrolling at the same time I had to set the scrollbind option in my .vimrc file (or set it in /etc/vim/vimrc as a global setting):

Redoing the diff

If you loose the diff for whatever reason (e.g. I lost the diff when opening a new tab with :tabnew), turn the diff option on again.

You'll also need to redo the diff if you make a non-trivial change to a line, in which case run the following:

Moving around

Gvim

Switch viewport:

Jump to next diff:

Jump to previous diff:

Merging

Whole diff

Linux

To replace a diff in the current viewport with that from the other viewport, use the :diffget command. This can be shortened to the following:

To replace a diff in the other viewport with that from the current viewport, use the :diffput command. This can be shortened to the following:

If you want to get contents from the other viewport when the current viewport has 'filler' - i.e. a series of dashes - then do so from the line below.

Part of the diff

Gvim32

To replace just a single line or multiple lines in a diff in the current viewport (rather than getting the entire diff), use a range. You have to use the full command for this - you can't use the shortened command shown above. For example, if you want to get line 63 from the other viewport, do the following:

The diffget command can be shortened slightly to diffg.

Gvim Linux

It's similar for diffput.

Gvim For Windows

References

Gvim Windows

  • Vim documentation: diff