<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: VIM as a Diff/Merge Tool</title>
    <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>VIM as a Diff/Merge Tool</title>
      <description>&lt;p&gt;Do you need a really quick, clean, powerful diff/merge tool that you can use in windows, mac, and various Unixen?  As a happy and pround &lt;a href="http://vim.org"&gt;vim&lt;/a&gt; user, I have been enjoying &lt;a href="http://www.vim.org/htmldoc/diff.html"&gt;vimdiff&lt;/a&gt; for a number of years.&lt;/p&gt;


&lt;pre&gt;
        &amp;gt; gvim -d file1 file2
        &amp;gt; vimdiff file1 file2
&lt;/pre&gt;

	&lt;p&gt;(G)vimdiff is wonderful. You can move changes between two versions of a file with
great ease (if you know vim) and amazing speed. It can handle files of any size and does a fine job of syncing up both versions.&lt;/p&gt;


	&lt;p&gt;Vim can do just about anything. I have learned that no matter how much I use and study Vim I still am just scratching the surface of what the editor can do.  I find little tricks and configuration options, new keystrokes, and fun little bits of minutae.  I think it&amp;#8217;s all new.  With my memory, sometimes I just &lt;strong&gt;think&lt;/strong&gt; something is new, and have to go check my &lt;a href="http://tottinge.blogsome.com/use-vim-like-a-pro/"&gt;past notes&lt;/a&gt; to see if I already knew it.&lt;/p&gt;


Today I (re)learned about diffopt, which makes gvimdiff more wonderful. 
&lt;pre&gt;
    :set diffopt=filler
&lt;/pre&gt;
By default, diffopt is set to &amp;#8220;filler&amp;#8221;.  Filler doesn&amp;#8217;t do much, it
just adds vertical spaces to keep the text of the left and right
pane aligned.  It&amp;#8217;s a good setting, and I don&amp;#8217;t much like working
without it.  But there are other settings which are overlooked, 
even by experts.
&lt;pre&gt;
    : set diffopt+=iwhite
&lt;/pre&gt;
My second favorite is &amp;#8216;iwhite&amp;#8217;, which stands for &amp;#8220;ignore whitespace&amp;#8221;.
It makes gvimdiff ignore leading, trailing, and embedded spaces so
that simple acts like retabbing or deleting vertical spaces won&amp;#8217;t 
obscure actual changes.   It really helps you to merge changes in 
situations where you&amp;#8217;ve adopted code that was built to entirely different
standards. 
&lt;pre&gt;
    :set diffopt+=icase
&lt;/pre&gt;
iCase ignores capitalization, which is not as useful as the other options, since programmers are normally interested in case, but it may be handy when someone has corrected and reformatted &lt;span class="caps"&gt;SQL&lt;/span&gt;.  I don&amp;#8217;t expect to use it much.
&lt;pre&gt;
    :set diffopt+=horizontal
&lt;/pre&gt;
The last interesting bit is the choice between vertical splits (the normal case) and horizontal splits (for very long lines on cinema-aspect screens).  I hope to never  need this option again, but I have needed to deal with absurdly long lines.

	&lt;p&gt;If you can use &lt;span class="caps"&gt;VIM&lt;/span&gt; at all, you will find vim&amp;#8217;s diffmode to be a very powerful and  useful tool.  If you can&amp;#8217;t use vim already, then maybe vimdiff will be the reason you will learn vim.&lt;/p&gt;</description>
      <pubDate>Wed, 30 Apr 2008 21:24:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:87ede884-c19a-4ab9-9a04-9b074bb32c86</guid>
      <author>Tim Ottinger</author>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool</link>
      <category>Tim's Tepid Torrent</category>
      <category>vim</category>
      <category>diff</category>
      <category>vimdiff</category>
      <category>diffopt</category>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by tim</title>
      <description>&lt;p&gt;Huh? No graphical indication?  You must not have been in diff mode, or you didn&amp;#8217;t have syntax enabled.   The differences are pretty stark if you have color syntax highlighting turned on, and you have shortcut keys to move between differences.&lt;/p&gt;


	&lt;p&gt;When I use vimdiff, it collapses the areas where there are no differences.  I see a few lines of context, and clearly colored areas of difference (including space changes within a line), and am able to copy changes between the panes pretty easily.&lt;/p&gt;


	&lt;p&gt;Maybe there needs to be some tutorial here.  With screenshots.&lt;/p&gt;</description>
      <pubDate>Mon, 05 May 2008 00:32:12 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b23c9954-ebb9-4063-a2e4-e29cd93794b4</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1749</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by Lorne</title>
      <description>&lt;p&gt;You can select two files, right click, and select &amp;#8216;Diff with Vim&amp;#8217;. Easy enough???&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 10:49:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3410df81-d2b0-45cf-8633-694e382d906a</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1746</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by pb</title>
      <description>&lt;p&gt;Just what I want &amp;#8211; to type in a stupid command line instead of selecting two file and right clicking to choose diff.&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 09:31:27 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6d3fe3e2-adab-4cfb-b000-ef12a59c7fc9</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1745</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by AqD</title>
      <description>&lt;p&gt;I found it hard to use for large files without the graphical indication of where the differences are&amp;#8230;. There are a lot of GUI diffs that are better for the job and I&amp;#8217;d use vimdiff only when I&amp;#8217;m on console mode.&lt;/p&gt;</description>
      <pubDate>Sun, 04 May 2008 01:56:11 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5df08254-6621-476a-9c5f-9f62def038f3</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1744</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by Tim</title>
      <description>&lt;p&gt;If you are on *nix, don&amp;#8217;t overlook meld.  It&amp;#8217;s quite a nice tool also.  I just tend to do more work with VIM than not.&lt;/p&gt;</description>
      <pubDate>Sat, 03 May 2008 17:56:08 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d705946d-09d0-4a92-8b3f-c5caa333cd55</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1742</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by Rob van Eijk</title>
      <description>&lt;p&gt;I discovered merging through gVim. It works like a charm. I use it to keep my dokuwiki main.php up to date when doing updates.&lt;/p&gt;</description>
      <pubDate>Fri, 02 May 2008 15:31:11 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:bc9392df-50b6-456d-ab72-485b70fc36ec</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1741</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by David Paxson</title>
      <description>&lt;p&gt;I used VIM&amp;#8217;s diff feature to compare/merge a base file along with two branches from it.  I also had a three monitor setup with the diff spread across the three monitors.&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 13:36:41 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ddeab745-aefa-44cb-81e6-7621c905ceec</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1738</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by kretik</title>
      <description>&lt;p&gt;Unless you&amp;#8217;re doing this because you&amp;#8217;re running on *nix, there&amp;#8217;s no reason not to use WinMerge. It&amp;#8217;s light years ahead of vim&amp;#8217;s diff functionality.&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 12:08:55 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8fbfe07a-326b-4d5f-bdbc-1d9a9c3f8cb2</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1737</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by Chris Gaal</title>
      <description>&lt;p&gt;I&amp;#8217;m an avid Vim user as well, and vimdiff has become an indispensable part of my daily tool kit.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;d offer two other tips on the topic of using Vim as a diff tool:&lt;/p&gt;


	&lt;p&gt;- Check out the DirDiff plugin (google &amp;#8220;vim dirdiff&amp;#8221;).  It&amp;#8217;s very nice for viewing diffs of directory contents.&lt;/p&gt;


	&lt;p&gt;- I&amp;#8217;ve found it helpful to map Vim&amp;#8217;s commonly used diff commands to single keys, and adding in a &amp;#8220;zz&amp;#8221; command to center the window on the current difference when jumping to the next diff.  This allows to you fly though diffs, quickly obtaining/putting changes.  I use the following, which uses similar key bindings to Araxis Merge (a tool I used in my pre-Vim life):&lt;/p&gt;


	&lt;p&gt;nmap &amp;lt;F7&amp;gt; [czz&lt;/p&gt;


	&lt;p&gt;nmap &amp;lt;F8&amp;gt; ]czz&lt;/p&gt;


	&lt;p&gt;nmap &amp;lt;F2&amp;gt; do&lt;/p&gt;


	&lt;p&gt;nmap &amp;lt;F3&amp;gt; dp&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 11:12:42 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1952442c-c83a-41dc-adb1-4843f887ca4d</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1736</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by A Purohit</title>
      <description>&lt;p&gt;I use vim and its diff tool &lt;em&gt;very&lt;/em&gt; heavily. I have defined the following shortcuts&lt;/p&gt;


&lt;p /&gt;nnoremap &amp;lt;Leader&amp;gt;u :diffupdate&amp;lt;cr&amp;gt;
&lt;p /&gt;nnoremap &amp;lt;Leader&amp;gt;g :diffget&amp;lt;cr&amp;gt;
&lt;p /&gt;nnoremap &amp;lt;Leader&amp;gt;p :diffput&amp;lt;cr&amp;gt;

	&lt;p&gt;(my leader is the comma character)&lt;/p&gt;


	&lt;p&gt;so I can type ,g to get ,p to put diffs (both commands work with respect to the current window) and ,u to refresh the screen. It really speeds things up.&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 11:06:55 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f853380e-1e3d-4fd6-bba3-7afac2021d7e</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1735</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by nicholas a. evans</title>
      <description>&lt;p&gt;I&amp;#8217;m an avid vim user, and I often use vimdiff when merging simple changes.  But when I&amp;#8217;m dealing with conflict resolution, I usually resort to kdiff3, which is available under Linux, Windows, and Mac OS X.&lt;/p&gt;


	&lt;p&gt;Although I think that meld looks nicer than kdiff3, the UI and workflow of kdiff3 seem the most intuitive to me when dealing with three-way diffs for conflict resolution.  And vimdiff is faster and closer to hand than meld when dealing with smaller diff tasks.&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 10:06:47 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:e0ccd228-f202-46b2-a191-4a151a3e1d9a</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1734</link>
    </item>
    <item>
      <title>"VIM as a Diff/Merge Tool" by P&#225;draig Brady</title>
      <description>&lt;p&gt;I&amp;#8217;ve not liked vimdiff when I tried it. I&amp;#8217;ll try again I promise.
My current merge tool of choice is meld, which I&amp;#8217;ve described here:
&lt;a href="http://www.pixelbeat.org/programming/diffs/" rel="nofollow"&gt;http://www.pixelbeat.org/programming/diffs/&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;The important thing to note anyway is that using these tools,
is infinitely better than merging manually.&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 09:19:11 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0df8158c-9a04-4147-8c33-4fe3ddd4daef</guid>
      <link>http://blog.objectmentor.com/articles/2008/04/30/vim-as-a-diff-merge-tool#comment-1733</link>
    </item>
  </channel>
</rss>
