Is there any workaround to create sub-cells in Spyder?
E.g. I know that with
#%% Cell 1
I can create a new cell.
But is there a way to create a sub-cell which is grouped under the cell as in
# Cell 1.1
?
I have found this discussion which didn't look encouraging. But I wanted to give it a try and ask here.
Similar to Jupyter notebook, Spyder IDE allows you to create cells. To create a cell, simply put #%% in the script. Each #%% will signal generation of a new cell. To run a cell, press shift+enter while in focus of a cell.
You can separate cells by lines starting with either: #%% (standard cell separator) # %% (standard cell separator, when file has been edited with Eclipse) # <codecell> (IPython notebook cell separator)
Ctrl + Enter will run the current cell. You can read more about cells in Spyder here.
Select multiple lines. Move using ctrl + cmd + down-arrow-key. Lines will be deselected.
As per the post linked, the feature you are asking has been implemented. I just tried it on my Spyder IDE version 4.1.3 and it works by using an increasing number of %
. For instance
#%% Section 1
some code
#%%% Sub-Section 1.1
some more code
#%% Section 2
and so on
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