在VS Code中呈现多个标尺


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

  "editor.ruler": 80

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

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

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


当前回答

使用Visual Studio Code 1.27.2:

当我转到文件>首选项>设置,我得到以下选项卡 我在搜索设置中输入标尺,得到以下设置列表 单击设置中的第一个Edit。json,我可以编辑用户设置 点击默认用户设置中出现在设置左侧的钢笔图标,我可以在用户设置中复制它并编辑它

在Visual Studio Code 1.38.1中,第三点显示的截图变成了下面的截图。

不再显示用于选择默认用户设置值的面板。

其他回答

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

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

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

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

如果你正在使用Flutter,那么你需要编辑dart的标尺,你将从RUN命令导航到文件: % APPDATA % \ \用户\ settings.json代码

把标尺设为0

就像图片。settings。json

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

}

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

"editor.rulers": [80,120]

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

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