-
Notifications
You must be signed in to change notification settings - Fork 2
A new indent script for php with many improvements never seen before
vim-scripts/PHP-correct-Indenting
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1120 GitHub: https://github.com/2072/PHP-Indenting-for-VIm (The version 1.39 of this script is included in VIM 7.4) Features: - Indents PHP code as "perfectly" as possible. - Comments' content or non-PHP code are ignored and don't break the algorithm. - Non-PHP code, multi-line /**/ comments and "Here Document" content remain unchanged. - HTML <Script.*> tags' content is indented as PHP and like if it was part of the surrounding PHP code. - Fast optimized indenting, the script knows when it's indenting large blocks and skips some unnecessary tests. - Support folding (fold markers don't break the indenting) - Auto-formatting for comments (using the Vim option formatoptions=qroc). - Indent correctly complex "non bracketed blocks": Example: (start of line spaces are replaced by ____) <?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. - Well commented source code. - Bug free as far as I know. A more complete example of its capabilities: <?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> <? ________echo "Something here"; ?> ________<script type="text/javascript"> ________// Note the indentation of the script as if part of PHP ________var truc=0; ________if (truc) { ____________nothing(); ________} ________</script> </head> <body> <b>some closing and oppening bracket here } } { nothing to indent here </b> </body> </html> <? ________Somethingelse(true); ____} if (foo) ____/* a useless comment here ____with useless code: ____if (broken code) { ___________________blabla(); ____*/ ____if (testHereDocument()) { ________echo <<<HEREDOC Here is an Here Document style echo, very useful. The following code isn't indented if (test) while (foo) { nothing(); } HEREDOC; ____} bye(); ?> That's all folks! This script can also be found there: (with a colourful example) http://www.2072productions.com/to/phpindent.txt There is also a newsletter where you can subscribe at: http://www.2072productions.com/to/php-indent-for-vim-newsletter.php (only about new releases of this script) Enjoy :)
About
A new indent script for php with many improvements never seen before
Resources
Stars
Watchers
Forks
Packages 0
No packages published