Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap Shift/Ctrl Enter to match VS Code? #363

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marius311
Copy link
Contributor

As mentioned by @tbenst here, currently Ctrl+Enter and Shift+Enter are backwards compared to the suggestion by @fonsp here, which means they are unfortunately also backwards to Jupyter/Juno.

Since I'm guessing many of us are coming from Jupyter in particular and I don't see any great reason to swap them, this puts them back.

@fonsp
Copy link
Owner

fonsp commented Sep 5, 2020

We will match keyboard shortcuts with VS Code for the defaults - what is the default there?

@marius311
Copy link
Contributor Author

VSCode's default Shift+Enter is indeed "execute-cell-and-move", which matches Juno and Jupyter and is backwards from Pluto.

Ctrl+Enter is "send-line-to-REPL-and-move" which doesn't exist in any of Juno/Jupyter/Pluto so I'd say is kind of moot, and otherwise there's no default binding for "execute-cell-without-moving".

So in terms of how to "execute-cell-and-move" and "execute-cell-without-moving", with this PR you match 1 VSCode default and both in Jupyter/Juno, whereas without it you don't match any for VSCode, Jupyter, or Juno, so I do think its the right choice.

@JobJob
Copy link

JobJob commented Sep 7, 2020

Good stuff.

Does this make shift-enter "run and move to cell below" (Jupyter default) or "run and insert cell below"?

I think Jupyter has:

  • shift + enter: run cell and move to cell below (only inserts a new cell if you're in the final cell of the notebook)
  • alt/option + enter: run cell and insert a new cell below
  • ctrl/cmd + enter: run cell (don't move)

Prob should match them by default no?

@fonsp
Copy link
Owner

fonsp commented Sep 7, 2020

How about notebook mode in VS Code - what are the shortcuts there? Try Ctrl+Enter and let us know what happened?

@fonsp fonsp changed the title swap Shift/Ctrl Enter to match Jupyter/Juno swap Shift/Ctrl Enter to match VS Code? Sep 7, 2020
@marius311
Copy link
Contributor Author

Try Ctrl+Enter and let us know what happened?

VSCode notebook mode (thankfully) seems to match Jupyter, so Ctrl-Enter is run cell (don't move) and Shift-Enter is run cell and move to cell below.

Does this make shift-enter "run and move to cell below" (Jupyter default) or "run and insert cell below"?

Shift-Enter in this PR stays run and insert cell below, which is indeed slightly different than Jupyter/etc..., but I think this is the right choice, I agree with @fonsp here:

Shift+Enter to run cell and add cell below.

with the philosophy that running and selecting the next cell is mostly useful in a non-reactive notebook, where you manually need to run a bunch of sequential cells.

@fonsp
Copy link
Owner

fonsp commented Sep 8, 2020

Can someone with a mac keyboard find out whether the shortcut to run a cell in VS Code notebook mode is Cmd+Enter instead Ctrl+Enter?

@fonsp
Copy link
Owner

fonsp commented Sep 8, 2020

@Pocket-titan do you still have access to a mac? With VS Code?

@Pocket-titan
Copy link
Contributor

@Pocket-titan do you still have access to a mac? With VS Code?

Yup, I can test in ~30 mins

@JobJob
Copy link

JobJob commented Sep 8, 2020

Yeah, in VS Code notebook mode on mac ctrl-enter is the default for run-cell (and don't move). Nonetheless cmd-enter on mac (the jupyter default) seems more natural to me - since usually on mac cmd replaces ctrl.

On ObservableHQ on mac - and I think Mike Bostock is, or at least was, a mac user:

cmd-enter is run and insert below (and if you immediately deselect the new inserted cell it is deleted - which is nice)
shift-enter is run and don't move
alt-enter is split cell

which seems good to me (edit: ... too, if we're not going to match Jupyter - though I guess that is the behaviour before this PR, modulo ctrl/cmd on mac?)

@Pocket-titan
Copy link
Contributor

Pocket-titan commented Sep 9, 2020

@fonsp Here's a list of all the default notebook-related shortcuts on Mac, should you ever need them. Both Ctrl+Enter and Shift+Enter are bound to Execute cell, and Cmd+Enter triggers Insert Code Cell below (without executing - this makes more sense in a non-reactive notebook environment, I'm not sure it does for Pluto).

Legend: ⌘ = Cmd, ⌃ = Ctrl, ⌥ = Option/Alt, ⇧ = Shift.

Image of notebook shortcuts on 🍏 vscode_mac_notebook_keyboard_shortcuts

@fonsp
Copy link
Owner

fonsp commented Sep 9, 2020

Awesome, thanks! I'll post the same from Windows:
image

@fonsp
Copy link
Owner

fonsp commented Sep 9, 2020

So we have:

VS Code

Action Mac Windows
Execute cell Ctrl+Enter or Shift+Enter Ctrl+Alt+Enter
Execute cell and select below Shift+Enter (again? huh) Shift+Enter
Execute cell and insert below Alt+Enter Alt+Enter
Insert below Cmd+Enter Ctrl+Enter

Hm...

Following earlier discussion, "Execute and select below" is less necessary in a reactive notebook, so we map it to "Execute and insert below". This gives us:

Pluto?

Action Mac Windows
Execute cell Ctrl+Enter or Shift+Enter Ctrl+Alt+Enter
Execute cell and insert below Shift+Enter (again? huh) or Alt+Enter Shift+Enter or Alt+Enter
Insert below Cmd+Enter Ctrl+Enter

I think that inserting a cell without executing it still useful in a reactive notebook, and this shortcut was asked for a couple of times.

Hmmmm... I feel like "Execute cell" is the most important one, and on Windows and Linux this should be a 2-key combination. What to do now...

@fonsp
Copy link
Owner

fonsp commented Sep 9, 2020

For completeness I'll post this:

Jupyter

Action Mac Windows
Execute cell Ctrl+Enter Ctrl+Enter 👈
Execute cell and select below Shift+Enter Shift+Enter
Execute cell and insert below Alt+Enter Alt+Enter
Insert below B in a second "command mode"... ...which Pluto will not have

Why did VS Code change the Windows shortcut 😥

@JobJob
Copy link

JobJob commented Sep 10, 2020

cmd+enter is run cell in Jupyter/Juno on mac - not ctrl+enter

Generally things that are mapped to ctrl+... on other operating systems, become cmd+... on mac

@carstenbauer
Copy link

carstenbauer commented Mar 8, 2021

cmd+enter is run cell in Jupyter/Juno on mac - not ctrl+enter

I'm on Mac and both CTRL+Enter and CMD+Enter evaluate the cell "in-place" for me. However, CMD+Enter annoyingly adds an empty line to the end of the cell I'm evaluating which is why I always use CTRL+Enter.

Jupyter

Action Mac Windows
Execute cell Ctrl+Enter Ctrl+Enter 👈
Execute cell and select below Shift+Enter Shift+Enter
Execute cell and insert below Alt+Enter Alt+Enter
Insert below B in a second "command mode"... ...which Pluto will not have

Note that Shift+Enter on both Mac and Windows also inserts a cell below if there is none to select. I'm using Jupyter notebooks for years now and I've almost never used Alt+Enter because of this feature.

In any case, based on the tables above the current Pluto defaults seem to clearly go against the main pattern here. So +1 for switching the behaviour of CTRL+Enter and Shift+Enter.

Base automatically changed from master to main March 11, 2021 21:33
@ianqsong
Copy link

ianqsong commented Apr 3, 2021

It has not been merged yet, but on release note of v0.14.0 I read
image
Thanks.

@carstenbauer
Copy link

@ianqsong Note that, AFAICT, nothing has happened on this front. the mention in the release notes is just my closed issue, #980, a duplicate of this one.

So we still have to hope and wait ...

@carstenbauer
Copy link

Sorry if I'm too curious, but I wonder a bit why this simple though impactful change takes >7 months to happen (no offense meant). Also, it seems intransparent why this PR/issue, somewhat confusingly, was closed on the 30th of Dec (without reason?) and only reopened months later. Would be great if someone from the Pluto team could comment on (hopefully not if but) when we will get the correct order of CTRL+Enter and Shift-Enter.

(Of course, this can wait until after PlutoCon 😄)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants