Skip to content

Instantly share code, notes, and snippets.

@pincheira
Created September 6, 2012 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pincheira/3658238 to your computer and use it in GitHub Desktop.
Save pincheira/3658238 to your computer and use it in GitHub Desktop.
Shorcut to add an Object method in JavaScript

Sublime Text shorcut to add an Object method in JavaScript

To achieve this easily:

start: function() {
  ...
}

You just need to write the name of the method start and then press command + shift + enter.

Snippet

Create a new file and name it object-method-command.sublime-snippet and add it to ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/JavaScript/

<snippet>
    <content>
      <![CDATA[: function() {
  ${1:...}
},]]>
    </content>
    <tabTrigger>object-method</tabTrigger>
    <scope>source.js</scope>
    <!-- Optional: Description to show in the menu -->
    <description>Object method / instance function</description>
</snippet>

Key binding

Go to Preferences > Key Bindings - Default and then add this object at the end of the array:

	{ "keys": ["option+shift+enter"], "command": "insert_snippet", "args": { "name": "Packages/JavaScript/object-method-command.sublime-snippet" } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment