Example: Create a new Console.log (), and the shortcut key is Co
Environment: Windows 7
Step1:
Tools--New Snippet
1 <Snippet>2 <content><! [Cdata[Consloe.log (${1:this});]]></content>3 <!--Optional:set a tabtrigger to define what to trigger the snippet -4 <Tabtrigger>Co</Tabtrigger>5 <!--HTML file -6 <!--<scope>text.html</scope> -7 <!--css File -8 <!--<scope>source.css, Source.less, Source.scss, source.stylus</scope> -9 <!--js file -Ten <Scope>Source.js</Scope> One <Description>Console.log</Description> A </Snippet>
- The second line of ${1:this} represents the position of cursor 1, multiple values: such as CSS padding:${1:this} ${2:this} ${3:this} ${4:this};
- Tabtrigger: Trigger Word
- Scope: File format, separated by half-width commas
- Description: Description displayed on the right side of the hint
Step2:
Save the file as C:\Users\yourname\appdata\roaming\sublime Text 3\packages\user\test.sublime-snippet
This folder is the package folder, Preferences, Browse Packages and the following user folder, must be saved as . Sublime-snippet suffix
Step3: Testing
Open or create a new JS file, enter "Co", and then press the TAB key, you can quickly enter console.log ();
Note: HTML and CSS, JS snippet in the <scope></scope> in the same way, HTML is <scope>text.html</scope>, and JS, CSS is <scope>source.js</scope> and <scope>source.css</scope>
Sublime Text 3 Add JavaScript snippet (snippet)