To split a Jupyter Notebook cell, click inside it where you want the break, then choose Edit > Split Cell. In many Jupyter setups, you can also press Ctrl+Shift+- while editing; the command divides the active cell at the cursor and creates two cells.
How to split a cell
A cell is the basic unit of a notebook: it holds code, Markdown, or another supported cell type. Splitting it does not run the code or alter the kernel by itself. It places a boundary at the insertion point, leaving the text before the cursor in one cell and the text after it in another.
- Click the cell you want to divide.
- Enter edit mode by clicking inside the cell or selecting it and pressing Enter. You should see a text cursor.
- Move the cursor to the exact point where the new cell should begin.
- Choose Edit > Split Cell, or use the shortcut if it is available in your interface.
- Review both resulting cells, then run them if you want to check their behavior.
The break is made at the cursor, not necessarily between lines. For example, if a code cell contains total = price * quantity and you place the cursor before quantity, splitting there produces an incomplete expression in each cell. Usually, put the cursor at the beginning of a line or between complete statements so that the new cells remain understandable and runnable.
Where the command appears in Jupyter
In the classic Jupyter Notebook interface, Notebook 7, and JupyterLab, the usual menu path is Edit > Split Cell. First select or edit the cell so the command applies to the intended location. The menu is a good option when you are unsure of a shortcut, because it makes the command explicit and avoids confusing a split with inserting a blank cell.
Keyboard shortcuts can differ with the interface, operating system, browser, or a customized keymap. Ctrl+Shift+- is a common default for splitting at the cursor in edit mode on Windows and Linux. On a Mac, do not assume that replacing Ctrl with Command will work; check the Edit menu for the shortcut shown by your installation, or use the menu command. If the shortcut is intercepted by your browser or system, the menu remains a dependable alternative.
Jupyter has two interaction modes that matter here. In edit mode, the cursor is inside a cell and keystrokes change its text. In command mode, the cell is selected but there is no text cursor; keys may trigger notebook commands instead. Press Enter to enter edit mode, and press Esc to return to command mode. Splitting at a specific text position requires edit mode.
What happens to the cell and its contents
After a split, the notebook has two separate cells in place of the original one. The cells generally keep the original cell type: a code cell becomes two code cells, and a Markdown cell becomes two Markdown cells. The split does not automatically add a blank cell elsewhere or execute either half.
Code execution is cell-based, so dividing a block can change how easy it is to run and understand. A later code cell can use variables created by an earlier cell if both have run in the same live kernel. But the code in a cell is not automatically combined with neighboring cells: a line that depends on an unfinished expression or an indented block from the previous cell may fail when run separately. Check syntax and indentation after dividing code.
Outputs are displayed with cells, and editing or splitting a previously run cell can make its displayed result a poor reflection of the code now present. Inspect the outputs after a split and rerun the relevant cells when you need current results. If the notebook depends on earlier calculations, run prerequisite cells first or use the notebook’s run controls in a deliberate order. A split is an editing operation, not a guarantee that the two parts are independently valid.
When splitting is useful
Splitting is helpful when a cell has grown to contain several distinct steps. Separating data loading from cleaning, or a calculation from its visualization, makes it easier to run one part again without rerunning unrelated statements. Smaller cells can also make a notebook easier to read during review and easier to debug when an error occurs.
- Separate setup from analysis: put imports or configuration in one cell and the analysis that follows in another.
- Isolate a result: give a plot or table its own cell so it can be regenerated or adjusted independently.
- Make a teaching sequence: divide a long example into steps so readers can run and inspect them one at a time.
- Improve Markdown structure: separate a heading from a long explanatory passage or divide text into clearer sections.
Cell boundaries are also a way of communicating intent. A notebook with one enormous cell may be difficult for someone else to navigate, even if it runs correctly. On the other hand, making every line its own cell can interrupt the narrative and create unnecessary execution steps. Split where a reader can understand the purpose of each new cell.
Splitting Markdown cells safely
Markdown cells can be split just like code cells, but Markdown is interpreted within each cell. A heading, list, or fenced code block that was valid as part of one cell may look different after the content is divided. For example, splitting a list between items may cause the two pieces to render as separate lists. Splitting between the opening and closing markers of a fenced code block can leave one or both cells with unfinished formatting.
For a heading and its text, decide whether they should stay together. A heading at the end of one cell with its explanation in the next may still render, but keeping related material together is generally clearer when readers edit or rearrange the notebook. After splitting, run or render the Markdown cell by leaving edit mode, then inspect the display. If the formatting is not what you intended, adjust the Markdown or undo the edit immediately.
Split cell versus insert a cell
Splitting and inserting a cell solve different problems. Split Cell divides existing content at the cursor. The text on both sides remains in the notebook, now in separate cells. By contrast, inserting a cell adds an empty cell before or after the selected cell; it does not divide the text already there.
Use split when you want to preserve and separate two portions of the current cell. Use the insert-cell commands or toolbar controls when you need a new blank place to write. If you accidentally insert an empty cell while intending to split, remove the unwanted blank cell and retry with the cursor positioned inside the original cell. If a split creates an unnecessary boundary, undo promptly with the interface’s Undo command or the applicable keyboard shortcut; the exact undo behavior can depend on the active editor and interface.
Common problems and fixes
- The shortcut does nothing: confirm that a cell is active and that you are in edit mode with the cursor at the intended point. Use Edit > Split Cell to bypass a shortcut conflict or a customized keymap.
- The wrong cell was split: select the intended cell, click inside its text, position the cursor again, and repeat the menu command. A visible cursor helps distinguish the active editing position from a merely selected cell.
- The new cells do not run: inspect the boundary for a broken line, missing parenthesis, unfinished string, or indentation that depended on the previous cell. Move the split to a logical statement boundary or edit the code to make each cell valid.
- Markdown formatting changed: check whether the split interrupted a list, heading, link, or fenced code block. Edit the Markdown so each cell has the structure you want, then render it again.
- The result looks stale: an output may have been produced by earlier code. Rerun the relevant cells and their prerequisites to see results that match the current contents.
If the menu command is unavailable or appears disabled, make sure a notebook cell is selected and that the notebook is not in a state that prevents editing. In a browser, a page refresh can discard unsaved changes, so save the notebook before trying disruptive troubleshooting steps. If a keyboard shortcut behaves differently from expected, use the menu and consult the shortcut listing for the particular Jupyter interface rather than assuming every installation has identical bindings.
A practical way to organize cells
Before splitting a long cell, identify the distinct actions it performs and choose boundaries that make sense both as prose and as executable units. For instance, a data-analysis sequence might use one cell to import libraries, another to load a file, a third to clean the data, and a fourth to produce a chart. This makes it easier to revisit the chart without mixing it with file setup, while keeping each cell large enough to express a coherent step.
After splitting code, test the notebook in the order a reader is likely to use it. A cell may work only because a variable was left in the kernel from an earlier run, even though the notebook’s visible order does not create that variable. Restarting the kernel and running cells from the beginning can reveal such hidden dependencies. Splitting does not create or solve those dependencies; it simply makes the execution boundaries more visible.
For collaborative or instructional notebooks, add brief Markdown explanations where a new boundary might otherwise feel arbitrary. The goal is not to maximize the number of cells. It is to make the notebook’s sequence clear, keep code manageable, and let readers rerun meaningful pieces without guessing what each one does.
Frequently Asked Questions
What is the shortcut to split a cell in Jupyter Notebook?
Ctrl+Shift+- is a common shortcut in edit mode, but bindings can vary. If it does not work, place the cursor in the cell and choose Edit > Split Cell.
Can I split a cell at a specific line?
Yes. Click in the cell and place the text cursor at the start of that line, then run Split Cell. The command splits at the cursor position, so choosing a line boundary usually keeps code easier to read.
Does splitting a cell run the code?
No. Splitting changes the notebook’s cell structure; it does not execute the resulting cells. Run them separately when you want to check their behavior or update their outputs.
Can I split a Markdown cell?
Yes. Use the same command while editing the Markdown cell. Review the rendered result afterward, because a split can change how lists, headings, or fenced code blocks are formatted.
Why does my split code fail after I run it?
The split may have separated parts of one statement, an indented block, or a dependency between lines. Move the boundary to a complete step or revise the code so each cell is valid in the order it runs.
Related
- Hayward Salt Cell Split Nut: Fit, Failure, and Replacement
- Calculated Field in a PivotTable: How It Works
- BI Conditional Formatting in Power BI: Rules and Uses
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Errors & fixes
- LEFT Function Not Working in Excel? Fix ItIf LEFT is not returning the characters you expect, check the formula, the character count, and whether the…
- Excel Rows Keep Collapsing? Find and Fix the CauseIf Excel rows keep collapsing or disappearing, first check for an active filter, a collapsed outline group, or…
- Excel Consolidate Not Working? Fix Common CausesIf Excel Consolidate is not working, check that you selected a blank destination cell, added every source range…
- COUNTA Formula Not Working? Fix Common Excel IssuesCOUNTA often seems not to work because it counts cells containing formulas that return an empty string, spaces,…
- Excel Filter Not Working With Merged Cells? Fix ItIf Excel’s filter is missing, disabled, or giving unreliable results around merged cells, unmerge the cells inside the…
- Excel VLOOKUP Not Working With Text? Fix the MatchIf VLOOKUP is not finding text in Excel, first use an exact match and check that the lookup…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.