VS Code有什么方法可以缩进方括号中吗? [英] Is there any way for VS Code to indent to an open bracket?

查看:98
本文介绍了VS Code有什么方法可以缩进方括号中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改VS Code的缩进行为,以便在键入这样的行后按Enter键:

I'm looking to modify VS Code's indentation behavior so that if I press enter after typing a line like this:

variable = function(param1,

它将缩进到开放括号的级别,以便我可以轻松地设置如下格式的代码:

It'll indent to the level of the open parenthesis so that I can easily format code like this:

variable = function(param1,
                    param2)

我希望它也适用于方括号和大括号:

I'd like it to work for open square brackets and curly brackets as well:

variable = function([1, 2, 3, 4
                     5, 6, 7, 8],
                    param2,
                    {'a': 1, 'b': 2,
                     'c': 3, 'd': 4},
                    param4)

尽管使用C ++或C#时花括号的行为不是必需的(甚至可能是不希望的),但我更希望它对我使用的每种语言都具有这种行为.

I'd prefer it to have this behavior for pretty much every language I work with, though the curly braces behavior isn't necessary (and may even be undesirable) when working in C++ or C#.

这与Sublime Text的 indent_to_bracket 设置非常相似.

This is very similar to Sublime Text's indent_to_bracket setting.

有什么办法可以做到这一点?如果没有设置,我愿意修改任何必要的内容.我也对可以执行此操作的扩展程序持开放态度,甚至在必要且有意义的情况下编写扩展程序.

Is there any way to accomplish this? If there's no setting, I'm willing to tinker with whatever is necessary. I'm also open to an extension that can do this, or even writing an extension if it's necessary and makes sense to do so.

推荐答案

有一个已解决的问题在GitHub上具有此功能.开发团队最近的评论如下:

There is a closed issue on GitHub for this very feature. A recent comment from the development team reads as follows:

在未来的6至12个月的路线图中将不会考虑此功能请求,因此我们将关闭此请求,以确保我们必须解决的问题数量才可解决.感谢您的理解和编码愉快!

This feature request will not be considered in the next 6-12 months roadmap and as such will be closed to keep the number of issues we have to maintain actionable. Thanks for understanding and happy coding!

因此,在可预见的将来将不包括该信息.

Therefore, it will not be included in the foreseeable future.

目前唯一的选择是尝试创建一个完全做到这一点的扩展,甚至破解主编辑器源代码.我建议您从这里开始: https://code.visualstudio.com/docs/extensions/overview

The only option right now would be to attempt to create an extension that does exactly this or even hack on the main editor source code. I suggest you start here: https://code.visualstudio.com/docs/extensions/overview

这篇关于VS Code有什么方法可以缩进方括号中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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