Giter VIP home page Giter VIP logo

trim-annoying-whitespace-from-google-sheets's Introduction

Trim Annoying Whitespace from Google Sheets

As referenced in this amusing thread, Google Sheets has a bad habit of adding random trailing whitespace to cells when you hit Tab or Enter. (Especially if you use Firefox, and this quirk is potentially on purpose!)

When this happens, the text in those cells appears to be stuck to the top of the cell, or top aligned, but changing the vertical alignment doesn't fix it.

There is a built-in function in Google Sheets you can use: DataTrim Whitespace. This fixes the problem reliably, but you have to manually select the cells you want to fix each time, and this menu function doesn't include a keyboard shortcut.

This repository contains a simple Macro that does the following:

  • Selects the entire sheet
  • Runs DataTrim Whitespace
  • Returns you to the cell, range, or ranges you had selected before you ran the macro

Demonstration of functionality

Installation

Google makes it pretty much impossible to import a macro from anywhere outside your account (which is annoying, but probably good security policy).

So in order to get this going, you have to pretend to record a macro for yourself, edit that macro, and replace it with the code you'll find in trim-whitespace.gs.

Here are the steps. It's pretty painless.

  1. In a Google Sheet document, go to ToolsMacrosRecord Macro.
  2. Click Save in the Macro recording card that pops up at the bottom of the screen.
  3. Go to ToolsMacrosManage Macros.
  4. Click the three-dot menu icon to the right of the macro you just recorded, and select Edit script.
  5. Select all in the script editor that comes up, and copy & paste the contents of trim-whitespace.gs.
  6. Click the disk icon in the menu bar, go to FileSave, or hit cmd/ctrl + S.
  7. Close the script editor browser tab.
  8. Back in your Google Sheets document tab, go ahead and give your macro a resonable name like "Trim Whitespace" and a useful keyboard shortcut. I chose cmd+option+shift+7 and it's been pretty easy to get used to hitting that occasionally to clean up the sheet.

Contributing

If you have ways to make this macro even better, do let me know, and/or submit a pull request.

I'm at @donnieclapp on Twitter.

trim-annoying-whitespace-from-google-sheets's People

Contributors

dhc02 avatar

Stargazers

Alex Folland avatar Nick Geoca avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.