問題描述
假設我輸入以下代碼并對其進行格式化.
Let's say I type in the following code and format it.
if (condition) { /* Hello! */ }
如果這是 C# 代碼,格式如下:
If this is C# code, it is formatted like this:
if (condition)
{
// Hello!
}
如果是 JavaScript,VSCode 的格式是這樣的:
If it is JavaScript, VSCode formats it like this:
if (condition) {
// Hello!
}
那么我怎樣才能為所有語言使用第一種格式樣式(新行上的花括號)?我找不到設置或類似的東西.有什么建議嗎?
So how can I use the first formatting style (curly braces on new lines) for all languages? I can't find a setting or something similar. Suggestions?
推薦答案
按照以下步驟使 Visual Studio Code 格式在 Java Script 的新行上打開花括號> 和 鍵入腳本.
Follow the steps below to make Visual Studio Code format opening curly braces on a new line for Java Script and Type Script.
在 Visual Studio 代碼 (v1.20.0)
- 轉到文件首選項設置
在用戶設置"(在右側窗格中)中添加以下行
- Go to FilePreferencesSettings
Add the following lines in 'User Settings' (in the right side pane)
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
保存用戶設置"即可完成!
這篇關于如何設置 VSCode 以將花括號放在新行上?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!