7

The opening and closing quotes (or brackets, braces etc) are highlighted in PyCharm(and other editors). So this means it can identify the pair.

Now, is there a way to delete both the quotes at once (or brackets, braces etc) when either of the opening or closing quotes are deleted, Since it identifies the pair?

For eg. I want this in one keyboard action (by both cases either deleting the opening or closing square bracket):
From this: [[a for a in l1 if a!=0]]
To this: [a for a in l1 if a!=0]

I googled and searched on SO but couldn't find it.

Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78

1 Answers1

0

I know of 2 quick ways, but none of them is quick enough.

1: Using the AceJump addon, you just jump to one parens, hit delete, then jump to the other one, and hit delete... Naturally this has the disadvantage that parentheses in a situation like this: ([{(([]))}) would be harder to jump to.

2: There is a command called "Move caret to matching brace". Then, using either AceJump to jump directly to your first brace (or just navigating to it in any way), you activate the function "Move caret to matching brace 2 times". After moving the caret 2 times, you can delete the first matching parens, and then use the action to navigate back ("Back"), and then delete your second brace.

3: Solution 2 does not work for quotes. For them, instead of executing the action "Move to matching brace" you can use the incremental selection, and jump to the most convenient of the 2 quote signs... This however doesn't allow you to navigate back to the previous(or next) quote and delete that one. Therefore for quotes, I have no solution, but this "incremental selection" can work in a few situations (when one of the quotes is at the beginning or the end of a line)

vlad-ardelean
  • 7,480
  • 15
  • 80
  • 124