2

How do I change the default indentation in the Google Apps Script editor. It defaults to 2. Even though there are lines, I find it difficult to align the code blocks, especially when they are quite large. Gets worse when there are try-catch statements. It would be a lot easier if the indentation were 3 or 4.

There don't seem to be any options anywhere.

  • The gear wheel just gives project settings.
  • I had a look in Script properties but there are no settings for indentation that I can find.
  • I've tried grabbing the indentation lines but they don't move

Apart from using spaces like I am currently doing, is there a default way of setting the indentation to 3 or 4.

2 Answers 2

2

You can change the indentation from the editor's Command Palette by pressing F1 and typing in 'Indent by spaces' and selecting an indentation level.

The GAS editor's command palette offers a number of indentation options you can experiment with.

However, there is a downside.

The changes only hold for the active tab and session - and once you switch to another file or close the session those settings are gone.

Sign up to request clarification or add additional context in comments.

3 Comments

Is yours the "paid for" version or the "free version"? I'm using the free version. I can get Indent using spaces but it does not ask or offer indentation levels.
Tested it against a free account. When you select Indent Using spaces, another dialog pops up to Select tab size with a list of numbers representing indentation levels.
OK - worked it out. press F1, type Indent, select Indent using spaces, hit return. If you don't hit return, you don't get the popup. What's annoying is if I don't click in the code space, F1 pops up some sort of help on another tab.
1

You may just have to use an alternative IDE.

You can use the Google Apps Script CLI (Clasp) to connect VSCode or something else. The files you write will be saved as .js files instead of .gs files however.

3 Comments

Can you give more details - how do I get Clasp to connect to VSCode
I can copy the code wholesale from the Appscript editor to VSCode and vice-versa but I don't know how to get the code to open directly in VSCode.
@cup if do the steps from the docs (github.com/google/clasp/blob/master/README.md) it should suffice you just need to make a new VSCode project

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.