Книга: Learning GNU Emacs, 3rd Edition
2.5.1 Fixing Transpositions
2.5.1 Fixing Transpositions
The most common typo involves the transposition of two letters, and most typos are noticed immediately after you make them. Pressing C-t transposes two letters, to put them in the right order:
Before C-t | After C-t |
---|---|
the best of timse, it |
the best of times _ it |
To transpose two letters, put the cursor on the second of the two letters to be transposed. Press C-t. (If you often transpose letters, word abbreviation mode, discussed in Chapter 3, cleans up typos automatically.)
You can also transpose two words, lines, paragraphs, or sentences. To transpose two words, put the cursor between the two words and press M-t. After Emacs has finished, the cursor follows the second of the two (transposed) words:
Before M-t | After M-t |
---|---|
one three _two |
one two three _ |
Interestingly, Emacs moves words, but not punctuation. Let's say that two names are reversed:
Before M-t | After M-t |
---|---|
Charles, Dickens |
Dickens, Charles _ |
To transpose two lines, put the cursor anywhere on the second of the two and press C-x C-t. Emacs moves the second before the first:
Before C-x C-t | After C-x C-t |
---|---|
second line |
first line |
first line |
second line |
third line |
third line |
Table 2-9 summarizes the transposition commands.
Table 2-9. Transposition commands
Keystrokes | Command name | Action |
---|---|---|
C-t | transpose-chars | Transpose two letters. |
M-t | transpose-words | Transpose two words. |
C-x C-t | transpose-lines | Transpose two lines. |
(none) | transpose-sentences | Transpose two sentences. |
(none) | transpose-paragraphs | Transpose two paragraphs. |