29

I am using Google Apps Script and was wondering if I could use any sort of editor outside of the one Google provides. (I purchased Sublime Text and would like to use that.)

The one Google provides is disgusting, with tiny text even though I have a giant screen and syntax colors that I find a bit difficult to distinguish on a white background with small text, and I don't have the beauties of Sublime like tons of custom keyboard shortcuts, all of my packages, etc.

programmedpixel
  • 368
  • 1
  • 3
  • 8
  • If you hold down the CTRL key, and scroll, your screen will increase/decrease (Zoom) the window. (Windows at least) – Alan Wells Jul 14 '14 at 16:48
  • 1
    @SandyGood - I understand that, but that zooms the whole window, not just the code which is what I would like zoomed. – programmedpixel Jul 16 '14 at 00:14
  • Same question like your and still waiting. This guy has that add on for ST2 only and the one for ST3 will be on air soon: https://github.com/revolunet/sublimetext-google-apps-scripts – Mark Jan 06 '18 at 13:59
  • Zooming doesn't solve the fact, I agree, that it is a very poor editor. – Quidam Feb 11 '20 at 17:20

7 Answers7

17

As of today (May 2018), every scripts that you add on Google App Scripts (including scripts on Google Drive like spreadsheets) will get accessible through https://script.google.com and will have a specific id that you can get through the url by opening it.

By using clasp which handle a project (like git), you can do:

clasp clone {id}

to have your script in a local folder. Then, after editing your file with your favorite text editor, upload it back with :

clasp push
Pierre Maoui
  • 5,976
  • 2
  • 27
  • 28
  • 2
    This sounds interesting. But this sounds like one cannot really test, run or debug the code with my favorite editor then, right? I would be very interested in other editors because the console logging in the Google editor is just a huge pain. –  May 10 '20 at 18:11
11

Google has dropped support for Apps Script inside Eclipse but you can set up a local development environment inside VS Code using the Apps Script Starter kit and CLASP.

Here's a video tutorial to help you get started.

Amit Agarwal
  • 10,910
  • 1
  • 32
  • 43
  • @Mogsdad yes. though as mentioned in Google's documentation, library calls are slow and not recommended if the end result is developing an add-on or extension. – Sujay Phadke Feb 08 '16 at 05:41
  • You can always do things like SpreadSheetApp.OpenByID("1234abcd... and then you have access to your spreadsheet, no need to have it "embedded". Almost everything can be done by this method, including setting menus etc. You may even be able to set triggers to run this code. Not sure about that, though. – pashute Feb 09 '17 at 12:13
6
  1. The eclipse plug-in is migrated now. You should install many files. lastly it couldn't import my google script files.
  2. nod-google-apps-script is depercated.
  3. gdrive can't handle google scripts beyond exporting the project in single json file. issue issue
  4. sublime-editor-plug-in has n't worked for me (I read the whole documents & issues)

The only working solution for me (ubuntu xenial) is clasp.

According to doc it can :

Develop Locally: clasp allows you to develop your Apps Script projects locally. That means you can check-in your code into source control, collaborate with other developers, and use your favorite tools to develop Apps Script.

Manage Deployment Versions: Create, update, and view your multiple deployments of your project.

Structure Code: clasp automatically converts your flat project on script.google.com into folders. For example:

On script.google.com: tests/slides.gs tests/sheets.gs

locally: tests/ slides.js sheets.js

N.B:. The fature of 'Manage Deployment Versions' isn't supported by eclipse plug in.

It give the following commands:

clasp login [--no-localhost]
clasp logout
clasp create [scriptTitle] [scriptParentId]
clasp clone <scriptId>
clasp pull
clasp push
clasp open
clasp deployments
clasp deploy [version] [description]
clasp redeploy <deploymentId> <version> <description>
clasp version [description]
clasp versions

By using it; you can use your favorite script editor; then push the changes.

Edit GAS Editor Autocomplete

Thanks to @tehhowch comment.

Auto complete of google objects is almost exclusive for online GAS editor, If you use any external editor , you will only get auto complete for the functions & variables of your own script (I am not sure about eclipse).

But online editor provides autocomplete which reveals the global objects as well as methods and enums that are valid in the script's current context.

To show autocomplete suggestions, select the menu item Edit > Content assist or press Ctrl+Space. Autocomplete suggestions also appear automatically whenever you type a period after a global object, enum, or method call that returns an Apps Script class. For example:

  • If you click on a blank line in the script editor and activate autocomplete, you will see a list of the global objects.
  • If you type the full name of a global object or select one from autocomplete, then type . (a period), you will see all methods and enums for that class.
  • If you type a few characters and activate autocomplete, you will see all valid suggestions that begin with those characters.
tabebqena
  • 1,204
  • 1
  • 13
  • 23
  • 1
    You should add comments about availability of autocomplete for Google built-ins. – tehhowch Mar 21 '18 at 12:14
  • Note that there is now a TypeScript `@types/google-apps-script` package that allows external editors to enjoy autocomplete for core Apps Script features. As time goes on the autocomplete for advanced services may improve as well. – tehhowch Feb 13 '19 at 23:09
3

You can use node-google-apps-script to edit scripts locally (described in this blog post from the google apps developer blog on 2015-12-17). This way you can use a more comfortable editor, version control and build scripts.

Caveats:

  • Like the eclipse plugin, node-google-apps-script requires that your add-on is a standalone script.
  • Debugging still requires google's script editor. With some additional setup you could run functions via the Execution API
  • It would be awesome if there was a Sublime Text plugin for code completion of google library methods, but I haven't found one (I don't think their default browser editor even offers this, though)
Jay
  • 3,857
  • 2
  • 23
  • 25
3

This is an answer for basic/beginner users of Intellij that are looking for code completion when writing Google App Scripts apps. Most of the answers above were helpful for getting me going, especially with Clasp. But none of them actually got Intellij to do the code complete. But this does:

Select File, Settings, Languages & Frameworks, JavaScript, Libraries.

Then on the right select Download, the scroll down to 'google-app-scripts'. (Lots of scrolling) Download and install and you're done. Almost so easy that it really shouldn't have been so hard to find.

enter image description here

1

Another option to contemplate: using "AppsScript Color" Google Chrome plugin and GAS editor shortcuts.

Here you have a list of most useful shortcuts: https://opensourceseo.org/useful-tips-for-using-the-google-apps-script-editor/

Jams
  • 81
  • 1
  • 8
-1

You can just install a Google Drive command line client (e.g. https://github.com/prasmussen/gdrive) and edit .gs scripts directly.

There's also a way to edit Google Apps Scripts in Eclipse, which may be interesting. https://developers.google.com/eclipse/docs/apps_script

ocodo
  • 29,401
  • 18
  • 105
  • 117
  • But then how do you run and debug inside the ide? – pashute Feb 09 '17 at 12:14
  • Sadly, the answer to that question is, you don't. – ocodo Feb 13 '17 at 00:17
  • In a different thread I wrote about the google execute api, and the possibility of connecting it to the eclipse import. It seems possible but I never tried it, and am not sure what I need to do to get it working... – pashute Feb 14 '17 at 09:23
  • @pashute I'm not sure, but perhaps this is useful https://developers.google.com/eclipse/docs/apps_script – ocodo Feb 28 '17 at 01:33