Next: , Up: Text   [Contents][Index]

25.1 Words

Emacs defines several commands for moving over or operating on words:


Move forward over a word (forward-word).


Move backward over a word (backward-word).








Transpose two words or drag a word across others (transpose-words).

Notice how these keys form a series that parallels the character-based C-f, C-b, C-d, DEL and C-t. M-@ is cognate to C-@, which is an alias for C-SPC.

The commands M-f (forward-word) and M-b (backward-word) move forward and backward over words. These META-based key sequences are analogous to the key sequences C-f and C-b, which move over single characters. The analogy extends to numeric arguments, which serve as repeat counts. M-f with a negative argument moves backward, and M-b with a negative argument moves forward. Forward motion stops right after the last letter of the word, while backward motion stops right before the first letter.


M-DEL (backward-kill-word) kills the word before point. It kills everything from point back to where M-b would move to. For instance, if point is after the space in ‘FOO, BAR, it kills ‘FOO, . If you wish to kill just ‘FOO’, and not the comma and the space, use M-b M-d instead of M-DEL.


To operate on words with an operation which acts on the region, use the command M-@ (mark-word). This command sets the mark where M-f would move to. See Marking Objects, for more information about this command.

The word commands’ understanding of word boundaries is controlled by the syntax table. Any character can, for example, be declared to be a word delimiter. See Syntax Tables in The Emacs Lisp Reference Manual.

In addition, see Position Info for the M-= (count-words-region) and M-x count-words commands, which count and report the number of words in the region or buffer.

Next: , Up: Text   [Contents][Index]