Python 如何像 Sublime Text 一样在 PyCharm 中包围选定的文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27152414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 01:28:45  来源:igfitidea点击:

How to surround selected text in PyCharm like with Sublime Text

pythonsublimetext2pycharm

提问by Alexis Benoist

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?

有没有办法将 PyCharm 配置为能够通过在括号键上键入来用括号括起选定的代码,就像我们使用 SublimText 2 时一样?

采纳答案by Arnaud P

I think you want something like

我想你想要类似的东西

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

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

回答by Andy

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

PyCharm 4.0 可以选择Surround With...,通过选择您的代码片段并按

ctrl+ alt+ T

ctrl+ alt+T

or on Mac: ?+ ?+ T

或在 Mac 上:?+ ?+T

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

选项 1 应该为您提供您正在寻找的功能:

PyCharm Ctrl+Alt+T

PyCharm Ctrl+Alt+T

回答by Adam H

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

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

Image of pycharm location of smart keys

pycharm 智能钥匙位置图