Like “Expand Selection to Scope”. But better!
Python
Clone or download
Permalink
Failed to load latest commit information.
messages Implement soft-undo, #31 Jan 12, 2015
test [LaTeX] Added tex_words to only use valid LaTeX chars in commands Apr 7, 2016
.travis.yml Update to new test structure and make some minor modifications Apr 28, 2014
Default.sublime-commands Add sublime command and update README Mar 6, 2014
ExpandRegion.py Fall back to the default Sublime Text Expand to Scope when if (#76) Nov 10, 2017
ExpandRegion.sublime-settings Read from settings, whether force soft_undo integration Jun 3, 2016
ExpandRegionFallback.sublime-settings Added a fallback settings, such that the user does not overwrite scop… Dec 21, 2015
LICENSE.md Add license, close #5 Feb 21, 2014
Main.sublime-menu User definable language selectors Dec 18, 2015
README.md Add prerelease description to the README Nov 20, 2017
__init__.py Update to new test structure and make some minor modifications Apr 28, 2014
expand_region_handler.py Fix debugging system (#74) Nov 5, 2017
expand_to_indent.py Fix debugging system (#74) Nov 5, 2017
expand_to_line.py Fix debugging system (#74) Nov 5, 2017
expand_to_quotes.py Fix debugging system (#74) Nov 5, 2017
expand_to_regex_set.py Fix debugging system (#74) Nov 5, 2017
expand_to_semantic_unit.py Fix debugging system (#74) Nov 5, 2017
expand_to_subword.py Unicode support for expand_to_word and modifications of expand_to_sub… Dec 14, 2015
expand_to_symbols.py Fix debugging system (#74) Nov 5, 2017
expand_to_word.py Unicode support for expand_to_word and modifications of expand_to_sub… Dec 14, 2015
expand_to_word_with_dots.py Fix bug, where expand_to_word did not work, when parts of the word we… Apr 27, 2014
expand_to_xml_node.py Fix debugging system (#74) Nov 5, 2017
html.py Added support for extend_to_subword Dec 2, 2015
javascript.py Fix debugging system (#74) Nov 5, 2017
latex.py Fix debugging system (#74) Nov 5, 2017
messages.json Implement soft-undo, #31 Jan 12, 2015
python.py python support Dec 12, 2015
utils.py Fix debugging system (#74) Nov 5, 2017

README.md

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).

Prereleases

Pre-releases help us to test new features and improve the stability of releases. You can benefit the newest features and help us testing them. Just open Preferences > Package Settings > Package Control > Settings - User and insert at a reasonable (correct JSON syntax) position:

    "install_prereleases": ["ExpandRegion"],

If you also use pre-releases of other packages just add them comma separated into the list.

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