Sublime Text: how to make shortcut for inserting text?

后端 未结 4 1715
灰色年华
灰色年华 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:55

    I did something a little bit more complex and complete too. Like \emph{} when you press ctrl+l, ctrl+e ... My job here is to write \textit{} when you press ctrl+shift+i.

    Go to Preferences > Browse Packages. There inside you should save a file named "Text ital.sublime-snippet" for example. Inside of this file put this code:

    
        Italic text
        
        
        
        text.tex.latex
    
    

    Then go to Preferences > Key Bindings. There inside you will write this:

    [
    { "keys": ["ctrl+shift+i"],  
        "context":  [
            {"key": "selector", "operator": "equal", "operand": "text.tex.latex"}],
        "command": "insert_snippet", "args": {"name":"Packages/LaTeXTools/Text ital.sublime-snippet"}}
    ]
    

    Remind that Packages/LaTeXTools/ is the Location of Preferences > Browse Packages. Remind too that you should insert a comma between two different shortcuts you create.

    Hope it works!

提交回复
热议问题