Use the Databricks notebook and file editor

This page describes some of the functions available with the Databricks notebook and file editor, including code suggestions and autocomplete, variable inspection, code folding, and side-by-side diffs.

Autocomplete

Autocomplete automatically completes code segments as you type them. Databricks supports two types of autocomplete: local and server.

  • Local autocomplete completes words that are defined in the notebook.

  • Server autocomplete accesses the cluster for defined types, classes, and objects, as well as SQL database and table names.

To activate server autocomplete, attach your notebook to a cluster and run all cells that define completable objects. Autocomplete suggestions automatically appear you type in a cell. Use the up and down arrow keys or your mouse to select a suggestion, and press Tab or Enter to insert the selection into the cell.

Note

Server autocomplete in R notebooks is blocked during command execution.

Variable inspection

To display information about a variable defined in a notebook, hover your cursor over the variable name.

how to inspect a variable

Code folding

Code folding lets you temporarily hide sections of code. This can be helpful when working with long code blocks because it lets you focus on specific sections of code you are working on.

To hide code, place your cursor at the far left of a cell. Downward-pointing arrows appear at logical points where you can hide a section of code. Click the arrow to hide a code section. Click the arrow again (now pointing to the right) to show the code.

how to fold code

For more details, including keyboard shortcuts, see the VS Code documentation.

Multicursor support

You can create multiple cursors to make simultaneous edits easier, as shown in the video:

how to use multiple cursors

To create multiple cursors in a cell:

  • On macOS, hold down the Option key and click in each location to add a cursor.

  • On Windows, hold down the Alt key and click in each location to add a cursor.

To create multiple cursors that are vertically aligned:

  • On macOS, use the keyboard shortcut Option+Command+ up or down arrow key.

  • On Windows, use the keyboard shortcut Shift+Alt+ up or down arrow key.

Column (box) selection

To select multiple items in a column, click at the upper left of the area you want to capture. Then:

  • On macOS, press Shift + Option and drag to the lower right to capture one or more columns.

  • On Windows, press Shift + Alt and drag to the lower right to capture one or more columns.

how to select columns

Bracket matching

When you click near a parenthesis, square bracket, or curly brace, the editor highlights that character and its matching bracket.

show the corresponding bracket

Side-by-side diff in version history

When you display previous notebook versions, the editor displays side-by-side diffs with color highlighting.

show the code diffs