It’s possible this already exists, but I couldn’t find it! If that’s the case, I apologize in the advance.
A favorite Jupyter Notebook feature of mine is shift+cmd+p’s command look up box (see attached image). It’s a handy way to search for anything you might want to do (and to discover other capabilities).
Just adding this to the list of Jupyter-like features that would be handy when using Observable “scratchpads.” (I still think “notebooks” is a better name ).
Hey Ben!
Totally - we have almost that: cells can only be deleted if they’re empty, and option-delete
merges a cell with its previous cell, so the magic trick is:
- ⌘A
- Hit delete
- Option+Delete
And you’ll have deleted a cell. Maybe we should add something to delete a cell regardless of whether it has contents?
Having a shortcut for deleting a cell that works anytime feels worthwhile, as does the search for command-bar. (Compare also to tools like LaunchBar, Alfred.)
In a similar vein: what about a shortcut to deselect the current cell. That’s needed when looking up shortcuts (pressing ?
) and when using arrow keys for navigation. esc
would seem an obvious choice?
Yeah I couldn’t figure out how to delete a cell at all - having a clickable “delete” button somewhere would be more discoverable.
The inserter button that lives between cells can also be used to delete cells by merging them. Hold down shift and click the little arrows as shown here:
Thanks for the tip. I’ll give that a try. I won’t pretend to have a deep design philosophy behind this request. I’m just very used to hitting “x” key to instantly nuke cells in Jupyter Notebooks. I’m also a fan of using “a” and “b” to add cells above and below the one that’s currently active.
I don’t think those particular keys are particularly well chosen or anything, but I do like that they allow me to be a little “vim like” and manipulate cells with a single stroke and no movement off the keyboard.
I’d like a way to do this that works on an iPad - I expect I’ll be using Observable on the iPad quite a bit.
These both seem a bit arbitrary and undiscoverable. Maybe you can figure out a way to unify deletion with the upcoming drag to rearrange feature?
FWIW, it took me forever to figure out how to delete a cell. Not discoverable, had to Google for it, then landed here.
What I tried before Googling: I kept hitting Backspace and Delete in the empty cell, hoping it would delete the cell. This may be a workable interaction to add to the editor.
There is now a delete action automatically when a cell is empty and is no longer focused.
So the way to do it now is to
- ⌘A
- Hit delete
- Hit escape
I still like the idea the you can’t delete a non-empty cell.
Update! Cells now have a delete button:
I’ve been reorganizing a few large notebooks a lot recently and found myself needing to delete many (50+) cells at once. I ended up using the 3 keyboard shortcuts (select all, delete, merge previous) over and over and found it rather unergonomic. I just tested out the other approach described here of merging all the unwanted cells by holding shift and clicking on the button between cells, and it is a little better, but still one has to retarget the mouse rather frequently.
It’d be nice if we could select multiple cells for deletion or rearranging or for splitting or copying into another notebook. Being able to act on more than one cell at once would also make it easier to undo, since the notebook history wouldn’t then be filled with lots of similar actions that all arise from the same “intent”. (I made a mistake and was able to recover, but bisecting a range of some 100 notebook versions manually and then repeating a bunch of deletions again was not fun).
Further down the line it might be nice if there was some basic support for metaprogramming on notebooks, even if only via exporting notebook JS files, processing them in some local editor or program and then reimporting them.
Thanks again to the team and happy holidays!
Yes to all of these requests.
There’s a hidden feature in compare mode that’s useful for recovery, which is that you can use the tilde (~) syntax to show recent changes. For example, to see the ten most recent changes to a notebook 0123456789abcdef:
https://beta.observablehq.com/compare/0123456789abcdef~10