December 29th, 2008 By: Daniel
In the words of Tim Pope “TextMate may be the latest craze for developing Ruby on Rails applications, but Vim is forever”
Here’s how I use vim (and gnome-terminal) to program in Rails on Ubuntu.
I have a ruby script that opens two gnome-terminals each with 9 tabs each. That may seem like a lot, but each one is assigned a specific purpose and by now my fingers know just where to go depending on the task at hand. For example, models, views and controllers each get their own tab. So if I need to edit a model my fingers will do an
vim model_name.rb (or :e model_name.rb if I’m already in vim). And of course bash aliases and tab_completion minimizes the actual number of keystrokes required. In the same way, I know exactly where to go to watch the log, play in the console, use the SCM or anything else.
So that’s what it actually looks like. Notice how I have Gmail in the background so I can know immediately when I get a new email or IM (and ignore it at my leisure). Not shown is a separate Firefox window running on my other monitor so that I can see both the code and the running application at the same time.
Now, I have some doubts as to how well my solution would work for other people as it requires a bit of discipline to make sure everything has a place and to train yourself to always do things in the right place. It seems most people prefer to have only a few windows (or tabs or buffers or whatever) open and use some sort of fuzzy finder or file explorer to find the file they want to work on next. But that’s what I love about vim. I can come up with a custom workflow that works for me instead of conforming to the whims of some dictatorial IDE. True, the learning curve was quite steep at first, and I still occasionally invest some of my time in learning how to use additional features and customizations, but now contemplating using another text editor is like going back to riding tricycles after learning to fly jet planes.
Here’s the current version of the ruby script in case anyone’s interested. I call it zvim_rails_ide so I can use it with a quick zv<tab>.