Search code examples
keyboard-shortcutssublimetext2

Sublime text 2, how to set hotkey to menu items 'View - Word Wrap Column - etc'?


I've found solutions on hotkeys Edit - Wrap - etc menu, and View - Word Wrap toggle. But not View - Word Wrap Column - etc menu items. Also tried to find plugins, nothing ...

https://www.sublimetext.com/docs/3/key_bindings.html

Currently there is no compiled list of all built-in commands. The names of many commands can be found by looking at the Default ({PLATFORM_NAME}).sublime-keymap files in the Default/ package.


Solution

  • If you open the console with Ctrl` and enter

    sublime.log_commands(True)
    

    it will print the command for every. single. thing. you. do. Change the True to False to turn it off.

    At any rate, for View → Word Wrap Column → 80, for example, it prints

    command: set_setting {"setting": "wrap_width", "value": 80}
    

    To set the keyboard shortcut, open your .sublime-keymap file and add the following:

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

    You can of course change the keys to whatever you want.