VScode "linkedEditing" not working for php files - visual-studio-code

I want to be able to easily edit HTML tags together. There is a built-in option for this in Visual Studio Code.
It works fine for HTML files. Buy why not for php files?
Does anybody know a work-around?
For example, let's say I wanted to change this div into a section. It should automatically select both opening tag and the closing tag.

Assuming you have html inside a PHP file. The simplest solution would be:
double click the element to edit
Holding control key double click the closing element ( open and close elements should be highlighted now)
type to edit the element

For now VS Code doesn't handle PHP with editor.linkedEditing.
But you can install Auto Tag Rename extension which will work for PHP files as well.
The extension will ignore certain file types if editor.linkedEditing = true, so you can install it without any conflicts.

Related

Disable onsave formating for .ejs files in visual studio code

I'm working with ejs files, but in order to reuse some code, I'm using the includes feature. Given that some opening/closing html tags are placed in other files, after I save my changes, something (I don't know if prettier extension or VS code editor) is including the closing tags into my code, causing several problems when I running it.
An other solution is to use a .prettierignore file and put in :
*.ejs
in your settings.json you should add these settings.
just instead of "[css]" type what you want. (the format of the file)
and just please ignore line 2 :) that's not related to this answer.
Edit
as #aegatlin said use this: "[html]".(if "[ejs]" didn't work for you)
I don't use EJS myself, but after playing around with it in VSCode, I noticed that my .ejs files were being treated as HTML files. You can see how your VSCode is interpreting the file by looking in the bottom right corner of the editor. You could search for EJS extensions as well.
You likely have the "Editor: format on save" option enabled. To disable that setting, go to Preferences, and in the search bar type "format on save". Find the setting. Uncheck the box. That should fix the problem.
If, as you mentioned, your closing HTML tags are in other files, then you have invalid HTML and the formatter (both Prettier's and the default one) will autocomplete the closing tag. (I would wager EJS also wouldn't like the lack of closing tags, but since I don't use it I'm not so sure, maybe it's fine.)
Zulhilmi Zainudin has the solution
https://medium.com/#zulhhandyplast/how-to-disable-vs-code-formatonsave-for-specific-file-extensions-c60e8f254243
In vscode setting file, associate ejs extentions files to a « language ». Then you can specify different rules for this that language :
.vscode/settings.json file content :
{
"files.associations": {
"*.ejs": "ejs" // this create the language « ejs » which refers to any .ejs file
},
"[ejs]": { // custom settings for the language « ejs »
"editor.formatOnSave": false
}
}

CSS Files Opening Up as Plain Text in VS Code

For some reason, whenever I create a new file and give it a css extension, the language mode is set to plain text. That is not the usual behavior and I don't know why it is acting that way.
Does anyone know how to fix that?
Thanks.
Click to the language at the right bottom bar of VSCode
Select Configure File Association for '.css'
Find CSS and select it.
You could run into problem cannot finding CSS in the last step I mentioned above, then here might be the fix for it btw:
Press Ctrl + , to open the Settings window.
Click Open Settings (JSON)
Find a line where there is
"files.associations": {
"*.css": "Plain Text"
}
and delete it, make sure the json file still in a correct format after deleting (no missing or extra comma ,).

Eclipse to color all occurances of an element in html file

While editing java files there is such a thing which highlights all the occurrences of the selected variable. Same thing exists in notepad++ for all the files, including html ones. In eclipse there is no such a thing for html files, or at least I dont know how to activate it
The support for HTML is in the Eclipse Webtools. Just install and select the correct Editor.

Eclipse file associations for extensions with multiple periods

I have several Mako templates in my project that are named things like header.html.tmpl and settings.py.tmpl. I would like to add file associations to Eclipse to open these with the appropriate editors. For example, I would like header.html.tmpl to be opened in the HTML editor, settings.py.tmpl to be opened in the Python editor, etc. I go to Preferences->File Associations and I try adding *.py.tmpl to the list but after I click "Ok" nothing happens and the desired extension does not appear in the list. If I try instead using .py.tmpl I can add it to the list and add the Python editor to its associated editors but when I double-click a .py.tmpl file it doesn't use the correct editor.
Obviously it would probably work to just use -tmpl instead of .tmpl, but I'm wondering if anyone knows a way around this or can confirm that it's a bug/missing feature.
Its a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=168573

View nicely formatted version of HTML source

I need to edit this HTML page and re-upload it.
The problem is that somehow all of the newlines have been eliminated from it so that its just one long line. I'm using Notepad++ now, although I don't have to be.
What is a good way to view and edit this HTML/PHP/Javascript source in a way that a reasonable human being can read it?
Thanks!
You can tidy this up (as #AR suggested) with notepad++. Go into Notepad++, go to the plugin manager and select
textFX and install that.
among other things, it will install a new menu item in the toolbar called "textFX"
select it, then select Text Fx HTML Tidy. This will give you a selection of formatting objects and ought to pretty it up for you.
once again:
TextFx >> TextFx HTML Tidy