paljenczy
paljenczy

Reputation: 4899

Sublime text - Tab remap

Is there a way to change Tab to a different key to trigger snippets in Sublime Text? As an analouge, in Vim I would re-define the map leader from \ to, say, ,.

Upvotes: 1

Views: 88

Answers (1)

Xælias
Xælias

Reputation: 868

You can edit your Key Bindings (Preferences → Key Bindgins - User) (you can also search for Key Bindings in the command palette). And then add the following:

{
    "keys": ["the_shortcut_you_want"],
    "command": "insert_best_completion",
    "args":  {"default": "default_character", "exact": false}
}

The args are not mandatory if you don't want your shortcut to do anything if not used in a snippet context.

EDIT: I've been asked to provide a real example, apparently this was not enough.
So to use the provided, yet not so related example:

{
    "keys": [","],
    "command": "insert_best_completion",
    "args":  {"default": ",", "exact": false}
}

This should get the comma to trigger the snippets. EDIT2: I can't test this right now, but I think that's exactly the kind of thing I tested. Mine was with a shortcut like ctrl+shift+d, so more like:

{
    "keys": ["ctrl+shift+d"],
    "command": "insert_best_completion",
}

Upvotes: 1

Related Questions