04 Juin 2010 @ 6:41  

Usefull vimdiff commands to view diff and merge

October 15, 2008 @ 8:20 am · Filed under Linux

Diffing the files and merging them is one of the very common task we do everyday. Following are few very useful commands to view the diff using vim and merge them using the vimdiff commands instead of copying and pasting from one file to another.

To diff two files using vim :

vimdiff file1 file2
or
vim -d file1 file2

Ofcourse you can use gvim also but I don’t prefer using GVIM.

gvimdiff file1 file2

Commands :

[c : Jump to previous diff
]c : Jump to the next diff

do or :diffget : Diff obtain (get the changes to the current buffer/file from the other buffer)
dp or :diffput : Diff Put (Put the changes from the current buffer/file to the other buffer)

As this being one of very command task I do, I have mapped them to single keys for the easy access.

nmap <F7> [czz
nmap <F8> ]czz
nmap <F2> do
nmap <F3> dp

The zz in the end of the command [c will center at the point of the diff so that we can view the diff clearly.

~Enjoy Vim

Posted By: stratus
Last Edit: 04 Juin 2010 @ 06:41

EmailPermalink
Tags
Tags: , , , ,
Categories: Dev, Linux


 

Responses to this post » (None)

 
Post a Comment

You must be logged in to post a comment.

Tags
Comment Meta:
RSS Feed for comments

 Last 50 Posts
 Back
Change Theme...
  • Users » 4
  • Posts/Pages » 85
  • Comments » 5
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

AquaTuX



    No Child Pages.

Music



    No Child Pages.
WordPress Appliance - Powered by TurnKey Linux