Sublime text: how to add key binding to package command
I have set the Hex Viewer package to sublime text 3, to switch it, I use ctrl + shift + p to open the command palette, then I search for "hex" and select the package command to switch the hexadecimal view.
I was wondering how to bind a key to a specific batch command, I know the key binding configuration file, but I donβt know which JSON string should be added to invoke the batch command.
This is my first question on stackoverflow, sorry if I did something wrong, have a good day!
EDIT: This is the github of the package: https://github.com/facelessuser/HexViewer It says:
There are 10 commands available via the Command Palette or Keybindings.
This is the one I would like to bind
Hex Viewer: Toggle Hexadecimal View
And this is the line I was trying to insert into the JSON file for key binding:
{"keys":["ctrl+shift+h"] , "command":"Hex Viewer: Toggle Hex View"}
source to share
You need to add a key binding for the Hex Viewer keyboard layout.
To do this, after installing Hex Viewer using package management, go to Package Settings -> Hex Viewer -> Key Bindings - Default
and add the following:
[
{
"keys": ["ctrl+shift+h"],
"command": "hex_viewer"
}
]
In order to save the file, you need to make sure that the directory exists %APPDATA%\Sublime Text 3\Packages\HexViewer
, assuming it is your packages directory.
There is also a keymap link on the GitHub link that you mentioned with the other available commands.
Example.sublime layout
[
{
"keys": ["ctrl+shift+b","ctrl+shift+h"],
"command": "hex_viewer"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+i"],
"command": "hex_show_inspector"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+f"],
"command": "hex_finder"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+e"],
"command": "hex_editor"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+x"],
"command": "hex_writer"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+u"],
"command": "hex_discard_edits"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+="],
"command": "hex_checksum",
"args": {"panel": true}
},
{
"keys": ["ctrl+shift+b","ctrl+shift+-"],
"command": "hash_selection"
},
{
"keys": ["ctrl+shift+b","ctrl+shift+g"],
"command": "hash_eval"
}
]
source to share