编辑器配置 - 如何对齐代码 [英] Editor config - how to align the code

查看:38
本文介绍了编辑器配置 - 如何对齐代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VS Code,为了格式化我的代码,我使用了格式化程序 CTRL + SHIFT + I.它工作正常,但我希望能够将我的代码格式化为以这种方式对齐:

I'm using VS Code and for formating my code I use a formatter CTRL + SHIFT + I. It works fine, but I would like to be able to format my code to be align in this way:

之前:

export const apiConfig = {协议:'https',url: 'www.example.com',超时秒数:15}

之后:

export const apiConfig = {协议:'https',url: 'www.example.com',超时秒数:15}

有什么办法设置吗?.editorconfig 的任何特定设置?

Any way to set it up? Any specific setting for .editorconfig?

推荐答案

您所要求的在 VScode 中不可能一次性轻松实现,并且与 .editorconfig 完全无关,因为它只管理而是基本功能 — 设计.

What you are asking for is impossible to easily achieve in one go within VScode and completely unrelated to .editorconfig, as it only governs rather basic features — by design.

您需要将格式与这样的对齐插件结合使用:https://marketplace.visualstudio.com/items?itemName=steve8708.Align

You will need to use the formatting in combination with an alignment plugin like this: https://marketplace.visualstudio.com/items?itemName=steve8708.Align

如果您喜欢冒险,您可以组合一个解决方案,通过按下键盘快捷键按顺序运行这两个命令.然而,VScode 在这方面不像 Vim 那样容易编写脚本.

If you feel adventurous, you may be able to hack together a solution which runs both commands in sequence at the push of a keyboard shortcut. However, VScode is not as readily scriptable in this regard as for example Vim is.

这篇关于编辑器配置 - 如何对齐代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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