Sublime Forum

Select all text between quotes/brackets?

#1

Hi

I’m new to Sublime and loving it so far. I was just wondering if there was an equivalent to the VIM ability to select/delete everything between a pair of quotes, or brackets, or square brackets, etc? Or even just highlight it for deletion/overwriting?

As an added bonus, is there a way to make Sublime “Auto navigate” to the LAST auto-inserted quote/bracket? Ie. If I’m typing (’ and Sublime inserts ') for me, but the cursor is still inbetween the quotes - if I press ) in Vim, it’ll skip the cursor past the quote and the bracket, but in Sublime, I’d have to enter both quote and bracket to get to the end?

Many thanks in advance

0 Likes

#2

for your first question, I think ctrl+shift+space does what you need. It also selects the brackets, though…

0 Likes

#3

Thanks - your tip actually led me onto examining the key bindings file more closely, and there was another command (ctrl+shift+m) right next to yours which does exactly what I want inside any kind of bracket. Combined with another plugin I found in the forums to do the same more reliably for quotes, and mission accomplished.

Now if I could just figure out the second part, and how to get autocomplete to pull from all open files/project files…

0 Likes

#4

The latest dev release now supports text objects in Vintage mode, so you can use, for example, the di" and ci( commands to do this (examples).

Hmm, nice. I didn’t know Vim did that. +1 for this feature. I’ve setup a Alt+Return binding that skips to the end of the line, but this would be better.

0 Likes

#5

For the sake of info: as of build 2132 (but earlier I guess), inserting a ( will auto-insert the matching ), leaving the cursor in between, and typing ) will jump after the auto-inserted ), as in Vim.

0 Likes

#6

[quote=“seeyou”]Thanks - your tip actually led me onto examining the key bindings file more closely, and there was another command (ctrl+shift+m) right next to yours which does exactly what I want inside any kind of bracket. Combined with another plugin I found in the forums to do the same more reliably for quotes, and mission accomplished.

Now if I could just figure out the second part, and how to get autocomplete to pull from all open files/project files…[/quote]

Could you tell me the name of the plugin?

Thanks.

0 Likes

#7

Is there any way to select without brackets/quotes/etc.?

0 Likes

#8

[quote=“Kaske”]

Is there any way to select without brackets/quotes/etc.?[/quote]

ctrl+shift+m work as you expect for brackets, trigger it one time for inside content and another time to add brackets.
For quotes I’m pretty sure there’s no solution out of the box, must write a plugin (or maybe only with a keybinding if there is a way to ask the expand_selection command to expand to specific chars, only Jon could help here).

0 Likes

#9

BracketHighlighter allows you to select strings without quotes or brackets. I think it is by default some goofy sequence like “ctrl+shift+b”, “ctrl+shift+s”], but you can change it something sensible. This was when I was still providing shortcuts in my plugins (there are so many shortcuts now it is hard to find free ones).

0 Likes

#10

[quote=“charlesroper”]The latest dev release now supports text objects in Vintage mode,
More at>> (examples).[/quote]

That’s great. Thanks for the info.

Do anyone know if there will be more “text objects” implemented, like:

[quote]# “it” selects the text within the surrounding HTML/XML tag or container, with the greedier version being “at”.

“iw” selects the surrounding word, with the greedier version being “aw”.

“is” selects the surrounding sentence, with the greedier version being “as”.

“ip” selects the surrounding paragraph, with the greedier version being “ap”. [/quote]

(From examples)

0 Likes

#11

Thanks, man, a bit cumbersome for such a simple feature but it works.

0 Likes

#12

[quote=“Kaske”]

Thanks, man, a bit cumbersome for such a simple feature but it works.[/quote]

If I was doing it now, I would have provided no shortcuts and let the user define them. It is goofy only because all other shortcuts were taken. The only good ones are “alt+up”] and “alt+down”] which jumps you between tags, brackets, or quotes.

But you can always override the default jump between brackets to use this one.

0 Likes

#13

I noticed a strange behaviour:

When I use Ctrl + Shift + Space inside an ID (inside quotes) it selects the word without quotes (just as I think is the most natural way of selection). But when I do the same inside a class it selects both the name and quotes.

Now, BracketHighlighter is one solution, but still it offers too many things I don’t won’t to have just for the sake of simple inside-quote selection.

0 Likes

#14

Yeah, noticed something similar as well.

ctrl+shift+space with the cursor on the last char will select the ". Works fine with the first char.

Example

var $foo = “text he|re”; => text here
var $foo = “|text here”; => text here
var $foo = “text here|”; => text here"

0 Likes

#15

github.com/kek/sublime-expand-s … -to-quotes

Plugin for selection inside quotes, completely analogous to behaviour of builtin bracket selection, is here if anyone still need it…

1 Like

#16

Hi, I have tried to find a way to select the characters within curly braces in VI mode.
The command I write is “vi{” (exactly:** v i AltGr+7** )
But the result I get is that all the characters from my cursor and back to first linebreak.
If I use the sublime command ctrl-alt-m it works great, but I would rather use the VI command, vi then character.

Can you guys try this out and see if you have the same issue. Or am I alone?

EDIT:
Forgot to mention I am using ST2 2.0.1

0 Likes

#17

I know this is an old thread, but just for the sake of reference, use Emmet for Sublime with shortcut Ctrl+Shift+.

http://docs.emmet.io/actions/select-item/

Hope that helps

2 Likes