next up previous contents
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.

A..1 Emacs

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)

A..2 Kate

In kate you set the indentation setting through the graphical user interface. Do the following
  1. Choose menu Settings $\rightarrow$ Configure Kate.
  2. In the tree, choose Editor $\rightarrow$ Editing.
  3. Set your preferred value in Tab and indent width.

A..3 Vi

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