Deleting blank lines from Jupyter notebook

If you are talking about deleting the empty line from jupyter notebook which opens in web browser then press Esc and D(keyboard key) 2 times.

You can also see all the keyboard shortcuts in the jupyter notebook file enter image description here

by clicking on the help and then from dropdown on keyboard shortcuts.


Pressing Esc and D (2 times) deletes the complete cell.

I guess the Question is about deleting the blank lines, unless the author interpretation of blank lines are blank cells.

If you came here looking for "How to delete a single line (whether code line or blank line) in a jupyter notebook cell"

Ans: ctrl-d (in Edit mode)


Using a Mac:

  • to forward delete a line from the curser use Fn + command + delete
  • to backward delete a line from the curser use command + delete
  • to delete a whole cell use Esc + (d twice)

These, and other shortcuts, can be found under the Help tab.


Pressing Esc and D (2 times) will delete only blank lines starting from the beginning. It won't delete any lines which have some text or code.