Vi IMproved--Vim and Happy Hacking Keyboard Lite 2
When you type vi on most Linux boxes, you're likely to get Vim. This is a good thing, but until now nobody has written a book that covers the features Vim has over vi.
Steve Oualline to the rescue. Some readers wrote in to say that Steve changed their lives with his article "That's Vimprovement! A Better vi" in our February issue. It's wonderful to be a part of bringing such a wonderful transformation to you people, and Steve's new book brings even more Vim knowledge to the masses.
Thank the book gods that it didn't come bundled with a CD-ROM. I hope this is a trend--book publishers should stop including software that will probably be obsolete for most of the book's shelf life. If this book should be bundled with anything, it's the new Happy Hacking Keyboard Lite 2 from PFU America. We used the QWERTY version, but there are also Dvorak and Japanese versions.
Vim enhances the original vi so you can edit faster, but the Happy Hacking series of keyboards removes features to achieve the same goal. There's no top row of function keys or anything right of Enter. Escape moves down to just left of the number one, which is why we're mentioning this keyboard in an review of a book about Vim--there'll be no more "Mom, can you make me some sandwiches? I'm going to go hit Escape today, be back for dinner." The missing keys are available with Fn, so you can still do a SysRq if you need to.
The Control key is where it belongs, above the left Shift. And the upper right corner is a little changed from a standard PC keyboard too. A DIP-switchable backspace/delete key is above Enter, and backslash/pipe and tilde/backquote are above that.
The Happy Hacking Keyboard Lite 2 adds cursor keys in an inverted T below the right Shift key. Fans of the original Happy Hacking Keyboard, which Linux Journal reviewed in 1998, will notice one other change--there's now a second Fn key on the left, so you can use both Fn and the left "diamond" (no Windows logo, but it acts like it) key.
Speaking of Fn keys, Fn works flawlessly with any other combination of modifiers, so if you have enough fingers you can still switch virtual consoles. Three-key combinations like Ctrl-Alt-F1 become four-key combinations like Ctrl-Alt-Fn-1. Set your fireworks on the ground before you light them and you should be OK.
How well does it work? The small size and small lip on the front increase the perceived height--because it's smaller, it feels thicker. If you use a wrist rest you might want to experiment with different ones. The key feel doesn't have the classic feel of increased resistance, then a spring click, then less resistance, as in an old IBM keyboard. The keys aren't completely mushy like a cheap PC keyboard, though. The closest I can come to describing the feel is that it's like a high-quality laptop keyboard but with much longer key travel.
The big question of course is can you use the Happy Hacking Keyboard and switch back to a regular keyboard for occasional edits without going insane? In my experience, yes.
Until your Happy Hacking Keyboard comes, if you're using a regular keyboard with Vim, you might want to stick "imap <F1> <esc>" in your .vimrc, to keep from hitting F1 for help when all you want to do is hit escape.
That brings us to the subject of .vimrc files. Do a Google search for "my .vimrc" and you will get hundreds of them--all full of productivity-maximizing, carpal-tunnel-saving goodness. Or, depending on your point of view, productivity-sucking days of tweaking your .vimrc just right so that when you do write something it will be really easy to do.
Even if you visit vim.org daily and are always working on your .virmrc to incorporate stuff you get off the Net, Steve's book makes a great command reference. One nice touch is that the reference appendices, which list commands in alphabetical order, include page numbers for those commands that are explained in detail in the body of the book.
If you're new to Vim, or to vi-like editors in general, the tutorial at the beginning of the book looks good and quickly transitions from a basic survival guide to true power editing. For basic wrist health reasons, it's a good idea to pick up as much text editing skill as possible, and carrying around a copy of this book is a great way to do it. If you just know enough vi to get by, you're leaving all the power of Vim on the table and needlessly trashing your wrists.
For example, if you've ever had unexpected results when pasting text into Vim from an X application, then :set paste will make the pasted-in text come out a lot closer to the original than it might otherwise. Commands and configuration settings abound.
There's also a detailed "Cookbook" chapter where you can find recipes for dealing with a lot of common editing tasks. Except where he has to, Steve keeps everything organized in short sections that you can read and apply quickly. The state of my .vimrc is much improved since the day I picked up this book.
As you might expect from the author of Practical C Programming, there is a lot of good information on how to customize Vim to handle C and other programming languages. Steve covers indentation, syntax highlighting and automatically dealing with make and the compiler in great detail. For example, you can insert a "modeline" in a file to enforce your tab settings even when someone with a differently configured Vim edits it. And Vim will run make for you, then automatically open any files with errors for editing.
There are no entries in the index for "mail" or "e-mail" and little information about how to use Vim for nonprogramming tasks like dealing with quoted text in e-mail. If you're searching for customization tweaks to make Vim do what you want as a mail editor, you might have to wait for a good book on Mutt.
There's excellent coverage of Vim's own built-in scripting language, but no examples of using Python or Perl, with which Vim can be integrated.
At no point does this book bother to say anything about which features are found in the original vi and which are Vim innovations. If you learn Vim, then log in to some legacy UNIX box, you'd better grab a copy of Vim. Fortunately, Vim is insanely portable, even to non-UNIX-like OSes, and there's an appendix that covers installation. So if you're spoiled by Vim and can never go back to regular vi, there's still hope for you.
Don Marti is the technical editor for Linux Journal. He can be reached at email@example.com.
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane