Coffee Space


Listen:

Using Vim

I’ve been using Vim a few years now have come to love it. Heck, this page was written in it. I love the syntax highlighting, the speed at which you can do repetitive tasks, the simple layout, the use of screen space - the list goes on. Of course you have Emacs, but I don’t want to get into that and really comes down to a matter of taste.

In this I plan to share a few of the things I’ve picked up that I use on a regular basis. It’s by no means even close to all that there is to offer, but it’s a good selection that gets you far enough to being productive. After all, search engines are always there for those non-trivial uses.

Layout

0001 Text goes here...
0002 ~
0003 ~
0004 ~
0005 ~
0006 ~
0007 ~
0008 ~
0009 ~
0010 ~
0011 ~
0012 ~
0013 ~
0014 ~
0015 ~
0016 ~
0017 ~
0018 ~
0019 ~
0020 -- INSERT --                                  1,1         0%

As you can see, this isn’t the standard layout, where the normal size of the screen is expected to be 80x25. The lines with ~ don’t exist in the file and represent “the void”. Bottom left, where you see the -- INSERT --, is what I think of as the command or section area. It’s where all of the action happens. To the right, you see 1,1 in this case for the cursor position and 0% for percentage through the file.

Selection

There are many methods to select text, but the two I find most useful are line select and visual block select.

First make sure that you are in the correct mode by pressing the Esc key to bring you into the correct mode. To select a block, press Ctrl + v and use the arrow keys to cover the area you wish to select. To select lines, press Shift + v and press up or down on the arrow keys.

Now you have made a select, refer to the command section without pressing Esc again unless you want to cancel your selection.

Commands

The following is a list of commands that you can do. Some have different operations if you have made selections and usually that corresponds to the area you have selected. Make sure you have pressed the Esc key (unless you have made a visual selection).

The following commands also work without the need for : to be entered:

Tabs

With some recent experimentation I stumbled upon the tabs. I feel bad for not having done it sooner, but at least I did end up finding them! They generate some simple but nice tabs at the top - which barely take up any screen space as you’ve come to know and love.

The following are some basic tab related commands (the ones worth remembering in my opinion):

Summary

A few Vim commands committed to memory go a really far way.