posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.72k stars 82 forks source link

Investigate the key bindings for executing code in various scenarios #1461

Open petetronic opened 1 year ago

petetronic commented 1 year ago

Jupyter Notebook: Shift + Enter -> runs code, advances cursor focus to next cell Cmd + Enter -> runs code, keeps cursor focused where it is Option + Enter -> runs code, inserts new cell Run selected text (No key binding, but a menu option. This is not common.)

Quarto will match this Jupyter Notebook behavior, but we also need an execute line based keyboard shortcut. TBD: Can we steal Option + Enter?

VSCode Jupyter: Shift + Enter -> runs cell, advances cursor focus to next cell Cmd + Enter -> currently does nothing (but should do the same as ctrl) Ctrl + Enter -> runs code cell, keeps focus where it is

RStudio Quarto Visual Editor: Cmd + Enter -> runs the line, goes to next line in same cell Cmd + Shift + Enter -> runs the entire cell, focus stays in the same cell Option + Cmd + N -> runs the next chunk

RStudio Editor: Cmd + Shift + Enter: -> Runs the whole file

VSCode Python Jupyter-Like Cell: Shift + Enter -> Runs cell, sends output to Interactive Terminal, creates new cell and advances focus. Cmd + Enter -> Nothing, just inserts new line Ctrl + Enter -> Runs cell, sends output to Interactive Terminal, leaves focus in current cell.

VSCode Python Extension: Shift + Enter -> keyboard has been taken over, but should have been Run line/selection in Terminal

Positron Editor: Cmd + Enter -> sends line/selection to Console Shift + Enter -> sends line Cmd + Shift + Enter -> source file to Terminal

Positron Python Jupyter-like Cell: Cmd + Enter -> Sends line/selection to Console Ctrl + Enter -> Runs cell an sends result to Interactive Window Shift + Enter -> Sends line/selection to Console Cmd + Shift + Enter -> Sources python file in Console (Positron)

petetronic commented 1 year ago

Changes:

Quarto: One option may be to keep Shift + Enter to run the whole cell and advances to next cell. But we could take over Cmd + Enter to just mean execute the current line and advance the code line but stay in same cell?

GitHunter0 commented 2 weeks ago

But we could take over Cmd + Enter to just mean execute the current line and advance the code line but stay in same cell?

That would be great. Currently in positron, Ctrl+Enter in .R files runs the current code block / selection and advances to the next. I cannot find a way to keep the cursor/focus where it is...

juliasilge commented 1 week ago

@GitHunter0 I believe you may be looking for what is requested in https://github.com/posit-dev/positron/issues/2778. Take a look and see if you have additional info to add!

GitHunter0 commented 1 week ago

@juliasilge , thank you Julia, that's exactly what I wanted.