Vim: How to start using it

The following quote from Why, oh WHY, do those #?@! nutheads use vi? basically sums up the “philosophy” of Vim use:

The first time you stumble into vi or vim, you are shocked and disgusted that you have to use ‘i’ to start typing text. Can’t remember which of hjkl moves in which direction. And you need to press ‘a’ if you want to insert after the last character of the line. Since you’re already probably used to other editors, and if the arrow keys work in insert mode (they do if the system is configured properly, which is over 90% of the cases), you will stay in insert mode and not go back to normal mode except if absolutely necessary. You’ll probably spend 20 minutes with it, and never go back. And also complaining: “How on earth am I going to remember whether I’m in insert or normal mode?”

Turns out, this is just a completely wrong way to use vi or vim. Using vi/vim properly, you don’t use it modally. You are always in normal mode, and only enter insert mode for short bursts of typing text, after which you press to go to normal mode. Thus, the remembering-the-mode problem just doesn’t exist: you don’t answer the phone in insert mode to get back to vi and not remember where you were. If you are typing text and the phone rings, you exit insert mode and then answer the phone. Or you press when you come back. But you never think about insert mode as a mode where you stay.

The best way to learn Vim IMHO is to learn incrementaly. Here’s a great article on that – Everyone Who Tried to Convince Me to use Vim was Wrong.

Tips to getting started with Vim :

1. Create a list of substitue Vim commands/keyboard shortcuts for the commands/keyboard shortcuts that you use for your current editor of choice.

There are some great cheatsheets and reference tables available online to help you out with creating your list.

Vim Commands Cheat
Essential Vim
Vim Quick Reference Card

2. Practice with vimtutor

3. Make mode change easier

Another important tips is to use another shortcut for Esc key. I use Ctrl-C. Here’s a link for other shortcuts and tricks to use alter methods.

4. Install essential plugins: These very useful plugins will make you usage experience a whole lot easier if you intend to code in Vim.

5. Watch Derek Wyatt’s Vim screencasts: Derek Wyatt has some excellent Vim tutorial videos starting from novice to expert level which will make you a Vim expert in no time.

Some useful talks and tutorials:

1. Vim Introduction and Tutorial : Nice tutorial for beginners with visual guides.

2. Ben Orenstein – Write code faster: expert-level vim (Railsberry 2012)

you can download the lecture materials from his github page. and his .vimrc file is here.

3. Vim Cookbook by Steve Oualline

4. Vimcasts.org archive : Great resource for digging deep into vim. Advanced stuff.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s