++, and Java buffers?
cc-mode features an interactive procedure for
customizing the indentation style, which is fully explained in the
CC Mode manual that is part of the Emacs distribution, see
Customization Indentation in The CC Mode Manual. Here’s a short summary of the procedure:
No extra indentation.
Indent one basic offset.
Outdent one basic offset.
Indent two basic offsets
Outdent two basic offsets.
Indent half basic offset.
Outdent half basic offset.
(c-set-offset 'syntactic-symbol offset)
where syntactic-symbol is the name Emacs shows in the minibuffer
when you type C-c C-o at the beginning of the line, and
offset is one of the indentation symbols listed above (
0, etc.) that you’ve chosen during the interactive
It is recommended to put all the resulting
customizations inside a C mode hook, like this:
(defun my-c-mode-hook () (c-set-offset ...) (c-set-offset ...)) (add-hook 'c-mode-hook 'my-c-mode-hook)
c-mode-hook avoids the need to put a
(require 'cc-mode) into your init file, because
c-set-offset might be
cc-mode is not loaded.
c-mode-hook runs for C source files only; use
c++-mode-hook for C
Java sources, etc. If you want the same customizations to be in
effect in all languages supported by