Sublime Forum

Keyboard shortcut for opening file in editor

#1

There are UI buttons for opening a file in an editor and revealing it in finder, but I didn’t find any way to use them with keyboard shortcuts.

0 Likes

#2

You can always create your own key binding, but I’m not sure if you can determine which file to open in an editor from a keybinding.

0 Likes

#3

I placed a Default.sublime-keymap file in the Data/Packages/User folder and its content is:
[ { "keys": ["ctrl+space"], "command": "toggle_side_bar" } ]
It doesn’t seem to be working…

0 Likes

#4

It works fine here. Do the menu commands in View > Side Bar work?

0 Likes

#5

Yeah, the toggle works, it just looks that my shortcut is completely ignored. Not sure if its an indicationg but the hint when I hover on top of the ‘toggle sidebar’ button still indicates the default shortcut

0 Likes

#6

Does it work any better if you use Preferences > Key Bindings and add it to the platform specific key bindings instead of Default.sublime-keymap?

Default.sublime-keymap is loaded first and Default (<Platform>).sublime-keymap is loaded second and overlaid on top, so if the platform specific key bindings also contains a binding to that key, that would mask it from doing what you want.

0 Likes

#7

I don’t see the Preferences > Key Bindings on build 1107 of Sublime Merge. All I’m trying to do is remap a keyboard shortcut (ctrl+space) to show/hide the sidebar. Shouldn’t that be done through the Default.sublime-keymap file?

0 Likes

#8

Oh my bad, I didn’t notice that this was in the Merge section of the forum.

Generally speaking, key bindings tend to differ by platform based on platform specific rules; for example many on MacOS use the command key while on Windows they would use Ctrl or Alt, and so on. So although keys can exist in the Default.sublime-keymap file, they’re generally put into a platform specific one instead. That allows people that sync their settings across multiple computers to not mess up bindings.

In any case, the problem that you’re having most likely stems from the fact that toggle_side_bar is a Sublime Text command for toggling the side bar (which is why I thought this was a text question). The command for doing this in Merge is toggle_location_bar. I’d try that in the file that you’re using and see if that works better.

0 Likes

#9

Using toggle_location_bar worked but I wonder why, in the Default (Windows).sublime_keymap package in the Packages directory of the install directory, there’s the instruction { "keys": ["ctrl+k", "ctrl+b"], "command": "toggle_side_bar" }, on the 13th line… Is there a reason why that wouldn’t say toggle_location_bar instead? Or am I misinterpreting/missing something?

0 Likes

#10

There is a Default.sublime-package in that folder and there’s also a Default - Merge.sublime-package as well.

The Default.sublime-package contains various resources that seem to be a blend of the resources for Text and Merge together (for example the context menu for branches is in there, but so is the menu file that describes encodings) while the Merge specific one has key bindings and preferences in it only.

I can’t recall offhand if it will load files first from Default and then from Default - Merge or if it only loads certain resources from certain places (my instinct is the first one). In any case, in order to get the full picture it’s helpful to look in the other package as well.

2 Likes