This key combination, a binding inherited from the
emacs editor, causes the last 2 characters typed to be swapped at the end of the line, used in the middle of a line, it swaps the character at the left of the cursor and the one under the cursor.
It may seem vain to have a binding for such a seldom used feature that be easily achieved with a few more key strokes. Old timers such as I use it quite often and it used to save some transmission time back in the days of 300 baud modems, in the late '70s, especially in the middle of long lines.
A similar and more useful command, bound to Alt+T, transposes the words at the left and at the right of the cursor.
T was chosen because it is the initial letter of transpose. Other bindings with similar origin include:
- Ctrl+B, for backward, moves the cursor left one position,
- Alt+B moves the cursor left one word,
- Ctrl+F, for forward, moves the cursor right one position,
- Alt+F moves the cursor right one word,
- Ctrl+A, for Anfang or ante, moves the cursor to the beginning of the line,
- Ctrl+E, for end, moves the cursor to the end of the line,
- Ctrl+N, for next, retrieves the next line,
- Ctrl+P, for previous, retrieves the next line,
- Ctrl+D, for delete, deletes the character under the cursor,
- Alt+D deletes the word under the cursor,
- Ctrl+K, for kill, cuts the end of the line,
- Ctrl+Y, for yank, pastes the contents of the clipboard,
These bindings, implemented in the GNU readline package, are therefore available in all programs that use it for user input, such as bash, but also gdb, bc, ...
Some of the are also available in other environments: The Firefox URL input line, text input fields in the OS/X graphical interface, and many X-based window managers.
vim users can select the corresponding bindings via an environment variable.