Handling folds in Spyder
Asked Answered
H

3

13

I am coming from a VScode background , and for my recent project (on Deep Learning) I am having to manage huge code files in Spyder (Version 3), and I am not seeing any option of code folding?

I am not willing to switch to another IDE , as Spyder is very productive for my project.

Please suggest any hack to do it , if it is not there in the Spyder codebase.

Heliogravure answered 18/9, 2018 at 6:53 Comment(3)
github.com/spyder-ide/spyder/issues/5724 supposedly going to be part of V4Organon
Till the V4 comes , any useful trick to implement it easilyHeliogravure
Not that I'm aware of. It's been raised multiple times on Github but I think the only way is to wait for the releaseOrganon
E
23

(Spyder maintainer here) You can install the first beta of Spyder 4 to get code folding.

If you use Anaconda, you need to use the following commands:

conda update anaconda

conda update spyder

or if you use pip, then you need to run

pip install -U --pre spyder

This beta is quite stable and it has been tested for more than a year.

Epistrophe answered 18/9, 2018 at 16:11 Comment(3)
The syntax : $ pip install -U -pre spyder , replies as no such option: -p in the terminal.Heliogravure
Sorry, it needs to be --pre. I updated the answer accordingly.Epistrophe
How to handle conda environments with spyder=4.0.0b1?, With above update spyder-kernels also gets updated to v1.2.0, while the modular approach for handling environments needs spyder-kernels==0.*Gravante
M
6

Spyder 4.0.1 is released, which supports code folding. If you are using anaconda, use

conda update --all

to get it.

Maccabees answered 28/1, 2020 at 6:32 Comment(2)
I have 4.1.5 and it there is no folding in my .py files, Preferences | Editor | Show code folding is enabled. Update: this is a known issue github.com/spyder-ide/spyder/issues/14166Fondafondant
The latest Anaconda comes with 4.1.5, the fix is to move to Spyder 4.2, a pain as upgrades in Anaconda seem inevitably to beFondafondant
G
2

If you want to fold more that just a loop or a function, you can also try:

#%% 

Code that you want to fold

#%%
Gavin answered 16/5, 2022 at 15:3 Comment(1)
Thanks, this works as well! This question is quite old, it did not used to work back then.Heliogravure

© 2022 - 2024 — McMap. All rights reserved.