How to make VSCode convert single quotes to double quotes on save? - visual-studio-code

I'm having an issue with VSCode formatting on Save.
While some of the settings work as expected I can't figure out why quotes don't work.
(I guess it could be a limitation)
I have this settings
"javascript.format.semicolons": "insert",
"javascript.preferences.quoteStyle": "double",
Semicolons work as expected, but not the quotes. I notice this is a "preferences" so I'm guessing it's not applied when formatting.
Can I get formatting without an extension like Prettier? And what is the "preference" used for if not formatting in this case?

Related

Always use double quotes in schema.prisma with Prettier in VSCode

I use prettier to save all quotes as single quotes in my JS and TS files.
However, single quotes are not valid in schema.prisma. Can I specify within Prettier to treat specific file extensions differently?
I have the "Prisma" extension in VS Code as well and tried to enable
"editor.formatOnSave": true
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
},
But it's not changing the single quotes in my schema.prisma file on save. What config and/or extensions do I need to achieve this behavior?

VSCode Rust add semicolon on save

I am using the Rust extension on vscode and NOT rust-analyzer. However, when I am saving a file, vscode is using rustfmt to format my file but it doesn't automatically insert semicolons. I have a trivial function like this
fn call_me() {
let x = 5
println!(x)
}
It doesn't add the necessary semicolons. How do I make it add semicolons? Are my installations somehow messed up?
Also, I have tried rust-analyzer and it doesn't add semicolons either.
Unlike JavaScript, semicolons are not syntactically optional in Rust. Thus, leaving them out is a syntax error, not just a matter of style, and rustfmt (the standard Rust code formatting tool) doesn't ever attempt to fix any syntax errors, no matter how “obvious” they might be — if it reads a file with errors it will not make any formatting changes.
(I don't know if there's a way to get rust-analyzer, vim, or VS Code to auto-insert semicolons as a matter of editing rather than formatting.)
Maybe not what you're looking for but there are language-agnostic options to reduce the friction of semicolon insertion.
For instance the vs code extension colonize adds the shortcut alt+enter which appends a semicolon and newline, no matter where in the line the cursor is.

Prettier formatting with double quotes

Anyone else come across Prettier formatting code with Double quotes instead of Single even though you
explicitly set it to replace with single in the preferences?
Here is a pic:
After a recent update to VSCode I started getting this issue and it is driving me crazy.
Any ideas as to how to fix this. Am I wrong that the Prettier: Single Quote in fact does not format with single quotes instead of double?
Thanks.
Try to create file .prettierrc at package.json level with property singleQuote set to true as below:
{
"singleQuote": true
}

in vs code, how to turn off auto closing bracket/quote [duplicate]

When I want to change from double quotes to single quotes, I'm used to selecting the double quote, and then type a single quote. I'm intending to use the overwrite feature, but instead, I'm getting the 'wrap with quote' feature.
For example:
"id"
Would result in:
'"'id"
I always turn this auto surround with wrapping off, but I was unable to find a setting for this in the settings file...
Is there a way to turn this off?
It is possible!
In settings.json which you can open via File>Preferences>UserSettings
UPDATE 2023
There are two settings
"editor.autoSurround": "never",
Possible values:
"never"
"languageDefined" - This is vsCode's default
"brackets" - meaning it automatically adds brackets, but not quotes
"quotes" - meaning it automatically adds quotes but not brackets
"editor.autoClosingQuotes": "never",
Possible values:
"never"
"languageDefined" - This is vsCode's default
"beforeWhitespace"
"always"
PS: In old ancient versions of vsCode, there was less granularity and a single setting would control quotes, braces and brackets. "editor.autoClosingBrackets" : "never"
I found this question via Google and the selected answer didn't work for me. I'm using VSCode version 1.27.2, and for me the I had to disable the Auto Surround option.
"editor.autoSurround": "never"
Using VSCode version: 1.36.0
You can use: "editor.autoClosingQuotes": "never"
or

Visual Studio Code: Disable quote wrapping text selection

When I want to change from double quotes to single quotes, I'm used to selecting the double quote, and then type a single quote. I'm intending to use the overwrite feature, but instead, I'm getting the 'wrap with quote' feature.
For example:
"id"
Would result in:
'"'id"
I always turn this auto surround with wrapping off, but I was unable to find a setting for this in the settings file...
Is there a way to turn this off?
It is possible!
In settings.json which you can open via File>Preferences>UserSettings
UPDATE 2023
There are two settings
"editor.autoSurround": "never",
Possible values:
"never"
"languageDefined" - This is vsCode's default
"brackets" - meaning it automatically adds brackets, but not quotes
"quotes" - meaning it automatically adds quotes but not brackets
"editor.autoClosingQuotes": "never",
Possible values:
"never"
"languageDefined" - This is vsCode's default
"beforeWhitespace"
"always"
PS: In old ancient versions of vsCode, there was less granularity and a single setting would control quotes, braces and brackets. "editor.autoClosingBrackets" : "never"
I found this question via Google and the selected answer didn't work for me. I'm using VSCode version 1.27.2, and for me the I had to disable the Auto Surround option.
"editor.autoSurround": "never"
Using VSCode version: 1.36.0
You can use: "editor.autoClosingQuotes": "never"
or