I tweaked this plugin so it would work with Sublime Text 2 on my machine. Here’s the code:
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:
{ "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!