VSCODE seems to be inserting spaces everywhere in my html code. I checked the settings and it's the following which is causing it: "editor.formatOnSave": true
Example:
How do I configure this to stop inserting spaces?
I have the following set :
"editor.formatOnSave": false,
"editor.insertSpaces": false
Now it is not inserting spaces. Hope it helps
Mine was caused by an extension JS/ CSS formatter, after i uninstalled and restart vscode works great.
After spending hours wondering why my django static links are broken smh
When saving, Visual Studio inserted a lot of spaces. This happened after an update of Visual Studio. This problem was because of an extension called Bracket Pair Colorizer. What I did was, uninstall and reinstall, and that solved the problem. I suggest to check all your extensions. It could be one of them.
I disabled the option of HTML formatting and no more space when saving files.
Settings > Extensions > HTML > Format: Enable
Enable/disable default HTML formatter.
What was the case with me is that I had the option Editor: Format on save mode to be set to file, this in combination with format on save would mean VS Code will try to format the entire file, resulting in spaces as defined in the formatter.
Change this to be modifictions, and VS Code will only save the lines you have made changes in.
Related
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
}
}
What happened is that when I move my codes to different lines, and when I CTRL+S, the code automatically get moved to a different line.
What setting in VS Code is this?
That's because you have format on save.
You need to go to VS Code settings and search formatOnSave and turn it off
check if the "auto format on save" option is on: VSCode: How do you autoformat on save?
you can also go into the dart plugin's preferences in vscode and change the line length at which formatting the code will auto-wrap it. You can make it however long you want. Just go into settings and search "Dart: Line Length"
For me, I went to the dart extension setting, there is an option of Dart: Enable SDK Formatter. It should be the problem I guess because when I disabled it, everything started working fine.
We can directly search for Dart: Enable SDK Formatter in VS Code settings.
On VS Code, I installed the prettier extensions, and since it doesn't support EJS, I added"prettier.disableLanguages": [ "ejs", ".ejs" ] to the setting.json file. This also shows up in the regular settings under Prettier: Disable Languages. Despite this, prettier keeps on re-formatting my EJS, which is super frustrating. How do I stop prettier from modifying a certain language besides this method?
Since Prettier knows nothing about EJS, it doesn't understand what you wrote in prettier.disableLanguages. Also VS Code considers .ejs files HTML. This not exactly accurate conclusion is passed to the Prettier extension, which in turn passes it to Prettier, so Prettier tries to format your files as pure HTML.
Try adding *.ejs to the .prettierignore file. You can read more about it here: https://prettier.io/docs/en/ignore.html
Your can add this
"[html]": { "editor.formatOnSave": false },
in your settings.json file in VSCode it will prevent auto formating html files, prettier still not have any ignore for .ejs files.
As .ejs files are still taken as html files by prettier.
Inside Visual Studio code editor(version 1.15.0) the cursor moves to end of line when taking a small pause while editing some text inside my file.Please help
Recently, I had the same kind of issue and the extension caused to the problem was EditorConfig. So what I simply did is open the file:
.editorconfig
which available in the same working directory, then I change:
insert_final_newline = true
to
insert_final_newline = false
Problem solved! :)
This problem is due to document formatting extension installed on VS CODE. Every time you add new lines to the file and take a pause, file is formatted which will take the cursor to end of file.
Here is the simple solution of your problem:
Go to File, then toggle Auto Save option. This will also prevent auto formatting of document. Formatting will be done on manually saving the document.
If your document is not being formatted on saving the document try this:
Click File > Preference > Settings
Type editor.format in Search Settings input field
Change editor.formatOnSave to true or add the following line to settings file "editor.formatOnSave": true
I fixed this issue by disabling all extension from visual studio code editor.Please see the a
ttached image on how to Disable all extension
After disabling all extension the cursor issue resolved and then i installed/enabled the required extensions only
You can quickly go back to the previous edit location ( before save ) with:
On Mac:
Ctrl+- .. navigate back
On Windows:
Alt+← .. navigate back
On Ubuntu Linux:
Ctrl+Alt+- .. navigate back
Not exactly a solution. But, a quick dirty work-around
I faced an issue and disabled the extension "JS, CSS, HTML Formatter". Now the issue is gone
Uninstall this --->
JS-CSS-HTML Formatter
lonefy.vscode-js-css-html-formatter
lonefy
Solved!
In my case auto save delay time is very less that's why cursor goes end of the page after small delay.
Go to setting -> commonly used ->increase time of Auto save delay.
File > Preferences > Settings > Auto SaveDelay
There you can specify the interval of inactivity in milliseconds:
And also you can turn off autosave (by putting it in the "off" position):
My problem is not present while editing a file, like here: Spaces to tabs in Visual Studio Code
VSC converts all tabs to spaces when I save the file. How could I stop that stupid behavior?
This are my actual user settings:
{
"editor.insertSpaces": false,
"editor.detectIndentation": false
}
Further informations:
"editor.formatOnSave": false
Wish I understood more about what's happening here, but in my case, what finally worked (for now) was unchecking "Editor: Insert Spaces" in my user prefs. Without this, disabling Save on Format didn't seem to help. ¯\_(ツ)_/¯
I had an extension which overrides the default behaviour:
https://marketplace.visualstudio.com/items?itemName=lonefy.vscode-JS-CSS-HTML-formatter