Home
So I’ve been using vim every day for about 6 months now. It was an exercise in frustration for most of that time, until it became second nature; so much so that I then found other editors and word-processors less effective to use as I’d keep trying vim commands…
Starting to use vim is easy with vimtutor, which is simply a clever text file that you learn to manipulate with vim. Here are a few tips:
:tabf
followed by a file name will open a file in a new tab — with tab completion. :tabnew
is self explanatory. gt
selects the next tab, gT
the previousCTRL+w, w
followed by s
splits horizontally, v
vertically. q
will close the window. To open a new file in a buffer, :sp
. You may switch windows with CTRL+w, w.
opens a split buffer vertically.CTRL+a
and CTRL+x
increment and decrement a (decimal) number under the cursor. Precede it with a number to repeat the operation–VISUAL BLOCK–
mode (CTRL+v
) combined with I
to prepend something to several lines at once. It will take effect when you go back to normal mode. You can also search and replace in the block in any visual mode!cc
blanks the line and puts you into insert modeO
and o
creates a newline above and below the current line respectivelyddp
swaps the current line with the nextci
followed by a delimiter will change text within that delimiter. For example, ci"
will change beans
in "beans"
cw
will change the current wordvim -p
will open a set of files in tabs. -o
will open in a split buffer, and -O
will do the same, but verticallyCtrl+f
will allow you to edit the command line vi-style. Ctrl+C
will exit this mode.Ctrl+[
may be better than ESC
as you don’t have the leave the home keysset -o vi
to your bashrc for (default insert-mode) readline editing!J
will join the next line on the end of the current linevi{
to visual mode select in {} parenthesis. Then zf
to fold that section.gv
to select the last selectiongq
to justify the current paragraphI recommend you customise vim; I tried getting used to the stock configuration on Ubuntu, but it was too minimal and there were far too many annoyances. Remove the irritating things, add features such as the solarized colour scheme; a well-engineered palette for anything you stare at. Pathogen is worth installing to make managing plugins easier.
I made a vimrc, and eventually got carried away and made a git repo with configuration files for bash, tmux and git. It’s worth a look and is mostly commented.
Thanks for reading! If you have comments or like this article, please post or upvote it on Hacker news, Twitter, Hackaday, Lobste.rs, Reddit and/or LinkedIn.
Please email me with any corrections or feedback.