[1+1=2]

OneAndOneIs2

« I like to...Thank god for regular expressions... »

Tue, Aug 25, 2009

[Icon][Icon]Merging diffs

• Post categories: Omni, FOSS, My Life, Programming, Helpful

I've got this hideous mass of files which need to be diff'd together. Manually doing the find & replace would be a nightmare, I wanted something that could make it easy to shunt text from one file to another.

And hey, I've got Vim installed...

It was HARD work figuring out how to get Gvim to do the diff thing tho. When you need to get the files through a GUI, not command-line, and then have no idea how to do all the diff things...

So here's what I needed to know:

  • Start up Vim
  • :vsplit to split the screen in half vertically
  • Open the first file
  • Use Ctwl-W and the left and right arrow keys to move between splits. Open the second file
  • :diffthis in both windows to get Vim to diff the files
  • :set wrap if your default is to turn off wrapping under diff
  • Now the fun bit. Getting text between the two...
  • To travel between diffs, use square brackets followed by 'c'
    ]c to go forward, [c to go back
  • Now you need to either Get the diff from the other side, or Put the diff from the side you're on. To Get the diff, use do and to Put the diff, use dp
  • Vim hides all non-identical lines by default, folding them out of sight. This means you can't see if you made a mistake. This is annoying. You open and close folds using zo and zc respectively. And you can open all the folds using zR (Thanks Dion!) and close them all with zM
  • :diffupdate to re-diff the files if Vim starts to lose track, which it might in a complex diff.
  • :diffthis in both windows when you open the next pair of files..

Sounds bloody awful, doesn't it? It certainly took me a while to figure out how to do everything that I needed to. But on the other hand, Vim can do everything I need it to do. Which is why it's still the best text editor ;o)

2 comments

Dion Moult
Comment from: Dion Moult [Visitor] · http://thinkmoult.com/
I quite dislike some of the default foldings so I find "zR" is a nifty function to unfold everything.
25/08/09 @ 23:49
oneandoneis2
Comment from: oneandoneis2 [Member] · http://geekblog.oneandoneis2.org/
Good tip, added it to the post! Cheers!
26/08/09 @ 00:48

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
 

[Links][icon] My links

[Icon][Icon] Hmm.. new look for twitter? I hope it gets less "Ick! Change! Put it back!" nonsense than Facebook..
08/02/12

[Icon][Icon] Facebook Syndication Error
11/02/12

[Icon][Icon] I last listened to:
Johann Pachelbel - Canon in D major

[Icon][Icon] Most recent photo:
Submersible houseboat

[Icon][Icon]About Me

[Icon][Icon]About this blog

[Icon][Icon]My LQ profile

[Icon][Icon]My /. profile

[Icon][Icon]My Wishlist

[Icon]MyCommerce

[FSF Associate Member]


February 2012
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29        

Search

User tools

XML Feeds

eXTReMe Tracker

Valid XHTML 1.0 Transitional

Valid CSS!

[Valid RSS feed]

powered by b2evolution free blog software