Next: B. Operator Precedence Order
Up: c++_coding_guidelines
Previous: Bibliography
Contents
Subsections
A. Indentation in Selected Text Editors
Note, every indentation level must be one tab each.
For emacs I want 2 space indentation, and this is
accomplished in the below excerpt from my .emacs file. Every
indentation level will generate a tab character in the file,
but displayed as 2 space characters. If you want to change indentation
to something else than 2, you must change both 2 characters
below.
(defun my-c-mode-hook ()
(setq c-basic-offset 2)
(setq-default tab-width 2)
(setq-default indent-tabs-mode t))
(add-hook 'c-mode-hook 'my-c-mode-hook)
(add-hook 'c++-mode-hook 'my-c-mode-hook)
In kate you set the indentation setting through the graphical
user interface. Do the following
- Choose menu Settings Configure Kate.
- In the tree, choose Editor Editing.
- Set your preferred value in Tab and indent width.
To get proper display of tab in vi (and clones?) you need to
add one line in .vimrc:
set tabstop=2
set sw=2
set ai
where you change the 2s to fit your preference. set ai
turns auto indentation on.
Jari Häkkinen
2016-06-13