ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Iifefy

by erquhart ALL

Sublime Text 3 plugin for wrapping Javascript code in IIFE's

Details

Installs

  • Total 385
  • Win 212
  • Mac 124
  • Linux 49
Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 29 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

iifefy

A Sublime Text 3 plugin for wrapping Javascript code in immediately invoking function expressions.

Installation

Using Package Control (Recommended)

For all Sublime Text 2/3 users we recommend install via Package Control.

  1. Install Package Control if you haven't already
  2. Use cmd+shift+P (or ctrl+shift+P for Windows) then select Package Control: Install Package
  3. Search for iifefy and select to install

Manual Install

  1. Click the Preferences > Browse Packages… menu
  2. Browse up a folder and then into the Installed Packages/ folder
  3. Download the zip archive, rename it to Iifefy.sublime-package and copy it into the Installed Packages/ directory
  4. Restart Sublime Text

Usage

This plugin provides two commands:

iifefy: Wraps each current selection in an IIFE. If nothing is selected it wraps the entire document.

iifefy_skip_initial_comments: Same as iifefy, except it begins wrapping at the first non-comment, non-blank line. This is useful for certain per-file configuration comments, which some prefer to keep as the opening line.

Both of these commands add 'use strict'; and a trailing newline to each IIFE by default, but you can change the opening and closing strings that form the IIFE to whatever you like under Preferences > Package Settings > iifefy > Settings - User.

The commands themselves are accessible directly in the context menu and from the Edit > Wrap submenu. Keyboard shortcuts can be added by going to Preferences > Key Bindings - User and adding the following to the file, replacing the key values with your preferred shortcuts:

{ "keys": [ "ctrl+i" ], "command": "iifefy", "context":
    [{ "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true }]
},
{ "keys": [ "ctrl+shift+i" ], "command": "iifefy_skip_initial_comments", "context":
    [{ "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true }]
}

Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

Code copyright 2014 Professant LLC. Code released under the MIT License.