2013-05-01 85 views
1

我爲Sublime Text 2創建了很多片段。我總是使用可選的標籤觸發器,並且從不使用觸發器範圍。我想編輯「新摘錄」模板,因此我不必每次都取消註釋並刪除這些相應的選項。如何在Sublime Text 2中編輯默認的'New Snippet'模板?

TL; DR - 哪裏有這個默認的「新段」文字來自這樣我就可以改變它:

<snippet> 
    <content><![CDATA[ 
Hello, ${1:this} is a ${2:snippet}. 
]]></content> 
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> 
    <!-- <tabTrigger>hello</tabTrigger> --> 
    <!-- Optional: Set a scope to limit where the snippet will trigger --> 
    <!-- <scope>source.python</scope> --> 
</snippet> 

回答

4

新的片段命令在包中定義/默認/ new_templates.py 。在那裏編輯它。 (我發現它在崇高打開Packages和尋找它的線路之一。

class NewSnippetCommand(sublime_plugin.WindowCommand): 
    def run(self): 
     v = self.window.new_file() 
     v.settings().set('default_dir', 
      os.path.join(sublime.packages_path(), 'User')) 
     v.settings().set('default_extension', 'sublime-snippet') 
     v.set_syntax_file('Packages/XML/XML.tmLanguage') 

     template = """<snippet> 
    <content><![CDATA[ 
Hello, \${1:this} is a \${2:snippet}. 
]]></content> 
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> 
    <!-- <tabTrigger>hello</tabTrigger> --> 
    <!-- Optional: Set a scope to limit where the snippet will trigger --> 
    <!-- <scope>source.python</scope> --> 
</snippet> 
""" 
+0

非常感謝,非常完美。 – 2013-05-01 23:44:28

+1

這將是聰明,使您的編輯到一個單獨的插件,讓你的變化不在更新中被刪除,你可以在這裏看到我是如何做到的:https://github.com/dsandstrom/CustomNewSnippet。我也爲我的插件做了一個菜單項。 – 2013-05-09 20:14:05