Indentation

noformnocontent edited this page Oct 28, 2012 · 4 revisions

Indentation

This article is about user-action line indentation, automatic indentation and mode-specific indentation.

Current implementation

a) press TAB and N spaces are inserted at the beginning of the line to match up evenly with N

b) press Shift+TAB and N spaces are removed from the beginning of the line to match up evenly with N

c) if the selection spans multiple lines, indentation is not adjusted to match up evenly with N. This design allows indenting or "dedenting" paragraphs like this:

    foo
     bar
   hello

[Press Shift+TAB]

  foo
   bar
 hello

[Press TAB]

    foo
     bar
   hello

...without "bar" or "hello" getting skewed.

d) When creating a new line the new line will retain the same indentation as the line from which you started. Note that it does actually make an exact copy of the previous indentation, thus any mixed tabs and spaces are retained.

e) Holding down the Alt key while pressing the TAB key circumvents the indentation features and inserts a regular tab character at the current selection.

Configuration properties

Most of the behavior is controlled by kconf/defaults properties:

  • editor/text/indentation represents the string which is used when creating or removing indentations (defaults to two spaces)

  • editor/text/newline represents the string which is used to terminate new lines and defaults to "\n"

  • editor/indent/newline is a boolean value controlling whether Kod performs "magic" when inserting new lines (namely retaining the previous indentation level or not). Defaults to being enabled.

  • editor/indent/tabkey is a boolean value controlling whether Kod translates a TAB key press as indentation adjustment. If disabled, pressing TAB inserts a regular tab character. Defaults to being enabled.