Sublime Forum

Key Binding Conflicts

#1

I have These Plugins installed:
Bracket Highlighter, Color Highlighter, Color Picker, Dayle Rees Color Schemes, Emmet, Find Key Conflicts, HTML5, IPS BBCode, JSFormat, LiveReload, MarkDown Editing, Package Control, PyV8, SideBarEnhancements, SublimeLinter - CSSlint, JSlint, Pylint, TernJS, x86 and x86_64 Assembly

I can’t use ctrl + shift + c + Tab for [code] blocks from IPS BBCode because it is also the Key Binding to open Color Picker.

I would like Color Picker key bindings to only be active on .html or .css tabs.
I would like IPS BBCode to be active only on untitled tabs, or a document extension .bb.

If Emmet only activates when you open an .html page why can’t Color Picker?

Can I assign document extensions to specific plugins so they are only active for that document type?

0 Likes

#2

File types can have specific configurations that apply to them (while such a file is open, Preferences->Settings - More ->Syntax Specific opens up the config so you can create/edit it), so if you plugins allow you to turn them on and off or otherwise configure them to work the way you want, that’s one way to go about it. That requires the plugin itself to be configurable the way you want, though.

Also, you can specify key bindings that only apply to certain scope (like only HTML files, or only comments in HTML files, etc), so you can definitely modify things so that key combinations work the way you want them to.

For example, I have these key combinations set up to only trigger in certain scenarios:

[
    {
        "keys": ["control+alt+shift+c"],
        "command": "change_request_comment",
        "context":
        [
            { "key": "selector", "operator": "equal", "operand": "comment.block.c" }
        ]
    },
    {
        "keys": ["ctrl+shift+alt+l"],
        "command": "run_datamill_lua",
        "context":
        [
            { "key": "selector", "operator": "equal", "operand": "source.lua" }
        ]
    }
]

This sort of setup will allow Ctrl+Shift+C to do what you want in certain files, but it won’t stop that key binding from taking effect in file types that you haven’t set up. Or to put it another way, it sounds like the color picker plugin has set up a keyboard shortcut that works everywhere, so you would (probably) have to stop it from doing that.

As far as I know (I’m pretty new to Sublime) the only ways to do this are to modify the plugin’s sublime-keymap file or make a global binding to that key that does something else. Modifying the plugin is not a good idea because if/when it updates your change will be lost, though.

You can use Preferences -> Key Bindings to see both the default key bindings (for Sublime) and to open the file where you put your own custom bindings, and the Preferences -> Browse Packages will let you get at the files for the plugin you’re interested in so that you can see what commands it’s binding.

You’d basically just copy the binding out of that file and paste it into your custom file, modifying as needed.

2 Likes

#3

if it’s on GitHub and I believe it is, make a pull request so others can benefit from your improvements :wink:

the advantage being, that if any other changes are ever made to the plugin, you won’t lose yours :wink: (assuming the PR was accepted and merged ofc - but even if not, you will have a reliable way to see what changes you made previously)

1 Like