Vscode-r: Send code from Rmd chunk to terminal

Created on 5 Feb 2018  路  10Comments  路  Source: Ikuyadeu/vscode-R

I have a simple question: Is it the intended behavior that I cannot send code from R Markdown code chunks to the integrated terminal? I am returning to VS Code after having used a much earlier version of this extension, and I was thinking this was a feature. I could be confusing it with a Sublime Text extension or something else from when I last tried out various editors for R support.

If this is supposed to work, then I'll submit more information so we can try to figure out why it does not for me.

If this is not a current feature, then I'll submit my suggestion that you add it :)

feature-request

Most helpful comment

I am going to work on these:

  • Run Current Chunk
  • Run All
  • Run All Chunks Above (not including chunk cursor is in)
  • Run All Chunks Below (including chunk cursor is in)

All 10 comments

@jacob-long Thank you for using this extension and interest.
Now, this extension does not support Rmd chunk.
How do you think, which is good example R studio or Sublime for Rmd support?

RStudio is probably the best example of Rmd support, but Sublime's R-Box might be the most useful example to look into. If I recall correctly, R-Box does it like this:

  • If the cursor is at the beginning of the code chunk, right after the ```, then the send to integrated terminal shortcut sends the entire chunk.
  • If the cursor is inside the chunk, then the shortcut for sending to the terminal works like it does inside any R script.
  • I'm not sure what it does if the cursor is outside of all the chunks when the shortcut is used, but hopefully it does nothing.

@jacob-long I just simple fix.
You can send rmd source code by shortcut command.
But this command will work whole rmd file if out of ```
More useful fix will later.
Thank you for the issue!

Hmm. I'm curious if we can use some commands from the the markdown-preview extension in Visual Studio Code and pull out the R portions sending them to the terminal.

https://code.visualstudio.com/docs/languages/markdown

That'd get us far ahead on the Markdown side.

This is tricky. So, I'm going to take care of open issues first and revisit this request to see how many bumps its gotten.

It would be good to have the following commands, which are available in RStudio:

  • Run Current Chunk
  • Run All
  • Run All Chunks Above (not including chunk cursor is in)
  • Run All Chunks Below (including chunk cursor is in)

I concur with @andycraig. It would be nice to have run all chunks above/below. This is useful especially if you are trying to render document and debug some code chunk.

I am going to work on these:

  • Run Current Chunk
  • Run All
  • Run All Chunks Above (not including chunk cursor is in)
  • Run All Chunks Below (including chunk cursor is in)

Microsoft is working on built-in notebooks for VSCode and I'm hoping some commands like Run All Chunks might be added as part of that. So, I'm going to wait to see what happens.

VSCode issue: https://github.com/microsoft/vscode/issues/90382

VSCode draft PR: https://github.com/microsoft/vscode/issues/90382

VSCode notebook experiment in separate repo: https://github.com/rebornix/notebook-test

See #378 #395

Closed by #429. Thanks again @renkun-ken!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nathaneastwood picture nathaneastwood  路  6Comments

michaelHL picture michaelHL  路  5Comments

awellis picture awellis  路  5Comments

JimmyZJX picture JimmyZJX  路  3Comments

bdeshon picture bdeshon  路  3Comments