VSCode single to double quote automatic replace

前端 未结 22 954
死守一世寂寞
死守一世寂寞 2021-01-30 12:03

When I execute a Format Document command on a Vue Component.vue file VSCode replace all single quoted string with double quoted string.

In my specific case

相关标签:
22条回答
  • 2021-01-30 12:47

    please consider .editorconfig overwrites everything, use:

    [*]
    quote_type = single
    
    0 讨论(0)
  • 2021-01-30 12:47

    I'm using typescript, for me it got resolved with checking "Tslint integration" flag under prettier settings (in vscode preferences):

    0 讨论(0)
  • 2021-01-30 12:48

    As noted by @attdona the Vetur extension includes prettier.

    While you can change the prettier settings, as per the accepted answer, you can also change the formatter for specific regions of a vue component.

    Here, for example, I've set Vetur to use the vscode-typescript formatter as it uses single quotes by default:

    0 讨论(0)
  • 2021-01-30 12:48

    You can use this in settings.json

    "javascript.preferences.quoteStyle": "single"
    
    0 讨论(0)
  • 2021-01-30 12:51

    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

    0 讨论(0)
  • 2021-01-30 12:53

    There only solution that worked for me: and only for Angular Projects:

    Just go into your project ".editorconfig" file and paste 'quote_type = single'. Hope it should work for you as well.

    0 讨论(0)
提交回复
热议问题