macvim_rSince 4 months I'm using Vim as my main text editor for editing R code. Out the box, Vim and R are not able to communicate together. The vim-r-plugin associated with the VimCom R package provides a highly efficient link between Vim and R.

On Mac OS X, MacVim is an elegant solution to use Vim with a good integration to the OS. This is also easier than a CLI version for a beginner to discover the power of Vim. Indeed, there is menus for common commands and a lot of things work as user should expect in Mac OS X: pasting to the system clipboard, binding to standard shortcuts, directly open a file from the Finder…

However, to take full advantage of the vim-r-plugin and VimCom in MacVim, one have to install the last development version, that could be awkward.

The aim of this article is to describe this installation.

Jakson Alves de Aquino, the creator of this fantastics plug-in, described in a figure I reproduce above how MacVim and R are communicating using vim-r-plugin and VimCom. It's quite complicated because, as he explained me, the solution needs three different ways of communication to benefit of all the integrations: omnicompletion, object browser, sending code from Vim to R…

[caption id="attachment_424" align="aligncenter" width="300"]Communication between and (extract from the vim-r-plugin documentation) Communication between and (extract from the vim-r-plugin documentation)[/caption]


These steps were tested with the following configuration:

  • OS X (Yosemite) 10.10.2
  • Have the administrator access

Install VIM side : vim-r-plugin

Install MacVim

If not already done, install MacVim

  1. Download the lasted snapshot
  2. Expand the archive and move MacVim to your /Applications/ folder

Install Pathogen

Pathogen is a plug-in manager for Vim

To install it, open a terminal an type (or copy-paste):

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim

Install Git

Git is a source control system. We will use it to download last version of the plug-in and the package.

To install Git:

  1. Go to
  2. Download it
  3. Install it

Install vim-r-plugin

Open a terminal and type:

cd ~/.vim/bundle/
git clone

To enable the documentation, open MacVim and type


Install the R side : VimCom package

Install R

Install last version of R with R GUI:

  1. Go to
  2. Download the binary for Maverick or higher (named R-3.1.2-mavericks.pkg today)
  3. Install it


To build the VimCom package from sources, you needs some dependancies from the X11 system. They can be installed with Xquartz. Reinstall it if necessary.

  1. Go to
  2. Download the last version (XQuartz-2.7.7.dmg today)
  3. Install it

Build the VimCom package

Finally we will build and install the VimCom package.

  1. Open the terminal
  2. Type (or copy-paste) the following commands:

cd ~/Downloads/
git clone
R --vanilla CMD INSTALL --configure-args=--enable-clientserver VimCom

Load VimCom when R start

  1. Open MacVim
  2. Type :o ~/.Rprofile
  3. Add the following lines:

if (interactive()) {

Check the installation

To check the plug-in is properly installed, open and type


The help dialog should open.

Try it

To check the installation, open MacVim, then

  • Set the file type as R: :set ft=R
  • Start R with local leader + r + f
  • In Vim, write 1 + 1, go back to normal mode, select the line and press space bar. The command should be send to R.
  • Open the object browser with local leader + r + o
  • Try omni-completion: in MacVim, Insert mode, type summ and then ctrl + x + o. It should complete with summary.
  • Try argument completion: type summary( and then ctrl + x + a. It have to propose the argument object.


  • Read the vim-r-plugin documentation. It's well done!
  • Check you have no old version of the plugin
  • must be open by the vim-r-plugin. Close before starting MacVim.

Go further

There is a lot of configuration possible. In another post, I will describe how to install the CLI version, with Tmux and nice colors in the R console.