How to select Build Window in Sublime Text with a keyboard shortcut. I can’t find command for it.
How to select Build Window in Sublime Text
You can use shift + escape to open the build panel (if you have already run a build system) or right click on the panel switcher icon on bottom left corner in status bar to select Build Results
Yes, but when I do that cursor is not in the Build Window. I still need to mouse click on Build Window to select text in it.
From a long time ago. I had the same issue:
It does seem strange that you can “jump aound” various boxes/tabs/windows/dialog boxes but not others. Sometmes it’s the really useful ones that you can’t; like when you want to copy and paste your error message into google for SO (eg)
Agreed. If you can click on it with a mouse you should be able to do the same with keyboard. That is the only box that I cant select with a keyboard. Also that box is like small text editor. It has capabilities like notepad on windows; you can select text copy, paste, type text in it, etc. When I do testing sometimes its handy to copy output of a build system in your code(main file), not to mention coping output for checking on the internet, as you mention.
It would be great if we had any way of selecting that box(plugin will be nice as well).
A simple plugin can do it.
import sublime
import sublime_plugin
class FocusExecPanelCommand(sublime_plugin.WindowCommand):
def run(self):
exec_panel = self.window.find_output_panel("exec")
self.window.focus_view(exec_panel)
And a sample key binding
{
"keys": ["ctrl+alt+shift+2"],
"command": "focus_exec_panel",
},
This plugin assumes that you already have the exec
panel visible (after running a build system). If you want to display the exec
panel and focus it, then we need an additional line of code.
import sublime
import sublime_plugin
class FocusExecPanelCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("show_panel", { "panel": "output.exec" })
exec_panel = self.window.find_output_panel("exec")
self.window.focus_view(exec_panel)
This will first display the exec
panel and then focus it.
ST3 last build before ST(4), Linux
I was a bit too ethusiastic, that line doesn’t work for me if there’s no exec panel open already, also after further testing that line makes no difference what so ever. If the panel is open I can access it, if it’s not I can’t; but still a great improvement !
The build output panel is only created in windows the first time a build is run in the window; otherwise it’s not there.
Also worth pointing out that the output panel is, as the name suggests, output only. So, unless you’re trying to get the input focus there so you can copy some of the text out without using the mouse, keep in mind that when you type into it, your text doesn’t go to the running program.
The plugin assumes that the exec
panel is already present. Feel free to improve it to show a status bar message or something to the users if the panel is not present. I’ll leave that as an exercise to the interested readers.
Also as noted by OdatNurd, if your goal to bring the focus to the panel is to type something and hope that it works as an input to the program, then that won’t work (And frankly speaking I am getting bored by telling why it doesn’t work). This is potentially useful to quickly copy some error and do a quick online search (at least, one use case I can think of)