5

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?

0

2 Answers 2

6

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>
Sign up to request clarification or add additional context in comments.

6 Comments

This bug should be reported upstream.
It's not a bug - it's a coding preference - if you don't like the semi colon, then update your snippet to remove it.
Uh, really? But nobody uses that in JavaScript. No single coding style guide for JS I've seen recommends that, I've even seen some warning against it as non-idiomatic (and from the technical perspective, it makes no sense to include empty statements). Therefore I think that it should not be the default setting.
I have the same problem with sublime text 3, and I do not have JavaScript folder, neither if.sublime-snippet file. Any ideas ?
@Milos you can use Package Resource Viewer to modify the snippet: stackoverflow.com/a/21196293/3481183
|
0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.