Download - Vim quick tutorial
12/7/2013 Quick and Dirty : Vimdiff Tutorial | Core Dump
http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html 1/5
28th August 2008I recently started using exclusively Vim (and gVim) for my coding needs. Vimdiff is a tool that comes bundledwith Vim and its a wonderful tool for comparing code and merging changes. If you'd prefer to use a non-Vimbased diff tool, checkout visual diff tools in linux [http://amjith.blogspot.com/2007/07/visual-diff-tools-in-linux.html]for more variety.
[http://3.bp.blogspot.com/_Klq-3NKFe2s/SMfeDZ9gY9I/AAAAAAAAAaA/zHwt-XJqt0M/s1600-h/vimdiff.png] Keyboard Shortcuts:
do - Get changes from other window into the current window.
dp - Put the changes from current window into the other window.
]c - Jump to the next change.
[c - Jump to the previous change.
Ctrl W + Ctrl W - Switch to the other split window.
Update: Allan [http://www.blogger.com/profile/06760506313601452399] commented these two tips that Ipersonally use quite often.
If you load up two files in splits (:vs or :sp), you can do :diffthis on each window and achieve a diff of filesthat were already loaded in buffers:diffoff can be used to turn off the diff mode.
Posted 28th August 2008 by Amjith Ramanujam
Labels: vim
Quick and Dirty : Vimdiff Tutorial
24 View comments
Casey 12:01 PM
12/7/2013 Quick and Dirty : Vimdiff Tutorial | Core Dump
http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html 2/5
Thanks, I've been looking everywhere for this.
Reply
mkoga 6:43 PM
Very cool, thanks for the tip!
Reply
yungchin 10:29 AM
Thanks! Just what I was looking for.
Reply
Partha Chatterjee 3:01 AM
Thanks a lot! I was looking around for these commands frantically. Its a great help. Thanks.
Reply
angel 1:38 AM
thanks a loads.... :) Jai ho!!
Reply
Alan Haggai Alavi 4:06 AM
Hi,
Nice information. However, `Ctrl W + Ctrl W' is not required to switch windows. Ctrl W + W is enough tocycle windows. You can try Ctrl W + <any of the direction keys> to switch among windows in vimdiff or invim with split windows.
For example:Ctrl W + L => Switch to the right window, which is similar to pressing Ctrl W + <Right arrow>.
Regards.
Reply
Saggi Malachi 9:06 AM
Great quick tutorial. Exactly what I was looking for.
Reply
Anonymous 4:56 PM
Thanks for the great tip
Reply
peerlessdeepak 6:27 AM
12/7/2013 Quick and Dirty : Vimdiff Tutorial | Core Dump
http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html 3/5
Replies
Reply
Nice one! I learnt vimdiff from it.
while(As long as i remember vimdiff)Thanks
Reply
Anonymous 8:15 AM
To ignore whitespace use this command: set diffopt+=iwhite
To turn that back off use: set diffopt-=iwhite
Reply
bothie 6:36 AM
The only thing missing in this tutorial: How can I undo a dp/do command?
Reply
Divye Kapoor 1:23 PM
+1 if you have a tip here.
Julio Angulo 12:03 PM
just type u
Anonymous 12:03 PM
After typing 'u', type ':e %' to get the coloring back.
~rAGU 1:38 PM
do command is bit tricky. Esc and then type do placing the cursor at the beginning of the diff and placecursor at the end then type do again to bring the change from the other window.+ can be expanded by pressing -> key to see text where there is no diff. Asusual :x saves and exits.
Reply
Martin 4:10 AM
Hi, this is nice, but I had to figure out how to get it into diff mode in first place. Might be nice, if you couldadd that here.
And somehow it is not very clever, I have two lines, both starting off the same and then ending in differntly.Still, it tells me the whole line in red color, like it were different.
Reply
Anonymous 11:38 AM
12/7/2013 Quick and Dirty : Vimdiff Tutorial | Core Dump
http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html 4/5
@bothie: just do 'u' in the affected window to undo the editing command, as usual in vim
Reply
Deepak 12:42 AM
This tip is very useful.. I started using vimdiff and enjoying.
Reply
Allan 2:14 PM
Yet another tip to help people out... if you load up two files in splits (:vs or :sp), you can do :diffthis on eachwindow and achieve a diff of files that were already loaded in buffers. I usually end up doing it this waybecause I already have the two versions loaded side by side.
Another tip to quit diffing a split is to use :diffoff. I remember this one by telling diff to f-off. :P
Reply
Amjith 2:22 PM
Thanks Allan:I've updated the post to reflect your tips. :)
Reply
shb 2:31 PM
I was just looking for it! :)
After a minute I also needed :diffupdate
Reply
Ondřej Jakubov 6:35 AM
Nice one, very quick:)
Reply
Justin Hopper 1:26 PM
Thank man - very useful commands
Reply
palak pal 10:53 AM
Vim tutorial Cheat Sheet , Learn VIM in 5 miunutehttps://www.youtube.com/watch?v=7BDh4bDqG8Y
Reply
12/7/2013 Quick and Dirty : Vimdiff Tutorial | Core Dump
http://amjith.blogspot.com/2008/08/quick-and-dirty-vimdiff-tutorial.html 5/5
Enter your comment...
Comment as: Google Account
Publish
Preview