Writing custom completions in Sublime Text 2

后端 未结 2 1818
天命终不由人
天命终不由人 2021-02-19 20:28

Sublime Text 2 comes with many built-in completions/templates for common idioms. In C++, these include for loops with fields, etc - if I wrote vec and pressed tab,

2条回答
  •  醉酒成梦
    2021-02-19 20:59

    You can edit the default ones by editing the files that generate them inside of your Packages directory. Just browse through the folders to the specific language or check the Default folder to find the right file to edit for one of the defaults.

    You can create custom snippets as well as modify the default ones by going to Preferences > Browse Packages > User and creating a new file with the .sublime-snippet extension.

    Then inside the file paste the following:

    
        
        
        xyzzy
        
        source.python
        
        My Fancy Snippet
    
    

    More info here.

    Alternatively, you can go to Tools > New Snippet and it will open the snippet template in a new file that you can then save and name with the same extension as above.

    Another option, is this way using the Gist package. The only thing I don't like about this setup is it creates a new file with the snippet rather than pasting it into your current file at your cursor. Still it is good for coordinating your most used snippets across several computers.

提交回复
热议问题