10131

Assigning multiple snippets to a single key binding

Question:

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

So <kbd>command</kbd> + <kbd>F1</kbd> 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 <kbd>command</kbd> + <kbd>F1</kbd>, a bunch of jQuery snippets on <kbd>command</kbd> + <kbd>F2</kbd> etc... and I don't have to remember a crazy number of key equ, just one for PHP stuff, etc...

Answer1:

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.

Recommend

  • Modify a string in a .properties file with batch
  • Batch file set command isn't working in if statement
  • Batch file for Services Start and stop
  • ActionBar three-dot dropdown opens at the wrong place
  • Access 2007 forms with parameterized RecordSource
  • preg_replace speed optimisation
  • Binding a list with another list with WPF
  • What is the first step to using a REST API in Rails?
  • How to find MongoDB field name at arbitrary depth
  • Grid creating extra spacing that I don't want
  • Plotting A Hyperboloid
  • Polymer paper-input and form submission
  • JavaScript overloading with a callback
  • Getting IIS6 to play nice with WordPress Pretty Permalinks
  • PHP: Calling a private method from within a class dying badly
  • Update varbinary(MAX) field in SQLServer 2012 Lost Last 4 bits
  • Regex for nested values
  • Android custom URI scheme incorrectly encoded when type in browser
  • Criterion causing memory consumption to explode, no CAFs in sight
  • HTML5 video only works in IE. The other browsers shows the black screen
  • Possible to “watch” both HAML and SASS at the same time?
  • Image map in Flex
  • Who propagate bugfixes across branches (corporate development)?
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • MySQL Order by column = x, column asc?
  • Parse a date string in a specific locale (not timezone!)
  • Assign variable to the value in HTML
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Email verification using google app script and google forms
  • Setting up SourceTree to merge unity3d scenes with UnityYAMLMerge
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Android screen density dpi vs ppi
  • Bug in WPF DataGrid
  • Redux, normalised entities and lodash merge
  • Do I've to free mysql result after storing it?
  • Compare two NSDates in iPhone
  • A cron job substitute?
  • json Serialization in asp
  • java string with new operator and a literal
  • How to push additional view controllers onto NavigationController but keep the TabBar?