How can I get KatePart to autoindent XXX code?

For Kate 3.0 (KDE 4.0) an up, indentation is scripted, that is you can write a javascript that can indent your files. Read Dominiks blog about indentation scripts.

Up to KAte 2.5.x the autoindenters except for Normal which simply indents equally to the first above line that is not blank are all depending on the highlight data, and therefore are not very flexible — for example the C Style indenter can not be used with perl or php code.

A better indentation framework is in the works for KatePart in KDE 4, for now you have these options:

  • You can get decent results with the Variable based indenter in many text formats from bash to perl to CSS, see this article.
  • You can write a indenter yourself, read this article.
  • You can help us writing a better indentation system for the next version of KatePart.