does anyone know how to fold code inside google app script editor ?
it's very hard to read/debug long code inside online editor.
I did some search on google and I couldn't find any result related to this matter.
does anyone know how to fold code inside google app script editor ?
it's very hard to read/debug long code inside online editor.
I did some search on google and I couldn't find any result related to this matter.
The Google Apps Script editor compared with Visual Studio Code1 and other IDEs is very limited. Since Google added CLASP to Google Apps Script "family" it's very unlikely that it will be added as a built-in feature but maybe this could be added by using a web browser extension.
On the Chrome Webstore there are already some Chrome extensions that extends the Google Apps Script editor but I don't know if already exists one to add code folding.
Notes
Related
References
There are many options for folding/unfolding (AKA "collapsing and expanding") sections of code in the Google Apps Script editor without adding a browser extension nor using an external editor.
Simply use: Ctrl
+ Shift
+ [
To view other methods, open the Command Pallet by doing one of the following while in the editor:
F1
key and type fold
fold
From there, you can either click on the command you'd like to execute, or finish typing the phrase followed by enter
, or using your arrow keys to select the command followed by enter
.
You may similarly unfold code by typing the word unfold
instead or using Ctrl
+ Shift
+ ]
Another option to quickly toggle folding/unfolding while in the editor is to:
alt
/option
key, and click.That will toggle between folding/unfolding all other areas of code besides the one you are working on. GAS remembers the last action you took (fold vs unfold) so sometimes it may require a couple clicks to get the desired result.
One last point which is related to this: You can define regions in your code that you'd like to be foldable. Folding/Unfolding that area will affect all code within it.
//#region My Custom Region
function myFn1() {
// Some code here.
}
function myFn2() {
// Some code here.
}
//#endregion
in 2022 this has been added as a built in feature in google appscript editor (new version) , no additional things are required