Using automatic indentation
Prev
Next

Using automatic indentation

The Kate editor component supports several autoindenting modes, designed for different text formats. You can pick from the available modes using the Tools->Indentation menu. The autoindent modules also provides a function Tools->Align which will recalculate the indentation of the selected or current line. Thus, you may reindent your entire document by selecting all the text and activating that action.

All the indent modes use the indentation related settings in the active document.

Tip

You can set all sorts of configuration variables, including those related to indentation using Document Variables and File types.

Available Autoindent Modes

None

Selecting this mode turns automatic indentation off entirely.

Normal

This indenter simply keeps the indentation similar to the previous line with any content other than whitespace. You can combine this with using the indent and unindent actions for indenting to your own taste.

C Style

An indenter for C and similar languages, such as C++, C#, java, javascript and so on. This indenter will not work with scripting languages such as Perl or PHP.

Python Style

An indenter specifically designed for the python scripting language.

XML

A very nice XML auto-indenter. However tempting, do not try to use this with HTML other than XHTML, because it fails with the old style HTML tags (open tags like for example <br>)

S&S C Style

An alternative indenter for C and similar languages, with the same constraints.

Variable Based Indenter

The variable based indenter is special in that it can be configured using variables in the document or in a filetype configuration. The following variables are read:

var-indent-indent-after

A regular expression which will cause a line to be indented by one unit, if the first non-whitespace-only line above matches.

var-indent-indent

A regular expression, which will cause a matching line to be indented by one unit if matching.

var-indent-unindent

A regular expression which will cause the line to be unindented by one unit if matching.

var-indent-triggerchars

A list of characters that should cause the indention to be recalculated immediately when typed.

var-indent-handle-couples

A list of paranthesis sets to handle. Any combination of 'paranthesis', 'braces' and 'brackets'. Each set type is handled in the following way. If there are unmatched opening instances on the above line, one indent unit is added. If there are unmatched closing instances on the current line, one indent unit is removed.

var-indent-couple-attribute

When looking for unmatched couple openings/closings, only characters with this attribute are considered. The value must be the attribute name from the syntax xml file, for example "Symbol". If it is not specified, attribute 0 is used (usually 'Normal Text').

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team