Guide to VIM in OSX Lion (& Linux)

Updated for Mountain Lion and misc. changes:

  • Install Xcode Command Line Tools
  • Upgrading VIM now possible directly through Homebrew (not with an alt repo)

This post details how to install a VIM working environment under OSX or Linux. The beauty of this approach is that it will allow you to consistently set up your IDE within minutes and get you productive. This setup can be cloned into remote servers over SSH, new machines, etc. These steps are the ones that I went through to set up my Lion machine, but have used this on Ubuntu based servers multiple times. For the Linux approach, begin with the cloning of the GIT repo.

screenshot

This procedure installs the following plugins:

OSX Environment Dependencies:

  • Homebrew - to install packages from the command line
  • Xcode 4+ - to have compilers, etc (gcc, g++, make)
    • Install from AppStore
    • Once installed, open Xcode, and install the Command Line Tools
    • Preferences --> Downloads --> Command Line Tools --> Install

OSX Nice to have:

Steps:

  • It is now possible to install the upgraded version of VIM directly from Homebrew (before it would warn that it's a duplicate from the one already installed with the OS). This make it very easy to get the latest version of VIM running
    • *Important: *If you've installed RVM, and are running a different Ruby, make sure you use the system Ruby, which is the one VIM will look for while running
    • rvm use system
    • brew install mercurial
    • brew install vim
  • Clone the VIM repo into your home directory
  • Move the vim directory to .vim (note that this will replace an existing directory, so make sure there's nothing in there you care about)
    • mv ~/vim ~/.vim
  • Create the _.vimrc _by linking the vimrc file in the .vim directory
    • ln -s ~/.vim/vimrc ~/.vimrc
  • This installation includes the awesome Pathogen script, which allows you to run VIM scripts/addons as modules
  • Initialize GIT submodules
    • cd ~/.vim
    • git submodule init
    • git submodule update
  • Initialize and compile Command-T (make sure System Ruby is being used by RVM)
    • cd ~/.vim/bundle/command-t/
    • rvm use system
    • ruby ruby/command-t/extconf.rb
    • rake make

That should be it. Open a new terminal window so all the files get sources. Open VIM, and should have all the toys installed.

Usage tips:

  • The VIM leader key has been changed to "," (comma)
  • To use Command-T (fuzzy search files), use +t
  • NerdTree (directory listing) is used with F2
  • Rails plugin instructions - TBD
comments powered by Disqus