BigQuery: Ultimate shortcut guide to enhance your SQL productivity

Have you ever dreamed of transforming your SQL writing experience in BigQuery? And no, I'm not talking about AI and the latest trendy LLM, but about those times when you have to leave dbt / VSCode and get your hands dirty writing queries directly through the BQ UI.
Those (elusive?) shortcuts for editing text from our favorite IDE that save us so much time haven't left our fingertips! (My apologies to VIM purists though, I have nothing for you...)
And if you've never done any dev work before discovering the world of data, you may have no idea what I'm referring to, so hang on tight but don't forget to blink.

Cursors, to turn your writing in writingS

Yes, plural. One cursor is great but why stop there? Free yourself from the shackles of Word, Notion, or Confluence, editing in various places the same thing multiple times is a thing of the past.

Point & Click

Image without caption
Add cursors to your hearts desire!
Image without caption

Next occurrences

Image without caption
Places a cursor on the following occurence of the initial selection. To only edit on the resulting selection.
Worry not, if you simply want to select all occurrences, it’s coming right after.
Image without caption

All occurrences

Image without caption
Places a cursor on all occurrences of the selection. A bit like a “search & replace” but faster. And more versatile. And more practical.
Image without caption

Add a cursor just above / below

Image without caption
Countless applications, but I picked this very handy one. To do a SELECT on all fields of a table when you have been told since early childhood that SELECT * is the evil incarnate.
With a guest appearance of CTRL + K (not mapped on Windows) at the 15 second mark, which deletes the rest of the line.
Image without caption

Combining more actions

And uh ... can we like navigate and copy/paste with all this?
Yes!
Generally, the shortcuts for moving with the arrow keys that work with a single cursor follow the same logic here:
  • Shift/Shift for selection.
  • Cmd/Home-End for starts and ends of lines.
  • Opt/Alt to jump word to word (fields_like_this counting as 1 word).
And if the number of copied items matches the number of active cursors, each item will be pasted at its respective cursor.
Image without caption

Undo a cursor

"Aah I went too far, quick up arrow! Nooo why did it add one way above ??"
Image without caption
Removes the most recent cursor. (No, it is still impossible to have a negative number of cursors.)
Image without caption

Comments?

No comment

Lines

Image without caption
Comments all selected lines via -- Also works to uncomment.
Image without caption

Sections / blocks

Image without caption
Add /* and */ around your selection to comment / uncomment it.
Image without caption

Bonus

Remove line breaks

Image without caption
When
the
default
formatting
makes the code
unreadable.
Image without caption
Shortcut not bound on Windows (still available in the command palette but much less useful)

Remove unnecessary spaces at the end of lines

Image without caption
This combo allows to remove the trailing spaces. A bit subtle but pay attention to lines 1, 2, 11, 13, and 15.
Image without caption
There are plenty of other K → ? combos to discover!

Change case

UPPERCASE KEYWORDS IS SQL FROM THE 70s!?
F1 allows you to open a menu giving the option to choose the desired case (and also gives access to many other useful commands).
Image without caption

Verdict

Whether you are completely discovering these shortcuts or you have never thought to test if they worked in a web UI, I hope this curated selection will be useful to you! Of course, feel free to share this article with your coworkers (but I know you'll want to flex your new skills directly to them).
Let me know if one of them has changed your life or if I actually missed your favorite one. (However, complaints about the dark mode rendering of this article are to be redirected to our Chief Notion Officer.)
There may be some unexpected interactions between some shortcuts and other applications / OS / layout / browser. You can always check in the F1 menu which keybind should work for you (if not overridden by another program) .
About the author : Xavier Hamida
About the author : Xavier Hamida
Image without caption
Data Engineer at Unnest, I transform raw data into business insights
Using BigQuery, I aggregate and model various data sources according to business rules to empower stakeholders
✉️ Reach out : xavier.hamida@unnest.co