预计阅读本页时间:-
Miscellaneous Commands
Several miscellaneous commands complete emacs editing mode; they are shown in Table 2-6.
Table 2-6. emacs-mode miscellaneous commands
广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元
Command
Description
CTRL-J
Same as RETURN
CTRL-L
Clears the screen, placing the current line at the top of the screen
CTRL-M
Same as RETURN
CTRL-O
Same as RETURN, then display next line in command history
CTRL-T
Transpose two characters on either side of point and move point forward by one
CTRL-U
Kills the line from the beginning to point
CTRL-V
Quoted insert
CTRL-[
Same as ESC (most keyboards)
ESC-C
Capitalize word after point
ESC-U
Change word after point to all capital letters
ESC-L
Change word after point to all lowercase letters
ESC-.
Insert last word in previous command line after point
ESC-_
Same as ESC-.
BSD-derived systems use CTRL-V and CTRL-W as default settings for the "quote next character" and "word erase" terminal interface functions, respectively.
A few of these miscellaneous commands are worth discussing, even though they may not be among the most useful emacs-mode commands.
CTRL-O is useful for repeating a sequence of commands you have already entered. Just go back to the first command in the sequence and press CTRL-O instead of RETURN. This will execute the command and bring up the next command in the history list. Press CTRL-O again to enter this command and bring up the next one. Repeat this until you see the last command in the sequence; then just hit RETURN.
Of the case-changing commands, ESC-L is useful when you hit the CAPS LOCK key by accident and don't notice it immediately. Since all-caps words aren't used too often in the UNIX world, you probably won't use ESC-U very often.
CTRL-V will cause the next character you type to appear in the command line as is; i.e., if it is an editing command (or an otherwise special character like CTRL-D), it will be stripped of its special meaning.
If it seems like there are too many synonyms for RETURN, bear in mind that CTRL-M is actually the same (ASCII) character as RETURN, and that CTRL-J is actually the same as LINEFEED, which UNIX usually accepts in lieu of RETURN anyway.
ESC-. and ESC-_ are useful if you want to run several commands on a given file. The usual UNIX convention is that a filename is the last argument to a command. Therefore you can save typing by just entering each command followed by SPACE and then typing ESC-. or ESC-_. For example, say you want to examine a file using more, so you type:
$ more myfilewithaverylongname
Then you decide you want to print it, so you type the print command lp. You can avoid typing the very long name by typing lp followed by a space and then ESC-. or ESC-_; bash will insert myfilewithaverylongname for you.
[3] Not available in versions of bash prior to 2.05a.
[4] emacs users will recognize this as minibuffer completion.