O'Reilly logo

Learning GNU Emacs, Second Edition by Eric S. Raymond, Bill Rosenblatt, Debra Cameron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Editing Tricks and Shortcuts

Now that you’ve learned the basics of editing--moving the cursor to the right position, deleting, copying, and moving text—you can learn some tricks that make editing easier.

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 ESC t. After Emacs has finished, the cursor follows the second of the two (transposed) words:

Before ESC t

After ESC t

one three two

one two three

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-5 summarizes the transposition commands.

Table 3-5. Transposition Commands

Keystrokes

Command Name

Action

C-t

transpose-chars

Transpose two letters.

ESC t

transpose-words

Transpose two words.

C-x C-t

transpose-lines ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required