VSCode сингл кавычек автоматической замены

Обновить

November 2018

Просмотры

17.8k раз

38

Когда я выполнить Format Documentкоманду на файл VSCode Вью Component.vue заменить все одиночные кавычки строку с двойной кавычки строки.

В моем конкретном случае это правило конфликтует с конфигурацией пуха электрон-вю, которые требуют singlequote.

У меня нет красивее расширений не установлены (не prettier.singleQuote в моей установке)

Как настроить vscode, чтобы избежать этого?

5 ответы

21

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

0

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

vscode settings for prettier, fixing double quote auto formatting issue

5

For newbies like me:

From the menu Nav bar at the top: Select File -> Preferences -> Settings. In the search text box, type in Quote In the filtered list that appears below, look for the gear icon and next to it - "Prettier". Click on check box to enable "Prettier: Single Quote"

3

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:

vscode vetur settings

68

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.

Связанные вопросы