Open fonsp opened 4 years ago
Same shortcuts as VS Code wherever possible.
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?
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.
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?
No worries! I added the last one to the TODO list. 👍
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?)
Added
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?
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?
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.
Pluto seems awesome. Most exciting development since Hydrogen / VScode Python Interactive. Some humble suggestions on keyboard shortcuts.
Ctrl+Enter to run cell Shift+Enter to run cell and add cell below.
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.
ctrl-up/down: not functional right now?
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?
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.
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 :).
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!
alt-up/down: suggest this swaps a line up/down
alt-shift-up/down: suggest this create new cursor above/below
ctrl-shift-D: suggest this duplicates line
ctrl-P: fuzzy file selector is awesome.
ctrl-shift-P: fuzzy command selector + keyboard shortcut lookup is awesome (but maybe better to just integrate with VScode)
@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?
thx for the comment. revised! I hope it's more helpful now
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.
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.
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.
No delete key on Mac; shift-backspace doesn't work to delete a cell.
What does ''
mean in the table for adding a cell?
I also don't have PgUp and PgDown and don't seem to be able to move between cells without clicking?
What about a shortcut for showing / hiding the cell's input block?
Cmd + /
for commenting all lines in a cell. (I think this is standard in CodeMirror?)
Keyboard shortcuts for moving between slides in presentation mode.
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.
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?
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.
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
I don't think it's been suggested before, but what about a shortcut to split a cell at point ?
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.
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> ")
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)
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!
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.
I don't see Cmd+]
and Cmd+[
for indent and dedent on the list.
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.
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.
@fonsp Is the issue description above documentation of all key shortcuts or there is a seperate space for it?
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 actionCmd+Alt+z
— undo cell deletionCtrl+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
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.
So what's the statement about the support for modality? Are now PRs allowed? @fonsp 🙂
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
While we're wishing, a keyboard shortcut to toggle the state of Live docs would be nice
While we're wishing, a keyboard shortcut to toggle the state of Live docs would be nice
+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.)
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 😆
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)
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
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.
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.
Is there a toggle for "begin end" in multiline cells?
I'd suggest a shortcut to toggle Show/hide code
F1
orCtrl+Shift+?
Shift+Enter
Ctrl+Enter
Ctrl+S
Tab
Backspace
orDelete
PageUp
/Fn+Up
andPageDown
/Fn+Down
Ctrl+Q
Ctrl+P
Ctrl+Z
but it's trickyCtrl+K
Alt+Up
andAlt+Down
Ctrl/Cmd+A
, thenAlt+Up
andAlt+Down
Ctrl+Shift+S
Ctrl+/
orCmd+/
begin ... end
let ... end
Ctrl/Cmd+C
andCtrl/Cmd+V
Ctrl
+primary clickI'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.