Sublime Forum

Some keymaps don't appear in command palette

#1

An odd thing; I’ve installed some plugins that add new key mappings.

In my case, it is QuickFileMove.

It defines a key mapping that works:

  { "keys": "super+shift+r"], "command": "quick_file_move" }
]

However, I would expect that the command palette would show this key mapping; it does not.

AFAIK, the QuickFileMove plugin has defined everything correctly, so it feels like a Sublime 2 bug that the key mapping does not appear the way it should.

0 Likes

#2

The keymap and command palette are defined by two different files. That being said, it’s very easy to add entries to the command palette. First, enter “sublime.log_commands(True)” in the console. Then hit whatever key binding you want. This will get you the command and arguments for that key binding. As a side note (because you also asked about something similar in another thread), this will also display the commands when run from a menu. Next, create a file named “Default.sublime-commands” in “Packages/User”. The contents of the file should be something like this.

    {
        "caption": "Quick File Move",
        "command": "quick_file_move"
    }
]

Of course, you can change the caption as you see fit.

The following is in response to your other thread, I’m just being lazy and don’t want to put it there too.

I believe some people have tried to create plugins to generate all possible commands. One problem with this is naming. Many plugins use the same command with different arguments. How would you create a caption for these commands that is clear and concise. For example, if you had the following command

{ "keys": "shift+down"], "command": "move", "args": {"by": "lines", "forward": true, "extend": true} },

How would you create a caption for it. On the command? Well there are a number of move commands that specify direction, extension, and how to move. So you can’t just use that. I could see a similar issue for menu entries. It’s completely acceptable to have entries with the same caption in the menu (perhaps under different sub menus). For this, would you want to display the entire navigation tree? Additionally, most users only use a subset of the menu commands.

I hope those explanations make sense and provide enough detail so you can customize your ST to fit your needs.

0 Likes

#3

Thanks for the help. Again, this is a shift in world-views from Emacs, but the ability to log executed commands is very nice!

So let me see if I get this straight.

A command exists because of python code in a plugin.

It appears in the command palette only if specified in a .sublime-commands file.

It can be executed by keystroke only if specified in a .sublime-keymap file.

The keyboard shortcut is only displayed if both of the previous are true.

0 Likes

#4

For

are you referring to in the menus? If so, I believe so. Though I’ve never really investigated how things appear in the menus. I tend to add entries to the command palette or create a custom key binding for any action I use on a regular basis. The other two points are correct. Oh, just as a note, they do have to be named “Default.sublime-commands” and “Default ().sublime-keymap” to be picked up by the editor. would be “OSX”, “Linux”, or “Windows”.

0 Likes

#5

This is actually incorrect… it only appears in the menus if it’s in a .sublime-menu file.

0 Likes

#6

True, guess I forgot that little detail when referencing the displayed keyboard shortcut part of the question. Think I touched on everything else though.

0 Likes