I'm trying to make some statements visually line-up on the equal signs (per company style), which requires me putting extra spaces inside the line.
However, when I press save, VS Code deletes the spaces: even though I have all extensions off, and have it set to show all whitespace.
clip of problem, jump is on save
Any clue what might be causing this? I've tried restarting, toggling all the whitespace settings, disabling all extensions; no luck.
ctrl+comma
add line:
"editor.formatOnSave": false
You can also exclude some file types from format on save if you don't want to turn format on save off:
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false
}
Related
Currently, whenever I create a new file (no matter the file type) it starts out using spaces for indention. I always have to click and convert to tabs.
How can I configure all new files to use tabs by default to avoid this step?
Put the following in whichever settings file makes sense for you (your user settings.json, or a .vscode/settings.json, or a .code-workspace file):
"editor.insertSpaces": false
You can change this setting on a per-file-type basis like so:
"[json]": {"editor.insertSpaces": true},
"[javascript]": {"editor.insertSpaces": false}
To change the indentation for an existing file, use the Convert Indentation to Tabs command.
You can also use editor.detectIndentation to change whether VS Code should try to detect what indentation a file is already using to follow it.
In the VS code editor, the default setting is to replace tabs by spaces, which is what I want. However, this is disastrous in a make file. I have written a make file (named Makefile) but VS code insists on changing tabs to spaces so I get a "Missing Separator" error when I run make.
If I go to File > Preferences > Settings and type #id:editor.insertSpaces in the menu, I see this:
When I click on Modified elsewhere I see this:
The second screenshot seems to says that the editor won't insert spaces in a Makefile, but it certainly is. What am I doing wrong, or what have I failed to do?
Try modifing settings.json
VScode Settings
There are 3 levels (by higher priority)
Worspace Settings JSON
User Settings JSON
Default Settings JSON
This should fix most inconveniences:
"[markdown]": {
"files.trimTrailingWhitespace": false,
"editor.insertSpaces": false
},
What worked for me was adding the following to settings.json:
"[makefile]": {
"editor.insertSpaces": false
},
I have made a pull request to a library on github. I am using vscode as the editor. It seems that vscode is removing a space after each comma created unnecessary changes in the diff. How can I stop this from happening.
I have a .vscode/settings.json with
"editor.formatOnSave": false,
"editor.insertSpaces": false,
This is what I am getting in my diff. Notice the extra space after the comma on line 55.
Thank you.
Turns out the above workspace config was not being respected. I had `editor.insertSpace:true" in the vscode global config. Taking it out solved.
So, I'm using VS Code with an extension called Prettier. The problem is that after I hit save my code is being "refined" but also separated into 2 lines even despite the fact it's a very short line and I still have plenty of space on the right. Could you please advice what setting is responsible for this conversion? It seems to me that I have checked all available options but unfortunately couldn't find anything which causes it.
"prettier.printWidth": "80"
in your settings.json or search for print width setting in the UI
Increase or decrease this setting. This limits the number of characters prettier limits a line to, it it exceeds this, it will try to break it into smaller ones.
Search for settings.json in visual studio.
You will find a json file in this path AppData\Roaming\Code\User\settings.json if it is a windows machine.
Add the below JSON in the file, If you keep "editor.formatOnSave" as false formatting won't happen when you save the file.
If you want to have this setting just make a specific property as false just the way I did for javascript and HTML in the below section.
"editor.formatOnSave": false,
"[handlebars]": {
"editor.formatOnSave": true
},
"[javascript]": {
"editor.formatOnSave": false
},
"[html]": {
"editor.formatOnSave": false
},
"[less]": {
"editor.formatOnSave": true
},
I'm working in a project that has wonky whitespaces at the end of lines and don't want to remove them to keep the git diff down.
In .vscode/settings.json I have:
{
"editor.formatOnSave": false,
"files.trimTrailingWhitespace": false
}
But whitespaces are still trimmed. Is there any setting I can turn on to stop VS code from trimming on save?
Try disabling any plugins that might format on save.