Scott Penrose

GVim

Scott Penrose is a perl hacker with an interest in home automation. He has been playing with electronics since he was old enough to burn his fingers with a soldering iron.

I use GVim for Mac OS X - http://macvim.org/OSX/ - but I run it mostly from the command line.

For many years I have used a macro for "vi" which runs GVim if it can, or text/termainl VIM if it can not. However in Mac OS X the application runs slightly differently.

Here is the bits I use to do my VIM.

#!Bash
# VIM
if which gvim > /dev/null;
then    
    alias vi=gvim
else
    if which vim > /dev/null;
    then    
        alias vi=vim
    else
        unalias vi
    fi
fi

# Mac VIM
if [ -x /Applications/Vim.app/Contents/MacOS/Vim ]; 
then
    alias vi=macvim
fi

The above BASH configuration works fine, except for when you SSH into the remote Mac system, need some tweaking there.

Then for the "macvim" macro.

#!Bash
function macvim () {
        /Applications/Vim.app/Contents/MacOS/Vim -g "$@" &
        disown
}

The trick with the entry above is to start the "Vim" application inside Vim.app - and to diwon it, thus running the full GUI VI - GVim.

Note too the useful command "$@" - which automatically adds each command line argument, wrapped in Quotes. So you can edit any number of files.