I have tried few different php indentation scripts, but they can't handle indentation of the following code:

myfunc(function(){
    echo "hello";
    if(1==2){
        echo "world";
    }
});

Can you point out vimrc settings or php indentation file for vim which would handle new syntax of PHP5.3?

Update: Here is what I get:

myfunc(function(){
        echo "hello";
        if(1==2){
        echo "world";
        }
        });

I use bundled indent for 7.3 from http://www.2072productions.com/vim/indent/php.vim John Wellesz

Remaining PHP syntax is indented correctly.

Comments

Have you considered GEdit?

Written by itsols

If he is coding via SSH(Assumption), GUI editors is an not option, or unless Gedit has SSH.

Written by robx

Please could you edit your question so that we can see what you see? Here it seems to be indented how I expect it to be indented. I use this syntax file and this indent file.

Written by romainl

note - i'm not using cindent, is there anything else I need to have in my .vimrc file?

Written by romaninsh

If you are editing via SSH, you can use SFTP to use a GUI editor. I use it with Kate all the time.

Written by John Chadwick

@John i know, but that's not exactly the solution I'm looking for.

Written by romaninsh

Can anyone confirm and post .vimrc file if 2072productions indent file works for you on my code?

Written by romaninsh

Accepted Answer

It may be because your closure syntax is incorrect. Closures shouldn't have names as far as I know. E.g. for a preg_replace_callback function, you'd either pass a variable containing a closure defined with function($matches){/* logic */} or the aforementioned code itself.

What you're trying to do here is define a function in a callback argument. BAAAAD for your script xD

Just get rid of the name like this and see if it helps:

myfunc(function(){
    echo "hello";
    if(1==2){
        echo "world";
    }
});

PHP docs show this syntax for closures too: http://php.net/manual/en/functions.anonymous.php

Written by Shadower856
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki