Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When indenting a block of code in Kate (3.11.2), spaces used for alignment are replaced by tabs, ruining all alignments and putting me in the hell of restoring all these spaces.


if (true)
—→$foo = 'bar'.

(—→ are tabs, spaces)

I indent using two characters wide tabs. The problem is when I select these lines and press the Tab key to add an indentation level: it replaces groups of two spaces by one tab:

—→if (true)
—→—→$foo = 'bar'.

Removing the last (odd) space. This is wrong since tabs width is undefined and must be able to vary without breaking the code presentation.

In my settings (Editor Component → Editing → Indentation), I set Indent using on Tabulators and Spaces but it doesn't save it and returns immediately on Tabulators.

Is it a bug? Or is my Kate misconfigured?

share|improve this question
up vote 3 down vote accepted

Being a Kate developer, the answer is as follows:

Kate's indentation system supports the concept of indentation and alignment:

Alternatively, an array of two elements can be returned:

   return [ indent, align ];

In this case, the first element is the indentation depth as above with the same meaning of the special values. However, the second element is an absolute value representing a column for "alignment". If this value is higher than the indent value, the difference represents a number of spaces to be added after the indentation of the first parameter. Otherwise, the second number is ignored. Using tabs and spaces for indentation is often referred to as "mixed mode".

So theoretically it works. However, in practice the "C Style" indenter and most other indenters do not support this. Instead, they just return the indentation level without distinguishing indentation from alignment.

In other words: The feature you want is not implemented.

The good news is that all these indenters are written in JavaScript and can therefore be changed very easily. Contributions are always welcome at kwrite-devel@kde.org. So if you are interested in working on this, please contact us!

share|improve this answer
I would like to add: Whenever you write an indenter or extend Kate in any way, please contribute your work to kwrite-devel@kde.org. We are always happy to accept patches to make Kate an even better text editor - thanks! – dhaumann Feb 7 '14 at 10:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.