0

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
  • sorry, don't quite follow. Do you want a menu to appear with all snippets in it? Commented Jun 15, 2012 at 17:35

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Any idea as to how ST2 determines what order to put those snippets in the menu? (I'd love to be able to reorder them)
@Jason - hmm, wierd. I don't see much of a pattern or order to it. my guess is ordered by scope, then alphanumeric on file name, but i don't have time to check it out properly right now...
File name or description does not seem to have any effect on order. FYI: I've asked this as a separate question here: stackoverflow.com/questions/11182708/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.