2
* name: Indenter name (appears in the menu)
3
* license: license (BSD, GPL, LGPL, Artistic, etc)
4
* author: first name last name <email-address>
5
* revision: 1 (simple integer number)
9
// specifies the characters which should trigger indent, beside the default '\n'
10
triggerCharacters = "{}/:;";
14
* This function is called for every <return/enter> and for all trigger
15
* characters. ch is the character typed by the user. ch is
17
* - "" empty for the action "Tools > Align"
18
* - all other characters are really typed by the user.
21
* - return -2; - do nothing
22
* - return -1; - keep indentation (searches for previous non-blank line)
23
* - return 0; - All numbers >= 0 are the indent-width in spaces
25
* Alternatively, an array of two elements can be returned:
26
* return [ indent, align ];
28
* The first element is the indent-width like above, with the same meaning
29
* of the special values.
31
* The second element is an absolute value representing a column for
32
* "alignment". If this value is higher than the indent value, the
33
* difference represents a number of spaces to be added after the indent.
34
* Otherwise, it's ignored.
37
* Assume using tabs to indent, and tab width is 4. Here ">" represents a
38
* tab, and "." represents a space:
39
* 1: > > foobar("hello",
40
* 2: > > ......."world")
42
* When indenting line 2, the script returns [8, 15]. Two tabs are inserted
43
* to indent to column 8, and 7 spaces are added to align the second
44
* parameter under the first, so that it stays aligned if the file is viewed
45
* with a different tab width.
47
function indent(line, indentWidth, ch)
52
// kate: space-indent on; indent-width 4; replace-tabs on;