This question already has answers here:
How to disable VS Code auto-rename-tag / HTML mirror feature?
(2 answers)
Closed 3 years ago.
I saw some similar questions but none of them solve my problem.
Whenever I edit an HTML tag, VS Code always selects what it thinks is the matching tag and edits it along with what I am typing. This is very annoying because it often changes the incorrect tags. I want to completely disable this. I do not want anything else in the file to be modified when I am changing an HTML tag. I have diabled HTML > Format and HTML: Auto Closing Tags but it still automatically changes other tags when I want to do it manually. Is there any other setting that will completely prevent any auto changes in HTML?
Settings
Incorrect tag being automatically selected and changed
settings.json
{
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"workbench.editor.enablePreview": false,
"python.formatting.formatOnSave": false,
"typescript.updateImportsOnFileMove.enabled": "always",
"workbench.tree.indent": 16,
"html.format.enable": false,
"typescript.autoClosingTags": false,
"javascript.autoClosingTags": false,
"html.autoClosingTags": false
}
The solution is to add the following setting:
"html.mirrorCursorOnMatchingTag": false
The setting documentation
I am currently using VSCode and am not experiencing these issues, it's strange that it's still doing it even after disabling the setting.
Can you please follow these instructions and post your settings.json file? (this is the underlying file that vscode uses to define it's settings)
Settings file locations (from https://code.visualstudio.com/docs/getstarted/settings)
By default VS Code shows the Settings editor, but you can still edit the underlying settings.json file by using the Open Settings (JSON) command or by changing your default settings editor with the workbench.settings.editor setting.
Depending on your platform, the user settings file is located here:
Windows %APPDATA%\Code\User\settings.json
macOS $HOME/Library/Application Support/Code/User/settings.json
Linux $HOME/.config/Code/User/settings.json
There should be a line similar to:
"html.autoClosingTags": true,
OR
"html.mirrorCursorOnMatchingTag": true,
If you change this to false it may fix the problem but if you show your config file we should be able to see if there is another issue.
Related
I have tried putting this in my settings.json file-
{
"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": {"django-html": "html"},
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements",
"*.html": "html"
}}
But it makes no changes vs code still only reads Django and not html. I am unable to get closing tags or autocomplete for html. I have tried every solution available on the internet but none works. Although every time I uninstall the django extension from vs code it starts reading html code again. I have tried all methods available on the internet but none work, sometimes it only read html and sometimes only django. Please help
According to Django Extension (I suppose you are using this one), below Usage section the appropriate settings to set are:
"files.associations": {
"**/*.html": "html",
"**/templates/**/*.html": "django-html",
"**/templates/**/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements"
},
Note: Copy and replace the code above with yours (which I think is the cause to your problem).
If you wanna take advantage of emmet, you should add the line below to your settings.json:
"emmet.includeLanguages": {"django-html": "html"},
Note: I don't think setting "emmet.triggerExpansionOnTab" to true is doing anything in your case.
Besides, django-html documents doesn't seem to get formatted properly with prettier formatter, so I suggest using the settings bellow to format django-html using beautify:
"beautify.language": {
"html": [
"django-html"
]
},
Prettier has just stopped working and is not formatting HTML in my VSCode.
In the output I get:
["ERROR" - 5:00:45 PM] Error formatting document.
["ERROR" - 5:00:45 PM] Unexpected closing tag "p". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (62:90)
Does anyone know what I can do to get working again?
Ive checked my various settings and not been able to see anything wrong.
I had the same problem and finally solved it.
I have in settings the default formatter as esbenp.prettier-vscode, then what I have done is in the html file, Ctrl+Shift+P --> preferences: configure language specific settings... then you search html and then you should have open the settings.json. in there I just pasted this
{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
}
}
and I don't know why but works
Trying out Windows Terminal customization via settings.json. I found a profiles.json that follow the new conventions closely enough to work when pasted into settings.json, (I know it took because the theme changed). The problem is that changes to "fontFace" are not having any effect. I'm trying to use a nerd font for some powerline stuff, works in Powershell running in ConEmu but not in Windows Terminal. Here is the relevant portion of settings.json:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"cursorShape": "vintage",
"fontFace": "Iosevka Nerd Font"
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"fontFace": "Iosevka Nerd Font",
"colorScheme": "PowerShellTom",
"useAcrylic": true,
"acrylicOpacity": 0.8
},
{ ...
I get the same behavior in Windows Terminal Preview, which is supposed to be the least "bleeding edge" version.
Even trying non-nerd fonts for "fontFace" has no effect, however, "fontSize" will work.
For people who are coming from SCOTT HANSELMAN article (especially from the third step)
Install Cascadia Code for all users
Change the "fontFace" property in the settings.json like this
Shortcut to open settings.json: Ctrl+Shift+, (comma)
here is the code to copy
"profiles": {
"defaults": {
"fontFace": "Cascadia Code PL"
// Put settings here that you want to apply to all profiles.
}
}
This is the only way I made that work (after 2 hours or trying)
Change the fontFace from "Iosevka Nerd Font" to just "Iosevka"; the fontFace attribute expects a font family, as far as I'm aware this isn't in the documentation and I only found it out after reading this issue on the WT github
I wanted to install MesloLGS NF Regular as a recommended font for Powerlevel10k in WindowsTerminal for WSL:
https://github.com/romkatv/powerlevel10k/blob/master/font.md
To make it work I had to:
Install it for all users as #hakan-fıstık showed in his answer.
Change the "fontFace" in settings.json to "MesloLGS NF" (Supplying full names of fonts is not working as supposed to).
Be sure to change size of font (changing font may make it huge): https://learn.microsoft.com/en-us/windows/terminal/customize-settings/profile-appearance
From a comment to the Issue I opened on Windows Terminal's GitHub page, (#6606), I was directed to another fontFace problem where choosing another font would not stick if you reopened WT, (not quite the problem I was having).
Anyway, the current solution to that is to uninstall any font you want to use, then right-click and choose "Install for all users". Double-click the file to open the sample view, and use the font name found just below the the two buttons. use the spaces in the font name as is in your settings.json file.
This worked for MesloLGL NF, but not Iosevka NF.
In my experience, editing the 'settings.json' file manually creates more issues than it resolves. The easiest way to edit the default font of your terminal is as follows:
Open the settings
Select Ubuntu under the 'Profiles' header on the sidebar
Scroll down to 'Additional Settings' and select 'Appearance'
Under the text header, change the 'Font face' attribute to your preferred font
Open 'settings.json' to view changes
You should see the expected format for selecting a font - Should you wish to edit the json file manually, you should follow this format
Save changes and exit
VS code has suddenly stopped recognizing html files (the file icon is the default one for files with no extension)
all other file extensions work just fine
except for html
the tags still work but it won't autocomplete
Adding this to file extensions worked for me:
"files.associations": {
"*.html": "html"
}
In my case, for this problem the solution was to manually add *.html to files.associations, in user settings. Its unlogical but it seems that somehow the extension wasn't associated to the type of file. Now everything works perfectly...
Go to the settings (In mac it is Code -- > Preferences --> Settings)
In the search bar search for Association.
In Files:Associations click on Add items.
update key = *.html & Value = html
Below is the screenshot for reference.
I had the same issue but none of the other solutions worked for me!
You can try this:
Go to the path where the "settings.json" file exits, for my case the path is:
C:> Users> User123 > AppData > Roaming > Code > User > settings.json
Now, paste the code in the file:
"code-runner.executorMap": {
"html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
}
Now search for the "files.associations" section in your settings.json file:
As an example
Now if you have the "files.associations" section then just add the line there:
"*html": "html"
(don't forget to write a comma after a line if there are more lines in it)
or if you don't have a "files.associations" section, then copy paste the code there:
"files.associations": {
"*.rmd": "markdown",
"*html": "html"
},
I had the same problem in Windows 10 a few minutes ago:
Yeah, from the solutions above I did this but still had some errors:
File -- > Preferences --> Settings
In the search bar search for Files: Association.
In Files:Associations click on Add item button.
update Item = *.html & Value = HTML
As shown below:
When I saved, I got this error
Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again.
The problem is that terminal.integrated.shellArgs settings have been deprecated.
One of the answers here will help:
So I just had this problem and I figured it out the problem was from an extension that I installed which is the pyscript extension I disabled it and everything started to work again!
Well if you have pyscript extension installed, disable it. It has conflicts with html files I guess.
Or if you don't want to disable it just ctrl+shift+p then change language mode. Select configure file association for html.
This applies for any extension not just pyscript. For me it was pyscript
When I view files on GitHub, tabs appear as 8 spaces.
Example:
Is that possible to change this configuration to 2 or 4 spaces?
You can append ?ts=2 or ?ts=4 to the URL to change the tab-size.
Example: https://github.com/jquery/jquery/blob/main/src/core.js?ts=2
It seems that the value can be anything from 1 to 12. It does not work on Gists or raw file views though.
Source: GitHub Cheat Sheet
Set default displayed tab size for your repository
When you have a .editorconfig in your repository it will respect it
when viewing code on GitHub.
indent_style = tab and indent_size = 4 shows tabs with 4 columns
instead of 8
https://github.com/isaacs/github/issues/170#issuecomment-150489692
Example .editorconfig for multiple extensions which works in JetBrains' products:
root = true
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
[*.{js,jsx,html,sass}]
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
Change how you see tabs on other repositories
Install Stylus in your browser, than install GitHub: better-sized tabs in code.
There are also Google Chrome extensions:
https://chrome.google.com/webstore/detail/github-tab-sizer/djpnapkcpjomnkfekaedkigfomiedpjf
https://chrome.google.com/webstore/detail/github-tab-size/ofjbgncegkdemndciafljngjbdpfmbkn/related
Since Sept. 2021, you can set the tab size directly in your GitHub settings: github.com/settings/appearance.
Announced in Changelog "Tab size rendering preference".
No more .editorconfig
No more ?ts=2 added to the URL
Just:
Note: you cannot enter "3" for instance. You would get:
Tab size rendering preference could not be saved:
Validation failed:
Tab size is not included in the list
It actually is possible to do it, with a browser extension. Install Stylish (in Firefox or Chrome), then install this user style: “GitHub: better-sized tabs in code”.
It might not work for some languages. For example, I was viewing a JavaScript file and I did not notice any changes. So I deleted the style the author had and put the following lines into it:
.tab-size {
-webkit-tab-size: 4 !important;
-moz-tab-size: 4 !important;
-o-tab-size: 4 !important;
tab-size: 4 !important;
}
And it worked on Chrome (screenshot).
As you can see from the screenshot, I also enabled widescreen mode and changed the color scheme to Solarized. So I have three user styles running on GitHub pages via the Stylish extension for Chrome. I hope this helps someone.
Update
Yes. As stated by mortenpi, this can be done by through an additional query parameter. See his answer for more details.
Original answer
Is that possible to change this configuration to 2 or 4 spaces?
No. It's only available as part of the editing feature through the Ace editor and the change is not persisted.
This blog post gives some more information about the embedded IDE.
However, provided you know the url of the blob (file) you're willing to review, you can switch to the edit mode easily by changing the blob segment with an edit segment and use the dropdown to select your prefered tab size.
Standard view: https://github.com/moroshko/mmSelect/blob/master/mm_select.js
Ace view: https://github.com/moroshko/mmSelect/edit/master/mm_select.js
If the project is yours, create a file in the project root named “.editorconfig” and give it the following contents.
[*]
indent_style = tab
indent_size = 4
This will cause GitHub to render tabs 4-wide within the project.
This is an EditorConfig file, which is formally specified, supported by many editors, and also supports more extensive editor configuration, like specifying that all .html files are UTF-8 encoded.
If the project isn’t yours, consider opening an issue requesting the author specify the indent style they intended.
If you're into UserScripts, this did it for me:
// ==UserScript==
// #name GitHub Tabs
// #namespace http://foldoc.org/
// #version 1
// #description Set sensible tabs on GitHub
// #author Denis Howe
// #match https://github.com/*
// ==/UserScript==
document.querySelectorAll('table').forEach(t => { t.dataset.tabSize = 2 });
I did that for fixing them http://valjok.blogspot.com/2014/07/indentation-correction-for-exposing.html.
Another option is when embedding your gist, replace all tabs with required number of spaces
<div id="willReplaceTabs">
<script src="https://gist.github.com/valtih1978/99d8b320e59fcde634ad/cf1b512b79ca4182f619ed939755826c7f403c6f.js"></script>
<script language="javascript">
var spaces = " "
willReplaceTabs.innerHTML = willReplaceTabs.innerHTML.replace(/\t/g, spaces)
</script>
</div>
If it's an option for the project you're working on, changing your editor to treat tabs as spaces will fix the problem.
So, for example, in Visual Studio Code, the config looks like this:
{
"editor.tabSize": 2,
"editor.insertSpaces": true
}
In Sublime it's:
{
"tab_size": 2,
"translate_tabs_to_spaces": true
}
Until recently I insisted on non-spaced tabs. After switching, it fixed the Github rendering weirdness, and I haven't noticed any significant downsides in my workflow.
The best solution is, if possible, to convince maintainers of the source code you're looking at to replace all the tabs by the correct number of spaces.
Using tabs is problematic in code today given that you're often seeing it on the web, where the decision of "how many spaces per tab" depends on where it's being displayed.