预计阅读本页时间:-
Word Commands
The basic commands are really all you need to get around a command line, but a set of more advanced commands lets you do it with fewer keystrokes. These commands operate on words rather than single characters; emacs-mode defines a word as a sequence of one or more alphanumeric characters.
The word commands are shown in Table 2-2. The basic commands are all single characters, whereas these consist of two keystrokes, ESC followed by a letter. You will notice that the command ESC X, where X is any letter, often does for a word what CTRL-X does for a single character. "Kill" is another word for "delete"; it is the standard term used in the readline library documentation for an "undoable" deletion.
广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元
Table 2-2. emacs-mode word commands
Command
Description
ESC-B
Move one word backward
ESC-F
Move one word forward
ESC-DEL
Kill one word backward
ESC-CTRL-H
Kill one word backward
ESC-D
Kill one word forward
CTRL-Y
Retrieve ("yank") last item killed
To return to our example: if we type ESC-B, point will move back a word. Since the underscore (_) is not an alphanumeric character, emacs-mode will stop there:
$ grep -l Duchess < ~cam/book/alice_in_[w]onderland
The cursor is on the w in wonderland, and point is between the _ and the w. Now let's say we want to change the -l option of this command from Duchess to Cheshire. We need to move back on the command line, so we type ESC-B four more times. This gets us here:
$ grep -l Duchess < ~[c]am/book/alice_in_wonderland
If we type ESC-B again, we end up at the beginning of Duchess:
$ grep -l [D]uchess < ~cam/book/alice_in_wonderland
Why? Remember that a word is defined as a sequence of alphanumeric characters only. Therefore < is not a word; the next word in the backward direction is Duchess. We are now in position to delete Duchess, so we type ESC-D and get:
$ grep -l []< ~cam/book/alice_in_wonderland
Now we can type in the desired argument:
$ grep -l Cheshire[]< ~cam/book/alice_in_wonderland
If you want Duchess back again you can use the CTRL-Y command. The CTRL-Y "yank" command will undelete a word if the word was the last thing deleted. In this case, CTRL-Y would insert Duchess at the point.