You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
I am using spyder4.0.0b1, so sorry if the following is already implemented in future releases.
First of all, thank you for implementing code-folding functionality!
What I could use is a 'Fold-all' button, or that the editor remembers the folding status, when a file is opened, such that I don't have to fold all the code again everytime I open a file.
Thanks
@Skottfelt
. This is a good point.
Code folding might need an epic issue.
Issues off the top of my head:
Shortcuts and menu items
fold all
unfold all
fold/unfold current block
Right click on a folding arrows shouldn't fold the code
Save fold state for files
code could be similar to saving the breakpoints?
Unfold code when cursor is placed inside of folded code
this happens with trace back links, selecting in the outliner, go to line, and other places
When folding and the cursor is in the folded block, move the cursor to the fist line of the fold so it not hidden
Code folding for code cell blocks
supporting code cell groups
Fold and unfold entire if/else blocks and try/except block when the if or try are folded
I love the new code folding!
I want to add a suggestion too: make code folding stop at first unindented line. Currently it stops at the first unindented code (I guess).
Here's what I mean:
After folding becomes:
And it would be better not to touch the comment.
First of all I'm super excited about finally being able to fold the code. Thank you for the great work with Spyder!
I also have two suggestions for further enhancements:
When re-opening Spyder it would be nice if the code was still folded the same way it was during the last session. (duplicate of what bcolsen wrote)
Currently, when folding an entire class (might be accidentally), upon unfolding every method within the class is also unfolded. I think it would be preferrable to restore the previous folding state, wouldn't it?
Tagging a bug in code folding onto this thread as it is closely related (presumably):
In case code blocks are folded, the hint re Code analysis does not appear. When clicking on the yellow icon, the editor window jumps close to the top of the code.
Using v 4.0.0.b1, python 3.7.1, ubuntu 18.04
Hi all,
I’ve been using version 4 for a few days.
Let me know if I’ve missed something as it’s been hard to access documentation.
Is there a way to add code folds
anywhere you like?
Currently it looks like it’s just under comments with “”” , and functions, classes etc.
However if you are working on a simple script, one can’t fold lots of code because python won’t let you indent without a reason under your comments (so you can’t use comments to break up your code and fold it into sections.)
Additionally, one wouldn’t want to create fake functions just to get code folded.
Thanks
@pbower
There are plans for code folding for code cell blocks with support for code cell groups which should cover most of your request.
Currently spyder4's outline explorer will place code cells as the top level for easy navigation of long files so you might not need the folding as much.
https://docs.spyder-ide.org/editor.html#defining-code-cells
Hey, I have another suggestion.
Also you did a fantastic job with code folding, I think there should be an option to deactivate it and remove the associated vertical bar (just as for line numbers).
I agree with this. See
#6628
.
折叠后变为:
![图片](
https://user-images.githubusercontent.com/15214418/48624757-8a144b80-e9ad-11e8-91a3-6b12d6c51e6e.png
I love the new code folding!
I want to add a suggestion too: make code folding stop at first unindented line. Currently it stops at the first unindented code (I guess).
Here's what I mean:
After folding becomes:
And it would be better not to touch the comment.
hello , I have updated the spyder to 4.0.1,but in setting i can not find the function of code fold. why? please help me.
I updated to 4b2 and I can't figure out how to use the folding. Would someone explain it to me? Thanks!
I updated to 4.0.1and I also can't figure out how to use the folding. what should i do? please help me
Improvement to code folding (ref: Pycharm kind of folding)
Seperate code folding provision for block of comments
window minimizing (console, help, plots windows) something like in Pycharm
Hopefully, these things in next release.
It is good but RStudio code folding is still a lot better. With a bunch of asterisk’s once can each separate / hide parts of their code so they don’t need to spend ages scrolling through things or hit the page up/down buttons.
In spyder, it’s not possible to manually add a code fold it only happens in certain situations, which is really annoying.
Get Outlook for iOS<
https://aka.ms/o0ukef
>
@pbower
In spyder, it’s not possible to manually add a code fold it only happens in certain situations, which is really annoying.
Have you tried using cells??
# %% This is a cell with a name and is foldable
Have you tried using cells??
Code cell folding isn't implemented in Spyder yet. It's one of the suggestions and should mostly cover
@pbower
's suggestions.
To navigate quickly through long code currently I'm using the outline panel with named code cells and code cell groups
Code cell folding would definitely do it. Yes the folding need is especially for long code, doing ‘page up’ ‘page down’ is very difficult when everything you want to be folded can’t be.
Even split screen on different parts of the code - still hard to navigate.
Thanks for responses.
Cheers
Get Outlook for iOS<
https://aka.ms/o0ukef
>
Hi folks,
I have been programming in MATLAB forever and they have excellent code folding capabilities. After reading all the comments above, I just want to reiterate the importance of saving the last folded "state" of a given file. I would also make the new suggestion where you can choose which parts of the code are folded (see image) once you hit the shortcuts for fold/unfold all.
I use this all the time and it really helps to have (in my case) methods and properties (attributes) folded inside my classes, as shown in the image below. Please keep in mind the syntax differences between MATLAB and Python.
Easier sad than done. I hope this helps.
Thanks,
Eduardo
+1 For a couple of variants of "fold-all" feature, as mentioned by
@bcolsen
,
@mcnoat
. My projects have been growing lately, and have found myself scrolling up and down my source code for unnecessarily long. Having shortcuts for "Fold all", "Fold all functions", "Fold all docstrings", and the like, would be a lifesaver for me. Also, remembering the source file folding state would be useful in the long run.