如何像使用Sublime Text一样围绕PyCharm中的选定文本

问题:如何像使用Sublime Text一样围绕PyCharm中的选定文本

有没有一种方法可以配置PyCharm,使其能够仅通过键入括号键就可以将所选代码括在括号中,就像我们使用SublimText 2一样?

Is there a way to configure PyCharm to be able to surround selected code with parenthesis by just typing on the parenthesis key, like when we use SublimText 2?


回答 0

我想你想要类似的东西

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

I think you want something like

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


回答 1

PyCharm 4.0可以选择Surround With...,选择代码段并按

ctrl+ alt+T

或在Mac上:+ +T

选项1应该为您提供所需的功能:

PyCharm 4.0 has the option to Surround With..., by selecting your code snippet and pressing

ctrl + alt + T

or on Mac: + + T

Option 1 should provide you with the functionality you are looking for:


回答 2

Windows:打开pycharm并选择文件,设置,编辑器,智能键,在列表中,您将选中“键入引号或花括号时的环绕选择”,然后应用。 在此处输入图片说明

智能钥匙的pycharm位置的图像

Windows: open pycharm and select file, settings, Editor, Smart Keys, in the list you will check “Surround selection on typing quote or brace”, then apply. enter image description here

Image of pycharm location of smart keys