Last updated: Apr 6, 2024
Reading time·4 min
.editorconfig
file takes precedence over VS Code settingsTo replace double quotes with single or vice versa in VS Code:
Ctrl
+ Shift
+ P
(or Command
+ Shift
+ P
on macOS).F1
to open the Command Palette.You can also open the settings screen by pressing Ctrl
+ ,
on Windows and
Linux or Cmd
+ ,
on macOS.
The JavaScript and TypeScript Quote style settings have 3 possible values:
auto
- the quote style is inferred from the existing code.double
- double "
quotes are always used.single
- single '
quotes are always used.If you only want to use single quotes in your files, set the following settings
to single
.
Conversely, if you only want to use double quotes in your code, set the
properties to double
.
Note: If you use Prettier in VS Code, click on the following subheading:
You can also set your preferred quote style in your settings.json file.
Ctrl
+ Shift
+ P
(or Command
+ Shift
+ P
on macOS).F1
to open the Command Palette.Type user settings json.
Click on Preferences: Open User Settings (JSON)
settings.json
file."javascript.preferences.quoteStyle": "single", "typescript.preferences.quoteStyle": "single",
Make sure to remove the trailing comma if the property comes last.
You can set the properties to double
if you'd rather use double quotes.
"javascript.preferences.quoteStyle": "double", "typescript.preferences.quoteStyle": "double",
If you use the Prettier extension to format your code, you have to edit your prettier-specific settings to make the change.
Ctrl
+ Shift
+ P
(or Command
+ Shift
+ P
on macOS).F1
to open the Command Palette.You can also open the settings screen by pressing Ctrl
+ ,
on Windows and
Linux or Cmd
+ ,
on macOS.
When the Prettier: JSX Single Quote setting is enabled, single quotes are used instead of double quotes in JSX (React.js) files.
When the Prettier: Single Quote setting is enabled, single quotes are used instead of double quotes everywhere (except for JSX files).
If you have a .prettierrc
, prettierrc.json
or .prettierrc.js
file, it
takes precedence over your VS Code settings.
The same is the case if you have a prettier
in your package.json
file.
If you have a .prettierrc
file, set the following properties.
{ "singleQuote": true, "jsxSingleQuote": true }
If you manage your prettier configuration in your package.json
file, you have
to add the following properties to your prettier
object.
"prettier": { "singleQuote": true, "jsxSingleQuote": true }
.editorconfig
file takes precedence over VS Code settingsIf you have a .editorconfig
file, you have to make the change in your
.editorconfig
as your VS Code settings won't be read.
Add the following line to your .editorconfig
file to replace single quotes
with double.
quote_type = single
If you only want to use double quotes, set the quote_type
to double.
quote_type = double
If the changes have no effect, restart VS Code.
I've also written an article on how to find and replace with a newline in VS Code.
You can learn more about the related topics by checking out the following tutorials: