Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting html inside php #23

Open
rgfx opened this issue Oct 9, 2017 · 6 comments
Open

Formatting html inside php #23

rgfx opened this issue Oct 9, 2017 · 6 comments

Comments

@rgfx
Copy link

rgfx commented Oct 9, 2017

Curious if I can format HTML inside a PHP file somehow? Right now It only formats purely PHP.

html

@ghost
Copy link

ghost commented Nov 28, 2017

Yes I got the same problem 👍 (But I love this tool)

@ryentzer
Copy link

ryentzer commented Feb 9, 2018

This would be great. You can however switch the file type to html, format it, then switch back to php if you have another formatter for html etc installed. I've done this. Obviously not as convenient as being able to do without switching file types.

@rgfx
Copy link
Author

rgfx commented Feb 9, 2018

I've been doing this since October :)

keybindings.json

[{ "key": "ctrl+l", "command": "workbench.action.editor.changeLanguageMode", "when": "editorTextFocus" }]

Ctrl + l > H > ENTER.
Then back to PHP ctrl + l > down arrow > ENTER.

@deviantnasir
Copy link

@rgfx that is so confusing. Can you explain what did you mean by

Ctrl + l > H > ENTER.
Then back to PHP ctrl + l > down arrow > ENTER.

@rokobuljan
Copy link

rokobuljan commented Jul 27, 2018

@deviantnasir What rgfx means is:

CTRL+SHIFT+P and type open keyboard shortcuts file and select/open it.

Insert the new keyboard shortcut

[
    {
        "key": "ctrl+l",
        "command": "workbench.action.editor.changeLanguageMode",
        "when": "editorTextFocus"
    }
]

Than go to your <somefile>.php. Now you can see that the predefined language mode (see lower VScode's right corner) where it says PHP. Now you can change to HTML by using the new Language shortcut:

  • CTRL+L (will open the language mode dialog)
  • Start typing H T... as for "HTML". Hit Enter to accept the HTML language mode.
  • Format HTML using the standard ALT+SHIFT+F
  • Go back to PHP mode using CTRL+L and Enter which should select "Auto Detect" Language (which will quickly set the mode back to PHP)

This is still truly sad to see such a beautiful editor not format properly mixed PHP and HTML - out of the box.

@RiFi2k
Copy link

RiFi2k commented Jul 31, 2018

I got a solution to the HTML formatting in PHP if your interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants