【问题标题】:Editor config - how to align the code编辑器配置 - 如何对齐代码
【发布时间】:2018-05-08 10:43:54
【问题描述】:

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

之前:

export const apiConfig = { protocol: 'https', url: 'www.example.com', timeoutSec: 15 }

之后:

export const apiConfig = { protocol: 'https', url: 'www.example.com', timeoutSec: 15 }

有什么方法可以设置吗? .editorconfig 的任何特定设置?

【问题讨论】:

    标签: visual-studio-code editorconfig


    【解决方案1】:

    您所要求的内容不可能在 VScode 中一次性轻松实现,并且与 .editorconfig 完全无关,因为它只管理而不是 basic features — 设计使然。

    您需要将格式与对齐插件结合使用,如下所示:https://marketplace.visualstudio.com/items?itemName=steve8708.Align

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 2015-12-07
      • 2020-05-17
      • 1970-01-01
      • 2012-10-29
      • 2011-06-24
      • 1970-01-01
      相关资源
      最近更新 更多