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. 選擇默認用戶設置值的面板不再顯示。

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