Vertical rulers in Visual Studio Code?

2019-01-08 03:35发布

How can vertical rulers (note the plural) be configured in Visual Studio Code?

In Sublime Text 2 I do

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

Neither

"editor.rulers": [72, 80]

nor

"editor.ruler": 80

seem to work.

4条回答
唯我独甜
2楼-- · 2019-01-08 04:00

In addition to global "editor.rulers" setting, it's also possible to set this on a per-language level.

For example, style guides for python projects often specify either 79 or 120 characters.

So in your settings.json, you'd put:

"[python]": {
    "editor.rulers": [
        79,
        120
    ]
}
查看更多
在下西门庆
3楼-- · 2019-01-08 04:02

VS Code 0.10.10 introduced this feature. To configure it:

  1. Go to File > Preferences > settings and in the right pane you can edit your User Settings or your Workspace settings.
  2. Add for example this line to your custom settings on the right: "editor.rulers": [80,120]
查看更多
Explosion°爆炸
4楼-- · 2019-01-08 04:07

VS Code: Version 1.14.2 (1.14.2)

  1. Type Shift+Command+p to open panel.
  2. Enter "settings.json" to open setting files.
  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.

查看更多
一夜七次
5楼-- · 2019-01-08 04:07

With Visual Studio Code 1.27.2, when I go to File > Preference > Settings, I get the following tab.

Screenshot

I enter rulers in Search settings and I get the following list of settings.

screenshot

Clicking on the first Edit in settings.json, I can edit the user settings.

screenshot

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.

查看更多
登录 后发表回答