Hopefully a simple question / answer, but I’ve spent ages trying to figure it out
In Sublime Text, in a Kirby template, if I type “c” I can then select “class” and it nicely inserts:
class="" with the curser helpfully between the quote marks.
But in VS Code it just write “class”.
Also in Sublime Text if I start to close an element by writing “</” it auto completes it. But again in VS Code it doesn’t.
Is this because the files are PHP and not HTML?
Can VS Code do this?
If so, how?
I’ve added this to the user settings
"files.associations": {
"*.php": "html"
}
It tells VS Code: “treat .php files as HTML when editing.”
That’s why class=“” and tag closing started behaving more like Sublime.
The tradeoff is the bottom-right says HTML instead of PHP, and PHP-specific autocomplete/checking is reduced. For Kirby template files, that’s usually fine because they’re mostly HTML with little PHP snippets mixed in.
Does this sound a sensible compromise for Kirby sites? Or is this going to create problems?
I think the issue is:
VS Code sees that Kirby templates and snippets are PHP and therefore suggests PHP autocompletions.
Whereas Sublime Text is clever enough to suggest PHP and HTML autocompletions within the same .php file.
Is that correct?
… might stick with Sublime Text