我如何设置VSCode把大括号放在一个新的线上? [英] How do I set up VSCode to put curly braces on a new line?

查看:1693
本文介绍了我如何设置VSCode把大括号放在一个新的线上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  if(condition){/ * Hello! * /} 

如果这是C#代码,它的格式如下:

  if(condition)
{
// Hello!



$ b

如果是JavaScript,VSCode将如下格式化:

  if(condition){
// Hello!





$ b

那么我怎样才能使用第一种格式化样式(在新行中使用花括号)对于所有语言?我找不到一个设置或类似的东西。建议?

解决方案

我认为在条件语句中没有副作用,但是在return语句中存在一个问题。检查这个链接: http://encosia.com/in- javascript-curly-brace-placement-matters-an-example /



如果你想学习javascript,我建议你阅读JavaScript:The好部分Douglas Crockford。

Let's say I type in the following code and format it.

if (condition) { /* Hello! */ }

If this is C# code, it is formatted like this:

if (condition)
{
    // Hello!
}

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?

解决方案

I think that in a condition statement there are no side effects, but in a return statement there is a problem. Check this link: http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/

If you want to learn javascript, I recommend you read the book "JavaScript: The Good Parts" by Douglas Crockford.

这篇关于我如何设置VSCode把大括号放在一个新的线上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆