In Pycharm, there's "code structurure" side bar which provides a tree to navigate through the code, but, it is only useful when the code has classes and methods and objects. If nothing of that is in code then it is useless. My question is: is there any way in which I dictate that this is a block, and I want to be able to collapse it and expand it? Something similar to Jupyter where the code is inherently divided to cells.
Currently, I'm doing this:
# ---------------------------------- chunck x blah blah -----------------------
EDIT: Most of comments say that I'm dumb and I don't know how to code efficiently and that I should use functions and classes. Guys, I know how to use those, that's not my question. Thanks.
Modules are files with “. py” extension containing Python code. They help to organise related functions, classes or any code block in the same file. It is considered as a best practice to split the large Python code blocks into modules containing up to 300–400 lines of code.
CTRL + M + O will collapse all. CTRL + M + P will expand all and disable outlining. CTRL + M + M will collapse/expand the current section.
To fold or unfold a code fragment, press Ctrl+NumPad - / Ctrl+NumPad + . PyCharm folds or unfolds the current code fragment, for example, a single method. To collapse or expand all code fragments, press Ctrl+Shift+NumPad - / Ctrl+Shift+NumPad + .
(Ctrl+M, Ctrl+H) - Collapses a selected block of code that would not normally be available for outlining, for example an if block. To remove the custom region, use Stop Hiding Current (or Ctrl+M, Ctrl+U). Not available in Visual Basic.
Turns out that the answer is very simple: Select the code, right click, do custom folding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With