Search code examples
performancesublimetext2sublimetext3code-snippets

Is there a keyboard shortcut for creating a snippet in Sublime Text?


Going to Tools > New Snippet everytime I need to create a new Sublime Snippet is starting to become cumbersome. Is there a way to create a shortcut in which I can jump to the new snippet page by pressing Command + i?


Solution

  • Preferences -> Key Bindings - User, then add the below line:

    { "keys": ["ctrl+g"], "command": "new_snippet" }
    

    You can replace the ctrl+g combination with anything of course.

    BUT be aware: it might happen that the keyboard layout doesn't send the exact keys that the command is bound to. To investigate this open the console at View -> Show Console or with CTRL+, and type sublime.log_input(True). Now click in the document and give your key combination a try - if the appropriate output doesn't appear in the console, you better specify another combination.

    Finally, if sublime.log_input(True) bothers your coding or debugging process, you can easily disable it by clicking again in the console and using the UP arrow to get the command you typed the last type, change True to False, then hit Enter.