Next: , Previous: , Up: Modification Commands   [Contents][Index]


2.3.7 Transposition Commands

Hemlock provides a number of transposition commands. A transposition command swaps the "things" before and after the point and moves forward one "thing". Just how a "thing" is defined depends on the particular transposition command. Transposition commands, particularly Transpose Characters and Transpose Words, are useful for correcting typos. More obscure transposition commands can be used to amaze your friends and demonstrate your immense knowledge of exotic Emacs commands.

To the uninitiated, the behavior of transposition commands may seem mysterious; this has led some implementors to attempt to improve the definition of transposition, but right-thinking people will accept no substitutes. The Emacs transposition definition used in Hemlock has two useful properties:

  1. Repeated applications of a transposition command have a useful effect. The way to visualize this effect is that each use of the transposition command drags the previous thing over the next thing. It is possible to correct double transpositions easily using Transpose Characters.
  2. Transposition commands move backward with a negative prefix argument, thus undoing the effect of the equivalent positive argument.
Command: Transpose Characters (bound to C-t)

This command exchanges the characters on either side of the point and moves forward, unless at the end of a line, in which case it transposes the previous two characters without moving.

Command: Transpose Lines (bound to C-x C-t)

This command transposes the previous and current line, moving down to the next line. With a zero argument, it transposes the current line and the line the mark is on.

Command: Transpose Words (bound to M-t)

This command transposes the previous word and the current or next word.

Command: Transpose Regions (bound to C-x t)

This command transposes two regions with endpoints defined by the mark stack and point. To use this command, place three marks (in order) at the start and end of the first region, and at the start of the second region, then place the point at the end of the second region. Unlike the other transposition commands, a second use will simply undo the effect of the first use, and to do even this, you must reactivate the current region.


Next: Whitespace Manipulation, Previous: Case Modification Commands, Up: Modification Commands   [Contents][Index]