Sublime text: how to add a key binding to hex_viewer package command

百般思念 提交于 2021-02-18 17:25:08

问题


I've installed the Hex Viewer package on sublime text 3, to toggle it i use ctrl+shift+p to open the command palette, then i search for "hex" and select the command of the package to toggle the hex view.

I was wondering how to bind a key to the specific package command, I'm aware of the key bindings configuration file but I don't know what JSON line should I add to call the package command.

This is my first question on stackoverflow, sorry if I did something wrong, have a nice 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 by key-bindings.

This is the one I should like to bind

Hex Viewer: Toggle Hex View

And this is the string I've tried to paste on the key-bindings JSON file:

{"keys":["ctrl+shift+h"] , "command":"Hex Viewer: Toggle Hex View"}

回答1:


You need to add a key binding for the Hex Viewer keymap.

To do this, after installing Hex Viewer via Package Control, navigate to Package Settings -> Hex Viewer -> Key Bindings - Default and add the following:

[
    {
        "keys": ["ctrl+shift+h"],
        "command": "hex_viewer"
    }
]

To save the file, you need to ensure that the %APPDATA%\Sublime Text 3\Packages\HexViewer directory exists, assuming this is your package directory.

There's also an example key map available on the GitHub link you mentioned with the other available commands.

Example.sublime-keymap

[
    {
        "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"
    }
]



回答2:


Your binding should be

{ "keys": ["ctrl+shift+h"] , "command":"hex_viewer"}



回答3:


you could use something like this to assign a key biding to a plugin

-> Preference -> key - bending - user

then add this

[
    { "keys": ["ctrl+shift+x"], "command": "the name of plugin." }

]


来源:https://stackoverflow.com/questions/25885473/sublime-text-how-to-add-a-key-binding-to-hex-viewer-package-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!