0

I can do this by clicking View -> Ruler -> 80 but it'd be a lot more convient to do it from the command palette or a hotkey (apart from alt, right, right, right, right, down, down, down, down, down, down, down, down, down, down, down, down, down, down, down, down, down, down, right, down, down, down, enter).

Edit: Though I found a way to make a file to add command palette options, I do not know how to make it work for arbitrary numbers, ideally typing set ruler 33 would set the ruler to 33 and set ruler 44 66 would make a ruler at 44 and 66. I only know how to do it by making an explicit command for each value rather than a dynamic one for all of them.

Captain Man
  • 6,997
  • 6
  • 48
  • 74

2 Answers2

1

Once you have the menu bar focused, you can generally hit the first letter of a menu to open it (V for View in this case), then the first letter of any submenus or options you wish to open or select, respectively. In previous versions of Windows (I haven't used Win10 yet) there was an option, usually set by default, to underline the "hotkey" of the menu item, which is especially useful if you have two menu items that begin with the same letter. If nothing is underlined, I would assume you can just start spelling out the menu item, so if you have View and Verify on the same submenu, you'd just type vi for the first and ve for the second one.

So, for your particular setup, just hit Alt to focus the menu bar, then V, R, 8 for View -> Ruler -> 80, respectively.


As a freebie, I'll give you not one but two keyboard shortcuts as well:

{ 
    "keys": ["ctrl+shift+8"], 
    "command": "set_setting", 
    "args": 
    {
        "setting": "rulers", 
        "value": [80]
    } 
},
{ 
    "keys": ["ctrl+shift+0"], 
    "command": "set_setting", 
    "args": 
    {
        "setting": "rulers", 
        "value": []
    } 
}

Add these to your user keymap, and CtrlShift8 will set the rulers to 80, while CtrlShift0 will set them back to none. Remember that this is for the current view only, not all open files, and any newly-opened files or views will default back to the value in either your project, user settings, or default settings (in that order).

MattDMo
  • 100,794
  • 21
  • 241
  • 231
0

It turns out making a file to add command line palette items is actually pretty easy! Make a file called ruler.sublime-commands and place it in the Installed Packages folder (differs by OS, on windows it is C:\Users\<you>\AppData\Roaming\Sublime Text 3\Installed Packages).

With the below content you can open the palette and type ruler 80 or unset ruler.

[
    {
        "caption": "View: Unset Ruler",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": []
        }
    },
    {
        "caption": "View: Set Ruler: 70",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": [70]
        }
    },
    {
        "caption": "View: Set Ruler: 72",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": [72]
        }
    },
    {
        "caption": "View: Set Ruler: 78",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": [78]
        }
    },
    {
        "caption": "View: Set Ruler: 80",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": [80]
        }
    },
    {
        "caption": "View: Set Ruler: 100",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": [100]
        }
    },
    {
        "caption": "View: Set Ruler: 120",
        "command": "set_setting",
        "args": {
            "setting": "rulers",
            "value": [120]
        }
    }
]
Captain Man
  • 6,997
  • 6
  • 48
  • 74
  • So you changed your question after accepting my answer, then unaccepted it and gave it to yourself? Cute. And, you deleted the comment asking me to make my suggestion an answer. And, you don't put that file in the `Installed Packages` folder, you put it in `Packages/User` (`Installed Packages` is solely for third-party `.sublime-package` archives). And, your answer still doesn't address your (changed) question, which is putting the ruler at an *arbitrary* spot. – MattDMo May 09 '16 at 23:05
  • See this [meta post](http://meta.stackexchange.com/q/93513) about "moving the goalposts" - it is specifically frowned upon. Answerers do not get notifications when questions change. Since you changed what you wanted *and* deleted the comments, my answer now looks stupid, like I'm answering the wrong question. If you had wanted to know how to add the shortcuts to the Command Palette, a simple comment on my answer would have sufficed. – MattDMo May 09 '16 at 23:21
  • @MattDMo In the text of the question I specifically asked for palete or hotkey so I don't think your answer looks dumb. At the same time though I do how asking one thing in the title and another in the body when switching which I view as "the real question" is not right. I will re-accept yours if it makes you happy, I didn't mean any of this as an attack. I didn't mean this as an attack. I deleted the comment because it seemed like clutter after you made the answer. I'll make a new question for arbitrary rulers as suggested in the meta post. – Captain Man May 10 '16 at 13:18