Command-Line Editing

Command lines can be edited like lines in either Emacs or vi. Emacs is the default. See "Line-Edit Mode" later in this chapter for more information.

vi mode has two submodes, input mode and command mode. The default is input mode; you can go to command mode by pressing Esc. In command mode, typing a (append) or i (insert) returns you to input mode.

Some users discover that the Del or Backspace key in the Terminal doesn’t delete the character before the cursor as it should. Sometimes this problem can be solved by issuing one of the following commands (or placing it in your .bashrc file):

    stty erase ^?
    stty erase ^H

See the stty command in Chapter 2 for more information.

Emacs commands use the Control key and the Meta key—a system-neutral way to describe a function-changing modifier key. On a Mac, this corresponds to the Option key, if you have the Terminal configured correctly. Under the Terminal menu, go to Settings, and select the Keyboard drop down. Check the “use option key as meta key” checkbox, and close the Terminal Inspector.

In this chapter, the notation C- indicates that the Control key is pressed at the same time as the character that follows. Similarly, M- indicates the use of the Meta, or Option key on Mac OS X: either hold Option while typing the next character, or press and release the Escape key followed by the next character.

Tables 5-3 through 5-16 show various Emacs and vi commands.

Table 5-3. Basic Emacs-mode commands

Command

Description

Ctrl-b ...

Get Mac OS X Tiger in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.