How to Customize Sublime Text's Default Auto-Complete

December 22, 2014

I use Sublime Text 3 every day, and I particularly appreciate its JavaScript auto-complete feature.

2014 12 22

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:

  1. Navigate to Preferences → Browse Packages to open the Sublime Text folder.
  2. Locate the folder named JavaScript (create one if it doesn’t exist).
  3. Inside this folder, open if.sublime-snippet (create one if it doesn’t exist).
  4. 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.


Profile picture

Victor Leung, who blog about business, technology and personal development. Happy to connect on LinkedIn