473,770 Members | 4,443 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
11 4147
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=q roc).

- Added the script option PHP_BracesAtCod eLevel 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
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
3179
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
34356
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
3574
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
9602
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
9439
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
10237
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
10071
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
10017
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
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.