English 中文(简体)
Hidden features of PyCharm [closed]
原标题:

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.

最佳回答

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.

  • Try Ctrl-clicking on everything (methods, functions, template tag names and parameters, etc.)
  • If Ctrl-clicking works, usually so does completion (Ctrl-Space), rename (Shift-F6) and Find Usages (Alt-F7)
  • Look through the menus and try out the actions that seem interesting
  • Look at Settings | Inspections to configure the warnings which can be highlighted by PyCharm, and note that many of the inspections have quickfixes to correct the problems automatically
  • Read the blog and try out the features highlighted there.
问题回答

I have recently discovered an option (I think it s off by default):

Surround selection on typing quote or brace

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

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.

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!

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-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!

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, then Edit Configurations. The third textbox from the top, labeled Script parameters, allows you to hardcode program parameters. These will be used each time the program is run from PyCharm.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签