Add vim as diff tool

Claus's Avatar

Claus

11 Jan, 2012 11:28 PM

I'd like to use Vim as diff tool. From command line I either use:

/usr/local/bin/mvim -d [file1] [file2] – this opens MacVim or
/sw/bin/vimdiff [file1] [file2] – this opens vim within the terminal (vimdiff is equivalent to vim -d)

I tested both variants (absolute path) by entering them in the "For Diffs use: Other ..." option in MacHg's preferences, however, calling diff from within MacHg does not open anything.

How can I make Vim my diff tool of choice?

Thanks for any help.

  1. Support Staff 1 Posted by jason on 12 Jan, 2012 12:04 AM

    jason's Avatar

    First step is to get vim working from the command line... (for hg) and not just as a general diff tool. the diff tools need to be called with the right arguments from extdiff (the external diffing extension which is built into Mercurial.) once you have that going than adding that to MacHg is fairly trivial. Ie most of the hard work is actually external to MacHg...

    I take it you have read http://machghelp.jasonfharris.com/kb/general/how-do-i-change-the-di... right?

  2. jason closed this discussion on 12 Jan, 2012 12:04 AM.

  3. Claus Atzenbeck re-opened this discussion on 12 Jan, 2012 02:01 AM

  4. 2 Posted by Claus Atzenbeck on 12 Jan, 2012 02:01 AM

    Claus Atzenbeck's Avatar

    Thanks for you e-mail. Yes, I saw the web page you're referring to. MacHg is setup to read ~/.hgrc. Below the content of that file; I got the content from <http://mercurial.selenic.com/wiki/MergingWithVim>.

    However, MacHg seems to not recognize vim or mvim.

    In order to further test it, I added the line "editor = /usr/local/bin/mvim", which should open MacVim as editor. However, still the "open -t -n -W" command from hgrc seems to be called. No idea, why ~/.hgrc is not considered. Or do I have to do any additional configuration?

    Thanks for any hint.
    Claus

    Here comes the content of ~/.hgrc:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [ui]
    merge = vimmerge

    [extdiff]

    # vimdiff
    vimdiff.executable = /sw/bin/vim
    vimdiff.args = -d $base $local $output $other +close +close

    # MacVim diff
    mvimdiff.executable = /usr/local/bin/mvim
    mvimdiff.args = -d $base $local $output $other +close +close

    [merge-tools]

    # vim merge
    # Source http://mercurial.selenic.com/wiki/MergingWithVim
    vimmerge.executable = /sw/bin/vim
    vimmerge.args = -d $base $local $output $other +close +close

    # MacVim merge
    mvimmerge.executable = /usr/local/bin/mvim
    mvimmerge.args = -d $base $local $output $other +close +close
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • MacHgScreenSnapz001.png 75 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac