Home Download Buy Blog Forum Support

"Unwrap" selection

"Unwrap" selection

Postby unphased on Thu Mar 28, 2013 4:48 am

I find myself often attempting something like replacing double quotes with single-quotes.

Basically, I really really enjoy the "wrap" feature where you select some text, and then hit any of the keys like double-quote, single-quote, open-paren, open-bracket, etc., and it wraps your selection in those characters.

It'd be even more awesome if we had a shortcut key that could do something similar to this but enhanced. Hit a key and it will search out to select the text inside the nearest "wrapped" bit of text, then another shortcut which can remove those "wrapping" characters. Or it could automatically remove them because it's super fast to re-make the same one anyway. This way a 3 keystroke combination can be used to modify the wrapping of stuff very quickly without having to manually do the closing.

Furthermore, this function can stack with the multi-cursor feature to allow you to perform this sort of operation on big swaths of code quickly. Have a bunch of double-quoted strings that are not structurally related but you want to replace certain ones with single-quotes? just ctrl+click in all the "regions", and then fire off two keystrokes. I do believe there is a vast space of amazing cool things we can do with these multi-selects.

I'm sure this is a trivial task for somebody to write given the rich API that is exposed for querying and modifying selection, I just am too busy to look into it now :oops: :lol:

Update: I realized that Ctrl+Shift+M (where Ctrl+M is find matching bracket) allows for selecting the contents wrapped by the nearest set of matching brackets containing the cursor. Will just need to extend this slightly to also include quote characters in this logic as well, and something for deleting/replacing those characters.
unphased
 
Posts: 28
Joined: Thu May 17, 2012 5:16 am

Re: "Unwrap" selection

Postby unphased on Thu Mar 28, 2013 10:05 pm

Found this:

https://github.com/spadgos/sublime-ToggleQuotes

It's really quite excellent and is so good at what it does that I can't really justify building something very similar anymore.
unphased
 
Posts: 28
Joined: Thu May 17, 2012 5:16 am

Re: "Unwrap" selection

Postby iamntz on Fri Mar 29, 2013 11:43 am

Also BracketHighlighter does that (and a lot of other awesome things!)
iamntz
 
Posts: 914
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: "Unwrap" selection

Postby unphased on Wed Apr 17, 2013 9:05 pm

Yes I have just re-discovered BH. This topic is completely obsolete. What an awesome plugin.
unphased
 
Posts: 28
Joined: Thu May 17, 2012 5:16 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 5 guests