Expand Selection to Function (JavaScript)
Expands the current selection to the enclosing JavaScript function.
Details
Installs
- Total 12K
- Win 7K
- Mac 3K
- Linux 2K
Aug 27 | Aug 26 | Aug 25 | Aug 24 | Aug 23 | Aug 22 | Aug 21 | Aug 20 | Aug 19 | Aug 18 | Aug 17 | Aug 16 | Aug 15 | Aug 14 | Aug 13 | Aug 12 | Aug 11 | Aug 10 | Aug 9 | Aug 8 | Aug 7 | Aug 6 | Aug 5 | Aug 4 | Aug 3 | Aug 2 | Aug 1 | Jul 31 | Jul 30 | Jul 29 | Jul 28 | Jul 27 | Jul 26 | Jul 25 | Jul 24 | Jul 23 | Jul 22 | Jul 21 | Jul 20 | Jul 19 | Jul 18 | Jul 17 | Jul 16 | Jul 15 | Jul 14 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
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.0.4 (6/4/2024)
- Support comment between function name and opening brace.
- Switched to semantic version numbers for future updates.
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.