PyCharm 的隐藏功能
我知道 PyCharm 是一个年轻的 IDE,但我想知道你们在使用它时是否发现了一些糖果。根据我的经验,我知道 JetBrains IDE 充满了糖果,我迫不及待地想找到这一切。
请列出您的提示,也许是您最初没有想到的。
I know PyCharm is young IDE but id like to know if you guys have found some candy while using it. I know from experience that JetBrains IDE's are filled with candy and can't wait to find it all.
Please list your tips, perhaps something you did not first expected to be there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
作为
PyCharm
的首席开发人员,我可以告诉您,我们通常不会在随机位置隐藏功能,并且有一些可靠的方法可以发现其中的大多数功能。PyCharm
突出显示的警告,并注意许多检查都有快速修复来自动纠正问题As the lead developer of
PyCharm
, I can tell you that we don't usually hide features in random places, and there are a few reliable ways to discover most of them.PyCharm
, and note that many of the inspections have quickfixes to correct the problems automatically我最近发现了一个选项(我认为默认情况下它是关闭的):
基本上,如果您可以快速从任何内容创建字符串,只需按 Ctrl-W 进行选择,然后键入引号即可。太棒了:)
PS: 要启用此使用设置搜索功能,请搜索:
surround
I have recently discovered an option (I think it's off by default):
Basically if you can quickly make a string from anything, just press Ctrl-W to select and then type quote. Awesome :)
PS: To enable this use settings search function, search for:
surround
我喜欢 ctrl-w,选择块功能。我以前从未遇到过这个问题,我认为只需按几次 ctrl-w 就可以选择一个函数/if 块,这是很棒的。
I like ctrl-w, the select block function. I've never ran across this before I think it's great to be able to select a function/if block by just pressing ctrl-w a couple of times.
这不是 PyCharm 特有的,我实际上是在 IntelliJ 中发现的,但我认为 PyCharm 用户也应该受益...
尝试 Alt+Click(如果使用 Gnome 默认键盘映射,则为 Ctrl+Alt+Click)并拖动以选择文本。它将使用自动换行选择有界块而不是完整的行。这些选定的块可用于键入重复文本或一次删除一行的许多部分。尝试一下,您会发现它的用途比您想象的更频繁!
This isn't PyCharm specific, I actually discovered it in IntelliJ but I though the PyCharm users should benefit too...
Try Alt+Click (Ctrl+Alt+Click if using Gnome default keymap) and drag to select text. It will select bounded blocks instead of complete lines using word wrap. These selected blocks can be used to type repetitive text or delete many parts of a line at once. Try it, you will find uses for it more often than you think!
我不知道这是否真的是一个隐藏功能,但是当您了解它时,测试就会变得更加容易。
如果您通过 PyCharm 运行测试,您可以单击回溯的名称和行,将您带到 Python 代码中的确切行。使测试变得更加容易。
I don't know if this is a hidden feature really but when you know about it makes testing so much easier.
If you run your tests through PyCharm you can click on the names and lines of the backtrace to take you to the exact line in your python code. Makes testing so much easier.
按住 Control 键并单击 URLconf 中的视图方法将打开views.py 并直接跳转到该方法。同样,在视图和其他模板(如
extends
标记)中按住 Control 键并单击模板名称将转到该模板。未隐藏,但在编辑 CSS 文件时,它会在任何使用颜色的样式的装订线中显示颜色。我喜欢那个。同样对于 CSS:代码洞察提供了标签的优化,以及将未使用的标签变灰的功能。
编辑 HTML 文件时,将鼠标移向编辑器的右上角将显示多个浏览器的图标...单击这些图标将在相应的浏览器中打开当前的 HTML。如果您使用 Django 模板,则没有那么有用,但仍然是另一块 IDE 糖果。
自动导入可能也是我最喜欢的功能之一。不过,它仍然需要一些工作。这只是一个预览版本,所以我相信它会不断变得更好。
干得好,JetBrains!
Control-clicking a view method in a URLconf will open views.py and bring you right to that method. Similarly, control-clicking template names in a view, and in other templates (like in the
extends
tag) will bring you to that template.Not hidden, but when editing a CSS file, it shows the colors in the gutter for any styles that use color. I love that. Also for CSS: code insight offers optimizations of tags, as well as graying out unused tags.
When editing an HTML file, moving the mouse towards the top-right of the editor will display icons for several browsers...clicking those will open the current HTML in the respective browser. Not as useful if you're using Django templates, but another piece of IDE-candy nonetheless.
Auto-import is also probably one of my favorite features. It still needs a bit of work, though. This is just a preview release, so I'm sure it'll continuously get better.
Well done, JetBrains!
我最近必须弄清楚如何在运行 Python 程序时将硬编码参数传递给它。我想在 IDE 中执行此操作,而不是必须来回切换到命令窗口来运行程序。
在 PyCharm 1.5.2 中,您可以单击
运行
,然后单击编辑配置
。从顶部数第三个文本框,标记为脚本参数
,允许您对程序参数进行硬编码。每次从 PyCharm 运行程序时都会使用这些。Something I recently had to figure out was how to pass hardcoded arguments to a Python program when running it. I wanted to do it in the IDE rather than having to switch back and forth to a command window to run the program.
In PyCharm 1.5.2, you can click on
Run
, thenEdit Configurations
. The third textbox from the top, labeledScript parameters
, allows you to hardcode program parameters. These will be used each time the program is run from PyCharm.