Command-line editing in shells

You can list, edit, and run previous commands in the Interix Korn shell and the Interix C shell. By default, both shells use vi(1) commands for editing the command line. To enter command-line editing mode, press ESC.

Basic vi commands for editing the command line

Command Result
h Moves cursor left one character.
l Moves cursor right one character.
k Displays previous command in the command history.
j Displays next command in the command history.
b Moves cursor one word to the left.
w Moves cursor one word to the right.
^ Moves cursor to the beginning of the line.
$ Moves cursor to the end of the line.
x Deletes character at the current cursor position.

You can also use emacs-style commands to edit the command line. In the Korn shell, to set the default command-line editor to emacs, type:

set -o emacs

Or, you can use the following command:

set -o gmacs

In the C shell, to set the default command-line editor to emacs, type:

bindkey -e