Previous Table of Contents Next


The following commands are supported in in-line vi edit mode but not in the vi editor.

n_ Append the nth argument from the previous command line after the cursor and enter insert mode.
word* Replace the current word with the output of filename generation from the word*. If no match, the word is left unchanged. If expansion occurs, then the cursor is moved to the end of the text and input mode is entered.
v This causes the in-line editor to enter the editor specified by the VISUAL variable if it is set. If it is not, then the value of the EDITOR variable is used. You can make corrections to the command line, exit the editor, and the shell reexecutes the command automatically. It is extremely useful for editing multiline command lines. This is equivalent to typing fc -e vi or just fc if the FCEDIT variable is set to vi.
For example, assume you have typed a while loop structure as follows on the command line.
                    while :
                     do
                      if [ -f anewfile ]
                      then echo "File is here."
                         braek
                      else sleep 15
                      fi
                     done

Notice the break command is misspelled. You have executed the command and realize the problem. To correct the error simply press Delete to stop the execution of the loop. Press Escape kv to enter the editor. The Escape enters the history editing feature. The k moves up one line and the v enters you into the editor. Now make the necessary changes (/braek<Return>llxp) and exit the editor by typing ZZ. The command is reexecuted by the shell immediately. The command is displayed on your screen and executed.

= Pathname listing. Causes the current word on the command line to be expanded to a list of pathnames. For example,
                    $ls m<ESC>=
                    1) myfile
                    2) myhome
                    $
\ Pathname completion. Causes the current word on the command line to be expanded to a filename or directory. If it is a directory then a / is added. For example,
                    $ echo my<Esc>\
would expand to myfile.
@letter Searches your list of aliases for one named _letter. If an alias is defined, its value is inserted as keystrokes. For example,
                    alias _Q='LBi"^V<Esc>Ea"^V<Esc>'
now if you are editing a command and type <Esc>@Q the current word you are on would be quoted.
# Insert a # (comment marker) at the beginning of a command.

The vi editor is described in Module 151.

Emacs Editing Mode

The emacs editing mode is based on the emacs editor. The following list describes the emacs commands. The n denotes a number that may be entered to provide a count for the command.

Cursor Movement
nCtrl-B Move cursor back n characters.
nCtrl-F Move cursor forward n characters.
Ctrl-A Move cursor to beginning of line.
Ctrl-E Move cursor to end of line.
nEsc-b Move cursor back to beginning of nth previous word.
nEsc-f Move cursor forward to beginning of nth word.
Ctrl-]c Move cursor to next character c.
Esc-space Ctrl-@ Set mark at cursor position.
Ctrl-X Ctrl-X Exchange cursor position and mark.
Line Search
nCtrl-P Select nth previous command line of history file.
nCtrl-N Select nth next command line.
Esc-< Select oldest command line.
Esc-> Select newest command line.
nCtrl-RstrReturn Search for the nth command line matching str.
Changing Text
nCtrl-H Delete n characters back from cursor.
nCtrl-D Delete n characters forward from cursor.
nEsc-h Delete n previous words.
nEsc-d Delete n words.
nCtrl-K Delete to end of line.
Ctrl-G Delete entire line.
Ctrl-W Delete from cursor to mark.
Ctrl-T Transpose characters.
Ctrl-C Capitalize character.
Esc-c Capitalize word.
Esc-l Lowercase word.
nEsc-. nEsc-_ Insert nth word of previous command.
Esc-Esc Esc-* Replace current word with files that would match the word followed by a *.
Miscellaneous
Ctrl-J Ctrl-M Return Execute command line.
Ctrl-L Redisplay current command line.
Ctrl-O Remember next command line, execute current line, then recall next line to window.
Ctrl-U Multiple next count n by 4.
Ctrl-V Display version of the shell.
\ Do not interpret next character. Allows insertion of Control and Escape characters in command lines.
Ctrl-D Terminate the shell, log out.
Esc-n Enter count for following command.

C Shell History File Editing

The C Shell uses a line editor approach to edit the history file. That is, you type in a command and the shell locates the command line in the history file and performs the editing commands you specified. Each command line in the history file is referenced by an event number. For example, the following output is from the history command:

1  mail dwh
2  write skb
3  vi wsr.092989
4  find /usr/local -name "dly.*" -print
5  vi apiprog.c

Event number 1 references the command line "mail dwh." The command,

     !3

reexecutes the "vi wsr.092989" command.


Previous Table of Contents Next