Search code examples
pycharmjupyter-notebook

How not to erase selection when trying to put it into brackets Pycharm


I'm trying to find a way to make bracket insertion work the same way in Pycharm as in a jupyter notebook, that is to say, when I have some code selected:

some_code

and I hit the '(' key, have it put into brackets, like this (some code) instead of having my whole selection erased and be left with ()

Any idea on how to make this possible ?


Solution

  • I think the answer proposed by Arnoud in 'How to surround selected text in PyCharm like with Sublime Text' is exactly what you're looking for.

    Namely using:

    Settings | Editor | General | Smart Keys -> Surround selection on typing quote or brace

    The advantage of this method is that it adds brakets without any extra shortcuts to remember.