To comment out multiple lines in a Databricks notebook, you can use the following methods depending on the type of code you are working with:

Python or Scala Code

  1. Select the lines of code that you want to comment out.
  2. Use the shortcut:
    • For Windows/Linux: Press Ctrl + /
    • For Mac: Press Cmd + /

This will add a # symbol at the beginning of each selected line, effectively commenting them out.

SQL Code

For SQL code, you can use bracketed comments to comment out multiple lines:

Example:

sql
/*
SELECT * FROM database.tablename
WHERE condition
*/

This method is useful for temporarily disabling sections of SQL code without deleting them.

Additional Shortcuts