Sublime Forum

Keyboard-only Side Bar tip (and question)

#1

Using the side bar seems to be very mouse dependant (and I hate being forced to use the mouse!). Fortunately I was able to come up with a simple solution:

[code]import sublime, sublime_plugin

class ShowSidebarAndFocus(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command(“toggle_side_bar”)
self.window.run_command(“focus_side_bar”)
[/code]
…I mapped this to the f1 key:

{ "keys": "f1"], "command": "show_sidebar_and_focus" },
…and now pressing f1 not only gives you the side bar, but gives it keyboard focus!

So now, here’s the question: Is it possible to tell if the side bar is already open, so that I can just give it focus?

Ideally the “toggle” logic would be…
a) if the side bar is not open, open it and give it focus.
b) if the side bar is already open, but doesn’t have focus, give it focus.
c) if the side bar is open and has focus, close it.

thanks!

0 Likes

#2

is there a way to tell if the side bar is already open?

0 Likes