Vim R plugin

Jakson Alves de Aquino
José Cláudio Faria


This plugin improves Vim's support to edit R code.

Download the plugin:

If you use Debian or a Debian based Linux distribution (Ubuntu or other), you may want to install the vim-r-plugin_1.2.6-1_all.deb package. After the installation, you can enable the plugin by doing the following commands:

   vim-addons remove r-plugin
   vim-addons install r-plugin


  1. The Debian package of the plugin works with the Debian package of Vim. You have to adjust Vim's runtimepath if you have compiled Vim yourself and want to use vim-addon to install the plugin.
  2. The command "vim-addons remove r-plugin" is necessary only if there was a previous version of the plugin installed because new versions may include new files and, thus, there may be broken symbolic links.
  3. The Debian package doesn't work properly if your ~/.vim directory is a symbolic link. You should turn the ~/.vim directory in a real directory BEFORE using the vim-addon manager to install or uninstall the plugin.
  4. The color scheme used in most screenshots is here.

Please, read the plugin's documentation for details on usage.


Sample vimrc:

set nocompatible
syntax on
filetype plugin on
filetype indent on

" Behavior
let maplocalleader = ","
let mapleader = ";"

" Appearance
colorscheme southernlights

" Search
set infercase
set hlsearch
set incsearch

" Showmarks
let marksCloseWhenSelected = 0
let showmarks_include="abcdefghijklmnopqrstuvwxyz"

" Vim-R-plugin
if has("win32") || has("win64") || $DISPLAY != ""
    let vimrplugin_openpdf = 1
    let vimrplugin_openhtml = 1
if has("gui_running")
    inoremap <C-Space> <C-x><C-o>
    inoremap <Nul> <C-x><C-o>
vmap <Space> <Plug>RDSendSelection
nmap <Space> <Plug>RDSendLine


Videos on youtube:




The plugin running in a terminal emulator, using the screen.vim plugin and the Tmux application to split the terminal in two regions separated by a green line. Vim is running in one region and R in the other. We are using Vim's omni completion feature to complete "read.s". The scratch window at the top shows the arguments of read.spss(). The operating system is Linux:

Omni completion


The Vim window was split in two. At the right side the object browser shows the loaded libraries and we can see the objects of the library foreign.

Object Browser


Now, the the object browser shows the objects that are in R's workspace:

Object Browser


R documentation for the function attr() is shown in a separate tab:

R help


Syntax highlight of R code. The output is being colorized by the R package colorout:

Syntax highlight


In this screenshot, we can also see the use of the ShowMarks plugin to highlight marks. In the example, we are repeatedly changing the legend's coordinates and sending the block of code between the marks 'a' and 'b' to find the best position of the legends:

Marked block


The plugin on Windows. The option r_syntax_folding was set in the vimrc to enable folding by syntax and the function makeMap() is folded:



Last change: May 2015