Line Editing Commands

A set of keystroke commands is used for editing lines in several editors (pico, emacs, jove, and xedit) as well as in the Unix command interpreters (“shells”), and in several other programs (S-plus with the “-e” option, maple, netscape, the tcsh shell, and others). In the editors, these commands are used to make small-scale changes to the file you are editing. In the other programs, these commands let you to modify a command that you entered, and enter it again, without having to type it all over again.

The common “emacs” style of line editing commands will be described first. A few programs (eg, S-plus and the shells) can also be set up to do “vi” style line editing. S-plus uses “vi” style by default, but this can be changed (see setting Unix options in your .profile file).

Which (if any) line editing scheme the default shell (sh) uses is controlled by setting the EDITOR environment variable to something ending in “emacs” or “vi”. See setting Unix options for details.

You can also repeat commands by grabbing text with the mouse.

“Emacs” style line editing

The “emacs” style commands are mostly single “control keys”, obtained by holding down the “Ctrl” key and a letter key simultaneously. Control keys are often written as (for instance) “Control/X” or “^X” (upper vs. lower case makes no difference). The commands operate in conjunction with a “cursor”, which identifies a current point in the line. The meaning of the keystrokes is as follows:

Control/P

In an editor, this will move you to the previous line. In a command-line program, such as maple, it will switch you to the previously-issued command (so, for example, typing Control/P and then Return will cause the last command to be done over again).
Control/N

Move to the next line, when editing a file, or look at command that was issued after the one being looked at now (ie, undo the effect of the previous Control/P).

Control/B

Move backward one character within the line being looked at.

 Control/F

Move forward one character within the line.

Control/A

 

Move to the beginning of the line.

Control/E

 

Move to the end of the line.

Backspace (or Control/H) and maybe Delete (or DEL)

Delete the character before the current point.

 

Control/D

Delete the character following the current point.

Control/K

Delete all the characters of the line that come after the current point.

Any character that isn’t a control key or other special key

The character typed is inserted into the line at the current point.

Note that there may be slight differences in how line editing behaves in the various programs that do it. Many programs also let you use the arrow keys to move around.

“Vi” style line editing

The “vi” style commands are similar to those used by the vi editor. When typing a command, you will start out in “insert” mode; to use most commands, you first must type ESC to get into command mode. An exception is that the arrow keys work without having to type ESC.

The “vi” style commands are available (with the right settings of the options) only in S-Plus, in the sh and tcsh shells, and, of course, in vi. In the standard shell, you get vi mode by setting the EDITOR environment variable to “vi”. To use the vi commands in tcsh, you must first issue the command

bindkey -v

 

Print Friendly