| United States-English |
|
|
|
![]() |
Shells: User's Guide: HP 9000 Computers > Chapter 20 Command Lines and Command HistoryUsing Inline Editing Modes |
|
There are two types of editing modes available in POSIX and Korn Shell: the vi mode and the emacs mode. A discussion of each of these methods follows. These Shell editing modes emulate the corresponding editors and all common commands are the same. Inline editing is very similar to using the editor in that inline editing uses the common editor's commands. The vi editing mode uses the same commands as the vi editor. If you are unfamiliar with the vi editor, see Using HP-UX, or The Ultimate Guide to the vi and ex Text Editors. There are several ways to enable the vi editing mode. One is to type:
For further details on the set command see Chapter 23 “Advanced Concepts and Commands”. Another is to set and export the VISUAL shell variable in your .profile or .kshrc, to a value ending in vi:
If VISUAL is assigned a string that ends in vi, gmacs, or emacs, then the corresponding editor mode is enabled. Finally, you can set and export EDITOR in your .profile or .kshrc:
Now, if VISUAL is not set, and EDITOR is assigned a string containing vi, gmacs, or emacs, then the corresponding editor mode is enabled. Now, you are ready to perform inline editing. Enabling an editor mode places you into the editor's command mode, although when typing it does not appear anything has changed. This allows you to continue typing and executing command lines as before. It also allows you to type ESC and enter input mode. Once you are in input mode, you can edit the specified line using most vi commands and then re-execute it by typing Return. For example, suppose you type:
Then, before you press the Return, press ESC. Now you can move on the line using Backspace (not LeftArrow) to the point where you made your mistake. Then you execute the vi delete command, x, to remove the extra r and the append command, A, to add the letter e to the end of the line:
The new line and output looks like this:
For a complete listing of all the vi commands usable within the POSIX and Korn Shell vi mode, see the sh-posix(1) and ksh(1) manual pages in the HP-UX Reference. The other editors implemented for inline editing are emacs and gmacs. The only difference between these two editor modes is the function of the CTRL-T command (which transposes characters). With these editors there is no command mode; you are always in input mode. To use emacs or gmacs commands, you hold the CTRL key down while pressing a character key or press ESC followed by a character key. Again, there are different ways to enable emacs or gmacs mode. One is to type:
or
The other is to set either VISUAL or EDITOR as described in “Enabling vi Line Edit Mode”. Now, you are ready to perform inline editing with emacs. As you know, enabling an editor mode places you into the editor's command mode. Although, to you it does not appear anything has changed as you continue typing in and executing command lines. For example, suppose you type:
Before you press the Return, press four CTRL-Bs. This moves you left on the line to the point where you made your first mistake. Then, it is a simple matter of executing the CTRL-D or delete command on the extra r. To move forward again, use CTRL-E to move the cursor to the end of the line. Now, simply type in the rest of the line:
The new line and output looks like this:
There are also ESC sequences that move you forward and backward by words rather than letters: ESCb moves you backward one word and ESCf moves you forward one word. For a complete listing of all the emacs commands usable within the POSIX and Korn Shell emacs mode, see the sh-posix(1) and ksh(1) manual entries in the HP-UX Reference. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||