Simple wrap with php tag request

Issue #1 closed
Lucas Lemonnier created an issue

Would it be possible to create a version which just wraps any selection (not limited to any language) with <?php ?>? Ideally it would respect indentation, but not add extra lines.

Basically mimicking the sublime ctrl+shift+w shortcut but for the php tag.

Comments (4)

  1. Lucas Lemonnier reporter

    To be more specific, it would not be related to commenting. What I am after is:

    echo $thing would become <?php echo $thing ?>

    Thanks!

  2. jordan trahanov repo owner

    Hi Lucas, thanks for the issue.

    The initial idea of the plug-in is to comment HTML code so this code doesn't get rendered in the source. For example in many (WordPress, in my case) files there's PHP, HTML, JS etc. in single file and if you use HTML comments they will still get printed in the page source code.

    I've limited the plug-in inside the PHP code because you can just use the default sublime shortcut shift+ctrl+/ which will comment the PHP code. And since echo $thing is supposed to be inside <?php ... ?> I think it's pointless to mess with the code there. There is an example on the repo page on how to use the plug-in options. In your case just edit your "Key Bindings - User" and add:

    {
        "keys": ["ctrl+alt+c"],
        "command": "wrap_html_in_php_comment"
    }
    

    This will allow the plugin to work everywhere without code limitation.

    Having that said, plug-in functionality is to wrap whole lines instead of selection, so you will still be unable to make inline wrappings.

    I will work on that and maybe try to add an option for wrapping only the selection.

  3. Lucas Lemonnier reporter

    Hey Jordan Thanks a lot for the feedback. Yeah, inline wrappings is what I'm after. Let me know if you ever add that feature :)

  4. Log in to comment