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


Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: 2.5 The fc Command Chapter 2
Command-line Editing
Next: 3. Customizing Your Environment
 

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. A vi user has the power to move mountains in few keystrokes-but at the cost of doing anything meaningful in very few keystrokes. Unfortunately, the latter 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 ESC ESC for filename completion.

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


Previous: 2.5 The fc Command Learning the Korn Shell Next: 3. Customizing Your Environment
2.5 The fc Command Book Index 3. Customizing Your Environment

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