I’d love to learn Street Fighter 2, but there are just so many combos!
- The Vim Learning Curve is a Myth, Thoughtbot
A lot of people are scared of learning of vim because of the initial learning curve.
When learning vim for the first time there are lots of approaches, but two common ways are:
- Learn “pure” vi/vim, then introduce vimrc options and then plugins
- Start with an existing “customization” (from someone else), then learn what things do
Once upon a time, I would have suggested learning the basic features of vim before getting into customization, but there are quite a lot of people who are not interested in learning the tool unless they can be productive straight away.
When coming from an IDE, the apparent shortcomings of a less integrated text editor will scare them away before they have discovered the power of editing text with vim.
This guide is aimed at those people. I want to outline some steps to learn vim that makes the transition from IDE to vim as easy as possible with the hope of making vim a less scary step.
Most systems will come with a version of vim, but you may want to get the latest version from the systems package manager for a more complete feature set.
On a mac, the standard install of
vim is missing clipboard support so I would recommend installing MacVim, here is how I do it with homebrew:
This package provides
mvim on the command line, but
vim will still refer to the system version, so I setup a couple of aliases in my
This guide is more about setting up vim in a manner that won’t seem too crippling when coming from an IDE, so I won’t focus too much on editing effectively with vim here.
If vim is completely new to you and you don’t know the basics such as the difference between command mode and insert mode or how to quit vim, I would recommend pausing the guide here and running
vimtutor in your terminal to learn the basics.
Vim uses a
.vimrc configuration file in your home directory. There is a plethora of configuration options you can put here, but I thought I would offer some basic options to get you started.
.vimrc is quite large, but here is a snippet for some basic options that you can put into your own
.vimrc to get started:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Vim has builtin support for
ctags, which indexes your code and allows you to jump to the definition of a method or class. As usual, on a mac you will have a standard version of
ctags installed, but it’s not very good, so I recommend installing the exuberant ctags package from homebrew:
1 2 3
To make use of ctags, in the root of a project run the following command:
This will need to be run when the code changes to keep the tags file up to date, so I have setup git hooks to automate this. If you don’t want to setup git hooks, you can execute this command from within vim with
:!ctags -R .
Now if you open some code, move your cursor over an occurrence of a method or class, you can jump into the definition of that method or class with the following key bindings:
] = Jump to definition (of what is under the cursor)
T = Jump back from following a tag
The following key bindings are also useful for navigation and do not require ctags:
/foo = Search for
* = Search for the word under the cursor
n = Jump to the next occurrence of the search
N = Jump to the previous occurrence of the search
o = Go back from the last jump
i = Go forward to the recent jump
Vim has a plugin system, but by default it does not do a good job of keeping plugins isolated from each other. To improve this, there are plugins that manage plugins.
I recommend using Vundle, here is how to set it up along with a few useful vim plugins:
Then place the following at the top of your
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Then, I choose configure some of those plugins towards the bottom of the
.vimrc like this:
1 2 3 4 5 6 7 8 9 10 11 12
Now, from within vim, run
At this point, you should have a somewhat powerful installation of vim, the next step is to learn how to use this power. Below are some resources to help you learn how to use vim effectively.