20
  • In JupyterLab, given the following code cell, how may it be split into multiple cells?

enter image description here

  • Likewise, given the following cells, how may they be combined into a single cell?

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158

2 Answers2

30

When working directly with JupyterLab, not in an IDE.

enter image description here

  • JupyterLab: splitCell
  • In order to split one cell into many cells:
    • Place cursors where the split is desired, and then press and release ctrl + shift + -
    • Multiple cursors may be placed, by holding ctrl, and clicking the location for the cursor.

enter image description here

  • JupyterLab: mergeCells
  • In order to merge multiple cells, into one cell:
    • Select the desired, consecutive cells, by holding shift, and clicking in the margin, where the [ ] is, which will highlight the selected cells.
    • While still holding shift, press m, and then release both keys.

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
6

For those that come here for Jupyter in VSCode, you can merge cells by:

  1. Selecting the cells (using shift + arrow is supported)
  2. Right click > Join With Previous Cell (or Join With Next Cell)

Join With Previous Cell key: Shift+Alt+Windows+J

Join With Next Cell key: Alt+Windows+J


NOTE: that it will join the selected range + previous or next cell. So, if you just want to merge two cell, no need to select using shift + arrow.

Muhammad Yasirroni
  • 1,512
  • 12
  • 22