Getting Started with Vim
12 Jan 2015For the past year, I’ve coded using sublime text 3 (ST3). It’s a great text editor, especially when you’re getting started. I’ve gotten so comfortable writing code in ST3, that it was hard to even think about switching text editors.
I kept hearing about IDEs and other text editors such as emacs and vim. It appeared that a large proportion of Rails developers were using vim. I was curious as to why. After getting comfortable with Ruby and working my way through a few Rails projects, I decided it was time to experiment with vim to see if it was the right fit for me.
Well, after two weeks of praciting with vim, it’s now hard to go back to ST3. It’s nice to write code without having to go back and forth between the keyboard and the mouse. It just feels smoother writing code in vim now.
Here are the primary resources I used to learn vim:
- Learn Vim in a Week (23 min video) - start here for a solid plan to learning vim.
- Sitepoint - Getting Started with Vim - a good intro and brief history of vim.
- Vim for Rubyists - breakdown of popular vim plugins and resources for rubyists.
Some general tips:
-
If you practice daily, it should take about 1-2 weeks to get comfortable using vim. Start off with basic commands, and gradually expand your vocabulary to more complex commands.
-
Work through some of the tutorials at jumpstartlab, using vim. You could possibly redo the blogger tutorial, or one of the advanced rails tutorials. The point is to work through something light, so you’re not getting bogged down from writing something more complex, while you’re learning vim.
-
Jot down all the commands in a notebook. It’s a good way to retain commands. While you’re working through a project, and don’t know how to do something in vim, you simply google how to do it, write it in your notebook, and you should be good to go the next time you want to do same command.
- As mentioned in the ‘Vim for Rubyists’ article, you might want to
start with janus, which comes with some of the most popular plugins such as
vim-rails
. I started with Janus, and it made the transition easier.If you are just starting with Vim, coming from TextMate or other editor, you can give Janus a shot. It’s a distribution of plugins and mappings for Vim, Gvim and MacVim. It’s bundled with a lot of useful tools for Ruby development and designed to reduce the learning curve of Vim.
- Lastly, if you haven’t used vim yet it won’t make sense, but
eventually you’ll most likely want to remap your
Esc
,Ctrl
, and<leader>
keys. It just makes it easier to work in vim without having to move all over the keyboard. An example is to remapEsc
to the keysjk
.
Hope that helps. Feel free to reach out if you have any issues learning vim.