Home Download Buy Blog Forum Support

Diff/merge two views

Diff/merge two views

Postby gpfsmurf on Thu Dec 10, 2009 10:19 pm

I often need to diff two files that are already opened in Sublime so I created a simple Merge plugin (available in the repo)

For simplicity, this command will diff/merge the last two selected files.

To use: click on view A, click on view B, press Ctrl+Alt+D. WinMerge will be launched with files A and B.

You need to have WinMerge installed: http://winmerge.org/
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Diff/merge two views

Postby GreyWyvern on Mon Feb 01, 2010 5:17 pm

Just thought I'd say thanks and give you a bump. Works great :)
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Diff/merge two views

Postby jpg on Sun Feb 07, 2010 5:41 pm

Hi

Works well in ST's Single-Pane mode (i.e. two tabs in same pane being compared). Couldn't get it to work in multi-pane layout with one file from each of two panes being compared though - ST hangs and WinMerge not launched. (I use ST 1.2.2, WinMerge 2.12.4 on W7HP).

Still, works great in Single-Pane mode. Thanks!

Rgds
JG
jpg
 
Posts: 4
Joined: Wed Feb 03, 2010 6:56 pm

Re: Diff/merge two views

Postby gpfsmurf on Mon Feb 08, 2010 6:58 pm

Thanks for the bug report - I changed the approach to make it work across different panes and windows.

The updated version is available on the repo.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Diff/merge two views

Postby jpg on Wed Feb 10, 2010 10:57 pm

Gonna grab it now. Thanks!

Best,
JG
jpg
 
Posts: 4
Joined: Wed Feb 03, 2010 6:56 pm

Re: Diff/merge two views

Postby lencioni on Tue Mar 15, 2011 7:59 pm

I tweaked this plugin so it would work with Sublime Text 2 on my machine. Here's the code:
Code: Select all
import os
from subprocess import Popen

import sublime
import sublime_plugin

WINMERGE    = '"%s\WinMerge\WinMergeU.exe"' % os.environ['ProgramFiles(X86)']
FILES       = [None, None]

class WinmergeCommand(sublime_plugin.TextCommand):

    def run(self, edit):
        print WINMERGE
        Popen('%s /e /ul /ur "%s" "%s"' % (WINMERGE, FILES[0], FILES[1]))

class WinmergeTracker(sublime_plugin.EventListener):
   
    def on_activated(self, view):
        if view.file_name() != FILES[0]:
            FILES[1] = FILES[0]
            FILES[0] = view.file_name()


And here's the keybinding I used:
Code: Select all
{ "keys": ["ctrl+shift+d"], "command": "winmerge" }


This is my first time working with a sublime plugin or python, so if there is any room for improvement, please post!
lencioni
 
Posts: 6
Joined: Thu Jul 08, 2010 3:32 pm

Re: Diff/merge two views

Postby StevenRas on Tue Mar 27, 2012 11:46 am

Hi guys,

can you tweak the plugin to support Apple FileMerge? Filemerge comes free with XCode...

Is there a way to use it as a replacement for the standard "Diff" Menu?
StevenRas
 
Posts: 11
Joined: Fri Mar 23, 2012 4:58 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests