Although Microsoft Notepad is clearly the superior text editor among its peers, occasionally we're forced to use a lesser editor like vi because we're stuck on one of those crusty old UNIX machines. Here's how to cope with the lack of features in vi and get it to work like your trusty Notepad.
The vi editor has some pretty strange ideas about how to edit a file. You can't just go on ahead and type. You need to move the cursor around with the arrow keys (or H, J, K and L on even older and crustier UNIX machines), and then hit i or a to insert or append text. You can also hit I or A, which inserts at the beginning or appends to the end of a line (how confusing is that? sheesh). Then, when you're done entering text, you have to hit ESC to go back to the normal mode.
Deleting characters is no picnic either. You can delete characters you've just typed using backspace if you're still in insert mode, but if you already hit ESC, tough luck. You have to use x on each character now. You can also delete the rest of the line using D.
You can just hit Enter to go to the next line, but if you're not already in insert mode, you can hit O or o to insert or append a line and start typing on it. If you want to delete a newline (i.e., join the next line to the end of the current line), you have to type J on the current line.
Remember: if in doubt, hit ESC. If that doesn't work, and vi has made a mess of your file because it wouldn't listen to your correct commands, hit :q! and everything will go back to the way it was.
The vi editor has some extraneous features no one uses that were intentionally left out of Notepad to make it more efficient (as if Microsoft needs to make its products even more efficient!), but I'll discuss a few here anyway just for kicks.
There are plenty more where these came from. For a good chuckle, check out the vi Reference written by Maarten Litmaath and maintained by James Hu.
Last modified Wednesday, January 20, 2010 (20:07 UTC)