I’ve mentioned in the past that I’ve been using vim as my primary
editor for some time, so I figure now is probably as good of a time as
any to give some tips I’ve picked up during my extensive use of vim.
First, people wonder why I use vim when I work primarily in GUI
environments:
These aren’t necessarily any better than anybody else’s tips, just a random smattering of lessons I’ve learned along the way.
EDITOR or VISUAL environment variables, and begin deliberately
forgetting to use -m when checking in code via git or svn so
that you get forced to use it.vimtutor. Make yourself at least 30 minutes to go through the
whole tutorial, and on multiple days. Do everything it says to do.
You’ll only get better at using vim by using it, so you have to
do what the tutorial says to do in order to start developng the muscle
emory required.f, t, F, T, ; and . commands early. These
shortcuts alone make me more efficient than most other editors..vimrc. Mine is pretty minimal, but I’m
working on it.set paste. You’re welcome.~/.vim/ftplugin/<type>.vim
instead of using a bunch of autocmd’s in your .vimrc.:help command. First, just do :help to learn how
to bounce around within the help. (Ctrl-] will follow a tag, if you
don’t bother to read that far initially).h, j, k, and l so
that one of these days when you’re on a vt100 terminal and the arrow
keys don’t work, you don’t suddenly get stuck with an editor that
won’t work at all for you. (You can use the arrow keys if you’re
in INSERT mode and don’t want to constantly switch back and forth -
although I’d recommend figuring out how to accomplish what you want to
do with normal mode.)vim, you’re kinda’ expected to be able to
use them to your benefit.u is undo. Ctrl-r is redo. You’re welcome. (Incidentally,
vim’s undo history is non-linear - if you make change 1, then 2,
then undo back to 1, make change 3, you can go back to 2. There are
some decent sites which explain how to make sense of this, but maybe
:earlier 20s will do what you really need.)vim to do everything
you want it to do, install some plugins.:set number because a lot of the commands I use are
easier to use by knowing line numbers. I don’t use visual mode too
much (although I’m getting better). Because I use line numbers so
much, but because on a terminal, they’ll be copied to the clipboard if
you’re selecting something to put in an email, say - you’ll want a way
to quickly turn those off. I use a keyboard shortcut, but :set nu!
is not too slow if you’re only going to do it on occasion.