Monday, October 18, 2010

How to make vim your primary editor for subversion.

How to make vim your primary editor

In Linux you can set the EDITOR environment variable by adding the following to your .bash_profile, .profile, .bashrc, or .bash_aliases file; depending on your distro.

export EDITOR=/usr/bin/vim

What about svn diff??

open subversion's config file, mine lives in /home/[user]/.subversion/config
Look for the line that talks about diff-cmd

diff-cmd = /home/[user]/.subversion/diffwrap.sh

Save and close the file.
save the contents of this code block as diffwrap.sh. Set the permissions to be executable by primary user. You will now be using vimdiff for your difference when you do an svn-diff

diffwrap.sh

#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/bin/vimdiff"

# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}

# Call the diff command (change the following line to make sense for
# your merge program).
$DIFF $LEFT $RIGHT

# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.

2 comments:

  1. I have been waiting for a svn-vimdiff script for a very long time, thank you for sharing this!

    (one note above, ".config" should be updated to "/config")

    LT

    ReplyDelete

Labels

android (2) debugging (1) fedora (1) linux (1) subversion (1) ubuntu (1) ui (1) vim (1)