Sublime Text: how to make shortcut for inserting text?

后端 未结 4 1689
灰色年华
灰色年华 2020-12-13 13:50

I need make a shortcut that will be adding certain text at the cursor, eg {sometext}, how can this be done?

4条回答
  •  温柔的废话
    2020-12-13 14:34

    Select the Key Bindings - User item under Sublime's Preferences, then add the following example line:

    {"keys": ["ctrl+shift+c"], "command": "insert_snippet", "args": {"contents": "hello!"}}
    

    This will add a CTRL+SHIFT+C shortcut to insert the hello! snippet.

    By the way, don't forget to add a comma to the previous key binding hash so that all but the last line end with a comma. i.e.:

    [
        {"keys": ["..."], "command": "..." },
        {"keys": ["..."], "command": "..." },
        {"keys": ["..."], "command": "..." },
        {"keys": ["ctrl+shift+c"], "command": "insert_snippet", "args": {"contents": "hi!"}}
    ]
    

提交回复
热议问题