0

In some IDEs there is a nice feature (named "Expand selection to include enclosing element" in Eclipse). It expands current text selection to 1 level up syntax element. For example, Eclipse does this with Alt+Shift+UpArrow hotkey combo, and so do some other IDEs, and IntelliJ IDEA does this with Alt+UpArrow hotkey combo. I'm wondering if Sublime Text 3 can do this too. (out of the box or with a plugin - doesn't matter) I guess, it has enough information to do it if it already does syntax highlighting.

1
  • I recently found Expand Selection to Quotes, which works specifically with strings. Expand Selection to Scope will select the contents of a string, but not the quotes themselves. With your cursor in a string, hit Ctrl-' once to select the string, and hit it again to select the quotes themselves. I work with strings a lot, and I've found it quite useful. The Package Control link claims it only works with ST2, but I just installed it in ST3 on OSX and it works fine...
    – MattDMo
    Commented Nov 2, 2013 at 17:46

1 Answer 1

1

Depending on your syntax, one of the the Selection » Expand Selection To … can do it.

For XML, I've found that Expand Selection to Tag (repeatedly) works. In Java source code, Expand Selection to Scope works. And for any formatted source code, Expand Selection to Indentation should work.

6
  • Thanks. But can I set it up so a single hotkey will do it, regardless of current syntax used? Expand to scope works, but in XML it "jumps too high" at a step. Commented Nov 2, 2013 at 17:26
  • @SargeBorsch For code, … to Scope works in my experience (don't have that much other source code around right now). Eclipse cannot even do the equivalent … to Tag, so you're not losing anything if you're only learning that one.
    – Daniel Beck
    Commented Nov 2, 2013 at 17:28
  • Yes, this is cool, the only downside is that this is 2 different commands Commented Nov 2, 2013 at 17:30
  • @SargeBorsch That's what I meant. For the equivalent functionality to Eclipse, it's still only one command.
    – Daniel Beck
    Commented Nov 2, 2013 at 17:31
  • Maybe I can merge them in single command that will choose what to use depending on syntax type via some Python kung-fu? Commented Nov 2, 2013 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .