ccmode: Movement Commands
4.3 Movement Commands
=====================
CC Mode contains some useful commands for moving around in C code.
‘C-M-a’ (‘c-beginning-of-defun’)
‘C-M-e’ (‘c-end-of-defun’)
Move to the beginning or end of the current or next function.
Other constructs (such as a structs or classes) which have a brace
block also count as “functions” here. To move over several
functions, you can give these commands a repeat count.
The start of a function is at its header. The end of the function
is after its closing brace, or after the semicolon of a construct
(such as a ‘struct’) which doesn’t end at the brace. These two
commands try to leave point at the beginning of a line near the
actual start or end of the function. This occasionally causes
point not to move at all.
By default, these commands will recognize functions contained
within a “declaration scope” such as a C++ ‘class’ or ‘namespace’
construct, should the point start inside it. If CC Mode fails to
find function beginnings or ends inside the current declaration
scope, it will search the enclosing scopes. If you want CC Mode to
recognize functions only at the top level(1), set ‘c-defun-tactic’
to ‘t’.
These functions are analogous to the Emacs built-in commands
‘beginning-of-defun’ and ‘end-of-defun’, except they eliminate the
constraint that the top-level opening brace of the defun must be in
column zero. See (emacs)Defuns, for more information.
‘C-M-a’ (AWK Mode) (‘c-awk-beginning-of-defun’)
‘C-M-e’ (AWK Mode) (‘c-awk-end-of-defun’)
Move to the beginning or end of the current or next AWK defun.
These commands can take prefix-arguments, their functionality being
entirely equivalent to ‘beginning-of-defun’ and ‘end-of-defun’.
AWK Mode “defuns” are either pattern/action pairs (either of which
might be implicit) or user defined functions. Having the ‘{’ and
‘}’ (if there are any) in column zero, as is suggested for some
modes, is neither necessary nor helpful in AWK mode.
‘M-a’ (‘c-beginning-of-statement’)
‘M-e’ (‘c-end-of-statement’)
Move to the beginning or end of the innermost C statement. If
point is already there, move to the next beginning or end of a
statement, even if that means moving into a block. (Use ‘C-M-b’ or
‘C-M-f’ to move over a balanced block.) A prefix argument N means
move over N statements.
If point is within or next to a comment or a string which spans
more than one line, these commands move by sentences instead of
statements.
When called from a program, these functions take three optional
arguments: the repetition count, a buffer position limit which is
the farthest back to search for the syntactic context, and a flag
saying whether to do sentence motion in or near comments and
multiline strings.
‘C-c C-u’ (‘c-up-conditional’)
Move back to the containing preprocessor conditional, leaving the
mark behind. A prefix argument acts as a repeat count. With a
negative argument, move forward to the end of the containing
preprocessor conditional.
‘#elif’ is treated like ‘#else’ followed by ‘#if’, so the function
stops at them when going backward, but not when going forward.
This key sequence is not bound in AWK Mode, which doesn’t have
preprocessor statements.
‘M-x c-up-conditional-with-else’
A variety of ‘c-up-conditional’ that also stops at ‘#else’ lines.
Normally those lines are ignored.
‘M-x c-down-conditional’
Move forward into the next nested preprocessor conditional, leaving
the mark behind. A prefix argument acts as a repeat count. With a
negative argument, move backward into the previous nested
preprocessor conditional.
‘#elif’ is treated like ‘#else’ followed by ‘#if’, so the function
stops at them when going forward, but not when going backward.
‘M-x c-down-conditional-with-else’
A variety of ‘c-down-conditional’ that also stops at ‘#else’ lines.
Normally those lines are ignored.
‘C-c C-p’ (‘c-backward-conditional’)
‘C-c C-n’ (‘c-forward-conditional’)
Move backward or forward across a preprocessor conditional, leaving
the mark behind. A prefix argument acts as a repeat count. With a
negative argument, move in the opposite direction.
These key sequences are not bound in AWK Mode, which doesn’t have
preprocessor statements.
‘M-x c-backward-into-nomenclature’
‘M-x c-forward-into-nomenclature’
A popular programming style, especially for object-oriented
languages such as C++ is to write symbols in a mixed case format,
where the first letter of each word is capitalized, and not
separated by underscores. E.g.,
‘SymbolsWithMixedCaseAndNoUnderlines’.
These commands move backward or forward to the beginning of the
next capitalized word. With prefix argument N, move N times. If N
is negative, move in the opposite direction.
Note that these two commands have been superseded by
‘subword-mode’, which you should use instead. Subword
Movement. They might be removed from a future release of CC
Mode.
---------- Footnotes ----------
(1) this was CC Mode’s behavior prior to version 5.32.