home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 31.2 Save Time and Typing with the vi map Commands Chapter 31
Creating Custom Commands in vi
Next: 31.4 vi @-Functions
 

31.3 What You Lose When You Use map!

Back in the old days (when bread cost five cents and my grandfather was just a boy...) a terminal's arrow keys didn't work during vi text-input mode. To move around in the file, you pressed ESC and used command-mode commands like 5k and 4w . Since then, lots of vendors and users have modified vi so that you can use arrow keys during text-input mode. In fact, we show you how to do it yourself in articles 31.2 and 31.13 . These days, lots of folks think the newfangled way that vi works is the right way. Here are some reasons to leave the arrow keys alone and do it the old way instead:

  • In most cases, the u (undo) command will be useless after text-input mode because the arrow keymap does several hidden commands. The only "undo" command that will do much good is U -it undoes all changes on the current line, and it doesn't work if you've moved off the line since you made the change you want to undo.

  • Beginners can get confused by this. They need to learn that vi is a moded editor, that you enter text in text-input mode and make changes in command mode. Movement through the file is with commands.

    When people start using vi and they find that some motion commands (the cursor keys) work in text-input mode, vi seems inconsistent.

  • If your map! runs commands that start with an ESC (and it almost always will), your ESC key may work more slowly. That's because every time you press the ESC key, vi will wait one second (or so) to be sure that the ESC is just an ESC alone and not the beginning of a map! ped sequence. Some vendors have changed this, though.

    The fast alternative is to press ESC twice. That rings the terminal bell, though.

- JP


Previous: 31.2 Save Time and Typing with the vi map Commands UNIX Power Tools Next: 31.4 vi @-Functions
31.2 Save Time and Typing with the vi map Commands Book Index 31.4 vi @-Functions

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System