How to Customize Sublime Text's Default Auto-Complete
I use Sublime Text 3 every day, and I particularly appreciate its JavaScript auto-complete feature.
However, there’s an issue with the default completion for if
statements; it includes an unnecessary semicolon at the end:
if (true) {
}
When using JSHint, this semicolon generates an error for most of the code I write. Having to manually delete it each time is counterproductive.
Solution for the Problem
- Navigate to Preferences → Browse Packages to open the Sublime Text folder.
- Locate the folder named
JavaScript
(create one if it doesn’t exist). - Inside this folder, open
if.sublime-snippet
(create one if it doesn’t exist). - Remove the semi-colon so that your snippet now looks like this:
<snippet>
<content><![CDATA[if (${1:true}) {${0:$TM_SELECTED_TEXT}}]]></content>
<tabTrigger>if</tabTrigger>
<scope>source.js</scope>
<description>if</description>
</snippet>
By following these steps, you can eliminate the unnecessary semicolon and make your coding process more efficient.