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

Execute only the selected parts of the code block #48

Open
tmieno2 opened this issue Aug 20, 2024 · 1 comment
Open

Execute only the selected parts of the code block #48

tmieno2 opened this issue Aug 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@tmieno2
Copy link

tmieno2 commented Aug 20, 2024

It would be great to be able to run only the selected parts of the code.

This can be useful for a number of reasons. For example, you may look at mtcars to see what other variables it has without deleting all the other codes. You may want to run only plot(fit) without displaying summary(fit) without removing summary(fit) from the console.

fit = lm(mpg ~ am, data = mtcars)
summary(fit)
plot(fit)

This is possible in quarto-webr, and I found myself (and students) using this feature a lot when I teach.

@georgestagg
Copy link
Member

georgestagg commented Aug 27, 2024

Sounds good! If you or others have ideas on the best workflow and/or shortcuts for students and readers, please feel free to chip in here.

@coatless's extension handles this well, and I think we can copy the approach here in the first pass. IIUC the rules would be:

  • Clicking "Run code" always runs the entire block.
  • "Shift-Enter" also always runs the entire block.
  • Without code highlighted hitting "Ctrl/Cmd-Enter" runs the current line and drops the cursor down a line.
  • Selecting code and hitting "Ctrl/Cmd-Enter" partially executes only the highlighted code, and keeps the currently selected code.

@georgestagg georgestagg added the enhancement New feature or request label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants