I just got started using Vim for Ruby on Rails development. To me, learning Vim is like growing a garden, it doesn’t happen overnight and you have to keep working at it. Also, getting Vim setup isn’t a one-and-done activity like installing a new toilet or a traditional editor/IDE. You have to keep tweaking and customizing it. Anyway, here are some of my notes on how I got started and some quick wins. Please note that this is more of a (rough) guide on how to get Vim setup for Ruby on Rails than it is how to use it.
First the easy part, download and install your flavor of Vim: http://www.vim.org/download.php
Now, before you start editing any files, you’ll probably want to create a vimrc file. You’ll be spending a lot of time in here, this is where most of you preferences and customizations for Vim will go. This file is like using a Vim performance enhancer. Tweaking this file will turn your normal ride into a high performance sports car. But to me, simply copying someone else’s vimrc file is like getting into someone else’s car where you have to adjust the seat, mirrors, steering wheel, radio presets, etc. because it’s customized for them, not you. And with my brief experience with Vim, it’s unlikely that you’re going to find a vimrc file that is exactly what you want. So you have to customize it. Below are some links on creating and customizing your vimrc file.
Information on the vimrc file: http://www.derekwyatt.org/vim/the-vimrc-file/
More basic info: http://vim.wikia.com/wiki/Open_vimrc_file
Here’s a good thread on Stack Overflow to find good settings for your vimrc file:
You can use vimbits.com to handpick vimrc settings.
You can browse and cherry-pick from other people’s vimrc files on GitHub, by using a search query like this in Google: “.vimrc site:github.com”
Here is an online resource for all vimrc options (which is the same as the built-in documenation):
If you want to know what a certain vimrc option does, just type: ‘:help option-name’ and it will tell you what it does and what the long and short form of the option is.
Learn more about the different key mappings:
Learn more about the <leader> character:
Set a default color scheme and font
Now that you have a basic vimrc file setup, here’s a quick and easy win to customize your Vim experience by picking a default color scheme and font.
Here are some good color themes I have found:
- jellybeans: http://www.vim.org/scripts/script.php?script_id=2555
- railscasts: http://www.vim.org/scripts/script.php?script_id=2175
- vividchalk: http://www.vim.org/scripts/script.php?script_id=1891
The color theme files go in ~/.vim/colors or ~\vimfiles\colors if you’re on Windows. Then you in your vimrc file you can set your default color scheme:
" Set default color scheme colorscheme jellybeans
It’s also nice to have a good programming font in Vim. Here’s a list of preferred fonts and also how to set a default font in your vimrc file:
Next, you’ll probably want to install some plug-ins to add additional functionality to Vim. There are two main ways (I know of) to manage your plug-ins: Pathogen and Vundle. Personally, I use Vundle, I like how you can keep track of all your plug-ins in your vimrc file and run one command to install them all, kinda like Bundler. Anyway, here are some handy plug-ins that I have discovered so far:
Well, that’s about it. Definitely not an exhaustive guide, but hopefully it’s enough to get started. Like I said I just got started using Vim for Ruby on Rails myself, so I know there’s a lot of plug-ins and settings I haven’t discovered yet.