fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.94k stars 285 forks source link

Keyboard only use #65

Open fonsp opened 4 years ago

fonsp commented 4 years ago
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 commented 4 years ago

Same shortcuts as VS Code wherever possible.

nilshg commented 4 years ago

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?

fonsp commented 4 years ago

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.

nilshg commented 4 years ago

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?

fonsp commented 4 years ago

No worries! I added the last one to the TODO list. 👍

nilshg commented 4 years ago

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?)

fonsp commented 4 years ago

Added

fonsp commented 4 years ago

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?

tamasgal commented 4 years ago

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?

fonsp commented 4 years ago

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.

tbenst commented 4 years ago

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)

fonsp commented 4 years ago

@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?

tbenst commented 4 years ago

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

fonsp commented 4 years ago

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.

tbenst commented 4 years ago

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.

jakobnissen commented 4 years ago

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.

dpsanders commented 4 years ago

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 commented 4 years ago

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

dpsanders commented 4 years ago

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

dpsanders commented 4 years ago
Moelf commented 4 years ago

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.

GiggleLiu commented 3 years ago

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?

eroomde commented 3 years ago

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.

samusz commented 3 years ago

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 ?

fonsp commented 3 years ago

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

Rabidax commented 3 years ago

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

eford commented 3 years ago

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 commented 3 years ago

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> ")
egolep commented 3 years ago

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)

pbouffard commented 3 years ago

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.

edit from @fonsp: thanks!

pbouffard commented 3 years ago

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 commented 3 years ago

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

yuhan0 commented 3 years ago

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 commented 3 years ago

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.

laksh225 commented 3 years ago

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

max-sixty commented 3 years ago

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

LinusSch commented 3 years ago

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

rashidrafeek commented 3 years ago

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:

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.

tamasgal commented 3 years ago

So what's the statement about the support for modality? Are now PRs allowed? @fonsp 🙂

AshtonSBradley commented 3 years ago

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

david-macmahon commented 3 years ago

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

david-macmahon commented 3 years ago

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

carstenbauer commented 3 years ago

+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.)

tamasgal commented 3 years ago

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 😆

pgagarinov commented 3 years ago

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)

tamasgal commented 3 years ago

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

jackos commented 3 years ago

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.

joshcho commented 3 years ago

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.

fieldofnodes commented 3 years ago

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

RichardScharf commented 3 years ago

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