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.
I would do that with macros.
[[a for a in l1 if a!=0]]
# ^ - place cursor here
Press the following:
[[a for a in l1 if a!=0]]
#^ - it will jump here
[a for a in l1 if a!=0]]
#^ - the first bracket was deleted
[a for a in l1 if a!=0]]
# ^ - will jump here
[a for a in l1 if a!=0]
# ^ - deleted the paired closing bracket
Now need to stop macro recording.
Links:
Macros documentation.
Source code navigation documentation.
Other suggestion to use Code|Unwrap/Remove. It will not work in some cases. For example, if you have incorrect code, the IDE cannot wrap it.