Override the default tab autocomplete content in Sublime Text 3

sublimetext3

Solution

The documentation on completions and the two `See Also` links at the top should provide plenty of detail on how to structure your `.sublime-completions` file for use in JavaScript. For example, the following exactly replicates the default snippet (use `\n` for newlines and `\t` for tabs, if needed):

{
        "scope": "source.js",

        "completions":
        [
                { "trigger": "fun", "contents": "function ${1:function_name} (${2:argument}) {\n    ${0:// body...}\n}" }
        ]
}

The easiest way to override the default `fun` JavaScript snippet is to first install the `PackageResourceViewer` plugin via Package Control. Once that's set up, restart Sublime and open the Command Palette with ⌘⇧P (OS X) or CtrlShiftP (Windows/Linux). Type `prv` to bring up the `PackageResourceViewer` options, and choose `PackageResourceViewer: Open Resource`. Scroll down the list and select `JavaScript`, then open the `function-(fun).sublime-snippet` file, using XML for syntax highlighting if you wish. If you are using a more recent version of Sublime, the file may be located under `JavaScript/Snippets`.

Next, set the contents of the file to the following:

<snippet>
    <content><![CDATA[]]></content>
    <tabTrigger>fun</tabTrigger>
    <scope>source.js</scope>
    <description>Don't Use</description>
</snippet>

Save the file, and you should be all set. Assuming your `.sublime-completions` file is set up correctly, when you type `fun` in a JS file you should only see your completion, not the default one.

Good luck!

Problem

What's the correct way to override the JavaScript "fun" tab completion for example? I've created a new file in my user package called: `my.sublime-completions` and I understand that file requires two properties (`scope` & `completions`)? Thanks in advance for the help :)

Original source