Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

Keyboard only use

Open fonsp opened this issue 4 years ago β€’ 67 comments

Which keys? Action
βœ… F1 or Ctrl+Shift+? List shortcuts
βœ… Shift+Enter Run cell
βœ… Ctrl+Enter Run cell if the code changed and add a new cell below
βœ… Ctrl+S Run all cells with modified code in a single batch
βœ… Tab Autocomplete
βœ… Backspace or Delete Delete empty cell (delete code manually first)
βœ… PageUp/Fn+Up and PageDown/Fn+Down Edit cell above/below
βœ… Ctrl+Q Interrupt all cells
βœ… Ctrl+P Export to PDF
βšͺ Ctrl+Z but it's tricky Undo delete cell
βœ… Ctrl+K Fold/unfold cell
βœ… Alt+Up and Alt+Down Move line(s) up/down
βœ… Ctrl/Cmd+A, then Alt+Up and Alt+Down Move cell(s) up/down
βšͺ Ctrl+Shift+S Move notebook file
βœ… Ctrl+/ or Cmd+/ Comment/uncomment selection
βšͺ TBD Wrap in begin ... end
βšͺ TBD Wrap in let ... end
βœ… Ctrl/Cmd+C and Ctrl/Cmd+V Cut, copy & paste cell(s)
βšͺ TBD Add cell without running
βœ… Ctrl+primary click Jump to definition
βšͺ TBD

I'm interested to hear suggestions on which Actions still need a shortcut (I will add them to the list), and which keys to use in case we have not yet decided upon one. If a key has already been decided, you will have to wait for #56 until you can use your alternative keybinding - it's not productive to post them here.

We will use the same shortcuts as the VS Code default keybindings wherever possible - please consider this in your suggestion.

fonsp avatar Apr 07 '20 11:04 fonsp

Same shortcuts as VS Code wherever possible.

fonsp avatar Apr 08 '20 09:04 fonsp

One of the nice things about Jupyter imho is the ability to switch between command and cell mode by doing Esc/Enter, and then simple shortcuts for creating/deleting cells, moving cells etc in command mode. Would it be an option to have this in Pluto?

nilshg avatar May 12 '20 07:05 nilshg

Hey! I am very reluctant to add a second editor mode 😬. Part of Pluto's UI design is having all primary functionality (edit, run, add, delete, move and hide) directly available, at the position on your screen where it takes effect.

fonsp avatar May 12 '20 14:05 fonsp

Now if I read this correctly I currently can't move between cells using the keyboard (but that will be added as per the list above) and I can't add a new cell without re-running an existing cell or re-order cells with a keyboard shortcut?

nilshg avatar May 12 '20 19:05 nilshg

No worries! I added the last one to the TODO list. πŸ‘

fonsp avatar May 12 '20 19:05 fonsp

Rereading the list above I think the only thing missing is the ability to create a new cell without running anything (although maybe that's actually pointless as Ctrl+Enter does this as long as a cell hasn't changed?)

nilshg avatar Aug 14 '20 09:08 nilshg

Added

fonsp avatar Aug 14 '20 09:08 fonsp

Also - can someone with a Mac keyboard explain when shortcuts should use Command and when they should use Control? Should any existing shortcuts be different?

fonsp avatar Aug 14 '20 09:08 fonsp

It would be really cool to support Jupyter-like single-letter keybindings (inspired by Vim), like o for new cell below, O for new cell above. For this however, it needs a modal state (command/insert).

@fonsp on a Mac, it's preferred to use CTRL shortcuts for nested apps since CMD shortcuts are usually system or application specific (in this case the application is the browser). Otherwise you need to find the subset of available keys for all kinds of browsers, which might be difficult.

Another reason why modal editing would be nice. It's usually done by two trigger keys (ESC to enter command mode and i to enter insert mode). When ESC is pressed, every key has a specific meaning, like x to delete a cell or as mentioned above o or O for new cell below/above. I guess you know this already but just in case :wink:

Edit: oh, I just read that you don't like modal editors. :disappointed: I read https://dl.acm.org/doi/pdf/10.1145/2212877.2212896 but I completely disagree. It's a matter of taste, I only use modal editing including my window manager, browser, mail, jupyter etc. :wink: nevertheless, I might invest time to make a PR in future if you consider to merge such a feature implemented by others?

tamasgal avatar Aug 17 '20 13:08 tamasgal

Thanks for the clarification about CMD!

I won't implement a modal editor right now (even if it is from a PR), but you can move your comment to #56. Once there is the possibility to customise shortcuts, we can also work on implementing an optional vim mode.

fonsp avatar Aug 17 '20 13:08 fonsp

Pluto seems awesome. Most exciting development since Hydrogen / VScode Python Interactive. Some humble suggestions on keyboard shortcuts.

keymaps that are out of spec

Ctrl+Enter to run cell Shift+Enter to run cell and add cell below.

  1. Based on https://github.com/fonsp/Pluto.jl/issues/56#issuecomment-608520571 and https://github.com/fonsp/Pluto.jl/issues/56#issuecomment-612507279 it seems like current (v0.11.6) ctrl/shift-enter does not match design.

  2. ctrl-up/down: not functional right now?

unintuitive

  1. Pgup/Pgdown: it's unfortunate to break the basic behavior of a key that works so consistently across the Internet. Current behavior is also substantially different from VScode. I use this all the time to scan through long notebooks. Perhaps ctrl-alt-up/down, or alt-pgup/pgdown instead?

  2. ctrl-z: very helpful how jupyter has cell-specific undo/redo. Across cells sounds fine, but ideally we would keep within cell granularity on edits. Tracked in https://github.com/fonsp/Pluto.jl/projects/2#card-39978916.

suggested higher-priority keymaps from VScode

VScode has hundreds of default keybindings, so IMHO still worth suggesting which ones to prioritize. Although maybe better to prioritize integration with VScode. Just user suggestions from my armchair over here, seems like you all already have great intuition of what is most impactful to work on :).

  1. ctrl-d/ctrl-k: in Atom (or VScode with Atom bindings), this allows one to create another cursor with next selection matching current cursor. ctrl-k skips selection for the next occurrence. This is my most used shortcut, and would love to have!

  2. alt-up/down: suggest this swaps a line up/down

  3. alt-shift-up/down: suggest this create new cursor above/below

  4. ctrl-shift-D: suggest this duplicates line

  5. ctrl-P: fuzzy file selector is awesome.

  6. ctrl-shift-P: fuzzy command selector + keyboard shortcut lookup is awesome (but maybe better to just integrate with VScode)

tbenst avatar Aug 17 '20 20:08 tbenst

@tbenst I've moved some of my comments to the first post to make them harder to miss - https://github.com/fonsp/Pluto.jl/issues/65#issue-595782206. Could you consider editing your comment?

fonsp avatar Aug 17 '20 21:08 fonsp

thx for the comment. revised! I hope it's more helpful now

tbenst avatar Aug 17 '20 21:08 tbenst

Thanks. About page up and page down - I appreciate your concern, but have you tried it out? It still works for scrolling the page, but when the focus is inside a cell editor, it switches between cells.

I like that you mention preserving the original action of that key, I also think that this is important. Normally (on the web), when you focus on a textbox (like the one i am typing in), page up/down are limited to within that box, and don't scroll the page. Because Pluto cells are often quite small, this function is of little use, so I thought that it is fine to hijack these keys and assign them to something more useful. The new behavior of the page keys is actually closer to the static page semantic: you use it to scroll up and down the page in jumps.

fonsp avatar Aug 17 '20 23:08 fonsp

Oh I didn't realize that! I had thought that since there was no modal editing that shortcuts would always act the same way. Some visual accent might be nice (eg how jupyter turns edited cell blue) might be nice UX to highlight that key may act differently but don't want to diverge from this Issue too much. The current pgup/pgdow behavior makes sense in that case.

tbenst avatar Aug 18 '20 00:08 tbenst

For keyboard-only use, it would be nice if, when deleting a cell, the focus automatically shifted to the next/previous cell, so you didn't have to click it.

jakobnissen avatar Aug 24 '20 12:08 jakobnissen

No delete key on Mac; shift-backspace doesn't work to delete a cell.

What does '' mean in the table for adding a cell?

dpsanders avatar Aug 28 '20 01:08 dpsanders

I also don't have PgUp and PgDown and don't seem to be able to move between cells without clicking?

dpsanders avatar Aug 28 '20 01:08 dpsanders

What about a shortcut for showing / hiding the cell's input block?

dpsanders avatar Aug 28 '20 01:08 dpsanders

  • Cmd + / for commenting all lines in a cell. (I think this is standard in CodeMirror?)

  • Keyboard shortcuts for moving between slides in presentation mode.

dpsanders avatar Aug 28 '20 02:08 dpsanders

we can also work on implementing an optional vim mode.

just want to say Jupyter after so many years never have tier 1 support Vim-like key binding, this is a huge deal for people who forgot how to use mouse.

We probably don't need full vim experience, as long as the movement and basic remap (map esc to kj in input mode for example) would suffice.

Moelf avatar Sep 02 '20 21:09 Moelf

Backspace or Delete | Delete empty cell (delete code manually first)

This is counter intuitive to me. I always delete more than I expected.

What about using "Shift+Backspace" to delete a cell?

GiggleLiu avatar Sep 03 '20 22:09 GiggleLiu

This is counter intuitive to me. I always delete more than I expected.

What about using "Shift+Backspace" to delete a cell?

Agreed on this - several times now I have held Backspace down (Mac) and it's deleted the contents of the cell [desired behaviour] then carried on immediately deleting the contents of the cell above [not desired behaviour (for me)]. It would be nice to discretely delete the contents of a cell without having to release at the correct millisecond before the cursor rampages backwards into the cell above, all from the keyboard.

eroomde avatar Sep 04 '20 14:09 eroomde

I would also really want an "all keyboard" Pluto.jl experience. My preference goes to vim or Spacemacs like key bindings/ shortcuts. I believe the Spacemacs with the which-key helper are great for beginner willing to learn shortcuts but I would get it if this is too much ! Maybe add a switch to select shortcuts e.g. Vim / CUA / Emacs ? And make shortcuts configurable ?

samusz avatar Sep 04 '20 15:09 samusz

https://github.com/fonsp/Pluto.jl/issues/65#issuecomment-674879675

fonsp avatar Sep 04 '20 17:09 fonsp

I don't think it's been suggested before, but what about a shortcut to split a cell at point ?

Rabidax avatar Sep 07 '20 10:09 Rabidax

A keyboard short-cut to toggle the editor.css.main.max-width variable to device-width. I find this particularly useful when visualizing large datasets on a large monitor.

eford avatar Sep 28 '20 07:09 eford

A keyboard short-cut to toggle the editor.css.main.max-width variable to device-width. I find this particularly useful when visualizing large datasets on a large monitor.

FWIW, Adding the following code to a cell at the bottom does the job (without a kb shortcut)

HTML("<style> main { max-width:1000px; } </style> ")

eford avatar Sep 30 '20 06:09 eford

I love many things about Pluto, but I have to admit that I'm really not enjoying the shortcuts. Being a keyboard fanatic (and a modal editing lover), I get frustrated quite rapidly, in particular for the inability to switch to a dual mode editing (something like Vim or even a simpler one like Jupyter). Would it be too hard to let the user choose between the two? Or giving the user the ability to set her own shortcuts, being them modal or not? (Maybe it's already possibile and I missed it, and in that case I apologize)

egolep avatar Oct 16 '20 07:10 egolep

Not sure if the right place to mention this but the FAQ* claims Ctrl+Shift+Delete deletes a cell but (at least for me on a Mac) it does nothing.

  • side note: emoji in URLs? Kids these days... πŸ˜‹

edit from @fonsp: thanks!

pbouffard avatar Oct 20 '20 17:10 pbouffard

Not strictly a keyboard shortcut, but: I stumbled onto the fact that Option+drag does column selection mode which is awesome but I can't find documented anywhere.

EDIT: In fact, it looks like multiple cursors in general are supported, just Cmd+click to add another cursor or Cmd+double click to add a word.

pbouffard avatar Oct 20 '20 17:10 pbouffard

I don't see Cmd+] and Cmd+[ for indent and dedent on the list.

pbouffard avatar Oct 21 '20 21:10 pbouffard

On macOS, the Cmd-Q and Cmd-P shortcuts can't be triggered because they're intercepted by the browser (to quit the application / print webpage respectively). I don't have an good suggestion for an alternative at the moment – Ctrl-C for interrupting execution would be nice, but not compatible with Windows. Perhaps Ctrl/Cmd-0? (Jupyter's shortcut is 0,0 in Normal mode)

I would also like the Up / Down arrows to navigate between adjacent cells when they go up against cell boundaries (this is supported by Jupyter).

Another point in favour of an explicit Shift-Backspace for deleting a cell instead of Backspace on an empty cell - the undo history of a cell is lost after being deleted and restored, meaning that holding down Backspace for too long could leave you with no way of recovering the deleted text.

yuhan0 avatar Oct 23 '20 08:10 yuhan0

Another welcome UX improvement: selecting text and typing an opening delimiter ([{" should enclose the selected text in the respective pair instead of replacing it.

This is really useful for eg. wrapping a function around some existing expression, and supported by most editors I know (VS Code, Atom, Jupyter, etc.)

If this is supported, it would be natural for the TBD actions "Wrap in begin ... end" and "Wrap in let ... end" to be implemented as simply b and l with a selected region.

yuhan0 avatar Oct 23 '20 08:10 yuhan0

@fonsp Is the issue description above documentation of all key shortcuts or there is a seperate space for it?

laksh225 avatar Oct 30 '20 18:10 laksh225

One approach to avoiding modal editing is a common modifier key to change an action between text and cell scope; for example:

  • Cmd+z β€” undo text action
  • Cmd+Alt+z β€”Β undo cell deletion

max-sixty avatar Dec 06 '20 22:12 max-sixty

Key suggestion: run, hide and open new cell

Ctrl+Shift+Enter

I came up with this when writing a notebook with several one-line cells with markdown and assignments. It makes good sense to me when doing a lot of writing in a notebook.

VS Code keybindings for folding are Ctrl + Shift + [ for fold, Ctrl + Shift + ] for unfold. I think this makes sense to use for hiding/unhiding. But the one I suggest above would still be a good addition, replacing the sequence Shift + Enter, Ctrl + Shift + [, Ctrl + Enter.

Reference VS Code keybindings: https://code.visualstudio.com/docs/getstarted/keybindings#_default-keyboard-shortcuts

LinusSch avatar Jan 27 '21 19:01 LinusSch

It would be great if some of these shortcuts for actions used frequently are implemented. As a person using jupyter notebooks a lot, where I don't need to use the mouse at all, I am not able to switch to Pluto (even though I want to) as productivity is reduced due to this not being present and have to use the mouse for common actions.

Some actions which are included in the list above which I think are most required:

  • Add cell without running
  • Fold/unfold cell
  • Cut, copy & paste cell(s)

Also a shortcut for indenting/dedenting would be nice (Also mentioned in a comment above).

I am willing to work on this, but am not familiar with javascript. Still could try out if some idea on what needs to be done are provided. Thanks.

rashidrafeek avatar Jan 28 '21 06:01 rashidrafeek

So what's the statement about the support for modality? Are now PRs allowed? @fonsp πŸ™‚

tamasgal avatar Feb 12 '21 13:02 tamasgal

markdown for empty cell: It would be great to have ctrl+m on the list (since it works), and in the shift+ctrl+? list in Pluto

AshtonSBradley avatar Mar 03 '21 20:03 AshtonSBradley

While we're wishing, a keyboard shortcut to toggle the state of Live docs would be nice

david-macmahon avatar Mar 12 '21 18:03 david-macmahon

While we're wishing, a keyboard shortcut to toggle the state of Live docs would be nice

david-macmahon avatar Mar 12 '21 18:03 david-macmahon

+100 for Keyboard-only use of Pluto.

But instead of posting my personal favourite keyboard combinations I really think that apart from figuring out reasonable defaults, it is much more important to be able to customise keyboard combinations (#56). People very much have different preferences and find different things "natural", often depending on their favourite IDE, their OS, and whatnot. Pluto is not going to change this and good defaults only take you so far.

(BTW, I'm on Mac and disagree with the general statement that "on a Mac, it's preferred to use CTRL shortcuts for nested apps". I use CMD+... in Jupyter all the time for in-cell operations like drop the line etc. Things like CMD+Q are a problem, obviously, but CMD+D or CMD+K etc. are not.)

carstenbauer avatar Apr 09 '21 08:04 carstenbauer

I fully agree with customisations and I think this also holds for modal editing, which of course cannot be solved by just allowing full customisation but requires a mode toggle which totally changes the behaviour.

Regarding the CTRL-thing under macOS, at least this is what I observed and I occasionally have clashes with keyboard shortcuts which are defined e.g. globally (mostly involving CMD). Anyways, I use modal editing wherever I can (also in Jupyter) so I cannot tell how well these things work. I had problem several years ago but never switched back when modality was introduced πŸ˜†

tamasgal avatar Apr 09 '21 09:04 tamasgal

Would it be possible to add the following shortcuts?

a) split a cell at point (Ctrl-Shift + "-" in Jupyter) b) add a cell before current cell (A in Jupyter) c) add a cell before current cell (B in Jupyter) d) delete a non-empty cell (DD in Jupyter)

pgagarinov avatar Apr 17 '21 15:04 pgagarinov

b), c) and d) would require "modal editing" which is not accepted even if it's from a PR, at least this is the last comment about it (from a year ago) from the main author: https://github.com/fonsp/Pluto.jl/issues/65#issuecomment-674879675

tamasgal avatar Apr 18 '21 08:04 tamasgal

Hi! Pluto is awesome, 100% agree with @crstnbr, keybinding modification is very important, I have about 30 I use in VS Code with Jupyter and it increases my productivity dramatically, things like splitting cells and merging are all on custom keybinds. A json style keybind preference that I can version control would be amazing. Note that I can do this by modifying keybinds with something like Tridactyl which I might explore, can't make the switch to a non modal environment unfortunately.

jackos avatar Apr 21 '21 03:04 jackos

I love Pluto, but I feel like a limb is missing when I don't have vim keybindings. I don't think this sentiment is uncommon. I feel like there is a way to use neovim backend (like with nvim plugin in VSCode), but allows you to move seamlessly between cells (pressing j on the bottom of cell 1 should move you to top of cell 2). Nobody uses enter and shift enter in normal mode, so you could keep those bindings, too. If you wanted to, you could go the spacemacs route and add a whole load of bindings with leader key (space) there, too.

joshcho avatar Jun 09 '21 18:06 joshcho

Is there a toggle for "begin end" in multiline cells?

fieldofnodes avatar Jun 22 '21 15:06 fieldofnodes

I'd suggest a shortcut to toggle Show/hide code

RichardScharf avatar Jul 27 '21 10:07 RichardScharf

Can we wrap a highlighted text in quotes?

fieldofnodes avatar Nov 01 '21 14:11 fieldofnodes

Using Safari on MacOS (Monterey) the combination Cmd+/ (for comment/uncomment) cell has no effect at all.

roland-KA avatar Nov 01 '21 17:11 roland-KA

Alt + Up and Alt + Down does not work in both of my Chrome and Firefox browsers. Is it just me?

GiggleLiu avatar Nov 30 '21 02:11 GiggleLiu

Alt + Up and Alt + Down does not work in both of my Chrome and Firefox browsers. Is it just me?

Same problem here on macOS/Safari. Outside a cell Option+Up and Option+Down has no effect at all. Inside a cell it moves the current line up or down.

roland-KA avatar Dec 02 '21 12:12 roland-KA

I second LinusSch.

I'd like to automatically hide my markdown cell when I hit ctrl + enter (I don't know whether that's appropriate for shift+ enter). And in case I make a mistake, either an "unhide" shortcut or Page+Up will allow me to edit that cell.

LAfihq avatar Jan 14 '22 12:01 LAfihq

Also - can someone with a Mac keyboard explain when shortcuts should use Command and when they should use Control? Should any existing shortcuts be different?

Cmd+Q closes the browser instead of interrupting the notebook. Maybe it should be Ctrl+Q.

I know that it's something that has been said above but it happens to me from time to time. I want to stop the notebook and instead I close the browser.

runjaj avatar Jan 17 '22 16:01 runjaj

EDIT: Is there a way to cut only a selected text? the only way I found to do it is using right-click mouse and select Cut, then Ctrl+V to paste. So far Ctrl+C copy the whole line while Ctrl+X cuts the whole line. With Ctrl+V pastes the whole line too. But I mean only the selected part of a line and not the whole line.

pablosaa avatar Feb 25 '22 18:02 pablosaa

Hi @pablosaa, sorry, what are you trying to do exactly? Ctrl+C looks to copy the selected text in the cell, while Ctrl+X cuts, on my end at least

icweaver avatar Feb 25 '22 18:02 icweaver

Hi, not sure if it conflicts with your general policy regarding shortcuts but as an R user I would really appreciate a shortcut for the pipe operator (e.g. ctrl + shift + m as in R)

osmankucuksen avatar Mar 01 '22 12:03 osmankucuksen

Which keys? Action
Shift+Enter Run cell
Ctrl+Enter Run cellΒ if the code changedΒ and add a new cell below

Hi, I'm a bit confused, why do these two default shortcuts are designed to behave in the opposite way as in jupyter notebook?

In jupyter notebook, usually we use Shift + Enter to run the current cell and select below, and Ctrl + Enter to run the current cell.

efJerryYang avatar Apr 28 '22 03:04 efJerryYang

I'd suggest a short-cuts to hide or unhide code for all Markdown cells. That would be useful when proofreading notebooks. For concreteness, I'll suggest Ctrl+Shift+M. But I'd be happy with any choice.

eford avatar Aug 17 '22 15:08 eford

Is there a shortcut for adding a cell above or below a given cell?

xaviergonzalez avatar Aug 31 '22 16:08 xaviergonzalez