Question

I installed the Emmet plugin in the Sublime text 3, and when I type 'function' in JavaScript syntax, the editor will autocomplete it into function function_name (argument) { // body... }, but I need to delete the space between the function_name and the argument.

Thank you.

Was it helpful?

Solution

This is actually a built-in Sublime snippet, and is not related to Emmet. To override the default, perform the following steps:

  1. Go to Preferences -> Browse Packages... to open a file explorer menu in your ST3 Packages directory.

  2. Create a new directory called JavaScript.

  3. Create a new file in Sublime with the following content:

    <snippet>
        <content><![CDATA[function ${1:function_name}(${2:argument}) {
        ${0:// body...}
    }]]></content>
        <tabTrigger>fun</tabTrigger>
        <scope>source.js</scope>
        <description>Function</description>
    </snippet>
    
  4. Save the file as Packages/JavaScript/function-(fun).sublime-snippet - make sure you use this exact name, or it won't override the built-in snippet.

  5. Restart Sublime (just in case), and now when you're writing JavaScript and type funTab it will display:

    function function_name(argument) {
        // body...
    }
    

OTHER TIPS

You can make this even easier by installing Package Resource Viewer

  1. Press Ctrl-Shift-P to bring up Package Control
  2. type install hit Enter to bring up Package Control: Install Package
  3. type PackageResourceViewer hit Enter

To modify the Javascript function-(fun) snippet:

  1. Bring up Package Control again (Ctrl+Shift+P)
  2. type ope hit Enter to bring up PackageResourceViewer: Open Resource
  3. type js hit Enter to browse the Javascript package
  4. type fun& select function-(fun) and edit to your heart's content :)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top