Saturday, May 29, 2010

Making VIM more TextMate like


TextMate is supposedly the text editor for MacOS to have. It's used by many Rails developers and I must admit it's quite slick and fast. It feels like a polished and better Emacs in my opinion and takes many of its keyboard shortcuts.  Unfortunately it's closed source, costs money and is only available on the MacOS platform.

I have converted back to VIM (I am using the MacVIM version). One of  features of TextMate that I am missing is the project drawer. Fortunately you can extend VIM with plugins. I have tried two plugins: Project and NERDTree. If you want something TextMate like go with NERDTree. You get a directory pane at the left, from which you can easily find and open files.

That's quite fine, but as a TextMate fan you will be missing the command line mate program to start with a directory "drawn out". I wrote a simple shell script to mimic that behavior and now typing 'vmate' behaves like its Mac OS counterpart:

function vmate(){
  if [ -d $1 ]; then
    mvim -c ":NERDTree $1"
  else
    mvim $1
  fi
}

To open a directory in project mode simply pass directory path to vmate. If you doing any Rails development be sure to check out the great rails.vim plugin.


No comments: