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


Book HomeBook TitleSearch this book

2.6. Finger Habits

To paraphrase the old adage, old finger habits die hard. In fact, that is the primary reason for the choices of vi and Emacs for the Korn shell's editing modes. If you are an experienced user of one of these editors, by all means use the corresponding Korn shell editing mode. If you are a vi wizard, you probably know how to navigate between any two points on a line in three keystrokes or less.

But if you're not, you should seriously consider adopting emacs-mode finger habits. Because it is based on control keys, just like the minimal editing support you may have already used with the Bourne or C shell, you will find emacs-mode easier to assimilate. Although the full Emacs is an extremely powerful editor, its command structure lends itself very well to small subsetting: there are several "mini-emacs" style editors floating around for Unix, MS-DOS, and other systems.

The same cannot be said for vi, because its command structure is really meant for use in a full-screen editor. vi is quite powerful too, in its way, but its power becomes evident only when it is used for purposes similar to that for which it was designed: editing source code in C and LISP. Doing complicated things in vi takes relatively few keystrokes. But doing simple things takes more keystrokes in vi-mode than it does in emacs-mode. Unfortunately, the ability to do simple things with a minimal number of keystrokes is most desired in a command interpreter, especially nowadays when users are spending more time within applications and less time working with the shell.

Both Korn shell editing modes have quite a few commands; you will undoubtedly develop finger habits that include just a few of them. If you use emacs-mode and you aren't familiar with the full Emacs, here is a subset that is easy to learn yet enables you to do just about anything:

  • For cursor motion around a command line, stick to CTRL-A and CTRL-E for beginning and end of line, and CTRL-F and CTRL-B for moving around.

  • Delete using DEL (or whatever your "erase" key is) and CTRL-D; as with CTRL-F and CTRL-B, hold down to repeat if necessary. Use CTRL-C to erase the entire line.

  • Use CTRL-P to retrieve the last command when you make a mistake.

  • Use CTRL-R to search for a command you need to run again.

  • Definitely use TAB for filename, command, and variable completion.

After a few hours spent learning these finger habits, you will wonder how you ever got along without command-line editing.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.