Search code examples
eclipseeclipse-cdtindentation

Eclipse: use both tabs and spaces for indentation


A project I'm working in has an indentation standard as follows:

  • A single tab-width is 4 space characters.
  • A double tab-width is a tab character displayed at 8 spaces wide.

Examples:

  • A singly-indented line begins with four spaces
  • A doubly-indented line begins with a tab character
  • A triply-indented line begins with a tab character followed by four spaces
  • A 4x indented line begins with two tab characters
  • ...and so on

In Vim, the necessary configuration is achieved with:

:set tabstop=8 softtabstop=4 noexpandtab

How can I configure Eclipse to automatically enforce this indentation standard?


Solution

  • Eclipse does support this natively.

    My eclipse version: My Eclipse version

    The result (see in-image comments):
    The result

    Step 1:
    1

    Step 2:
    2

    Step 3:
    3

    Step 4 (the most important step):
    4