Victor Leung
Victor Leung

Reputation: 439

Unnecessary semicolon using Sublime Text 3 autocomplete for JavaScript if-statement

I am using sublime text 3 autocompletion for JavaScript.

For if-statement, it added a semicolon at the end.

if (true) {};

Using JSHint, it gives me an error for most of my code written.

I would like to ask how to customise this autocompletion as my preference?

Upvotes: 5

Views: 1150

Answers (2)

select
select

Reputation: 2618

Since @wesbos answer did not do the trick for me here is what I found out.

Sublime 3 does not extract packages. You will find your packages (on linux) in either /opt/sublime_text/Packages/ for default packages or ~/.config/sublime-text-3/Installed Packages for packages you installed, in a zip archive with the extension .sublime-package.

To change the content of a package install the Package Resource Viewer and execute the command : Open resource browse to the file you want to change (if.sublime-snippet, I would also change the for-()-{}.sublime-snippet since it has the same strange semicolon in there) and edit it.

Once you save the file it will save it to ~/.config/sublime-text-3/Packages/JavaScript/if.sublime-snippet. This file then overwrites the default file in the original zip package.

As I understood it is important to know that files that you overwrite in this way will not be updated when you update packages, since they overwrite whatever is in the updated package!

Upvotes: 0

wesbos
wesbos

Reputation: 26317

Open the Sublime Text Folder by going to PreferencesBrowse Packages.

Then find the folder called JavaScript

Then open if.sublime-snippet and delete the semi-colon so 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>

Upvotes: 6

Related Questions