Page 1 of 2

(Granted) SurroundSelection Option ?

Posted: 12 Apr 2024 14:04
by GreetingsFromPoland
hi! when coding in NPP, VSCodium, PHPStorm, etc., one feature i use all the time is something called "SurroundSelection". it allows to you surround your selection with whatever you type, e.g. single quote, double quotes, parenthesis, brackets, etc.

i was using inline rename to take LaRoy Texas 2023 to LaRoy Texas (2023) and thought it would be nice if i could double-click on 2023 (which i can, it selects the word), but then press ( and it would wrap it like this (2023).

right now i start the inline rename, use the arrow keys to scoot the cursor before the word, press ( then scoot to the end of the word and press ), etc.

if added, certain character would have their match added, so typing ( would wrap () and [ would wrap [], " would simply be " " and ' would be ' '.

it's something i do hundreds of times a day in my IDE, thought it would be neat to have an option in XY for the same.

Re: SurroundSelection Option ?

Posted: 12 Apr 2024 15:35
by admin
Interesting, here is an animated illustration of it: https://devblogs.microsoft.com/visualst ... xperiment/

Not immediately planned, but maybe later...

Re: SurroundSelection Option ?

Posted: 19 Jun 2024 16:22
by GreetingsFromPoland
hi! with the recent updates to the inline edits (lowercase, uppercase, etc.), any chance you can revisit this wish ?

Re: SurroundSelection Option ?

Posted: 19 Jun 2024 18:00
by matewo
Hi GreetingsFromPoland,

not an integrated way in XYplorer, but have you tried AHK (AutoHotKey) or Espanso?

Both work application independent.

Best regards, Markus

https://www.autohotkey.com/
https://espanso.org/

Re: SurroundSelection Option ?

Posted: 19 Jun 2024 20:40
by admin
GreetingsFromPoland wrote: 19 Jun 2024 16:22 hi! with the recent updates to the inline edits (lowercase, uppercase, etc.), any chance you can revisit this wish ?
Good timing. :) Next beta...

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 17:59
by eil
If user selects part of text and uses "ending quote" like ) > ] then it will result into adding "starting quote" from next pair. Example: Picture)Old<Style.
Can't say it's a bug cause in some circumstances it may be a feature, but some users may consider it a bug.

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 18:10
by admin
LOL, I totally forgot about this kind of abuse. I guess I should prevent it.

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 18:15
by eil
I'd propose no matter if user pushed ( or ), < or > it will properly cover selected text into () and <>.

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 18:17
by admin
That's an interesting idea. Are there any SurroundSelection standards out there?

PS: Another option would be to reverse the order in this case: abc + ) --> )abc(

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 20:15
by eil
admin wrote: 20 Jun 2024 18:17 reverse the order in this case: abc + ) --> )abc(
That's better, adds more options.

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 20:20
by admin
Exactly :tup:

Re: SurroundSelection Option ?

Posted: 20 Jun 2024 21:22
by GreetingsFromPoland
admin wrote: 20 Jun 2024 18:17 That's an interesting idea. Are there any SurroundSelection standards out there?
hi! not sure about any standard out there; however, in Notepad++, PHPStorm and VSCodium (the 3 i tried), pressing ( or ) wraps it with it's match.
for example, abc + ) ==> (abc), abc + ( ==> (abc), abc + > ==> <abc> and abc + < ==> <abc>.

Re: SurroundSelection Option ?

Posted: 21 Jun 2024 16:07
by GreetingsFromPoland
v26.10.0203 - 2024-06-20 20:27
* Surround Selection: Now when you type the second character of the pair, the selected
text will be surrounded by the pair in reverse order.
hi! to me, this change makes no sense at all. am i the only one that thinks this ? unless i am mistaken, i don't believe any other software that supports "surround selection" does this. what would be the purpose of reverse order ? what am i missing ?

the beauty in surround selecting was that you could select either part of the pair and it was smart enough to properly surround it.

Re: SurroundSelection Option ?

Posted: 21 Jun 2024 16:18
by admin
It's mentioned above: adds more options.

Re: SurroundSelection Option ?

Posted: 21 Jun 2024 17:05
by GreetingsFromPoland
eil wrote: 20 Jun 2024 20:15
admin wrote: 20 Jun 2024 18:17 reverse the order in this case: abc + ) --> )abc(
That's better, adds more options.
there appears to be a bug. selecting text and pressing ] results in base ]2024{.

also, argh., this is not better. still makes no sense to me and is opposite from other implementations. the base wish was to surround your selection with a pair, no matter what side was typed. no other "options" were needed. i can't see any reason why the reverse would ever be needed or used.