This extension provides a few snippets and key bindings for common tasks in .Rmd
documents, such as inserting code chunks and including images using knitr::include_graphics()
.
Additionally, it aims to provide some helper functions for Bookdown and Blogdown.
This project is at its very early stage of development. Contributions are welcome!
- R Markdown All-in-One for VS Code
- Table of Contents
- Video Demos
- RMarkdown-Specific Features
- Bookdown-Specific Features
- Blogdown-Specific Features
- Other Markdown Features
- TODO
- Change Log
If you prefer reading text, jump to RMarkdown-Specific Features, Blogdown-Specific Features, Bookdown-Specific Features, or Other Markdown Features.
As you would do in RStudio, you can use Ctrl/Cmd+Alt+I
to insert a code chunk (alternatively, you can write \code
to trigger this snippet). The language defaults to R, but you can also use many other langauges supported by knitr.
The first tab stop allows you to configure this code chunk (language, label, eval
, echo
, etc.), and the second one is where you write the code. The third tab stop inserts a blank line between after the code chunk, which is required by the .Rmd
format.
In the world of R Markdown, knitr::include_graphics()
is the preferred way of inserting images over Markdown's native ![]()
syntax. If you don't know it, you should. Its syntax, however, is rather verbose.
With VSCode RMarkdown extension, you use the \fig
snippet.
Use Ctrl/Cmd+Shift+K
to knit the document with options specified in the YAML header, like in RStudio.
Description | Windows/Linux | Mac | Note |
---|---|---|---|
Insert Code Chunk | Ctrl+Alt+I |
Cmd+Option+I |
The first tab stop allows for easy configuration, the second for the actual code |
Knit | Ctrl+Shift+K |
Cmd+Shift+K |
Knit current .Rmd document with options specified in the YAML frontmatter |
\ref
or \@ref
: general cross-reference; inserts \@ref($1)
\refsec
or \@sec
: section cross-reference; inserts Section \@ref($1)
\reffig
or \@fig
: figure cross-reference; inserts Figure \@ref(fig:$1)
\reftab
or \@tab
: table cross-reference; inserts Table \@ref(tab:$1)
\code
: insert a code chunk
\fig
: insert a chunk using knitr::include_graphics()
to include an image; hit tabs to conviniently fill out label, fig.cap
and out.width
.
Before you can use blogdown-specific features, you need to first open the directory of your bookdown project. The easiest way is to use RStudio's 'New Project'.
- In the command palette (
Ctrl/Cmd+Shift+P
), search forserve book
- Execute
Blogdown: Serve Site
- Click the link in the output to view your book
You are redirected to your new site (not implemented yet)!
Before you can use blogdown-specific features, you need to first open the directory of your blogdown project. The easiest way is to use RStudio's 'New Project'.
- In the command palette (
Ctrl/Cmd+Shift+P
), search fornew post
- Execute
Blogdown: New Post
, then fill out basic information (title, author, category, archetype)- You can set the default author in the settings
Ctrl/Cmd + ,
- You can set the default author in the settings
- You are redirected to your new post!
- In the command palette (
Ctrl/Cmd+Shift+P
), search forserve site
- Execute
Blogdown: Serve Site
- Click the link in the output to view your blog
You are redirected to your new site (not implemented yet)!
Mostly adapted from microsoft/vscode and yzhang-gh/vscode-markdown.
Mostly adapted from yzhang-gh/vscode-markdown.
Description | Windows/Linux | Mac | Note |
---|---|---|---|
toggle bold | Ctrl + B |
Cmd + B |
|
toggle italics | Ctrl + I |
Cmd + I |
- general
- adapt and modify existing markdown support extensions preview HTML/PDF
- insert tables (with labels and captions)
- citation autocompletion
- run code?
- Navigation bar
- bookdown
- blogdown
- to be consistent with RStudio's plugin, 'new post' should produce
<date>-<slugified-title>.Rmd
?
- to be consistent with RStudio's plugin, 'new post' should produce
See CHANGELOG.md
(certain command may provide no response or give out errors when the packages are not installed)
rmarkdown
bookdown
servr