Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
RStudio 1.4 was released in January 2021 and switched to calendar-based versioning as of 2021.09. Starting with 1.4, the IDE includes a visual markdown editor that works on any markdown-based document, such as .md
or .Rmd
files. Visual editing mode provides a better experience when writing reports and analyses. You can see changes in real-time and preview what your document looks like without re-knitting.
In addition, the visual markdown editor provides extensive support for citations, scientific and technical writing features, outline navigation, and more.
In this blog post, we’d like to show how to use the visual markdown editor and highlight some features that you should know.
- How to get started with the visual markdown editor
- How to create content in the visual markdown editor
- How to edit content in visual editing mode
Get Started With the Visual Markdown Editor
To switch into the visual mode for a markdown document:
- In RStudio v2022.02, click the “Visual” button located on the left side of the editor toolbar.
- In earlier versions, click the compass icon located on the right side of the editor toolbar.
Alternatively, use the ⇧ + ⌘ + F4 keyboard shortcut.
You can customize various editor settings. Go to Tools -> Global Options -> R Markdown -> Visual to choose your options, such as:
- Whether your new documents use the visual markdown editor by default.
- Whether the document outline shows by default.
- How to wrap text in the document.
Create Content in the Visual Markdown Editor
How to embed rich media
Once in visual editing mode, you can paste rich content (tables, images, some formatting, etc.) into a document and match it in the source document.
How to use keyboard and markdown shortcuts
The visual mode supports both standard keyboard shortcuts (e.g., ⌘ + B for bold) and markdown syntax.
Here are some commonly used shortcuts:
Command | Keyboard Shortcut | Markdown Shortcut |
---|---|---|
Bold | ⌘ B | bold |
Italic | ⌘ I | italic |
Code | ⌘ D | code |
Link | ⌘ K | |
Heading 1 | ⌥⌘ 1 | # |
Heading 2 | ⌥⌘ 2 | ## |
Heading 3 | ⌥⌘ 3 | ### |
R Code Chunk | ⌥⌘ I | “`{r} |
Check out more on the Editing Shortcuts page of the Visual R Markdown site.
How to use the catch-all shortcut to insert anything
You can also use the catch-all ⌘ + / shortcut to insert headings, comments, symbols, and more.
How to use the editor toolbar
The editor toolbar includes buttons for common commands to edit formatting or insert content.
Edit content in visual editing mode
The visual markdown editor also provides efficient tools to edit and customize content.
How to edit a table’s rows, columns, and alignment
Right-click on a table in your document. You can set the alignment, add or delete rows and columns, add a header, and more.
How to change an image’s height, width, and aspect ratio
Once you have an image in your document, you can edit the size and aspect ratio with the visual markdown editor. Click on the image and a small window will appear. Edit the numbers to change the height, width, and aspect ratio.
Learn More
The visual markdown editor has many other features for efficient report writing.
- Check out more information on the Visual R Markdown website.
- Download the latest RStudio IDE version to try out the editor.
- Watch Tom Mock live code in visual editing mode in his webinar, R Markdown Advanced Tips to Become a Better Data Scientist & RStudio Connect.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.