Sublime Text: how to make shortcut for inserting text?

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

    @skyisred I think the question is already very well answered to the point. But web-developers often will need to generate dummy content to fill the elements. Say "Lorem ipsum".

    Sublime's dummy text generator

    Type lorem and hit Tab

    Sublime will generate the complete Lorem ipsum dummy text for you.

    Creating shortcut keys to do it

    If you really want to do it with a shortcut

    Go to
    [On Windows] Preferences > Key Bindings - User
    [On OS X] Sublime Text > Preferences > Key Bindings - User

    [
         {"keys": ["ctrl+alt+i","ctrl+alt+s"], "command": "insert_snippet","args": {"contents": "A small snippet"}},
         {"keys": ["ctrl+alt+i","ctrl+alt+m"], "command": "insert_snippet","args": {"contents": "A medium-sized snippet, just good enough to fill in a normal span element."}},
         {"keys": ["ctrl+alt+i","ctrl+alt+l"], "command": "insert_snippet","args": {"contents": "A large snippet, a little more than the medium snippet and just good enough to fill in a paragraph element.This will make your work so much more easier."}}
         ]
    

    I have written an article on creating custom keyboard shortcuts in Sublime Text which might be helpful to you to create shortcuts for other common operations in Sublime Text.

提交回复
热议问题