How to comment out a block of code

In order to comment out an entire block of code in the LookML editor, following these steps:

  1. Select the lines you want to comment out
  2. Press ⌘+/ on a Mac, or ctrl+/ on a Windows computer

Your code should now be commented out with a # symbol, like this:

#  - dimension: id                         
#    type: int
#    primary_key: true
#    sql: ${TABLE}.id 

Read about all the keyboard shortcuts available in Looker here.

Commenting out SQL blocks

If you are commenting out lines that are entirely within a SQL code block, you will want to manually add SQL comment notation. Note that SQL comments must appear only in SQL blocks that are indented beyond the LookML parameter above it. This looks like:

Multi-line comments:

- view: user_order_facts
  derived_table:
    sql: |
      /*
      SELECT
         users.id as user_id
         , COUNT(*) as lifetime_orders
         , MAX(orders.date) as most_recent_purchase_date
       FROM orders
       GROUP BY user.id
       /*

Single line comments:

- view: user_order_facts
  derived_table:
    sql: |
      SELECT
         users.id as user_id
         , COUNT(*) as lifetime_orders
         -- , MAX(orders.date) as most_recent_purchase_date
       FROM orders
       GROUP BY user.id
4 5 22.6K
5 REPLIES 5

how do you uncomment?

You just use exactly the same key combo to uncomment the code.

multi line comment syntax should terminate in */

How to set my own keyboard shortcut for comment?

I don't think there is a way to bind keys like this within Looker, but # is all you need to comment out a line, and you can comment out a block of code by simply highlighting and pressing ctrl + / in Windows (or command + / on a Mac). 

You can see a comprehensive list of keyboard shortcuts here.

Top Labels in this Space
Top Solution Authors