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

Expand​Region

by aronwoost ST2/ST3

Like “Expand Selection to Scope”. But better!

Details

Installs

  • Total 7K
  • Win 3K
  • OS X 3K
  • Linux 1K
Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8
Windows 4 6 4 2 3 2 3 5 1 4 3 6 2 3 2 4 1 2 3 3 1 3 3 5 5 2 8 4 2 1 0 6 3 3 5 6 1 4 8 13 4 3 0 2 2 4
OS X 3 1 3 3 2 2 2 1 1 0 0 5 1 3 2 2 3 0 5 6 2 2 0 2 3 0 2 4 4 6 3 6 1 4 5 5 4 5 3 4 1 3 3 3 0 0
Linux 1 0 1 0 2 1 0 1 2 1 2 2 2 0 3 2 0 1 3 0 1 2 2 0 1 1 2 4 1 1 1 1 1 2 1 1 1 0 1 6 1 2 1 1 1 2

Readme

Source
raw.​githubusercontent.​com

Build Status

ExpandRegion for Sublime Text

Like “Expand Selection to Scope”. But better!

ExpandRegion works a bit like the build in “Expand Selection to Scope”, however it does not depend on Scopes (Scopes are used by ST to “understand” code, i.e. for syntax highlighting). Therefore selection expansion can be more granular and customizable.

It works similar to ExpandRegion for Emacs and “Structural Selection” (Control-W) in the JetBrains IDE's (i.e. IntelliJ IDEA).

Example

JavaScript (should also work for other c'ish languages like Java).

  1. Expand selection to word
  2. Expand selection to quotes (content only)
  3. Expand selection to quotes (with quotes)
  4. Expand selection to square braces
  5. Expand selection to expression
  6. Expand selection to content of braces (all arguments in this case)
  7. Expand selection to line
  8. Expand selection to function body (w/o curly brace)
  9. Expand selection to function body (with curly brace)

and so on…

Python

Behaves similar to JavaScript, but also depends on indentation:

  1. Expand selection to word
  2. Expand selection to parentheses (content only)
  3. Expand selection to parentheses (with parentheses)
  4. Expand selection to function call
  5. Expand selection to line (w/o indent)
  6. Expand selection to indentation
  7. Expand selection to block start before indentation
  8. Expand selection to indentation
  9. Expand selection to block start before indentation
  10. Expand selection to indentation
  11. Expand selection to block start before indentation

and so on…

HTML

  1. Expand selection to word
  2. Expand selection to quotes (content only)
  3. Expand selection to quotes (with quotes)
  4. Expand selection to complete self closing tag
  5. Expand selection to parent node content
  6. Expand selection to complete node
  7. Expand selection to parent node content

and so on…

LaTeX (thx r-stein)

  1. Expand selection to word
  2. Expand selection to command
  3. Expand selection to command arguments
  4. Expand selection to brackets (content only)
  5. Expand selection to brackets (with brackets)
  6. Expand selection to surrounding command
  7. Expand selection to surrounding environment (content only)
  8. Expand selection to surrounding environment (whole)
  9. Expand selection to surrounding environment (content only)
  10. Expand selection to surrounding environment (whole)

and so on…

Installing

With the Package Control plugin: The easiest way to install ExpandRegion is through Package Control, which can be found at this site: http://wbond.net/sublime_packages/package_control

Once you install Package Control, restart ST and bring up the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows). Select “Package Control: Install Package”, wait while Package Control fetches the latest package list, then select ExpandRegion when the list appears. The advantage of using this method is that Package Control will automatically keep ExpandRegion up to date with the latest version.

Without Git: Download the latest source from GitHub and copy the ExpandRegion folder to your Sublime Text “Packages” directory.

With Git: Clone the repository in your Sublime Text “Packages” directory:

git clone https://github.com/aronwoost/sublime-expand-region.git ExpandRegion

The “Packages” directory is located at:

  • OS X:

    ~/Library/Application Support/Sublime Text 2/Packages/
    
  • Linux:

    ~/.config/sublime-text-2/Packages/
    
  • Windows:

    %APPDATA%/Sublime Text 2/Packages/
    

Using

  • Set a shortcut. Open “Key Bindings - User” and add to following line:
{ "keys": ["super+shift+space"], "command": "expand_region" },
{
  "keys": ["super+u"],
  "command": "expand_region",
  "args": {"undo": true},
  "context": [{ "key": "expand_region_soft_undo" }]
},

Note: third party plugins can not properly hook into the history. So soft-undo in basically only a undo expand selection. Soft-redo will not work.

Develop

Background

This plugin is inspired by the amazing expand-region for Emacs.

Here a video showing this feature (in Emacs):

Read more:
Extend Selection by Semantic Unit

License

MIT