Ruby On Rails, Design, Simplicity, Web 2.0, Ajax, Mac and Tons of Pizza.

Aug 15

Use MacVim and rails.vim plugin to edit your Rails work

Posted by Massimo Sgrelli in Ruby on Rails - 6 comments digg this add to delicious

A couple of years ago I bought a copy of TextMate, the preferred and “exclusive” text editor of Ruby on Rails community. Two years ago I was a newcomer to Ruby language and Rails framework and TextMate helped me to enter quickly in this marvelous world. Coming back to then I chose this editor because on Rails official web site there weren’t others good suggested tools.

NOTE THIS: actually checking on the site, a few things are really changed. I read, “The entire Rails core team is using TextMate on Mac OS X. It’s a fantastic editor that ships with Ruby on Rails highlighting and macros”. I know it’s not true (Jeremy Kemper must is actually using a different tool).... is it some kind of hidden advertising?

In any case the Macromates product is definitely a good one, but soon I felt I needed something different, something I could suggest to my colleagues, to my friends, without force them to invest 30 bucks or so. I needed something like vi... vi?

Now vi has been replaced by vim.
VIM (an improved version of vi) is already installed on OSX or on Ubuntu and it’s free. But to be used as my preferred Ruby and Rails text editor I needed it could manage 2 things:

  • some sort of integration with Rails (how?)
  • syntax coloring TextMate-like (yeah, I like it)

No problem: the first issue has been trivial. You need to download rails.vim and extract the zip file to ~/.vim directory. This completes the installation :)

For the second issue wanted to have IR_Black theme (the theme I’m using under TextMate) on VIM too. This is how it looks like under TextMate:

... and you know what? It actually exists for VIM. Todd Werth, the creator of IR_Black theme for TextMate made it available for the Unix text editor. So I downloaded and put it under ~/.vim/colors directory, I launched vim and…

... this screen showed. From the shell, in the xterm, you have access to 16 ANSI colors only, so forget the full color result. I didn’t know that.

So? No fancy colors under VIM?

The solution is to download MacVim a project under the Google Code site, that easily access all the colors, using all the previous settings already stored under your ”.vim” directory.
The final result is awesome:

Comments

  • Tim Harper

    Posted on August 15

    I just jumped on the vim boat a few months ago and loved it. I tried emacs, and gave it a fare shot (not nearly as fare of a shot that I gave VIM, after all I did climb the vertical learning curve of torture and pain), but vim clicked with me better. It must be that it just is a better fit for how I prefer to think and operate. I still find myself reaching for TextMate for rails development because: a) it's still an awesome editor (and is much easier to extend), and b) RubyAMP.tmbundle and Git.tmbundle. Funny enough, I started the tools that are keeping me hooked. Tim
  • Massimo Sgrelli

    Posted on August 15

    I've just seen your work. Pretty amazing! RubyAMP is definitely cool, but I'm convinced that all those add-ons - even if useful - can be something really distracting. We interviewed Rayn Singer at the RailsConf and he told us that he - has a designer - is using vim, also because it doesn't admit the mouse usage. I agree with him. I think we have to learn again to look for simplicity while working and that will make us more effective. Sometimes keep us up-to-date on IDE-based features is a full time job.
  • Tim Harper

    Posted on August 15

    Well, it's a wonderful world where we are free to choose the tools that make most happy :)
  • Lisa Seelye

    Posted on August 16

    I use TextMate inside OS X but vim on remote machines. In fact I use TextMate for managing notes from phone calls and to type drafts of long blog posts or emails. Vim, however, is still my favourite on the command line.
  • Mark Wilden

    Posted on August 16

    I also went from TextMate (back) to Vim. But not for simplicity - for power. TextMate is a toy compared to a "real" editor like Vim, emacs or even Visual Studio. How, for example, could someone use an editor that doesn't support multiple windows?? You can't see your code and your test at the same time! I write more about this at http://mwilden.blogspot.com/2008/03/textmate-is-worst-program-that-people.html .
  • Adam

    Posted on August 22

    Lately I've been trying to do everything in the terminal. Terminal.app only supports 16 colors so I switched to using mrxvt through X11. vim color themes look great in it and now I don't have to worry about platform specific gui apps. I use OS X, Ubuntu, and Windows so it was essential to learn to live in a terminal for a unified experience. I highly recommend mrxvt or another 256 color terminal emulator if you want to get back into the terminal. I will say, however, that being able to copy paste in MacVim with the command keys is awesome. Thanks for the great post.

Post a comment

Categories:

Tags:

Powered by Mephisto, Valid XHTML 1.1, Valid CSS - Supported by Wave Factory