Undocumented CodeMirror Shortcuts (multiple selection)

Hey all, loving using Observable so far.

I noticed that the text input is based on CodeMirror, and allows multiple cursors (via ctrl-click to add/remove a cursor, or alt for rectangular selections). This isn’t listed in the ‘?’ shortcut popup, which kinda makes sense because it’s more about the code editor env than the Observable one. However, I think these aren’t common knowledge and would be good to list there, or somewhere else, especially because CodeMirror’s docs don’t have an obvious listing of their default keybindings (which I think is what’s being used?).

I suspect there are also other undocumented shortcuts; in particular I would love Sublime style ctrl-D for “add next instance of selected to selection”. Currently ctrl-D deletes the current line, and I haven’t been able to find an alternate shortcut that does what I’m looking for, though I know CodeMirror supports this.

There was also this older discussion about enabling custom keybindings; doing that would also resolve this.

1 Like

Hey Zev!

Good question, and that’s right - we don’t currently document the built-in CodeMirror-inherited keybindings, and we should. I’m adding it to my list to add more complete documentation, but for now you can check out the CodeMirror command documentation, which specifies the built-in bindings in gray on the right.

Thanks for that link. Unfortunately it looks like the selectNextOccurrence command isn’t defined in the default bindings, only the Sublime ones. I’m guessing you probably don’t want to start adding one off bindings like that, so I’ll just say I’m very excited about being able to use alternate bindings at some point in the future :slight_smile:

Hey :wave:

I’d like to use the opportunity to push this topic again given the current UI overhaul in Observable next :sparkles:

I’d really love to have the Atom/Sublime/VSCode style ctrl-d / cmd-d “selectNextOccurrence” shortcut in Observable :blush: Personally, I think it’s a huge performance boost!

1 Like

One of our engineers working on Next just brought that up the other day! It’s on our radar. Thanks Chris!

1 Like

Ah I’m glad the subject comes to the table !
It’s one of those small things that matter.