Reputation: 1663
This is a simple problem with a potentially simple solution (maybe there is a plugin that will help or a better way of working with the tool).
I have a large Python file with many function definitions that look very similar. Each definition is a few hundred lines long. When I'm trying to make sense of a few lines of code I often want to know which function definition those lines of code belong to. My current method for doing this is scrolling back up the file (I'm using PyCharm) until I reach the start of the function definition. This is tedious and time consuming. Is there a better way of determining which function I am currently viewing?
Upvotes: 1
Views: 105
Reputation: 83328
There is a method called Context info (found under View menu) and bind to CTRL + SHIFT + Q on OSX and ALT + Q on Linux. It will flash you the current class, function, etc, parents of the current cursor position at at the top of code editor.
(Basically it shows the same line if you would scroll up manually).
Upvotes: 4
Reputation: 5896
Press Ctrl-Shift-(Numpad Minus)
. It will collapse all the functions, putting your cursor back to the start of the current function. Then press Ctrl-Shift-(Numpad Plus)
and you will get back where you were before. Or you can use Ctrl-(Numpad Minus)
and collapse only the function you are in now.
Upvotes: 2