Is there another way than pressing Ctrl+. until the whole cell is selected and then pressing Del?

If this is not built in, can I create some sort of a global macro to do this and bind it to a keyboard shortcut?

  • $\begingroup$ Here is a more general solution, too. $\endgroup$
    – Vladimir
    Commented Apr 25, 2020 at 20:36

2 Answers 2


Referencing Szabolcs's answer, here is the code that must be added to KeyEventTranslations.tr:

Item[KeyEvent["m", Modifiers -> {Control}],
        FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], All, Cell], 

I chose Ctrl+M at random; change it to whatever you want.

See this before you edit the file.

  • 3
    $\begingroup$ Change All, Cell], -> All, CellGroup], to delete the whole cell group, such as Input+Output group. Or change it to All, CellGroup, 2], to delete the cell group of level 2, and so on. $\endgroup$
    – Vladimir
    Commented Mar 11, 2013 at 22:08
  • $\begingroup$ @Vladimir Thanks for the tips. $\endgroup$
    – Mr.Wizard
    Commented Mar 12, 2013 at 1:24

I usually press the down key until I get out of the cell, then press shift-up to select it.

Here are two buttons that will select or delete the whole cell for you:

select = Button["Select Cell", SelectionMove[SelectedNotebook[], All, Cell]]
delete = Button["Delete Cell", SelectionMove[SelectedNotebook[], All, Cell]; 

CreatePalette[Column[{select, delete}]]

I'll leave it to others to set up keyboard shortcuts for these.

I would like to note that these actions don't require the kernel to execute. If you are going to send them to the front end for direct execution (FrontEndExecute), use the versions prefixed by FrontEnd`, i.e. FrontEnd`SelectionMove, etc. You could probably add this version directly to KeyEventTranslation.tr, but I don't have time to test it now.

  • 8
    $\begingroup$ +1 "I usually press the down key until I get out of the cell, then press shift-up to select it." ... Your Hired - TY. I'm a shortcut fanatic I hate mouse navigation. $\endgroup$ Commented Nov 22, 2012 at 3:32
  • $\begingroup$ Is there any way to select all code inside the cell (not the cell itself)? (Or should I ask this as a separate question.) (Looking to make a keyboard binding but code for a button should be easy enough to convert.) $\endgroup$
    – Kvothe
    Commented Jun 14, 2018 at 15:41
  • $\begingroup$ @Kvothe I usually just jump to the beginning with Command-Left, then select to the end with Command-Shift-Right (it may be necessary to press Down a few times). $\endgroup$
    – Szabolcs
    Commented Jun 14, 2018 at 16:14
  • $\begingroup$ @Kvothe Ctrl+. extends the selection. Pressing a few times usually selects everything. Alternatively, End; Shift+Home selects everything. $\endgroup$
    – Joakim
    Commented May 26, 2020 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.