To split a Databricks notebook cell, place the editing cursor where you want the break, then choose Edit > Split cell at cursor. Databricks creates a second cell from the content after the cursor; the text before it stays in the original cell. The split changes the notebook’s layout, not whether either cell runs.
What splitting a cell means
A Databricks notebook is made up of cells: separate areas for code, SQL, Markdown, and other supported content. Splitting a cell divides its contents at a chosen point and places the two resulting portions in separate cells. It is useful when one long block has become difficult to read, when you want to run only part of a block, or when you want explanatory text between sections of code.
Splitting is different from breaking a line in the editor. Pressing Enter inserts a line break but keeps the text in the same cell. A cell split creates a new notebook cell, with its own controls and execution boundary. It is also different from splitting the browser window or arranging multiple notebooks side by side.
The command works at the cursor position, so it does not automatically identify a sensible place to divide a program. Review the code or text around the cursor before using it. A split in the middle of a statement can leave both resulting code cells incomplete.
Steps to split a cell
- Open the notebook and select the cell you want to divide.
- Click inside the cell’s editor at the exact point where the new cell should begin. The content to the left of the cursor remains in the first cell; content to the right moves to the new one.
- Open the notebook’s Edit menu and choose Split cell at cursor.
- Inspect both cells. Check the last line of the first and the first line of the second, and confirm the new cell has the intended language or format.
- Run the cells when you are ready. Splitting does not itself execute them.
For example, imagine a Python cell that loads a table, filters it, and displays a result. Put the cursor before the filtering section and split there. The first cell can contain the load operation, while the second contains the filter and display steps. This makes it possible to rerun the analysis section without rerunning the load step, although whether that is appropriate depends on the notebook’s state and data.
Databricks interfaces can change, and menu labels or placement may vary by editor version. If the command is not visible, check that the cell editor has focus and inspect the notebook’s available Edit or cell actions. Avoid assuming that a shortcut from Jupyter or another notebook product is supported in your workspace.
Choose the right place for the break
A good split usually falls between complete tasks, rather than at an arbitrary line number. In code, consider dividing after a meaningful operation such as reading data, defining a transformation, or producing a final result. In SQL, a natural boundary may be between complete queries or between setup and analysis. In Markdown, a heading or paragraph boundary is often clearer than dividing a sentence.
- Keep statements intact. Avoid separating a function call, list, dictionary, SQL clause, or multiline expression in a way that leaves invalid syntax in either cell.
- Keep related setup nearby. Imports, configuration, and definitions should be easy to find when a later cell depends on them.
- Make each cell understandable. A reader should be able to tell what a cell does without reconstructing a long chain of unrelated fragments.
- Consider reruns. A cell that depends on variables created earlier may fail if run by itself or after a cluster restart.
For instance, if a Python cell contains a function definition followed by a call to that function, splitting between the two can be reasonable: the first cell defines it and the second uses it. Splitting inside the function body is generally not, because the first cell may contain an unfinished definition.
What happens to code, formatting, and outputs
The split divides the cell’s editable content at the cursor. It does not convert code into Markdown, translate code between languages, or automatically add explanatory text. Check the new cell’s language indicator before running it, particularly in notebooks that use more than one language. Databricks notebooks can use language-specific cells and magic commands; a split is a structural edit, not a language conversion.
Previously displayed results are a separate consideration from the source text. The split command is not a way to recompute results, and readers should not treat an existing output as proof that the new cell boundaries have been run successfully. After making a meaningful code change, run the relevant cells and confirm that their displayed results match the current code. If the display is confusing or stale, use the notebook’s available output-clearing controls and rerun as appropriate.
Markdown also has cell boundaries. Splitting a Markdown cell can make sections easier to edit, but consider how the text will render: a heading separated from its explanation, or a paragraph broken into fragments, may look awkward. Preview the rendered notebook after the edit. The same principle applies to SQL and other languages: a clean visual division is useful only if the resulting content remains understandable and valid.
How splitting affects execution
Creating a new cell does not automatically run either portion. In a Databricks notebook, cells are executed as notebook commands on attached compute, and the notebook’s state can be shared across cells in the relevant session. Consequently, a new cell may rely on a variable, temporary view, import, or configuration established by an earlier cell. The split itself does not recreate those prerequisites.
This distinction matters when debugging. If the second cell fails when run alone, the cause may be a missing earlier step rather than the split operation. Run the necessary setup cells first, or use the notebook’s run controls to execute cells in the intended sequence. Conversely, splitting a large cell can help isolate an error by letting you run smaller logical sections, but it does not guarantee that those sections are independent.
Execution order also matters when a notebook has been run out of order. A cell can show output from an earlier run even though upstream code has since changed. After reorganizing cells, review dependencies and rerun the parts needed to produce trustworthy results. For collaborative or scheduled work, make the intended run order clear in the notebook rather than relying on undocumented interactive state.
Splitting versus other ways to reorganize a notebook
Splitting is appropriate when one existing cell contains two or more sections that should become separate cells. It is not always the best fix for an editing problem. Use the approach that matches the goal:
- Insert a blank cell when you want a new place to write without dividing existing content. Use the notebook’s cell insertion controls, then add or move content as needed.
- Move or copy content when the sections need to appear in a different order or in another cell. Be careful not to leave duplicate code that might later be run unintentionally.
- Merge cells when an unnecessary boundary separates content that belongs together. Review the result because combining cells can also combine language or formatting contexts in ways that are not what you intended.
- Use functions or clearer structure when a long code cell contains a reusable procedure. A cell split improves notebook organization, but it does not replace sound program structure.
Cell boundaries are not the same as a transaction boundary, a separate cluster, or a guarantee of isolated execution. If you need a different execution environment, workflow, or reusable unit, a simple split may not meet that requirement.
Common problems and how to fix them
The command is unavailable. First click inside the cell’s editable area, rather than only selecting its outer border or an output. Then check the Edit menu again. If the option is still missing, the workspace may have a different notebook editor experience; use its visible cell actions or consult the Databricks documentation for that interface rather than relying on an unrelated product’s shortcut.
The new cell contains the wrong portion. The cursor position determines the split point. Undo the edit if appropriate, place the cursor more precisely, and split again. Before continuing, inspect both cells so that no line is missing or duplicated.
The second cell fails to run. Check for incomplete syntax at the split, then look for dependencies defined in earlier cells. A statement may have been divided at the wrong point, or the cell may need an import, variable, view, or configuration created elsewhere. Running the notebook in a deliberate order can distinguish a syntax problem from a missing prerequisite.
Markdown or SQL looks different afterward. Review the cell type and language, along with the placement of headings, comments, and query clauses. A new boundary can change how content is edited or rendered even though the text itself was not intentionally rewritten. Correct the content and preview or rerun it as appropriate.
The visible output seems inconsistent with the code. Outputs may reflect a prior execution. Run the edited cells and inspect the current results instead of assuming the split refreshed them.
Good habits for maintainable notebooks
Use cell boundaries to communicate the notebook’s logic. A useful notebook often separates preparation, transformation, analysis, and presentation, while avoiding a cell for every trivial line. Too few cells can make it hard to locate errors or rerun one stage; too many can make execution order and dependencies harder to follow.
After splitting, add a short Markdown explanation when the purpose of the next section is not obvious. Keep setup steps discoverable, use descriptive comments where they clarify non-obvious choices, and remove abandoned or duplicate code. If the notebook is shared, run the relevant workflow from a clean or clearly documented starting point when practical. These habits make a cell split valuable to the next reader, not just visually tidy for the person editing it.
Frequently Asked Questions
Does splitting a Databricks cell run the new cells?
No. Splitting changes the cell structure; it does not execute the resulting cells. Run them separately or use the notebook’s run controls when you are ready.
Can I split a cell at a specific line?
Yes. Put the editor cursor at the desired boundary on that line and use Edit > Split cell at cursor. The split is at the cursor, not automatically at the start or end of a selected line.
Is there a keyboard shortcut to split a Databricks cell?
Do not assume that shortcuts from Jupyter, VS Code, or another notebook apply. Shortcut support can depend on the Databricks editor experience. The Edit menu’s split command is the clearest option when available.
Can I split a Markdown cell as well as a code cell?
Notebook cell content can include Markdown as well as code. When dividing Markdown, check that headings and paragraphs still read and render naturally. For code, also confirm that each resulting cell contains valid syntax and the intended language.
Will variables be available in the new cell?
Splitting does not create or reset variables. A later cell can use values created earlier in the notebook’s execution context, but it may fail if those earlier steps have not run or the session state has changed.
Related
- Excel Shortcut Keyboard Mat: What It Is and How to Choose
- Excel Shortcut Mouse Pad: What to Look For
- Excel Shortcut to Move Between Tabs: Windows and Mac
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Bi-Monthly Budget Template in Google Sheets: Setup GuideA bi-monthly budget template in Google Sheets can track income, planned spending, and actual expenses for each pay…
- Install Solver in Excel: A Step-by-Step Setup GuideTo install Solver in Excel for Microsoft 365 on Windows, open File > Options > Add-ins, choose Excel…
- How to Read a Box Plot in Excel: A Practical GuideTo read a box plot in Excel, locate the median line inside the box, use the box edges…
- How to Make a Flowchart in PowerPointTo make a flowchart in PowerPoint, choose Insert > SmartArt > Process for a quick, mostly linear diagram,…
- Hanging Indent in Word: Set It Up Step by Step in MinutesTo create a hanging indent in Word, select the paragraphs you want to format, open the Paragraph settings,…
- Find and Replace Colors in Excel: A Practical GuideYes. In Excel for Microsoft 365 on Windows, use Home > Find & Select > Find, open Options,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.