Next: , Previous: Motion, Up: Top


4 Indentation

PHP mode's indentation settings follow the PHP PEAR “Coding Standards”1. This has the consequence in PHP mode of making the indentation commands use four spaces, and not tabs.

PHP does not appropriately indent HTML tags. See Embedded HTML.

To customize PHP mode's indentation rules, change the following variables.

c-basic-offset
This style variable of CC mode controls how many columns in the level of indentation. By default this is 4 spaces in PHP mode (and in CC mode).
indent-tabs-mode
Variable of Emacs that determines whether indentation commands should insert the tab character or insert the equivalent number of space characters. In PHP mode, this is set to to nil by default.
tab-width
This variable of Emacs determines how “wide” a tab in the buffer should be considered. This is also traditionally described as setting the distance between “tab stops”. By default, tabs are not inserted by PHP mode.

The usual commands for indenting in Emacs2 and Emacs's C mode3: are supported in PHP mode, following the indentation rules of PHP.

TAB
Properly indent current line, even from the middle of the line (c-indent-command).
C-j
Insert text after point to a newline, and properly indent the newline (c-indent-command).
C-M-\
Properly indent each line of region (indent-region).
C-c C-q
Properly indent each line of current top-level function or top-level class (c-indent-defun).

Footnotes

[1] http://pear.php.net/manual/en/standards.php

[2] See Indentation Commands.

[3] See Indentation Commands.