Ping Services

Wednesday, November 16, 2011

How to become comfortable with vim




Vim is an extremely powerful text editor based on vi. It has been around for 20 years but one of the main problems that users have is that they have no idea what to do when they first use it:




 Figure: Everyone's first vi/vim session.


First and foremost, vim is not for everyone. I'm not going to shove it down your throat because you may already be using something that does what you need it to do very well. However, many people are very curious to try vim and I will aim to make your first half hour relatively pain free so that it's a fun challenge to learn vim rather than plain frustration.

When I first tried vim, I left it instantly as my experience was similar to the image above. Here are some quicks tips so that your experience would be better than mine:

1. Install GVim:

GVim provides a graphical interface to vim so that if you forget the command for performing a certain action, you may find what you were looking for in the menus.


 It should be available in your repositories and is also available from the official website for Windows/Mac users

2. Liberally use the the insert mode (at first).

By pressing "i", you enter the insert mode, which is used for inserting text like in any normal text editor. Pressing escape takes you back to command mode. Though you may be advised to go all out and use command mode most of the time, you will encounter a lot of frustration and not get any work done. I recommend using insert mode when you have to in the beginning and then gradually learn the vim commands.

3. Vim Tutor:

This is probably the fastest way to get used to vim. Just open a terminal and type in "vimtutor". You will then be guided through an interactive tutorial so that you can learn by doing rather than reading manuals.


4. Open vim: 

Open vim is an online tutorial that is also an excellent way to get used to vim. You  can use it here.

5. Using help.
You can access help by entering ":help" under command mode. To expand a certain section of the user manual press "CTRL+]"  (square bracket, not J). You can move back by pressing "CTRL+O" (small-case O).



6. Using the vim quick reference card.
It will take you a while to get used  to using commands. You can easily find the command that you're looking for using the vim quick reference card.

A shorter than normal article but I hope that you find it useful.

Links:
[1] Vim official website

No comments:

Post a Comment