feedback icon indicating copy to clipboard operation
feedback copied to clipboard

Idea: "just type" keyboard shortcuts for starting a new cell

Open skybrian opened this issue 2 years ago • 4 comments

The new menu when inserting a cell gives users a lot of interesting choices, but sometimes I already know what I want. I'd like to be able to start typing and have the menu automatically disappear, sort of like using autocomplete in a text editor. Here are some keyboard shortcuts that I think would be useful:

  • Typing # means you're probably entering a Markdown header, so autoselect Markdown and put what you typed into the cell.
  • Typing an identifier followed by '=' means you're probably entering JavaScript. Choose that and put whatever you typed into the cell.
  • Typing '<' followed by a tag name means you're probably entering HTML.

Also, maybe someone else like @wizzard0 would want this:

  • Typing md` means you've been using Observable a long time and want Markdown. Switch to Markdown? Or maybe they'd rather it chooses JavaScript?

skybrian avatar May 26 '22 21:05 skybrian

yeah like starting you off with undifferentiated pluripotent protocells that only take form once they have some content. (the word "pluripotent" always reminds me of my friend alexi, hi alexi…)

during development we tried an experiment where, if you type enough that no menu items match the filter, the top item is a suggestion to insert those contents as a cell with autodetected mode:

https://user-images.githubusercontent.com/841829/170589766-12c9b9b2-8cd1-42a1-b3f4-50579156df69.mov

although as ever there's a tension between a UI being "smart" and being predictable

tophtucker avatar May 26 '22 22:05 tophtucker

That looks nice! Although, a drawback with only triggering when no menu items match is that the shortcut could change when more items are added to the menu. It seems like hard-coding a few of the most common choices would be better for muscle memory, so that they don't change and you can type them "blind" without looking at the menu.

skybrian avatar May 26 '22 23:05 skybrian

although as ever there's a tension between a UI being "smart" and being predictable

Agree, that UI on the video is too smart.

But little aid with selecting the menu item will be nice. Like @skybrian said, when the first symbol is "#", it's markdown. Now when I type # it looks like this: image And at that moment my hands are on letters and I have to reach to arrows to choose "Insert as Markdown". And then back to letters to continue typing.

But if Makrdown menu item will have a hidden keyword "#" and html will have "<", then if I type "#" it will look like this: image

And if I type "<": image

oluckyman avatar Nov 30 '22 09:11 oluckyman

I really like that suggestion!

CobusT avatar Dec 01 '22 03:12 CobusT