Next: Declaration scanning, Previous: Unicode support, Up: Top [Index]
For general information about indentation support in GNU Emacs, see (emacs)Indentation.
In Haskell, code indentation has semantic meaning as it defines the block structure4.
As GNU Emacs’ default indentation function
(i.e. indent-relative
) is not designed for use with Haskell’s
layout rule, Haskell mode includes indentation rules adapted to
Haskell. haskell-indentation-mode
binds TAB to cycle
through possible indentation points based on some clever heuristics.
SHIFT-TAB cycles in the reverse direction, and RET moves
to a new line and indents to the first possible indentation level.
If you want to use the obsolete haskell-indent-mode
, the
recommended way is to load it in haskell-mode-hook
. This can be
done either by using M-x customize-variable RET
haskell-mode-hook which provides a convenient user interface or by
adding the following line to your .emacs file:
(add-hook 'haskell-mode-hook 'haskell-indent-mode)
This will turn off haskell-indentation-mode
.
haskell-indentation
can move whole blocks to the left or to the
right. Just mark a block and then use TAB or S-TAB.
GNU Emacs provides so-called rectangle commands which operate on rectangular areas of text, which are particularly useful for languages with a layout rule such as Haskell. See (emacs)Rectangles, to learn more about rectangle commands.
Moreover, CUA mode (see (emacs)CUA Bindings) provides enhanced
rectangle support with visible rectangle highlighting. When CUA mode is
active, you can initiate a rectangle selection by C-RET and extend
it simply by movement commands. You don’t have to enable full CUA mode
to benefit from these enhanced rectangle commands; you can activate CUA
selection mode (without redefining C-x,C-c,C-v, and
C-z) by calling M-x cua-selection-mode (or adding
(cua-selection-mode nil)
to your haskell-mode-hook
).
Haskell also supports braces and semicolons notation for conveying the block structure. However, most Haskell programs written by humans use indentation for block structuring.
Next: Declaration scanning, Previous: Unicode support, Up: Top [Index]