Assigning multiple snippets to a single key bindin

2019-08-29 10:39发布

问题:

In Textmate I have several snippets assigned to specific key equivalents.

So command + F1 would open a little menu that gave me the choice of some number of snippets.

Is the same thing possible in Sublime Text 2?

Follow-uo: In Textmate you assign key equivalents to a snippet and you can assign the same key equ. to multiple snippets. When there is more than one snippet for a selected key equ. a menu opens with all of the snippets assgned to that key equ on it.

This really helps me out...I can have a number of PHP snippets on command + F1, a bunch of jQuery snippets on command + F2 etc... and I don't have to remember a crazy number of key equ, just one for PHP stuff, etc...

回答1:

If you add this line:

{ "keys": ["shift+f1"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "snippet"} }

to your keybindings file /Packages/User/Default (Linux).sublime-keymap. Then everytime you press shift+f1. A popup menu will appear with all snippets. But you only want some snippets. So... in you snippet files that you want to appear add the line:

<description>php snippet, some description</description>

And change the line in the top keybinding from "text": "snippet" in the to "text": "php snippet". Now when you hit shift+f1 all snippets with description beginning with php snippet will appear, with their full descriptions. And you can repeat this process for all your different groups.