php.vim : THE Original indent for php
script karma |
Rating 40/25,
Downloaded by 4774 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Miles Lott |
|
script type |
indent |
|
description |
This was the original vim php indent file written in 2002 and included in Vim 6.X releases. It still works with the latest 9.X release.
Indents after <?php tag, <? tag (optional), ( )or { }. The script can also format switch/case statements and more recently will automatically format /* comment sections */
It likes the following format:
<pre>
if($something)
{
dothis();
}
OR
if($thisone) {
dothis();
}
</pre>
Comment sections are automatically formatted, adding the * on a new line until closure by */ :
/* Comment line 1
* Line 2
*/
Comments done using # also receive a new line with the # prepended. But, you will have to end it manually since there is no difference between lines and the end of such sections.
Comments done using // also receive a new line with the // prepended. But, you will have to end it manually since there is no difference between lines and the end of such sections.
It was not designed to and will not handle if blocks etc. without brackets and also does not format html. Please use braces and separate display logic for more readable code.
|
|
install details |
Place in your /usr/share/vim/vim8X/indent directory (e.g. /usr/share/vim/vim81/indent), replacing the version which is installed by default. NOTE: This script is no longer included in Vim as of 7.0, yet was replaced by another script. After many years I still use this one with Vim 7.X and 8.X because it handles tab indentation correctly without adding spaces, etc. The current official script seems to favor the use of spaces and if you want to always start with a tab you will have to enter that yourself on a new line after a closing bracket. You're welcome to submit ideas for improvement.
Configuration
These can optionally be added to your vimrc:
php_noindent_switch -- do not try to indent switch/case statements or comments (version 0.1 behavior)
php_indent_shortopentags -- indent after short php open tags, too
php_no_autocomment -- do not automatically format comment sections
php_indent_space -- Use spaces instead of tabs [ This may work already if you have expandtab set in your config. ]
|
|
script versions (upload new version)
Click on the package to download.
php.vim |
1.4 |
2024-04-07 |
7.0 |
Miles Lott |
Add formatting of heredoc instances in code
Fix indentation of lines following a // or # comment line |
php.vim |
1.3 |
2019-06-24 |
6.0 |
Miles Lott |
Added the ability to configure use of spaces instead of tabs for indenting. FWIW, this script is still working for me on the latest version of vim, even after 12 years. |
php.vim |
1.2 |
2007-02-18 |
7.0 |
Miles Lott |
Versions 0.8 - 1.1 have a switch/case formatting bug caused by an incomplete variable renaming. 1.2 should fix this. |
php.vim |
1.1 |
2007-02-18 |
7.0 |
Miles Lott |
Same as the last version, adding #-commented lines |
php.vim |
1.0 |
2007-02-18 |
7.0 |
Miles Lott |
Decided to skip lines commented using // except for the initial tab |
php.vim |
0.9 |
2007-02-18 |
7.0 |
Miles Lott |
Sameday bugfix for certain commenting styles, e.g. closing with /**/ |
php.vim |
0.8 |
2007-02-18 |
7.0 |
Miles Lott |
Borrowed methods from current dist of php.vim for automatic formatting of comments (http://www.2072productions.com/?to=phpindent.txt). Otherwise, the function of the file is largely unchanged, i.e. it STILL works.
|
php.vim |
0.7 |
2006-08-01 |
6.0 |
Miles Lott |
Fixed /* comment */ indentation with patch from [email protected]. |
php.vim |
0.6 |
2005-03-21 |
6.0 |
Miles Lott |
Fix indentation for closing bracket (patch from ITLab at MUSC - http://www.itlab.musc.edu/). Problem reported by various users. The fix came via the debian vim maintainers (bug 282135). |
php.vim |
0.5 |
2004-05-18 |
6.0 |
Miles Lott |
Bug fix for open tag and empty statements. |
php.vim |
0.4 |
2004-05-18 |
6.0 |
Miles Lott |
Fixes for closing php tag, switch statement closure, and php_indent_shortopentags option from Steffen Bruentjen <[email protected]>
|
php.vim |
0.3 |
2002-12-16 |
6.0 |
Miles Lott |
This adds an option to turn off the formatting of switch/case statements. This combines versions 0.1 and 0.2. |
php.vim |
0.2 |
2002-07-21 |
6.0 |
Miles Lott |
This adds formatting of switch/case/default, but with some strict requirements for preformatting.
Please read the file to see what I mean. |
php.vim |
0.1 |
2002-07-20 |
6.0 |
Miles Lott |
Initial upload |
ip used for rating: 207.241.235.164
|