How do I set up VSCode to put curly braces on a new line?(如何设置 VSCode 以将花括号放在新行上?)
问题描述
假设我输入以下代码并对其进行格式化.
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 以将花括号放在新行上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何设置 VSCode 以将花括号放在新行上?


基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Bokeh Div文本对齐 2022-01-01