473,763 Members | 5,396 Online
Bytes | Software Development & Data Engineering Community
+ 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 "))
____{
________somethi ngelse("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>
<?
________Somethi ngelse(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($Histor y_lst_sel))
____if (!isset($Histor y_lst_sel))
________if (!isset($Histor y_lst_sel)) {
____________$Hi story_lst_sel=0 ;
________} else
____________$fo o="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 4144
In article <Xn************ *********@213.9 1.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******** *****@individua l.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_removeCRwh enUnix' 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_removeCRwh enUnix' 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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5868
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 is probably correct according to the specification (text-indent is inherited), don't you think it makes no sense to apply text-indent to such elements ? Here is an example: I have a paragraph, starting with a clickable image, that's followed by...
22
27254
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
8202
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
1289
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 the xsl code? ----------------------------------------------------------- Indent4ATab.xml <?xml version="1.0" encoding="GB2312"?> <?xml-stylesheet type="text/xsl" href="Indent4ATab.xsl"?> <htmlCode><!]></htmlCode>
1
1602
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 'catch' could be wrongly indented... (thanks to Gert Muller for finding this issue) You can view its capabilities and download it there:
5
1986
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
3178
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' conveniently. For example, I: expand -t4 test.py >/tmp/test2.py vi /tmp/test2.py Then in vim, the indents should be: /^\( \{4\}\)*/
6
34352
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 run the .py script from shell saying:
2
3573
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, that text-indent is ignored. When I supply the style to a
0
9564
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.