문제

<tabTrigger>hisnip</tabTrigger>
<description>Test Snippet</description>
<scope>js, php</scope>
<!-- 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> -->

how can I import this file, mySnippet.sublime-snippet into sublime setting so I could always access this snippet without adding to the JS and PHP snippet default file. Is this the way to create snippet in sublime? I want to have a snippet file with my custom code snippets and maybe prioritize them above the default. but seems like sublime does not have user snippet and default snippet json.

도움이 되었습니까?

해결책

First and foremost: your snippet, as such, probably won't do much. You'll want to format it in the following way:

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

To begin creating a new snippet, go to Tools > New Snippet in the menu bar. This will create a new snippet with default options and formatting. You can get a comprehensive list of custom options from the docs.

Once you've created and customized your snippet, go to Sublime Text > Preferences > Browse Packages... and save the snippet in the User directory:

Navigating to Browse Package...

Saving Sublime Text 2 snippet

Note that the proper file extension for snippets is .sublime-snippet. You may also need to restart Sublime Text to load the snippet into use.

Once loaded into the environment, you'll be able to access your snippet by typing hisnip (or whatever is encapsulated between the <tabTrigger></tabTrigger> tags) and pressing the Tab key.

다른 팁

There is a simple but useful package called 'SublimeSnippetMaker'.

https://github.com/jugyo/SublimeSnippetMaker

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top