[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
8.1 Indentation Commands | ||
8.2 Movement Commands | ||
8.3 Other Commands |
See also 5. Text Filling and Line Breaking and 6. Macro Handling, for commands concerning those bits.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following list of commands reindent C constructs. Note that when you change your coding style, either interactively or through some other means, your file does not automatically get reindented. You will need to execute one of the following commands to see the effects of your changes.
Also, variables like c-hanging-*
and c-cleanup-list
only affect how on-the-fly code is formatted. Changing the
"hanginess" of a brace and then reindenting, will not move the brace
to a different line. For this, you're better off getting an external
program like GNU indent
, which will rearrange brace location,
among other things.
Reindenting large sections of code can take a long time. When CC Mode reindents a region of code, it is essentially equivalent to hitting TAB on every line of the region.
These commands are useful when indenting code:
c-indent-command
)
c-tab-always-indent
,
c-insert-tab-function
, and indent-tabs-mode
. With a
numeric argument, this command rigidly indents the region, preserving
the relative indentation among the lines.
c-indent-exp
)
c-indent-defun
)
indent-region
)
indent-for-comment
)
c-indent-comment-alist
, c-indent-comments-syntactically-p
and comment-column
. Then position the point after the comment
starter. This is a standard Emacs command, but CC Mode enhances it a
bit with two variables:
comment-column
. See the documentation string for
c-indent-comment-alist
for a full description of the available
line types and actions (use C-h v c-indent-comment-alist).
nil
, M-; will indent
comment-only lines according to c-indent-comment-alist
, just as
it does with lines where other code precede the comments. However, if
you want it to act just like TAB for comment-only lines you can
get that by setting c-indent-comments-syntactically-p
to
non-nil
.
If c-indent-comments-syntactically-p
is non-nil
then
c-indent-comment-alist
won't be consulted at all for comment-only
lines.
c-mark-function
)
c-indent-defun
, this command operates on
top-level constructs, and can't be used to mark say, a Java method.
These variables are also useful when indenting code:
c-indent-command
)
operates. When it is t
, TAB always indents the current
line. When it is nil
, the line is indented only if point is at
the left margin, or on or before the first non-whitespace character on
the line, otherwise some whitespace is inserted. If this variable is
some other value (not nil
or t
), then some whitespace is
inserted only within strings and comments (literals), but the line is
always reindented.
c-insert-tab-function
is
called. Normally, this just inserts a real tab character, or the
equivalent number of spaces, depending on indent-tabs-mode
.
Some people, however, set c-insert-tab-function
to
tab-to-tab-stop
so as to get hard tab stops when indenting.
nil
, tabs can be used in a line's
indentation, otherwise only spaces can be used.
nil
to
inhibit the progress messages, or set it to an integer which is how
often (in seconds) progress messages are to be displayed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
CC Mode contains some useful commands for moving around in C code.
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.
In AWK mode, a defun doesn't necessarily have braces at all. AWK Mode therefore has its own version of this function which is bound by default to C-M-a. You can thus chose freely which function to bind to C-M-a for the other modes without worrying about AWK buffers. See section 12.3 AWK Mode Defuns.
end-of-defun
,
except it eliminates the constraint that the top-level opening brace of
the defun must be in column zero. See end-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.
In AWK Mode, a defun doesn't necessarily have braces at all. AWK Mode therefore has its own version of this function which is bound by default to C-M-e. You can thus chose freely which function to bind to C-M-e for the other modes without worrying about AWK buffers. 12.3 AWK Mode Defuns.
c-up-conditional
)
`#elif' is treated like `#else' followed by `#if', so the function stops at them when going backward, but not when going forward.
c-up-conditional
that also stops at `#else'
lines. Normally those lines are ignored.
`#elif' is treated like `#else' followed by `#if', so the function stops at them when going forward, but not when going backward.
c-down-conditional
that also stops at `#else'
lines. Normally those lines are ignored.
c-backward-conditional
)
c-forward-conditional
)
c-beginning-of-statement
)
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.
c-end-of-statement
)
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.
This command moves point forward to next capitalized word. With prefix argument n, move n times.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here are the various other commands that didn't fit anywhere else:
c-scope-operator
)
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.