<html lang="en">
<head>
<title>Indentation - PHP Mode Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="PHP Mode Manual">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="Motion.html#Motion" title="Motion">
<link rel="next" href="Editing.html#Editing" title="Editing">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual documents PHP mode version 1.4.0 for
use with GNU Emacs.
Copyright (C) 2008 Aaron S. Hawley
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.2 or any later version published by the Free Software
Foundation; with no Invariant Sections, and no Cover Texts. A
copy of the license is included in the section entitled ``Copying
This Manual.''
A copy of the license is also available from the Free Software
Foundation Web site at `http://www.gnu.org/licenses/fdl.html'.
The document was typeset with
GNU Texinfo (http://www.texinfo.org/).
$Date: 2008-01-03 20:50:20 -0500 (Thu, 03 Jan 2008) $
$Revision: 30 $-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Indentation"></a>
Next: <a rel="next" accesskey="n" href="Editing.html#Editing">Editing</a>,
Previous: <a rel="previous" accesskey="p" href="Motion.html#Motion">Motion</a>,
Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">4 Indentation</h2>
<p><a name="index-indentation-68"></a><a name="index-PEAR-69"></a><a name="index-spaces-70"></a><a name="index-tabs-71"></a>PHP mode's indentation settings follow the PHP PEAR “Coding
Standards”<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>.
This has the consequence in PHP mode of making the
indentation commands use four spaces, and not tabs.
<p><a name="index-HTML-72"></a>PHP does not appropriately indent HTML tags. See <a href="Embedded-HTML.html#Embedded-HTML">Embedded HTML</a>.
<p>To customize PHP mode's indentation rules, change the
following variables.
<a name="index-indentation-level-73"></a>
<a name="index-c_002dbasic_002doffset-74"></a>
<dl><dt><code>c-basic-offset</code><dd>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).
<a name="index-indent_002dtabs_002dmode-75"></a><br><dt><code>indent-tabs-mode</code><dd>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.
<a name="index-tab_002dwidth-76"></a><br><dt><code>tab-width</code><dd>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.
</dl>
<p>The usual commands for indenting in
Emacs<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
and Emacs's C mode<a rel="footnote" href="#fn-3" name="fnd-3"><sup>3</sup></a>: are supported in PHP mode, following the
indentation rules of PHP.
<a name="index-tab-77"></a>
<a name="index-indent-line-78"></a>
<a name="index-line_002c-indent-79"></a>
<a name="index-c_002dindent_002dcommand-80"></a>
<a name="index-TAB-81"></a>
<dl><dt><kbd>TAB</kbd><dd>Properly indent current line, even from the middle of the
line (<code>c-indent-command</code>).
<!-- provide examples? - ash 2007-12-29 -->
<a name="index-newline-82"></a><a name="index-indent-newline-83"></a><a name="index-indent-newline-84"></a><a name="index-newline_002dand_002dindent-85"></a><a name="index-C_002dj-86"></a><br><dt><kbd>C-j</kbd><dd>Insert text after point to a newline, and properly indent
the newline (<code>c-indent-command</code>).
<a name="index-indent-region-87"></a><a name="index-region_002c-indent-88"></a><a name="index-indent_002dregion-89"></a><a name="index-C_002dM_002d_005c-90"></a><br><dt><kbd>C-M-\</kbd><dd>Properly indent each line of region (<code>indent-region</code>).
<!-- I'm not going to bother mentioning C-x TAB, -->
<!-- M-x indent-rigidly. - ash 2007-12-29 -->
<a name="index-function_002c-indent-91"></a><a name="index-indent-function-92"></a><a name="index-class_002c-indent-93"></a><a name="index-indent-class-94"></a><a name="index-c_002dindent_002ddefun-95"></a><a name="index-C_002dc-C_002dq-96"></a><br><dt><kbd>C-c C-q</kbd><dd>Properly indent each line of current top-level function or
top-level class (<code>c-indent-defun</code>).
</dl>
<div class="footnote">
<hr>
<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> <a href="http://pear.php.net/manual/en/standards.php">http://pear.php.net/manual/en/standards.php</a></p>
<p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> See <a href="../emacs/Indentation-Commands.html#Indentation-Commands">Indentation Commands</a>.</p>
<p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small> See <a href="../ccmode/Indentation-Commands.html#Indentation-Commands">Indentation Commands</a>.</p>
<p><hr></div>
</body></html>