Search code examples
sublimetextsublimetext3autohotkey

AutoHotkey script for toggling Sublime Text 3 sidebar or is there a native ST setting?


I'm trying to write an AutoHotkey script for toggling Sublime Text 3's sidebar. Here's what I have so far:

; Custom Script for Sublime Text 3
; Map 'F10' key to Control+k, Control+b (open/close sidebar)

; If in Sublime Text
#IfWinActive ahk_class PX_WINDOW_CLASS
F10::
    Send {Ctrl down}
    SetKeyDelay -1
    Send {k down}
    SetKeyDelay 0
    Send {Ctrl down}
    SetKeyDelay -1
    Send {b down}
return

So far I can toggle the sidebar closed but the script is not toggling it back open.

The script actually causes weird keyboard functionality in Windows so I don't recommend testing it as is.

How can I rewrite this so it toggles the sidebar properly?


Solution

  • You can change that within Sublime.

    Go to Preferences -> Key Bindings - User and paste this:

    [
        { "keys": ["f10"], "command": "toggle_side_bar" }
    ]
    

    If you already have a bunch of custom key bindings, omit the square brackets.

    { "keys": ["f10"], "command": "toggle_side_bar" }