Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change from double quotes to single quotes in VS Code quick fix?

When using VSCode with Angular, I write my import statement list this:

import { AppComponent } from './app.component';

The VSCode Quick Fix adds them like this:

import { WelcomeComponent } from "app/home/welcome.component";

Is there a way to change the VS Code Quick Fix with a VS Code setting to use single instead of double quotes?

like image 411
DeborahK Avatar asked Jun 23 '17 07:06

DeborahK


5 Answers

If your project has a .editorconfig file, try adding the following line:

[*]
...
quote_type = single

I've found that the .editorconfig file seems to override any settings for vscode, prettier, tslint, etc. and it seems to default to something other than single quotes.

Deleting the file can work as well if you don't need it.

More info on editorconfig.

like image 180
David Long Avatar answered Oct 19 '22 23:10

David Long


You can use the Prettier Extension with the following settings (global/workspace).

"prettier.singleQuote": true
like image 40
gngchrs Avatar answered Oct 20 '22 01:10

gngchrs


This works nice and simply...

Open settings in VSCode, e.g. Command + ',' and then filter for "typescript":

enter image description here

Look for "quote style" and change:

enter image description here

like image 31
Andrew E Avatar answered Oct 20 '22 01:10

Andrew E


Check your tslint.json for the quotemark part.

If it's setted to use doublequote by

"quotemark": [
  true,
  "double"   < ------mention here
]

then there will be warning at your typescript file while using singlequote. And this will lead VS Code's quick-fix(show fix option for me) to change singlequote to doublequote.

So the solution should be change double to single.

"quotemark": [
  true,
  "single"   < ------change here
]
like image 26
Pengyy Avatar answered Oct 20 '22 00:10

Pengyy


Press Ctrl + , for settings.

Then search for prettier. Find the setting Prettier: Single Quote

Set that to true.

You can set that in user settings or work space setting.

like image 24
VivekDev Avatar answered Oct 19 '22 23:10

VivekDev