Next: , Previous: Words, Up: Text


30.2 Sentences

The Emacs commands for manipulating sentences and paragraphs are mostly on Meta keys, so as to be like the word-handling commands.

M-a
Move back to the beginning of the sentence (backward-sentence).
M-e
Move forward to the end of the sentence (forward-sentence).
M-k
Kill forward to the end of the sentence (kill-sentence).
C-x <DEL>
Kill back to the beginning of the sentence (backward-kill-sentence).

The commands M-a and M-e (backward-sentence and forward-sentence) move to the beginning and end of the current sentence, respectively. They were chosen to resemble C-a and C-e, which move to the beginning and end of a line. Unlike them, M-a and M-e move over successive sentences if repeated.

Moving backward over a sentence places point just before the first character of the sentence; moving forward places point right after the punctuation that ends the sentence. Neither one moves over the whitespace at the sentence boundary.

Just as C-a and C-e have a kill command, C-k, to go with them, so M-a and M-e have a corresponding kill command M-k (kill-sentence) which kills from point to the end of the sentence. With minus one as an argument it kills back to the beginning of the sentence. Larger arguments serve as a repeat count. There is also a command, C-x <DEL> (backward-kill-sentence), for killing back to the beginning of a sentence. This command is useful when you change your mind in the middle of composing text.

The sentence commands assume that you follow the American typist's convention of putting two spaces at the end of a sentence; they consider a sentence to end wherever there is a ‘.’, ‘?’ or ‘!’ followed by the end of a line or two spaces, with any number of ‘)’, ‘]’, ‘'’, or ‘"’ characters allowed in between. A sentence also begins or ends wherever a paragraph begins or ends.

The variable sentence-end controls recognition of the end of a sentence. If non-nil, it is a regexp that matches the last few characters of a sentence, together with the whitespace following the sentence. If the value is nil, the default, then Emacs computes the regexp according to various criteria. The result is normally similar to the following regexp:

     "[.?!][]\"')]*\\($\\| $\\|\t\\|  \\)[ \t\n]*"

This example is explained in the section on regexps. See Regexp Example.

If you want to use just one space between sentences, you should set sentence-end to this value:

     "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*"

This is what setting the variable sentence-end-double-space to nil automatically does. But note that this makes it impossible to distinguish between periods that end sentences and those that indicate abbreviations.