Set a breakpoint for all search results in PyCharm - python

I have made a search in PyCharm with classical Ctrl+Shift+F, and I just want to set a breakpoint at every line in result for debugging at once.
Does exists some functionality in the IDE to do this?

There's no such feature, unfortunately. Though you can place breakpoints manually in "Find in Path" preview window for a given search item.
Feel free to create a feature request in PyCharm's bug tracker https://youtrack.jetbrains.com/issues/PY

Related

PyCharm won't accept code completion on enter

since yesterday PyCharm 2016.3 won't accept selected lines from the list of code completion:
If I hit enter, a new line will be set into the editor rather than the selected line of the popup window. Is there any setting for this behaviour? Until now I couldn't find anything.
I noticed on a few occasions the GUI going somehow off-rails, including in ways similar to the one described. I couldn't determine a pattern in the occurences. Just closing and re-opening the project didn't always help.
What worked pretty reliably for me in the end was exiting PyCharm (giving it ample time to finish), making sure no related java processes remains active (running on Linux, in some cases I had to manually kill such processes when it became clear they're not going away by themselves) and then re-starting the IDE.
I found the current keymap for code completion by chance. This is set via:
Settings > Keymap > Code > Completion > Basic

Documentation Pop Ups

How can I configure Pycharm such that I always have the documentation pop up every time I hover over a method or an class?
For example in eclipse:
If I hover the cursor over a c++ function or a class, I can see the documentation for the same in a small pop up window.
Is there some plugin or setting in Pycharm where I can enable the same?
PS: I know PyCharm already has F1 button that can do the same, I was just looking for a hover alternative as I am used to the eclipse way of doing it
Just for completeness, in current versions of PyCharm (in the years 2016+), quick documentation is available on hover and can be configured in Preferences > Editor > General > Other
The feature is called "Quick Documentation" and the default shortcut for this is CTRL+Q or ALT+MOUSE BUTTON 2.
As far as I know, there is no way to enable it on-hover (personally, I found this very annoying in Eclipse).

How do I make pyCharm stop hiding (unfold) my Python imports?

Every time I open a Python file PyCharm will hide all imports and shows:
import ...
within the editor.
I have to manually unfold it to see the imports. Where do I find the setting to undo auto-hiding of import statements?
As this question may be useful for people who also are not looking for the term "code folding", I'll make my comment an answer.
As extracted from IntelliJ IDE Web Help, but also worked on PyCharm CE 3.4.1:
Open the IDE Settings (File > Settings, or Ctrl+Alt+S).
Under the "Editor" node, click "General" and then "Code Folding". The "Code Folding" page is displayed.
In the "Collapse by default list", select the check boxes to the left of the code constructs you want to be displayed collapsed. So here you can uncheck "Imports".
Apply changes.
The image below shows what it looks like:
Actually in pycharm 2016.1 it's Editor -> General -> Code Folding

Optimal switching between file editors in PyCharm

I'm coming to PyCharm from Eclipse, and something that is annoying me is how I switch between open files in the editor.
In Eclipse, I had a hotkey set up to open the previous editor. A menu would appear with the files in order of most-to-least recently viewed. If I hit the key once quickly, it would switch to the last file viewed. Whatever I had been working on recently would always be readily available.
In PyCharm, the files are listed in the editor in seemingly random order. Control+left (or right) takes you to the next file in the listing, which may be near a file unrelated in any way. I can use the mouse to select a file, but I'm not used to this, and it makes me stop and think about what the file name was, what module it was in, etc.
Natural, quick, efficient, minimum of thought -- this is what I'm looking for in navigating between open files in the PyCharm editor. Does anyone know of a way I can achieve this?
Thanks!
Ctrl-Tab switches in most-recently-used order (like Alt-Tab for the desktop). Ctrl-E will show recent files.
You should look at Help > Default Keymap Reference, under the navigation heading, for more helpful shortcuts.

GEdit/Python execution plugin?

I'm just starting out learning python with GEdit plus various plugins as my IDE.
Visual Studio/F# has a feature which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console.
Is there a similar facility/plugin which would enable this sort of behaviour for GEdit/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy/paste can get a bit tiresome)
... or perhaps there is a better way to do code exploration?
Many thx
Simon
Yes, you use "external tools plugin"
http://live.gnome.org/Gedit/ToolLauncherPlugin
As an example,
Edit > Preferences
Plugins
Tick "External Tools"
Close the Preferences Window
Tools > Manage External Tools
Click the "Add new too" icon in the bottom left
Name it "Execute Highlighted Python Code"
give it a keyboard shortcut
change the input combo box to : "highlighted selection"
change the output to : "Display in Bottom Pane"
In the editor window for the tool, replace everything with :
.
#!/usr/bin/env python
import sys
result = eval(sys.stdin.read())
print expression, "=>", result, type(result)
.
If you wish to see the result of entire .py file, you can put this code in your new created external tool window
#!/usr/bin/env python
import sys
exec(sys.stdin.read())
and change the Input to Current document.
For python, You can use "external tools plugin":
#!/bin/sh
python3 "$GEDIT_CURRENT_DOCUMENT_PATH"
Option of external tool:
Save: Current Document
Input: Current Document
Output: Display in bottom panel
Language: Python or Python3
Don't forget the quotes around $GEDIT_CURRENT_DOCUMENT_PATH....
To answer your second question, and hopefully guide you in a direction you'll be happier with, I think you ought to consider trying some different editors. There are many with more powerful code exploration features than GEdit has. Check out this post:
What IDE to use for Python?
I installed iPython console in gedit and do most of my simple scripting in it, but gedit is a very simple editor, so it'll not have some advance feature like an IDE
But if you want code exploring, or auto completion, I recommend a real IDE like Eclipse.
If you just want a editor, KomodoEdit is fine.
What I do is keep a file called python_temp.py. I have a shortcut to it in my dock. I use it as a scratch pad. Whenever I want to quickly run some code, I copy the code, click the shortcut in the doc, paste in the text and hit f5 to run. Quick, easy, simple, flexible.
I think what you're looking for is http://live.gnome.org/Gedit/Plugins/BetterPythonConsole.
You hit F5 and it runs the code in your file in a IDLE-like console. I don't know if it can only run selected code. (I don't think it can) but you can always copy the needed code in a new window and run it from there.
Have a look through the plugin list for other interesting stuff: http://live.gnome.org/Gedit/Plugins
The closest to a decent IDE...
Install gedit-developer-plugins (through synaptic || apt-get) and don't forget to enable (what you need) from gEdit's plugins (Edit->Preferences [tab] plugins) and happy coding

Categories