[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In this chapter we describe the commands that are especially useful for the times when you catch a mistake in your text just after you have made it, or change your mind while composing text on the fly.
The most fundamental command for correcting erroneous editing is the
undo command, C-x u or C-_. This command undoes a single
command (usually), a part of a command (in the case of
query-replace
), or several consecutive self-inserting characters.
Consecutive repetitions of C-_ or C-x u undo earlier and
earlier changes, back to the limit of the undo information available.
@xref{Undo}, for for more information.
1.1 Killing Your Mistakes | Commands to kill a batch of recently entered text. | |
1.2 Transposing Text | Exchanging two characters, words, lines, lists... | |
1.3 Case Conversion | Correcting case of last word entered. | |
1.4 Checking and Correcting Spelling | Apply spelling checker to a word, or a whole file. |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Delete last character (delete-backward-char
).
Kill last word (backward-kill-word
).
Kill to beginning of sentence (backward-kill-sentence
).
The <DEL> character (delete-backward-char
) is the most
important correction command. It deletes the character before point.
When <DEL> follows a self-inserting character command, you can think
of it as canceling that command. However, avoid the mistake of thinking
of <DEL> as a general way to cancel a command!
When your mistake is longer than a couple of characters, it might be more convenient to use M-<DEL> or C-x <DEL>. M-<DEL> kills back to the start of the last word, and C-x <DEL> kills back to the start of the last sentence. C-x <DEL> is particularly useful when you change your mind about the phrasing of the text you are writing. M-<DEL> and C-x <DEL> save the killed text for C-y and M-y to retrieve. @xref{Yanking}.
M-<DEL> is often useful even when you have typed only a few characters wrong, if you know you are confused in your typing and aren’t sure exactly what you typed. At such a time, you cannot correct with <DEL> except by looking at the screen to see what you did. Often it requires less thought to kill the whole word and start again.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Transpose two characters (transpose-chars
).
Transpose two words (transpose-words
).
Transpose two balanced expressions (transpose-sexps
).
Transpose two lines (transpose-lines
).
The common error of transposing two characters can be fixed, when they
are adjacent, with the C-t command (transpose-chars
). Normally,
C-t transposes the two characters on either side of point. When
given at the end of a line, rather than transposing the last character of
the line with the newline, which would be useless, C-t transposes the
last two characters on the line. So, if you catch your transposition error
right away, you can fix it with just a C-t. If you don’t catch it so
fast, you must move the cursor back to between the two transposed
characters. If you transposed a space with the last character of the word
before it, the word motion commands are a good way of getting there.
Otherwise, a reverse search (C-r) is often the best way.
@xref{Search}.
M-t (transpose-words
) transposes the word before point
with the word after point. It moves point forward over a word, dragging
the word preceding or containing point forward as well. The punctuation
characters between the words do not move. For example, ‘FOO, BAR’
transposes into ‘BAR, FOO’ rather than ‘BAR FOO,’.
C-M-t (transpose-sexps
) is a similar command for transposing
two expressions (@pxref{Lists}), and C-x C-t (transpose-lines
)
exchanges lines. They work like M-t except in determining the
division of the text into syntactic units.
A numeric argument to a transpose command serves as a repeat count: it tells the transpose command to move the character (word, sexp, line) before or containing point across several other characters (words, sexps, lines). For example, C-u 3 C-t moves the character before point forward across three other characters. It would change ‘f∗oobar’ into ‘oobf∗ar’. This is equivalent to repeating C-t three times. C-u - 4 M-t moves the word before point backward across four words. C-u - C-M-t would cancel the effect of plain C-M-t.
A numeric argument of zero is assigned a special meaning (because otherwise a command with a repeat count of zero would do nothing): to transpose the character (word, sexp, line) ending after point with the one ending after the mark.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Convert last word to lower case. Note Meta-- is Meta-minus.
Convert last word to all upper case.
Convert last word to lower case with capital initial.
A very common error is to type words in the wrong case. Because of this, the word case-conversion commands M-l, M-u and M-c have a special feature when used with a negative argument: they do not move the cursor. As soon as you see you have mistyped the last word, you can simply case-convert it and go on typing. @xref{Case}.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes the commands to check the spelling of a single word or of a portion of a buffer. These commands work with the spelling checker program Ispell, which is not part of Emacs.
Check and correct spelling of word at point (ispell-word
).
Check and correct spelling of each word in the buffer.
Check and correct spelling of each word in the region.
Check and correct spelling of each word in a draft mail message, excluding cited material.
Complete the word before point based on the spelling dictionary.
Restart the ispell process, using dict as the dictionary.
Kill the Ispell subprocess.
To check the spelling of the word around or next to point, and
optionally correct it as well, use the command M-$
(ispell-word
). If the word is not correct, the command offers
you various alternatives for what to do about it.
To check the entire current buffer, use M-x ispell-buffer. Use M-x ispell-region to check just the current region. To check spelling in an email message you are writing, use M-x ispell-message; that checks the whole buffer, but does not check material that is indented or appears to be cited from other messages.
Each time these commands encounter an incorrect word, they ask you what to do. It displays a list of alternatives, usually including several “near-misses”—words that are close to the word being checked. Then you must type a character. Here are the valid responses:
Skip this word—continue to consider it incorrect, but don’t change it here.
Replace the word (just this time) with new.
Replace the word with new, and do a query-replace
so you
can replace it elsewhere in the buffer if you wish.
Replace the word (just this time) with one of the displayed near-misses. Each near-miss is listed with a digit; type that digit to select it.
Accept the incorrect word—treat it as correct, but only in this editing session.
Accept the incorrect word—treat it as correct, but only in this editing session and for this buffer.
Insert this word in your private dictionary file so that Ispell will consider it correct it from now on, even in future sessions.
Insert a lower-case version of this word in your private dictionary file.
Like i, but you can also specify dictionary completion information.
Look in the dictionary for words that match word. These words become the new list of “near-misses”; you can select one of them to replace with by typing a digit. You can use ‘*’ in word as a wildcard.
Quit interactive spell checking. You can restart it again afterward with C-u M-$.
Same as C-g.
Quit interactive spell checking and move point back to where it was when you started spell checking.
Quit interactive spell checking and kill the Ispell subprocess.
Refresh the screen.
This key has its normal command meaning (suspend Emacs or iconify this frame).
The command ispell-complete-word
, which is bound to the key
M-<TAB> in Text mode and related modes, shows a list of
completions based on spelling correction. Insert the beginning of a
word, and then type M-<TAB>; the command displays a completion
list window. To choose one of the completions listed, click
Mouse-2 on it, or move the cursor there in the completions window
and type <RET>. @xref{Text Mode}.
Once started, the Ispell subprocess continues to run (waiting for something to do), so that subsequent spell checking commands complete more quickly. If you want to get rid of the Ispell process, use M-x ispell-kill-ispell. This is not usually necessary, since the process uses no time except when you do spelling correction.
Ispell uses two dictionaries: the standard dictionary and your private
dictionary. The variable ispell-dictionary
specifies the file
name of the standard dictionary to use. A value of nil
says to
use the default dictionary. The command M-x
ispell-change-dictionary sets this variable and then restarts the
Ispell subprocess, so that it will use a different dictionary.
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated on January 15, 2023 using texi2html 5.0.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ Up ] | Up | Up section | 1.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated on January 15, 2023 using texi2html 5.0.