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.

abunickabhi
  • 558
  • 2
  • 9
  • 31

3 Answers3

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.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • The syntax : $ `pip install -U -pre spyder` , replies as `no such option: -p` in the terminal. – abunickabhi Sep 20 '18 at 09:51
  • 2
    Sorry, it needs to be `--pre`. I updated the answer accordingly. – Carlos Cordoba Sep 20 '18 at 14:43
  • 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](https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder#the-modular-approach) for handling environments needs `spyder-kernels==0.*` – steadyfish Mar 29 '19 at 13:47
6

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

conda update --all

to get it.

Martin Eckardt
  • 121
  • 2
  • 5
  • 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 https://github.com/spyder-ide/spyder/issues/14166 – boardtc Jan 27 '21 at 17:16
  • 1
    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 be – boardtc Jan 27 '21 at 17:26
2

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

#%% 

Code that you want to fold

#%%