Coder Social home page Coder Social logo

expand-selection-to-function-js's Introduction

Expand Selection to Function (JavaScript)

A command to expand the current selection to the enclosing JavaScript function. This works with named and anonymous functions.

Each time this command runs it will expand farther out. For anonymous functions, the local variable or property name that refers to the function can also be selected. For example, expanding from the alert line below will first select the anonymous function (as represented with the «angle quotes»):

var foobar = «function() {
    alert('Example!')
}»;

Running it again will then select the variable and trailing semicolon:

«var foobar = function() {
    alert('Example!')
};»

After expanding, you can restore the last selection, which will contract the selection back to what it was before. You can expand several times then restore several times to return to your original selection, which is useful for quickly visualizing the scope of deeply nested functions.

Usage

Both commands are available in the Selection menu and bound to the following keyboard shortcuts on Windows and Linux:

Expand Selection to Function (JavaScript)   Alt+Up
Restore Last Selection                      Alt+Down

Or similarly, on OS X:

Expand Selection to Function (JavaScript)   ⌥↑ (Option+Up)
Restore Last Selection                      ⌥↓ (Option+Down)

Compatibility

Compatible with both Sublime Text 2 and Sublime Text 3.

Version History

1/3/2015

  • Support for ES 6 fat arrow functions (with braces) courtesy of Cheng Lou.
  • Fixed typos in the keyboard shortcuts in this README.

The Past

  • Initial version.

expand-selection-to-function-js's People

Contributors

chenglou avatar gillibrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

expand-selection-to-function-js's Issues

Confused by comments

If you have a comment like

// function a () {

Then the plugin will consider that an actual function and stop the expansion there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.