在VS Code中呈现多个标尺


VS Code标尺的默认配置如下所示。

  "editor.ruler": 80

我的问题与默认的VS Code配置(如上所示)是它只呈现一个标尺。在Sublime文本编辑器中,我可以使用以下Sublime配置渲染任意多的标尺。

  "rulers": [72, 80, 100, 120]

有可能在V.S.代码中渲染多个标尺吗?如果可能的话,在VS Code中多标尺配置看起来像什么?


当前回答

文件->首选项->设置或cntrl+, 输入“ruler”,然后单击Edit settings .json

3.添加大小值','如你所愿

像这样(Gif)

其他回答

进入菜单文件->首选项->设置并添加

"editor.rulers": [preferred-value, preferred-value]

颜色可定制

workbench.colorCustomizations

Visual Studio Code 0.10.10引入了这个特性。要配置它,请转到菜单文件→首选项→设置,并将其添加到您的用户或工作区设置:

"editor.rulers": [80,120]

尺子的颜色可以这样定制:

"workbench.colorCustomizations": {
    "editorRuler.foreground": "#ff4081"
}

在v1.43中是单独为垂直标尺着色的功能。

支持多个不同颜色的标尺-(在settings.json中):

"editor.rulers": [
  {
    "column": 80,
    "color": "#ff00FF"
  },
  100,  // <- a ruler in the default color or as customized (with "editorRuler.foreground") at column 100
  {
    "column": 120,
    "color": "#ff0000"
  },
]

更改标尺的默认颜色:

"workbench.colorCustomizations": {

  "editorRuler.foreground": "#fffa"   
            // or "#ffffffaa" - the a's are alpha transparency values
}

结合kiamlaluno和Mark的答案,以及formatOnSave到Python的自动意图代码:

{
    "editor.formatOnSave": true,
    "editor.autoIndent": "advanced",
    "editor.detectIndentation": true,
    "files.insertFinalNewline": true,
    "files.trimTrailingWhitespace": true,
    "editor.formatOnPaste": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.snippetSuggestions": "top",
    "editor.rulers": [
        {
            "column": 79,
            "color": "#424142"
        },
        100, // <- a ruler in the default color or as customized at column 0
        {
            "column": 120,
            "color": "#ff0000"
        },
    ],

}

除了全局的“editor.ruler”设置外,还可以在每种语言级别上设置。

例如,Python项目的样式指南通常指定79或120个字符,而Git提交消息应该不超过50个字符。

在你的设置中。Json,你会写:

"[git-commit]": {"editor.rulers": [50]},
"[python]": {
    "editor.rulers": [
        79,
        120
    ]
}