Remove quotes and parens


#1

I can mark some text and type ( to surround the text with parens. I can type ' to surround it with single quotes. This is very awesome. However, what I miss is the opposite operation.

In other words, first I do one of the following two:

  • Select text that is surrounded by parens or quotes
  • Select text that begins and ends with parens or quotes

And then I invoke some command, and the parens or quotes are removed.

Say I have this text:

abc xyzzy def

If I select/highlight “xyzzy” and hit the open parenthesis, I get this:

abc (xyzzy) def

Now I want the opposite operation, i.e. given the above text, I either select “xyzzy” or I select “(xyzzy)” and I perform some command, and I go back to the original text:

abc xyzzy def

#2

What package does this?


#3

Not sure what you mean by “this” :smile:

You may be referring to surrounding the selection with parentheses.
So, when I do atom --safe . and open a random file and select a random word and hit the open-paren key, that word gets surrounded by parens. I don’t know which of the built-in packages does this, though.

You may also be referring to removing the surrounding parentheses.
I don’t think that feature exists, it’s a feature I’m asking for. I thought the “features” tag was for feature requests… Let me edit the title to make this more explicit.


#4

It has never done that for me and I just tested it. I’m on windows. It is possibly a key binding only enabled on the Mac?


#5

Quite possible it’s Mac only. Hm. The keybinding resolver doesn’t tell me what ( does. Hm. Ah! When I hit a, I get the binding in the tree view, but I don’t get the usual binding that inserts the character into the current editor. So maybe native bindings are not shown in the keybinding resolver.

I’m not sure where to go from here.


#6

To be honest, I think surrounding the selection with parens seems like a useful behavior on all systems, so why would this be Mac only?


#7

Atom definitely does this on Ubuntu 14.04 as well. I opened a plain text file, selected some text, pressed ", and quotes appeared around the selected text. I’m guessing that’s the bracket-matcher package? Not sure though.
I also tried it on Windows 8.1 and Atom doesn’t do it there. Even if I type a single ", it waits for a second one be typed before showing the first one, while on Linux it inserts two “” instantly with the cursor in the middle.

I assume that’s the expected behavior, so maybe that’s something for an issue?

To answer the question: I don’t know of any package that reverses this behavior. Atom does however on Linux delete the two quotes if there are two right next to each other and you delete the first one from the middle. So you could cut the text, press backspace and paste it again. :smile:
That seems like a relatively easy thing to implement in a package though.


#8

As @StenV said, it is the bracket-matcher package that provides the smart quotes and brackets behaviors.


#9

That makes sense. I don’t run that package.

@kgrossjo, you must be mistaken about it happening in --safe mode.


#10

That’s a package that does stay enabled if I start in safe mode. It doesn’t happen if I explicitly disable it.


I did some more testing on Windows and I’m not really sure if this is just weird behaviour or if I did something wrong. I selected some text and then pressed " twice (pressing " once and then a space gives similar results).

No --safe mode:

–safe mode:


#11

I probably disabled it. So --safe mode doesn’t re-enable disabled things? I would think --safe mode should return things to “factory settings”.


#12

The bracket-matcher package is a default-installed package:

Safe Mode isn’t currently about resetting everything to factory defaults. It is about determining if unexpected behavior is due to third-party code. Your configuration is still used … which is what tracks disabled packages. I can understand a case being made to change that definition … but I don’t see that it has been necessary, yet.


#13

You don’t happen to be using the “international English” keyboard layout where double-quote is a dead key? You can type it followed by a and then you get ä.


#14

Ah, that’s why… Thanks, didn’t know that!


#15

Back to the original topic, I would also love this feature. It’s super annoying to have to select the last paren, remove it, then select the first paren and remove it as well. Same thing for quotes. It’s so easy to wrap something in quotes or parens. It sucks we still have to go in the opposite direction the old way.

If anyone finds a solution to the above, please do share.


#16

Try CTRL + ] to remove matching brackets. Does that help?


#17

I signed up to like this. You have changed my life!


#18

Are you on a Mac? For me there is a conflict:
image