How to use vim, really

I’m an Emacs man myself. I’ve never really used vim at all, and I use vi only for crontabs and commit messages. I’ve always grasped in the abstract the potential advantages of its modal editing, but that’s as far as it ever went.

Jonathan McPherson’s site has a great introduction to using vim that opened my eyes. His explanations of vim’s features offer just the right amount of detail. Most importantly he explains why particular commands are a good idea. Not explaining that is one of the classic failings of manpages – and I suspect that the vi manpage is the beginning and end of many users’ attempts to learn it. They learn about insert mode, command mode, loading and saving files, and that’s about it. Luckily, those just happen to be the prerequisites for McPherson’s tutorial. Clever fellow.

His most important bit of general advice:

In general, you want to spend as little of your time in vim’s insert mode as possible, because in that mode it acts like a dumb editor. This is why most vim novices spend so much time in insert mode – it makes vim easy to use. But vim’s real power lies in command mode! You’ll find that the better you know vim, the less time you will spend in insert mode.

I’ll never be a full convert (I’ve sold my soul to TextMate, and in the shell I’m happy with Emacs), but I’m definitely going to pull up that page the next time I need to use vi.

:wq


Robert Loomans commented on Mon Jan 9 22:47:03 2006:

If you want to use emacs for commit messages and crontab editing, then set the EDITOR environment variable.

For bash:

export EDITOR=emacs

and add it toyour shell startup scripts.

For bash:

echo ’export EDITOR=emacs’ ».bash_profile


Paul commented on Tue Jan 10 06:54:49 2006:

Oh, I know – but thanks!

I’ve often left my $EDITOR as vi just to make sure I am forced to use it once in a while – figuring that some dark day I’d be on a box with no Emacs and would be mighty embarassed not to remember how to make simple edits.


Faried Nawaz commented on Sat Jan 21 06:39:23 2006:

Even better – set EDITOR and VISUAL to “emacsclient”, and start gnuserv inside a running emacs process.


Kamen commented :

Yeah, I know Textmate takes many souls with it’s pretty GUI, but hey, if you force yourself to use vim a while, You’ll find many ways to make it beautiful to you.

That and you’ll be ruined forever because whenever you go into any other editor you’ll be frustrated that ESC doesn’t respond.



Share: