If you are coding php using GVIM, you will appreciate this new indent script:
Download there:
http://www.vim.org/scripts/download_...hp?src_id=3710
or here:
http://www.2072productions.com/vim/indent/php.vim
Description: (that you can find at http://www.vim.org/scripts/script.php?script_id=1120 )
Features:
- Indent "perfectly" PHP code
- Comment or non-PHP code doesn't break the algorithm
Example: (start of line spaces are replaced by ____)
<?php
if ($foo="thing") // as you see an opened bracket isn't needed to indent correctly :)
____if (foo("something"))
____{
________somethingelse("blabla");
?>
<html>
<head>
<title>SOME HTML CODE</title>
<script type="text/javascript">
var truc=0;
if (truc) {
____nothing();
}
</script>
</head>
<body>
<b>some closing bracket here }}</b>
</body>
</html>
<?
________Somethingelse(true);
____}
?>
- Non-PHP code is indented like PHP code would be, so javascript code is indented too :)
- Fast optimized indenting, the script knows when it's indenting large blocks and skip some unecessary tests...
- Support folding (folds don't break the indenting)
- Indent correctly "non bracketted blocks" (like in language C)
Exemple:
<?php
if (!isset($History_lst_sel))
____if (!isset($History_lst_sel))
________if (!isset($History_lst_sel)) {
____________$History_lst_sel=0;
________} else
____________$foo="truc";
____else
_______$bla= "foo";
$command_hist = TRUE;
?>
- Direct indenting, the text is indented as you type it.
- switch/case are indented correctly
- Script source code very well commented
- Bug free as far as I know :)
That's all folks!
Enjoy :)
install details
:
Just make sure the name of the file is php.vim and copy it under your vimfiles/indent folder.