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.
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.
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.
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).
:d
- Deletes a line or selection.:m
- Moves a line or selection by either parameters +N
/-N
relative to the current line or N
being the line to move to.The following commands also work without the need for :
to be entered:
y
- Copies a line or selection.p
- Pastes a line or selection.i
- Insertion mode at current cursor position.Shift + i
- Insertion mode at start of line.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):
:tabe
- Open a new tab to the right of your current tab.:e .
- Opens a text based file browser in your current tab.:tabn
- Opens the next tab.:tabp
- Opens the previous tab.Ctrl + Shift + Down
- Opens the next tab.Ctrl + Shift + Up
- Opens the previous tab.A few Vim commands committed to memory go a really far way.