I've used vi for around 20 years, and I remember working on a platform that was too old for even vi (an Onyx Z8000 system running Version 7). Lots of people love to hate vi, but the "vi Improved" - "vim" - has all kinds of goodies that aren't always so obvious. I was chatting with a friend today and commented about the multi-window support that character-mode vim has.
"Really?"
"You bet."
When in vim, there are plenty of commands that work with split windows, but in practice you only need a couple to get real benefits.
control-W s - split current file into two windows
control-W n - create new (empty) window
control-W w - go to next window
Those are the big three. Once you're in a window, you can close it with the traditional :q just like closing any other kind of file, but this time it closes the window. Closing the last window exits vim entirely.
When you're in a window, you can :e filename to replace the current file with a new one. This works particularly well when you're in a blank window and want to edit an actual file rather than create a new one.
It seems that yank buffers are shared, so if you y a line in one window, going to another window (even a different file) will "paste" that line there. Numbered yank buffers are shared too.
It's worth taking a few minutes to get handy with this, because it really does become second nature after a short time, and it's so helpful that you'll wonder why you didn't learn this sooner.
Posted by Steve at August 22, 2002 09:30 PMYou think that's cool? Try using screen for a while. :-)
Posted by: Jeremy Zawodny on August 23, 2002 11:47 PMOkay, screen is indeed very cool, but a different category though :)
Posted by: kasia on August 25, 2002 07:26 AM