Indenting with the new editor

451 views
Skip to first unread message

Andrew Roberts

unread,
Nov 3, 2022, 6:10:22 AM11/3/22
to Google Apps Script Community
Here's a fun (I mean annoying) little fact I found out today: if you use CTRL-/ to uncomment multiple lines of code that were commented out with the old editor, all the functions code is now only indented by one space!

Old Editor:

//function foo() {
//  var a = 1;
//}

New editor

// function foo() {
//   var a = 1;
// }

The new editor puts a space after the comment, so if there is no space when you remove the comments (inserted by the old editor) it takes it from within the function leaving only one space indent.

I don't think I could cope with a world where I have functions with only one space indents!!!

DimuDesigns

unread,
Nov 3, 2022, 9:58:08 AM11/3/22
to Google Apps Script Community
That's problematic for comments coming from the legacy editor. But there are ways to fix it. From the command palette (F1) select 'Detect Indentation from Content' and then 'Format Document'. Those commands when run in sequence should resolve your indentation woes (though it might be tedious if you have a lot of scripts files in your projects).

Andrew Roberts

unread,
Nov 3, 2022, 1:54:53 PM11/3/22
to google-apps-sc...@googlegroups.com
That's great! Thanks. I thought there would be some clever commands in that long list that would sort it out. 

I'd commented out tens of test functions so wasn't looking forward to re-indenting them all, but this did it, just leaving some of the deep object indentation a bit funny.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/3bf19023-dbf4-4291-bb12-8713630acb63n%40googlegroups.com.

CBMServices Web

unread,
Nov 3, 2022, 1:57:12 PM11/3/22
to google-apps-sc...@googlegroups.com
You can indent a large number of lines with one command. Just select all the lines you want to indent and hit Tab or shift-Tab for reverse indenting.


Reply all
Reply to author
Forward
0 new messages