Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode single to double quote automatic replace

People also ask

How do you replace double quotes?

Use the String. replaceAll() method to replace single with double quotes, e.g. const replaced = str. replaceAll("'", '"'); . The replaceAll method will return a new string where all occurrences of single quotes are replaced with double quotes.

How do you auto adjust in VS code?

Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.


I dont have prettier extension installed, but after reading the possible duplicate answer I've added from scratch in my User Setting (UserSetting.json, Ctrl+, shortcut):

"prettier.singleQuote": true

A part a green warning (Unknown configuration setting) the single quotes are no more replaced.

I suspect that the prettier extension is not visible but is embedded inside the Vetur extension.


Well, like the guy (@user2982122) mentioned but instead of File go to Code -> Preferences -> Settings, then look for Quote, select Prettier and check both boxes

enter image description here enter image description here


For projects that use .editorconfig file by default. The formatter will ignore the rules in the settings and use the rules in .editorconfig, then you can either:

  • Remove .editorconfig file, and use your VSCode settings.
  • Add quote_type = single to the .editorconfig file regarding your file type. You can also set quote_type value to double or auto.

It looks like it is a bug open for this issue: Prettier Bug

None of above solution worked for me. The only thing that worked was, adding this line of code in package.json:

"prettier": {
    "singleQuote": true
  },