By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,997 Members | 2,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,997 IT Pros & Developers. It's quick & easy.

A new vim indent script for php

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
In article <Xn*********************@213.91.2.138>, John Wellesz wrote:
If you are coding php using GVIM, you will appreciate this new indent script:
http://www.2072productions.com/vim/indent/php.vim


Meaby you want to have a look at:
http://timvw.madoka.be/vimrc

i think it has also the features you summed up (+ function list etc..)
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #2

P: n/a
On 16 déc. 2004, Sir Tim Van Wassenhove <eu**@pi.be> claimed in
news:32*************@individual.net:

Meaby you want to have a look at:
http://timvw.madoka.be/vimrc

i think it has also the features you summed up (+ function list etc..)

Thank you for the link but mine is an indent script, yours contains mapping
for "real time" coding only, once your code has been messed up you cannot
indent it correctly, with mine you can... that's the difference.

Jul 17 '05 #3

P: n/a
New version of the script!

List of changes:

- Switch block were no longer indented correctly...
- Added an option to use a default indenting instead of 0.
- A problem with ^\s*);\= lines where ending a non '{}' structure.
- Changed script local variable to be buffer local variable instead.
You can find the new version there:

http://www.vim.org/scripts/download_...hp?src_id=3714

Or there (if the above link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Don't forget that you can vote for this script:

http://www.vim.org/scripts/script.php?script_id=1120

John Wellesz
Jul 17 '05 #4

P: n/a
Version 1.08 has been released!

CHANGES:

- End comment tags '*/' are indented like start tags '/*'.

- When typing a multiline comment, '}' are indented according to other
commented '{'.

- Added a new option 'PHP_removeCRwhenUnix' to automatically remove CR at
end of lines when the file format is Unix.

- Changed the file format of this very file to Unix.

- This version seems to correct several issues some people had with 1.07.
Download:

http://www.vim.org/scripts/download_...hp?src_id=3754

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
John Wellesz

Jul 17 '05 #5

P: n/a

Version 1.09 has been released!

What's new:

- The javaScript code was not always directly indented when typing.
Download:

http://www.vim.org/scripts/download_...hp?src_id=3838

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Contact me if you have any problem with this version.

On 11 janv. 2005, Sir John Wellesz
<jo*****************************@teaser.fr> claimed in
news:Xn**********************@213.91.2.138:
Version 1.08 has been released!

CHANGES:

- End comment tags '*/' are indented like start tags '/*'.

- When typing a multiline comment, '}' are indented according to other
commented '{'.

- Added a new option 'PHP_removeCRwhenUnix' to automatically remove CR
at
end of lines when the file format is Unix.

- Changed the file format of this very file to Unix.

- This version seems to correct several issues some people had with
1.07.
Download:

http://www.vim.org/scripts/download_...hp?src_id=3754

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
John Wellesz


Jul 17 '05 #6

P: n/a
Version 1.10 has been released!

What's new:

- Lines beginning by a single or double quote were not indented in some
cases.
Download:

http://www.vim.org/scripts/download_...hp?src_id=3893

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Contact me if you have any problem with this version.
Jul 17 '05 #7

P: n/a
Version 1.11 has been released!

What's new:

- If the "case" of a "switch" wasn't alone on its line and if the
"switch" was at col 0 (or at default indenting) the lines following the
"case" were not indented.
Download:

http://www.vim.org/scripts/download_...hp?src_id=4291

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Contact me if you have any problem with this version.

Jul 17 '05 #8

P: n/a
If you like this script don't forget to rate it at
http://www.vim.org/scripts/script.php?script_id=1120

(It coulb be directly included in VIM package replacing the old indent
script)

Thank you,

John
Jul 17 '05 #9

P: n/a
Version 1.12 has been released!

What's new:

- The bug involving searchpair() and utf-8 encoding in Vim 6.3 will not
make this script to hang but you'll have to be careful to not write
'/* */' comments with other '/*' inside the comments else the indentation
won't be correct.

exemple:

/*
Blablabla
Blablabla
Blablabla
/* <----- this "/*" will be wrongly identified as the start of the
comment.
Blablabla
Blablabla
Blablabla
*/

NOTE: This is true only if you are using utf-8 and vim 6.3.
Download:

http://www.vim.org/scripts/download_...hp?src_id=4330

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Contact me if you have any problem with this version.

Jul 17 '05 #10

P: n/a
Version 1.15 has been released!

What's new:

- Corrected some problems with the indentation of multiline "array()"
declarations.

- Added auto-formatting for comments (using the Vim option
formatoptions=qroc).

- Added the script option PHP_BracesAtCodeLevel to indent the '{' and '}'
at the same level than the code they contain.

- Some code cleaning and typo corrections (Thanks to Emanuele Giaquinta for
his patches).

Download:

http://www.vim.org/scripts/download_...hp?src_id=4387

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Contact me if you have any problem with this version.

Jul 17 '05 #11

P: n/a
Version 1.17 has been released!

What's new:

- Now starting and ending '*' of multiline '/* */' comments are aligned on
the '*' of the '/*' comment starter.
- Some code improvements that make indentation faster.
- Now following parts of split lines are indented:
Instead of:
$foo=
"foo"
."foo";

You have:
$foo=
"foo"
."foo";

- If a "case : break;" was declared on a single line, the following "case"
was not indented correctly.
- If a </script> html tag was preceded by a "?>" it wasn't indented.
- Some other minor corrections and improvements.
Download:

http://www.vim.org/scripts/download_...hp?src_id=4411

Or (If the other link doesn't work):

http://www.2072productions.com/vim/indent/php.vim
Contact me if you have any problem with this version.

Jul 17 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.