collapsing functions in the main window

is there a way to collapse the functions i have written in my sketch i am near on to 2000 lines of code and most of it is funtions i really don't need to read anymore.

im getting lost in my own code. and i am finding it hard to tame

Hi Mike

The native editor in the IDE does not have that ability, but there are a couple of ways to achieve what you want.

You can configure an external editor for the IDE. This video has more information: - YouTube

You can split your program into multiple files in the same folder, which then appear as multiple tabs in the IDE window. Have one main .ino file that #includes .h / .cpp files. Arduino - How to split project in multiple file - Programming Questions - Arduino Forum

Regards

Ray

Downloading the latest version will give you this feature.

From the menus: File->Preferences then tick 'enable code folding'.

However at the moment, there is a slight bug. If you switch tabs, the collapsing is reset as each tab shares the same editor window. Soon this will be solved with each tab using its own editor.

2 Likes

If your on Windows then I recommend Notepad++ (NPP) and configure it to suit Arduino keywords using example here.
You can then fold functions etc and with plugins do auto indent, file compare, function list, split windows, multiple files at a time and much more.
I also use a run command within NPP to launch the Arduino IDE with the active file so I can compile/upload it easily. I have not tried this but the newer IDE's support command line compile & upload so this could probably all be done from within NPP without needing to launch the Arduino IDE.

In other words you need to find a proper text editor that understands programming languages
and provides such features - there are many out there, I'd recommend anything that can be
driven without a pointer/mouse, because that's a major slow-down in any UI you use a lot.

Always consider the benefit of choosing a platform-independent open-source editor, because
you are investing a lot of time in learning the keyboard short-cuts and really don't want to
be subject to the vagaries of a proprietry software tool that could go away, or become expensive
or change radically.

There's a useful feature comparison at

but it doesn't show which are cross-platform and open-source.

[ I use the same editor I did in 1983 and its available on almost everything ]

pYro_65:
Downloading the latest version will give you this feature.

From the menus: File->Preferences then tick 'enable code folding'.

However at the moment, there is a slight bug. If you switch tabs, the collapsing is reset as each tab shares the same editor window. Soon this will be solved with each tab using its own editor.

bingo . thanks for the heads up on this

I would argue that if the file is so large it is hard to manage, it should really be broken into several smaller files.

Regards,
Ray L.

As of version 1.8.5 (I don't know about previous versions) this is now possible - it is check box labeled "Code Folding" under the "File / Preferences".