在 VS Code 中更漂亮 - 在双引号内格式化双引号 [英] Prettier in VS Code - Format double quotes inside double quotes
本文介绍了在 VS Code 中更漂亮 - 在双引号内格式化双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 VS Code 中使用扩展 Prettier.我想要代码中的双引号.jsxSingleQuote"和单引号"设置为 false.
I'm using the extension Prettier in VS Code. I want double quotes in the code. The "jsxSingleQuote" and "singleQuote" are set to false.
当我在这行代码上运行 format
When I run format on this line of code
var hello = "\"hello\"";
Prettier 将其格式化为:
Prettier formats it to:
var hello = '"hello"';
我想保留双引号,代码行不要格式化!
I want to keep double quotes and the line of code should not be formatted!
这里是设置:
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"filepath": "..../app.js",
"parser": "babel"
}
推荐答案
尝试,在根级别创建文件 .prettierrc
,即 package.json 的兄弟,具有属性 singleQuote
设置为 true 如下:
Try, creating file .prettierrc
at root level, i.e sibling to package.json, with property singleQuote
set to true as below:
{
"singleQuote": true
}
这篇关于在 VS Code 中更漂亮 - 在双引号内格式化双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文