www.delorie.com/gnu/docs/emacs/cc-mode_17.html   search  
 
Buy the book!


CC Mode Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2 Movement Commands

CC Mode contains some useful command for moving around in C code.

M-x c-beginning-of-defun
Moves point back to the least-enclosing brace. This function is analogous to the Emacs built-in command beginning-of-defun, except it eliminates the constraint that the top-level opening brace must be in column zero. See beginning-of-defun for more information.

Depending on the coding style being used, you might prefer c-beginning-of-defun to beginning-of-defun. If so, consider binding C-M-a to the former instead. For backwards compatibility reasons, the default binding remains in effect.

M-x c-end-of-defun
Moves point to the end of the current top-level definition. This function is analogous to the Emacs built-in command end-of-defun, except it eliminates the constraint that the top-level opening brace of the defun must be in column zero. See beginning-of-defun for more information.

Depending on the coding style being used, you might prefer c-end-of-defun to end-of-defun. If so, consider binding C-M-e to the former instead. For backwards compatibility reasons, the default binding remains in effect.

C-c C-u (c-up-conditional)
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 treated like `#else' followed by `#if', so the function stops at them when going backward, but not when going forward.

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 point forward into the next nested preprocessor conditional, leaving the mark behind. A prefix argument acts as a repeat count. With a negative argument, move point 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)
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 (c-forward-conditional)
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 (c-beginning-of-statement)
Move point to the beginning of the innermost C statement. If point is already at the beginning of a statement, move to the beginning of the closest preceding statement, even if that means moving into a block (you can use M-C-b to move over a balanced block). With prefix argument n, move back n - 1 statements.

If point is within or next to a comment or a string which spans more than one line, this command moves by sentences instead of statements.

When called from a program, this function takes 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.

M-e (c-end-of-statement)
Move point to the end of the innermost C statement. If point is at the end of a statement, move to the end of the next statement, even if it's inside a nested block (use M-C-f to move to the other side of the block). With prefix argument n, move forward n - 1 statements.

If point is within or next to a comment or a string which spans more than one line, this command moves by sentences instead of statements.

When called from a program, this function takes 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.

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'.

This command moves point forward to next capitalized word. With prefix argument n, move n times.

M-x c-backward-into-nomenclature
Move point backward to beginning of the next capitalized word. With prefix argument n, move n times. If n is negative, move forward.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003