0

Is it possible to insert a snippet in sublime text 3 from the menu or some other way?

I read several instructions and many of them said I should define a tab trigger binding with tab, but is it also possible to insert a snippet in another way? I am not using tab triggers.

A key binding with ctrl or alt would be nice!

1 Answer 1

0

Insert a snippet using the menu

menu tools > snippets ...

A lists with all the available snippets appears

Assign a keyboard shortcut to a snippet

Find out the relative path to the snippet file inside the sublime data directory. For example: packages/user/mysnippet.sublime-snippet

Go to menu preferences > keybindings user

insert this entry into the list. In this example the new keybinding would be ctrl-7:

{
   "keys": ["ctrl+7"],
   "command": "insert_snippet",
   "args": {
     "name": "packages/user/mysnippet.sublime-snippet"
   } 
},

The "command" needs always to be "insert_snippet".

Use forward slashes in the "name", even on windows.

You can use the following modifiers and also glue them together like ctrl+alt+7. Some of them try to be platform independendent:

ctrl

control

alt

option - apple/pretzl/clover key on a Mac

command - command key on a Mac

super - the logo key on any keyboard (apple, pretzl, clover, windows, ...)

primary - Ctrl on Windows and Linux, or apple/pretzl/clover key on a Mac

You can use a-z and 0-9 and also special keys:

, . \ / ; ' + - = [ ] up down left right insert home end pageup pagedown backspace delete tab enter pause escape spacekeypad0 keypad1 keypad2 keypad3 keypad4 keypad5 keypad6 keypad7 keypad8 keypad9 keypad_period keypad_divide keypad_multiply keypad_minus keypad_plus keypad_enter clear f1 f2 f3, etc

Be sure you don't overwrite a keybinding that you still want. See menu preferences > keybindings default and also preferences > keybindings user (the file that you are just editing).

I found that most ctrl+alt combinations with a letter a-z (except p which is occupied) seem to be unused currently.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .