Emacs has commands for moving over or operating on words. By convention, the keys for them are all Meta characters.
forward-word).
backward-word).
kill-word).
backward-kill-word).
mark-word).
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-d (kill-word) kills the word after point. To be
precise, it kills everything from point to the place M-f would
move to. Thus, if point is in the middle of a word, M-d kills
just the part after point. If some punctuation comes between point
and the next word, it is killed along with the word. (If you wish to
kill only the next word but not the punctuation before it, simply do
M-f to get the end, and kill the word backwards with
M-<DEL>.) M-d takes arguments just like M-f.
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>.
M-t (transpose-words) exchanges the word before or
containing point with the following word. The delimiter characters between
the words do not move. For example, ‘FOO, BAR’ transposes into
‘BAR, FOO’ rather than ‘BAR FOO,’. See Transpose, for
more on transposition.
To operate on the next n words with an operation which acts on
the region, use the command M-@ (mark-word). This
command does not move point, but sets the mark where M-f would
move to. Once the mark is active, each additional M-@ advances
the mark by one additional word. M-@ also accepts a numeric
argument that says how many words to scan for the place to put the
mark.
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.
blog comments powered by Disqus