Next: , Previous: , Up: Editing Programs   [Contents][Index]


7.2 Indentation

Nearly all programming languages have conventions for indentation or leading whitespace at the beginning of lines. The Hemlock indentation facility is integrated into the command set so that it interacts well with other features such as filling and commenting.

Command: Indent (bound to Tab, C-i)

This command indents the current line. With a prefix argument, indents that many lines and moves down. Exactly what constitutes indentation depends on the current mode (see Indent Function).

Command: Indent New Line (bound to Linefeed)

This command starts a new indented line. Deletes any whitespace before the point and inserts indentation on a blank line. The effect of this is similar to Return followed by Tab. The prefix argument is passed to New Line, which is used to insert the blank line.

Command: Indent Region (bound to C-M-\)

This command indents every line in the region. It may be undone with Undo.

Command: Back to Indentation (bound to M-m, C-M-m)

This command moves point to the first non-whitespace character on the current line.

Command: Delete Indentation (bound to M-^, C-M-^)

Delete Indentation joins the current line with the previous one, deleting excess whitespace. This operation is the inverse of the Linefeed command in most modes. Usually this leaves one space between the two joined lines, but there are several exceptions.

The non-whitespace immediately surrounding the deleted line break determine the amount of space inserted.

  1. If the preceding character is an "(" or the following character is a ")", then this inserts no space.
  2. If the preceding character is a newline, then this inserts no space. This will happen if the previous line was blank.
  3. If the preceding character is a sentence terminator, then this inserts two spaces.

When given a prefix argument, this command joins the current and next lines, rather than the previous and current lines.

Command: Quote Tab (bound to M-Tab)

This command inserts a tab character.

Command: Indent Rigidly (bound to C-x Tab, C-x C-i)

This command changes the indentation of all the lines in the region. Each line is moved to the right by the number of spaces specified by the prefix argument, which defaults to eight. A negative prefix argument moves lines left.

Command: Center Line

This indents the current line so that it is centered between the left margin and Fill Column. If a prefix argument is supplied, then it is used as the width instead of Fill Column.

Hemlock Variable: Indent Function (initial value tab-to-tab-stop)

The value of this variable determines how indentation is done, and it is a function which is passed a mark as its argument. The function should indent the line which the mark points to. The function may move the mark around on the line. The mark will be :left-inserting. The default simply inserts a tab character at the mark.

Hemlock Variable: Indent with Tabs (initial value indent-using-tabs)
Hemlock Variable: Spaces per Tab (initial value 8)

Indent with Tabs holds a function that takes a mark and a number of spaces. The function will insert a maximum number of tabs and a minimum number of spaces at mark to move the specified number of columns. The default definition uses Spaces per Tab to determine the size of a tab. Note, Spaces per Tab is not used everywhere in Hemlock yet, so changing this variable could have unexpected results.


Next: Language Modes, Previous: Comment Manipulation, Up: Editing Programs   [Contents][Index]