Visual Studio Code中的垂直标尺?

本文翻译自:Vertical rulers in Visual Studio Code?

How can vertical rulers (note the plural) be configured in Visual Studio Code? 如何在Visual Studio Code中配置垂直标尺(注意复数)?

In Sublime Text 2 I do 在Sublime Text 2中

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

Neither 都没有

"editor.rulers": [72, 80]

nor 也不

"editor.ruler": 80

seem to work. 似乎有效。


#1楼

参考:https://stackoom.com/question/21kAt/Visual-Studio-Code中的垂直标尺


#2楼

VS Code 0.10.10 introduced this feature. VS Code 0.10.10引入了此功能。 To configure it, go to File > Preferences > Settings and add this to to your user or workspace settings: 要对其进行配置,请转至文件 > 首选项 > 设置 ,并将其添加到您的用户或工作空间设置中:

"editor.rulers": [80,120]

The color of the rulers can be customized like this: 可以像这样自定义标尺的颜色:

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

#3楼

VS Code: Version 1.14.2 (1.14.2) VS代码:版本1.14.2(1.14.2)

  1. Type Shift + Command + p to open panel. 键入Shift + Command + p打开面板。
  2. Enter "settings.json" to open setting files. 输入“ settings.json”以打开设置文件。
  3. At default setting, you can see this: 在默认设置下,您可以看到以下内容:

     // Columns at which to show vertical rulers "editor.rulers": [], 

    This means the empty array won't show the vertical rulers. 这意味着空数组将不显示垂直标尺。

  4. At right window "user setting", add the following: 在右侧的“用户设置”窗口中,添加以下内容:

    "editor.rulers": [140]

Save the file, and you will see the rulers. 保存文件,您将看到标尺。


#4楼

In addition to global "editor.rulers" setting, it's also possible to set this on a per-language level. 除了全局的"editor.rulers"设置外,还可以在每种语言级别上进行设置。

For example, style guides for python projects often specify either 79 or 120 characters, vs git commit messages should be no longer than 50 characters. 例如,Python项目的样式指南通常指定79或120个字符,而git commit消息应不超过50个字符。

So in your settings.json , you'd put: 因此,在您的settings.json ,您将:

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

#5楼

With Visual Studio Code 1.27.2: 使用Visual Studio Code 1.27.2:

  1. When I go to File > Preference > Settings , I get the following tab 转到“ 文件”>“首选项”>“设置”时 ,我得到以下标签

    屏幕截图

  2. I type rulers in Search settings and I get the following list of settings 我在“ 搜索设置”中键入标尺 ,然后得到以下设置列表

    屏幕截图

  3. Clicking on the first Edit in settings.json , I can edit the user settings 单击settings.json中的第一个Edit ,我可以编辑用户设置

    屏幕截图

  4. Clicking on the pen icon that appears to the left of the setting in Default user settings I can copy it on the user settings and edit it 单击默认用户设置中设置左侧出现的笔图标,我可以将其复制到用户设置中并进行编辑

With Visual Studio Code 1.38.1, the screenshot shown on the third point changes to the following one. 使用Visual Studio Code 1.38.1,第三点上显示的屏幕截图将更改为下一个。

在此处输入图片说明

The panel for selecting the default user setting values isn't shown anymore. 选择默认用户设置值的面板不再显示。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章