vi – keyboard navigation

vi, the unix text editor, is an incredibly useful and powerful piece of software. It is daunting to learn at first, but it’s the one piece of software that you can be 99.9% certain of finding on any *nix type system. And if the machine isn’t working right, it may be the only tool you have to fix it, so it’s useful to know how to use it.

The general stuff, switching modes, search and replace, those I pretty much have remembered. It’s the stupidly simple stuff, navigating around the document, that gets me. OK, so a modern keyboard has `end`/`home` keys and also `page up` and `page down`, as well as the cursor keys, but vi doesn’t know about these (though I’m sure it can be programmed with a macro), so to scroll large quantities of text can be very frustrating. I don’t use any of this stuff often enough for these things to be remembered through repetition, so I’ve created this page so that I can just refer here when I need to know!

Screen navigation
H top line of screen
M centre line of screen
L bottom line of screen
ctrl+f forward (down) one screen
ctrl+b backward (up) one screen
ctrl+u up half a screen
ctrl+d down half a screen
Document navigation
gg first line of document
G last line of document
Word navigation
b back one work
w word step forward