Workflow to use R with Neovim

Notes on how to work with Neovim to use it as an IDE for R with the most used commands and functionalities.


February 27, 2023


There are several reasons why using Neovim with Lua and Packer for working with R can be beneficial:

  1. Lightweight and Customizable: Neovim is a lightweight text editor that runs in the terminal, providing a clean and minimalistic interface. By configuring it with Lua, you have the flexibility to customize and personalize your editor to match your preferences and workflow.

  2. Efficient R Coding: Neovim offers powerful features and key bindings specifically tailored for working with R, such as sending code to the R console, code navigation, code completion, and documentation lookup. These features help streamline your R coding workflow and enhance your productivity.

  3. Package Management with Packer: Packer is a plugin manager for Neovim that simplifies the installation and management of plugins. With Packer, you can easily add, update, and remove plugins, allowing you to extend the functionality of Neovim and enhance your R coding experience.

  4. Terminal-based Environment: Working in a terminal-based environment can be advantageous for R development. It allows you to focus on your code without distractions and provides a consistent experience across different platforms and systems.

By following the tutorial here, you can learn how to install and configure Neovim with Lua and Packer to set up an efficient and streamlined environment for working with R.

Give it a try and see how this setup can enhance your R coding experience!


  1. Open any R file with nvim
  2. Use the \rf command to open the R console
  3. Start modifying and running code with the spacebar


ctrl + w + l Jump to left panel

ctrl + w + h Jump to right panel

gg Move to of file

G Move bottom of file

function + Shift + up or down Take to the upper or lower page section

{ Go one paragraph up

} Go one paragraph down

R specific commands

\rf Connect to R Console

\rq Quit R Console

\d Run current line and move to the next line

\l Run current line, but cursor will stay on the same line.

\pp Run paragraph. But cursor will stay on the same block.

\pd Runs block and move to the next one

\ss Execute a block of selected code. This has to be done with visual mode

\aa Run entire script

\ro Open the “Global Environment”

\r= Expand all

\r- Collapse all

\qp Render preview .qmd (If I save the doc, it will re-render the site)

\gn Next chunk

\gN Previous chunk

\ch Run all previous chunks to here

\cc Run current chunk

space bar Run one line of code (You need to create this key binding)

Edit files

:%s/word_in_file/word_to_insert Substitute all matches

:set spell will set the grammar check in the document

z= will open the options to correct a word.



BibTeX citation:
@online{a. hernandez mora2023,
  author = {A. Hernandez Mora, Ronny},
  title = {Workflow to Use {R} with {Neovim}},
  date = {2023-02-27},
  url = {},
  langid = {en}
For attribution, please cite this work as:
A. Hernandez Mora, Ronny. 2023. “Workflow to Use R with Neovim.” February 27, 2023.