在VS Code中呈现多个标尺


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

  "editor.ruler": 80

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

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

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


当前回答

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

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

颜色可定制

workbench.colorCustomizations

其他回答

结合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"
        },
    ],

}

要在上面的基础上展开,您可以为每个标尺设置多个标尺和颜色。默认的颜色是“#5a5a5a”,如果你在最后添加两个数字,你可以调整它的透明度,使一些标尺比其他的更暗。

下面是我的标尺,以一种更容易编辑的简洁方式定义。

"editor.rulers": [
    {"column":   0, "color": "#5a5a5a80"}, // left boundary is 50% opaque
    {"column":   2, "color": "#5a5a5a20"}, // tab stops are 12.5% opaque
    {"column":   4, "color": "#5a5a5a20"},
    {"column":   6, "color": "#5a5a5a20"},
    {"column":   8, "color": "#5a5a5a20"},
    {"column":  10, "color": "#5a5a5a20"},
    {"column":  40, "color": "#5a5a5a20"}, // center line
    {"column":  79, "color": "#5a5a5a20"}, // right rule minus one
    {"column":  80, "color": "#5a5a5a80"}, // right rule
    {"column": 120, "color": "#5a5a5a40"}  // extra right rule
],   

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

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

颜色可定制

workbench.colorCustomizations

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

"editor.rulers": [80,120]

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

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

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

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

像这样(Gif)