Skip to main content

26.12.1 C Mode Motion Commands

This section describes commands for moving point, in C mode and related modes.

C-M-a​

C-M-e​

Move point to the beginning or end of the current function or top-level definition. In languages with enclosing scopes (such as C++’s classes) the current function is the immediate one, possibly inside a scope. Otherwise it is the one defined by the least enclosing braces. (By contrast, beginning-of-defun and end-of-defun search for braces in column zero.) See Moving by Defuns.

C-c C-u​

Move point back to the containing preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move point forward to the end of the containing preprocessor conditional.

‘#elif’ is equivalent to ‘#else’ followed by ‘#if’, so the function will stop at a ‘#elif’ when going backward, but not when going forward.

C-c C-p​

Move point back over a preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move forward.

C-c C-n​

Move point forward across a preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move backward.

M-a​

Move point to the beginning of the innermost C statement (c-beginning-of-statement). If point is already at the beginning of a statement, move to the beginning of the preceding statement. With prefix argument n, move back n - 1 statements.

In comments or in strings which span more than one line, this command moves by sentences instead of statements.

M-e​

Move point to the end of the innermost C statement or sentence; like M-a except that it moves in the other direction (c-end-of-statement).