[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These commands move point or set up the region based on top-level major definitions, also called defuns.
beginning-of-defun
).
end-of-defun
).
mark-defun
).
The commands to move to the beginning and end of the current defun
are C-M-a (beginning-of-defun
) and C-M-e
(end-of-defun
). If you repeat one of these commands, or use a
positive numeric argument, each repetition moves to the next defun in
the direction of motion.
C-M-a with a negative argument -n moves forward n times to the next beginning of a defun. This is not exactly the same place that C-M-e with argument n would move to; the end of this defun is not usually exactly the same place as the beginning of the following defun. (Whitespace, comments, and perhaps declarations can separate them.) Likewise, C-M-e with a negative argument moves back to an end of a defun, which is not quite the same as C-M-a with a positive argument.
To operate on the current defun, use C-M-h (mark-defun
)
which puts point at the beginning and mark at the end of the current
defun. This is the easiest way to get ready to kill the defun in
order to move it to a different place in the file. If you use the
command while point is between defuns, it uses the following defun.
In C mode, C-M-h runs the function c-mark-function
,
which is almost the same as mark-defun
; the difference is that
it backs up over the argument declarations, function name and returned
data type so that the entire C function is inside the region. This is
an example of how major modes adjust the standard key bindings so that
they do their standard jobs in a way better fitting a particular
language. Other major modes may replace any or all of these key
bindings for that purpose.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |