sublime Snippet如何編寫

下面由sublime教程欄目給大家介紹sublime snippet如何編寫!

sublime Snippet如何編寫

sublime Snippet編寫

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

snippet是片段的意思,就是說智能提示的概念。

content是片段內(nèi)容,scope標(biāo)簽是觸發(fā)的文件類型,tagTrigger是觸發(fā)的關(guān)鍵字,description是注釋說明

他和macro的區(qū)別是:
宏的操作都是需要用快捷鍵的,而且保存的宏必須加載在系統(tǒng)keymap文件user自定義部分當(dāng)中。
eg:

對(duì)已經(jīng)保存的宏的操作:

[ ? ? ?{ “keys”: [“ctrl+shift+;”], “command”: “run_macro_file”, “args”: {“file”: “res://Packages/User/test.sublime-macro”} } ?] ?而snippet操作是用于只能提示,只要文件保存了系統(tǒng)就會(huì)自動(dòng)加載,不需要keymap。

但是,marco是對(duì)多個(gè)操作的統(tǒng)一規(guī)劃,而snippet只是只能提示罷了。
也就是說當(dāng)你需要一堆有順序的按鍵操作的時(shí)候,使用marco,記錄宏實(shí)際上就是記錄你的按鍵順序。
而當(dāng)你想加載一個(gè)模板或者智能提示時(shí),用snippet

效果如圖所示

sublime Snippet如何編寫

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊10 分享