简体   繁体   中英

Sublime Text 3 (Windows 10) - Command Palette Won't Open, its mixed up with Package Manager

I installed package manager and a bunch of packages right after I installed SublimeText3. When I go to Tools -> Command Palette, its opens up the package manager. Also, it said before that its key binding is CTRL + \\ but when I ran that, it did nothing. So I set a new key binding for it: 在此处输入图片说明

and when I run that key binding, it opens up the package manager. Thats kind of useful for me because CTRL + SHIFT + P does not open the package manager for me (hence why I added it to the user keymap file, it still doesn't work though). I can't actually find package manager in the key bindings file.

So somehow the command palette is tangled up with the package manager. Is there a file where all of the commands are listed and mapped? How would I go about fixing this?

EDIT: I forgot to mention, the package manager I'm talking about is Package Control: 在此处输入图片说明

PackageControl provides its list of commands from the command palette itself, so that might be the source of your confusion. In particular:

  • If you open the command palette ( Shift+Ctrl+P by default under Windows/Linux), the package control commands can be found in it prefixed by the text "Package Control:", for example "Package Control: Install Package". Thus you can find the commands there by entering pc: in the command palette.

  • Package Control modifies the main menu by adding a Preferences > Package Control menu item which, when selected, opens up the command palette pre-populated with the filter that filters down to only see package control commands.

So in answer to your question, there is a file where the various commands are listed out. Commands are added to the command palette by way of .sublime-commands files. If you use PackageResourceViewer you can use it to open up the Default.sublime-commands file provided by the PackageControl project.

This is a simple JSON file that provides the captions and associated commands that make up PackageControl's additions to the command palette. If you wanted to bind a key to invoke a PackageControl action directly, such as installing a package, you can find it's entry in the file to determine the command.

The entry in the file for the install command is:

{
    "caption": "Package Control: Install Package",
    "command": "install_package"
},

So you could bind this to a key with something like:

{ "keys": ["ctrl+alt+shift+i"], "command": "install_package" }

If instead you wanted to bind a key to do what the Preferences > Package Control menu item does, opening the command palette and showing only the list of Packge Control commands, you can replicate what the menu command does by showing the overlay with the text pre-populated. To get at how that works, you can open up the Main.sublime-menu file provided by PackageControl (also using PackageResourceViewer) to see what command is doing that.

Such a binding would look like this:

{
    "keys": ["ctrl+alt+shift+i"],
    "command": "show_overlay",
    "args": {"overlay": "command_palette", "text": "Package Control: "}
}

Note that this is the same as the default command for opening the command palette, only we are providing an extra option to specify what text the text entry field should be initially populated with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM