VMS-to-Unix Phrase Book
<=  Return           

1.1  Command Line Editing

Problem

You want to edit and recall commands entered at the Korn shell (command line) prompt.

Solution

Set the Korn Shell (ksh) to use the editing conventions of your favor Unix editor. Note that unlike VMS, the command line editing conventions established for the shell do not necessarily extend into other interactive applications. But having the shell follow (more or less) the line editing conventions used by your preferred text editor is a significant convenience.

Please see the Typographical Conventions page for more information on the control-key notations used below.

Discussion

To start with, your .profile file should contain the following two commands to set your terminal:

stty dec
tset -I -Q
This is assuming that you are using the same terminal or terminal emulator as you normally used on VMS. These settings should make the key that you are use to hitting for 'rubbing out' the previous character work as expected. This key is known in Unix as the 'erase' key. In addition, C-u will erase the current command entry, which is similar to what it does under VMS. This key is called the 'kill' key.

Command line editing is not turned on by default for ksh (although your site adminstrator may have provided local initialization files that have turned it on for you). This is because there are two fundamental styles of command line recall, modeled after the two predominant editors, vi and Emacs. To enable command line editing, set the EDITOR shell variable using one of the following:

unix> EDITOR="vi"; export EDITOR
... or ...
unix> EDITOR="emacs"; export EDITOR

The EDITOR environment variable is not only used by ksh to determine the command line editing style, but also other applications and utilities, such as crontab when it is necessary to invoke an editor on your behalf. See 1.6 for information on how to setting your preference every time you logon. For reasons explained in Emacs for the EVE User we discuss only the Emacs environment in this article. Consider the following table:

DCL Ksh Action
C-a -- Toggle insert/overstrick mode.
C-u -- Delete from cursor to beginning of line.
-- C-u Delete entire command line.
C-h C-a Go to start of line.
C-e C-e Go to end of line.
C-r C-l Refresh current line.
C-j ESC C-h Erase previous word.
-- ESC f Forward one word.
-- ESC b Backward one word.
-- C-] x Jump forward to character 'x'.
-- ESC C-] x Jump backward to character 'x'.
-- C-d Delete character under cursor.
-- ESC d Delete current word.
-- C-t Transpose current and next character.
-- C-k Delete from cursor to end of line.
-- C-r Incremental reverse search through command history.
-- ESC ESC Complete as much as possible of filename entered so far.
-- ESC = Show list of files that match filename entered so far.
-- ESC * Generate list of all files matching filename entered so far.

The arrow keys are not shown above since they operate exactly as you would expect having come from DCL. However the control-keys used for command line editing are almost entirely different.

While most of the keys described are self-explanatory a few deserve special mention:

Some final notes:

See Also

1.2 - Interactive Job Control;
1.6 - Environment Initialization;
Chapter 3 of Unix for OpenVMS Users .


<=  Return           

Colophon:
Best Viewed With Any Browser
This page maintained by:
    Bill.Costa@unh.edu
    of the Enterprise Computing Group
    in the dept of Computing & Information Sevices
    at the University of New Hampshire

Typographical
Conventions

Created:  31-Jan-2001 BC
Revised:  30-Mar-2001 BC