5

The VSCode setting "javascript.preferences.quoteStyle": "single" did not work for me and I'm still getting double quotes in my JavaScript snippets as shown in the picture:

image showing snippet using double quotes

Is there a way I can make VSCode use single quotes without having to use any external extension like Prettier?

Kewal Shah
  • 1,131
  • 18
  • 29
  • 3
    The ` "javascript.preferences.quoteStyle"` setting controls quote style for auto imports and refactoring. The example you show is a snippet which is hardcoded to use double quotes. You can create your own snippet if you wish to use single quotes – Matt Bierner May 28 '20 at 22:07
  • @MattBierner I see. It would be great if VSCode gave us the ability to customize their inbuilt snippets to use single quotes instead of us having to create a new one. – Kewal Shah May 29 '20 at 08:50

2 Answers2

-1

Maybe you have a plugin that dictates the style of quotes. Have you tried changing the EditorConfig? https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties

quote_type = "single"

But changing the preferences as you did would do the job. Going to try on my machine and edit this comment if I find out something.

You could also read about this PR to VSCode: https://github.com/Microsoft/TypeScript/pull/17750

BTW Maybe your snippets plugin has hardcoded double quotes

  • The "import" snippet I am using is from VSCode's built-in JavaScript Language Basics extension as shown in the picture. It's not any external plugin using double quotes. – Kewal Shah May 28 '20 at 12:18
  • Also, adding "quote_type: single" in my settings.json does not work and shows that it's an unknown configuration. – Kewal Shah May 28 '20 at 12:22
-1

You’ll need to create a custom snippet. See: Create your own snippets.

To “replace” the existing snippet, you’ll need to hide it from IntelliSense. See: Can I remove snippets from IntelliSense?

Mikol Graves
  • 320
  • 4
  • 6