A new vim indent script for php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Wellesz

    A new vim indent script for php

    If you are coding php using GVIM, you will appreciate this new indent script:


    Download there:


    or here:



    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.


  • Tim Van Wassenhove

    #2
    Re: A new vim indent script for php

    In article <Xns95C16EF340D 7Lord2072@213.9 1.2.138>, John Wellesz wrote:[color=blue]
    > If you are coding php using GVIM, you will appreciate this new indent script:
    > http://www.2072productions.com/vim/indent/php.vim[/color]

    Meaby you want to have a look at:


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


    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://www.timvw.info>

    Comment

    • John Wellesz

      #3
      Re: A new vim indent script for php

      On 16 déc. 2004, Sir Tim Van Wassenhove <euki@pi.be> claimed in
      news:32c9nnF3jn jv2U1@individua l.net:

      [color=blue]
      > 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..)[/color]


      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.

      Comment

      • John Wellesz

        #4
        Re: A new vim indent script for php

        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:



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




        Don't forget that you can vote for this script:





        John Wellesz

        Comment

        • John Wellesz

          #5
          Re: A new vim indent script for php

          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:



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




          John Wellesz

          Comment

          • John Wellesz

            #6
            Re: A new vim indent script for php


            Version 1.09 has been released!

            What's new:

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


            Download:



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




            Contact me if you have any problem with this version.



            On 11 janv. 2005, Sir John Wellesz
            <john.wellesz-N0-SPAM-OR-BCURSED@teaser. fr> claimed in
            news:Xns95DBDC5 406A59Lord2072@ 213.91.2.138:
            [color=blue]
            > 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
            >[/color]

            Comment

            • John Wellesz

              #7
              Re: A new vim indent script for php

              Version 1.10 has been released!

              What's new:

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


              Download:



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




              Contact me if you have any problem with this version.

              Comment

              • John Wellesz

                #8
                Re: A new vim indent script for php

                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:



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




                Contact me if you have any problem with this version.

                Comment

                • John Wellesz

                  #9
                  Re: A new vim indent script for php

                  If you like this script don't forget to rate it at


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

                  Thank you,

                  John

                  Comment

                  • John Wellesz

                    #10
                    Re: A new vim indent script for php

                    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:



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




                    Contact me if you have any problem with this version.

                    Comment

                    • John Wellesz

                      #11
                      Re: A new vim indent script for php

                      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:



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




                      Contact me if you have any problem with this version.

                      Comment

                      • John Wellesz

                        #12
                        Re: A new vim indent script for php

                        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:



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




                        Contact me if you have any problem with this version.

                        Comment

                        Working...