Well, if you read my diatribe on the preceding page, you know that I rather like vim. In fact, I'm writing this HTML page in vim...what else would I write it in, anyway? Great as vi is, there is definitely a bit of a learning curve past the basics of j, k, h, l, i, d, x, c, r, R, y, p, and the infamous :wq. Learning is a lifelong process, but getting the most out of vim shouldn't be - though you may find that you learn something new everyday. Somedays may get you to think "wow!" while others will just get you using vim only a tad more efficiently. vim.org has some good documentation online, and there are many user-contributed tips there to find out new ways to do things. (This page does include a number of tips I've learned from there, though this is only off the top of my head.)
Tired of finding some cryptic way of deleting a piece of text, undoing it, and then pasting the text elsewhere? vi does have a means of selecting text, but sometimes this little fact is glossed over by vi primers. Enter a basic text selection mode by pressing 'v' while in command mode, and then use the cursor keys (or *any* form of cursor navigation, including searches) to highlight the desired text. Once highlighted, use the traditional text manipulation keys to delete, yank, or replace the selection. Shift-v will give you a quick selection of whole lines at a time. While the preceding two 'v' commands are already helpful, Ctrl-v is useful in those moments when trying to figure out "How can I change that whole batch of text...in just one part?" You could probably construct a regular expression longer than this whole paragraph (or something so elegant, that it takes you half an hour [or longer] to write), or you could do a block/marquee select with Ctrl-v. (Extremely useful when working on fixed width delimited documents.)
Yes, that's the Ctrl key, followed by the left square bracket - it's an alternative way to hit Escape. Someday, you may find yourself on an a tty or virtual terminal that just isn't mapped correctly to send the Escape key, and that makes vi awfully hard to use - Ctrl-[ can help you out. It's also rather useful if your Escape key is Way Up There in No Man's Land, and your pinky has gotten tired of reaching that far. Oh, and if you hate the Caps Lock key like I do, you might find it convenient to bind Escape to it, to give your pinky a break, and put an otherwise useless key to work.
While the above might look like shorthand for expressing the qualities of Emacs, they are in fact very fast search keys for vi. While in command mode, with your cursor over a word, pressing '*' will take you to the next occurance of the word, and '#' will search in reverse for it. If you put the cursor over one part of a set of nested syntactical punctuation (i.e. curly braces), pressing '%' will take you to the corresponding part.
Besides being hard to pronounce syllables from Eastern European languages, these letters, typed next to one another, will take down or up one line of text as displayed on your screen when line wrap is on. Ergo, when using vi at 80 columns, and working on a piece of HTML that is already approaching 307 columns, appearing to be on 5 lines, pressing 'gk' will take the cursor up one 'virtual line.' Of course, the proper solution is to make sure all documents are no wider than 80 columns, but regrettably, there are times when this is not possible.
Return to John's Page on Applications
(C) 2006 John Silvestri.