22

I wish to set the following rulers only when viewing *.py files. Is that possible?

{
    "editor.rulers": [72, 79]
}
fredrik
  • 9,631
  • 16
  • 72
  • 132

2 Answers2

46

As of version 1.9, Language specific settings was introduced. This means that you can now use the following configuration to achieve what you want:

"[python]": {
    "editor.rulers": [72, 79]
}
Zsw
  • 3,920
  • 4
  • 29
  • 43
  • 3
    How do you set a default to be used if the file type is not of the type specified? – JosephTLyons Sep 27 '19 at 03:21
  • 2
    @joe_04_04 I would assume one simply adds `"editor.rulers": [72, 79]` to `settings.json`, not inside a language-specific tag. – Liam Baker Mar 12 '20 at 08:42
  • 3
    To get the correct language to put in `[]`, use VS Code's **[Preferences: Configure Language Specific Settings](https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings)** command and then select the language from the dropdown. – Gino Mempin Feb 05 '22 at 12:15
0

It looks they have recently added support to have different settings for notebooks. Adding the following to my settings.json has done the trick of adding the rulers to my .py files, but removing them from .ipynb, for example.

"[python]": {
    "editor.rulers": [79, 120]
},
"notebook.editorOptionsCustomizations":{
    "editor.rulers": []
}
ErrorJordan
  • 611
  • 5
  • 15