473,466 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A new vim indent script for php

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
11 4119
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
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
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
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

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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vincent | last post by:
I noticed an irritating behaviour of the text-indent property and I wonder if I'm the only one to feel this way about it: it seems that text-indent applies even to floated elements. Although this...
22
by: Firas | last post by:
Hi, Is there a CSSish way to indent a paragraph except for the first line? I tried p:first-line { text-indent: 0em; }
2
by: Eugene | last post by:
Hi, Is there a way to align/indent the stored procedure script ( like VBA Add-Ins Smart Indenter ) Thanks, Eugene
0
by: saabi | last post by:
How to indent length 4 a tab in IE? The text in this CDATA was some html code, it would indent length 8 a tab in IE, but I like to indent length 4 like in the original html editor, How to change...
1
by: John Wellesz | last post by:
For those who use Vim to program in PHP, the version 1.21 of my indent script is available. Changes: - 'try' and 'catch' were not registered as block starters so the '{' after a 'try' or...
5
by: M.N.Smadi | last post by:
Hi there; i have a script that is not indented properly. Is there a way that i can have it auto indented. thanks moe smadi
1
by: Rocky Zhou | last post by:
I am accustomed to vi my pthon scripts with 'tab' indent. But when I copy some code to my script, the indent may be 'spaces'. So I wanna a way to substitute those 'spaces' to be 'tabs'...
6
by: desktop | last post by:
I have this class: class case(blop.case): def __init__(self, n, a, b): blop.case.__init__(self) print 'Monty Python's Flying Circus has a ' within it...' ... ... But I get an error when I...
2
by: Chris Seidel | last post by:
Hi, I have a submit-element with a background-image of 16x16 px and the following style: background-image: url("ok.gif"); background-repeat: no-repeat; text-indent: 20 px; The problem is,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.