## R-PLUGIN

*r-plugin.txt*                                                  *vim-r-plugin*
				 Vim-R-plugin
			     Plugin to work with R

Authors: Jakson A. Aquino
Jose Claudio Faria

Version: 1.2.7
For Vim version 7.4

1. Overview                                    r-plugin-overview
2. Main features                               r-plugin-features
3. Installation                                r-plugin-installation
4. Use                                         r-plugin-use
5. Known bugs and workarounds                  r-plugin-known-bugs
6. Options                                     r-plugin-options
7. Custom key bindings                         r-plugin-key-bindings
9. FAQ and tips                                r-plugin-tips
10. News                                        r-plugin-news

--------------------------------------------------------
*r-plugin-overview*
1. Overview

This plugin improves Vim's support for editing R code and makes it possible to
integrate Vim with R. If you want to use Neovim and R, see:

https://github.com/jalvesaq/Nvim-R

The plugin uses some ideas and code from Johannes Ranke's (vim-r-plugin), Eric
Van Dewoestine's (screen.vim plugin), Vincent Nijs (R.vim for Mac OS X) and
some ideas from the Tinn-R (Windows only) project.

The latest stable version of this plugin is available at:

http://www.vim.org/scripts/script.php?script_id=2628

Feedback is welcomed. Please submit bug reports to the developers. Do not like
a feature? Tell us and we may add an option to disable it. If you have any

The plugin should emit useful warnings if you do things it was not programmed
to deal with. Cryptic error message are bugs... Please report them at:

https://github.com/jcfaria/Vim-R-plugin/issues

We do not plan to take the initiative of writing code for new features, but
patches and git pull requests are welcome. If you want a feature that only few
people might be interested in, you can write a script to be sourced by the
Vim-R-plugin (see vimrplugin_source).

--------------------------------------------------------
*r-plugin-features*
2. Main features

* Syntax highlighting for R code, including:
- Special characters in strings.
- Special highlighting for R output (.Rout files).
- Spell check only strings and comments.
- Fold code when foldmethod=syntax.
* Syntax highlighting for RHelp, RMarkdown and RreStructuredText.
* Smart indentation for R, RHelp, Rnoweb, RMarkdown and RreStructuredText.
* Integrated communication with R:
- Start/Close R.
- Send lines, selection, paragraphs, functions, blocks, entire file.
- Send commands with the object under cursor as argument: help, args,
plot, print, str, summary, example, names.
- Send to R the Sweave, knit and pdflatex commands.
* Omni completion (auto-completion) for R objects (.GlobalEnv and loaded
packages).
* Auto-completion of function arguments.
* Auto-completion of knitr chunk options.
* Ability to see R's documentation in a Vim's buffer:
- Automatic calculation of the best layout of the R documentation buffer
(split the window either horizontally or vertically according to the
available room).
- Automatic formatting of the text to fit the panel width.
- Send code and commands to R (useful to run examples).
- Syntax highlighting of R documentation.
* Object Browser (.GlobalEnv and loaded packages):
- Send commands with the object under cursor as argument.
- Call R's help() with the object under cursor as argument.
- Syntax highlighting of the Object Browser.
* SyncTeX support.
* Most of the plugin's behavior is customizable.

For screenshots see: http://www.lepem.ufc.br/jaa/vim-r-plugin.html

--------------------------------------------------------
*r-plugin-installation*
3. Installation

The installation instructions are split in six sections:

3.1. Preliminary system setup on Windows
3.2. Preliminary system setup on Mac OS X
3.3. Preliminary system setup on Unix
3.4. Plugin installation
3.5. Troubleshooting
3.6. Optional steps

--------------------------------------------------------
3.1. Preliminary system setup on Windows

Before installing the plugin, you should install several external
dependencies:

* R's version must be >= 3.0.0: http://www.r-project.org/

* vimcom = 1.2-7: http://www.lepem.ufc.br/jaa/vimcom.html

Note: If you cannot build vimcom yourself, you will want to

* Only if you write Rnoweb code:

* Sumatra PDF viewer >= 3.0.

* MikTeX or other LaTeX distribution.

* Perl (required to run latexmk).

   options(vimcom.verbose = 1)
   library(vimcom)

If you do not know where your .Rprofile is, do the following command in R
Console to open it:

   edit(file = "~/.Rprofile")

--------------------------------------------------------
3.2. Preliminary system setup on Mac OS X

Before installing the plugin, you should install its dependencies:

   Depends:

R >= 3.0.0: http://www.r-project.org/

vimcom = 1.2-7: http://www.lepem.ufc.br/jaa/vimcom.html

Only if you edit Rnoweb files: MacTeX, BasicTeX or other LaTeX system.

If you want to call R.app from MacVim, put in your ~/.Rprofile:

   if(interactive()){
       options(vimcom.verbose = 1) # optional
       library(vimcom)
   }

On Mac OS X, the plugin will use AppleScript to send commands to the R Console
application unless vimrplugin_applescript = 0. In this case, R will run in a
external terminal emulator. The advantage of running R in a terminal emulator
is that its output can be colorized by the R package "colorout". If you want
to try this configuration, install Tmux and the R packages "setwidth" and
"colorout" (see instructions in section 3.3) and put in your ~/.Rprofile:

   if(interactive()){
       library(colorout)
       library(setwidth)
       options(vimcom.verbose = 1) # optional
       library(vimcom)
   }

Note: The plugin is fully functional with MacVim, but the Vim application that
comes with MacVim does not have the the server side of the 'clientserver'
feature which is required to have the plugin working properly. If you want to
run both Vim and R in the same Tmux window in a terminal emulator, you have to
follow the instructions from section 3.3.

--------------------------------------------------------
3.3. Preliminary system setup on Unix

Before installing the plugin, you should install its dependencies:

   Depends:

Note: The Vim-R-plugin requires Vim compiled with +libcall,
+clientserver and +conceal features. In Normal mode, do
:version  to check if your Vim has these features.

If you need to use the Vim-R-plugin in a Unix system without the
X Server running (e.g. Linux Console, and any system accessed
through ssh), the best option is to use Neovim and Nvim-R:
https://github.com/jalvesaq/Nvim-R
If you cannot use Neovim and need to use Vim in these

R >= 3.0.0: http://www.r-project.org/

vimcom = 1.2-7: http://www.lepem.ufc.br/jaa/vimcom.html

Tmux >= 1.8:   http://tmux.sourceforge.net
Tmux is necessary to send commands from Vim to R Console.

wmctrl:     http://tomas.styblo.name/wmctrl/
Required for better SyncTeX support under X Server.

   Suggests:

colorout:      http://www.lepem.ufc.br/jaa/colorout.html
Colorizes the R output.

setwidth:      An R package that can be installed with the command
install.packages("setwidth").
The library setwidth adjusts the value of options("width")
whenever the terminal is resized.

ncurses-term:  http://invisible-island.net/ncurses
Might be necessary if you want support for 256 colors at the
terminal emulator.

latexmk:       Automate the compilation of LaTeX documents.
See examples in vimrplugin_latexcmd.

Note: Vim, R, Tmux, ncurses-term and latexmk are already packaged for most
GNU/Linux distributions and other Unix variants. Unfortunately their
installation instructions vary widely and are beyond the scope of this
documentation.

Put the following lines in your ~/.Rprofile:

   if(interactive()){
       library(colorout)
       library(setwidth)
       options(vimcom.verbose = 1) # optional
       library(vimcom)
   }

Put the following in your ~/.bashrc:

   alias vim="vim --servername VIM"

Before proceeding, you have to start a new shell session to have the alias
enabled.

If you start Vim in a terminal emulator, inside of a Tmux session, the plugin
will split the Tmux window in two and start R in the other pane. This is the
recommended way of running the plugin on Linux (read r-plugin-tmux for
details). If you either use GVim or Vim not inside a Tmux session the plugin
will start R in a external terminal emulator. This is useful if you have two
monitors.

If you run Vim in a terminal emulator, it must be started with the argument
--servername to enable the 'clientserver' feature (please, read the section
r-plugin-bash-setup to know some tips on how to configure Bash). This is not
necessary with GVim because it always runs with the 'clientserver' feature
enabled.

--------------------------------------------------------
3.4. Plugin installation (instructions for all systems)

You need to activate plugins and indentation according to 'filetype'. You
should have at least the following options at the top or near the very top
of your vimrc (but below set runtimepath, if you have set it):

   set nocompatible
   syntax enable
   filetype plugin on
   filetype indent on

http://www.vim.org/scripts/script.php?script_id=2628

If you either are on Windows or prefer to use a graphical interface, start the
file manager, find the file Vim-R-plugin.vmb and open it with GVim or
MacVim. Otherwise, start a terminal emulator, go to the directory where you

   vim Vim-R-plugin.vmb

Then, in Vim, type:

   :so %

Press <Enter> to start the installation and press the <Space> bar as many
times as necessary to finish the installation. You should, then, quit Vim.

Note: If you need to install the plugin in a non default directory, do
:UseVimball [path]. In this case, the configuration of Vim's 'runtimepath'
must be done before the command "filetype on" in both the system and the user
vimrc files, otherwise, some file types might not be correctly recognized.

The plugin is installed and will be activated next time that you start to edit
an R script.

You may want to improve the configuration of your vimrc for a better use of

If you want to uninstall the plugin, do

   :RmVimball Vim-R-plugin

--------------------------------------------------------
3.5. Troubleshooting (if the plugin doesn't work)

Note: The <LocalLeader> is '\' by default.

The plugin is a file-type plugin. It will be active only if you are editing
a .R, .Rnw, .Rd, Rmd, or Rrst file. The menu items will not be visible and the
key bindings will not be active while editing either unnamed files or files
with name extensions other than the mentioned above. If the plugin is active,
pressing <LocalLeader>rf should start R.

Did you see warning messages but they disappeared before you have had time to
read them? Type the command :messages in Normal mode to see them again.

On Windows, if R does not start and you get an error message instead, you may
want to set the path to your Rgui.exe in your vimrc, for example (please

   let vimrplugin_r_path = 'C:\\Program Files\\R\\R-3.1.2\\bin\\i386'

Are you using Debian, Ubuntu or other Debian based Linux distribution? If yes,
you may prefer to install the Debian package available at:

http://www.lepem.ufc.br/jaa/vim-r-plugin.html

Did you see the message "VimCom port not found"? This means that R is not
running, the vimcom package is not installed (or is installed but is not
loaded), or R was not started by Vim.

If R takes more than 5 seconds to load, you should adjust the value of
vimrplugin_vimcom_wait.

--------------------------------------------------------
3.6. Optional steps

3.6.1 Customize the plugin

section r-plugin-indenting of this document.

--------------------------------------------------------
3.6.2 Install additional plugins

You may be interested in installing additional general plugins to get
functionality not provided by this file type plugin. Particularly interesting
details. If you edit Rnoweb files, you may want to try LaTeX-Box for
omnicompletion of LaTeX code (see r-plugin-latex-box for details).

--------------------------------------------------------
*r-plugin-use*
4. Use

4.1. Key bindings

Note: The <LocalLeader> is '\' by default.

Note: It is recommended the use of different keys for <Leader> and
<LocalLeader> to avoid clashes between filetype plugins and general plugins
key binds. See filetype-plugins, maplocalleader and r-plugin-localleader.

To use the plugin, open a .R, .Rnw, .Rd, .Rmd or .Rrst file with Vim and type
<LocalLeader>rf. Then, you will be able to use the plugin key bindings to send
commands to R.

This plugin has many key bindings, which correspond with menu entries. In the
list below, the backslash represents the <LocalLeader>. Not all menu items and
key bindings are enabled in all filetypes supported by the plugin (r, rnoweb,
rhelp, rrst, rmd).

Menu entry                                Default shortcut
Start/Close
. Start R (default)                                  \rf
. Start R (custom)                                   \rc
--------------------------------------------------------
. Close R (no save)                                  \rq
. Stop R                                          :RStop
--------------------------------------------------------

Send
. File                                               \aa
. File (echo)                                        \ae
. File (open .Rout)                                  \ao
--------------------------------------------------------
. Block (cur)                                        \bb
. Block (cur, echo)                                  \be
. Block (cur, down)                                  \bd
. Block (cur, echo and down)                         \ba
--------------------------------------------------------
. Chunk (cur)                                        \cc
. Chunk (cur, echo)                                  \ce
. Chunk (cur, down)                                  \cd
. Chunk (cur, echo and down)                         \ca
. Chunk (from first to here)                         \ch
--------------------------------------------------------
. Function (cur)                                     \ff
. Function (cur, echo)                               \fe
. Function (cur and down)                            \fd
. Function (cur, echo and down)                      \fa
--------------------------------------------------------
. Selection                                          \ss
. Selection (echo)                                   \se
. Selection (and down)                               \sd
. Selection (echo and down)                          \sa
. Selection (evaluate and insert output in new tab)  \so
--------------------------------------------------------
. Paragraph                                          \pp
. Paragraph (echo)                                   \pe
. Paragraph (and down)                               \pd
. Paragraph (echo and down)                          \pa
--------------------------------------------------------
. Line                                                \l
. Line (and down)                                     \d
. Line (and new one)                                  \q
. Left part of line (cur)                       \r<Left>
. Right part of line (cur)                     \r<Right>
. Line (evaluate and insert the output as comment)    \o
--------------------------------------------------------

Command
. List space                                         \rl
. Clear console                                      \rr
. Clear all                                          \rm
--------------------------------------------------------
. Print (cur)                                        \rp
. Names (cur)                                        \rn
. Structure (cur)                                    \rt
. View data.frame (cur)                              \rv
--------------------------------------------------------
. Arguments (cur)                                    \ra
. Example (cur)                                      \re
. Help (cur)                                         \rh
--------------------------------------------------------
. Summary (cur)                                      \rs
. Plot (cur)                                         \rg
. Plot and summary (cur)                             \rb
--------------------------------------------------------
. Set working directory (cur file path)              \rd
--------------------------------------------------------
. Sweave (cur file)                                  \sw
. Sweave and PDF (cur file)                          \sp
. Sweave, BibTeX and PDF (cur file) (Linux/Unix)     \sb
--------------------------------------------------------
. Knit (cur file)                                    \kn
. Knit and PDF (cur file)                            \kp
. Knit, BibTeX and PDF (cur file) (Linux/Unix)       \kb
. Knit and Beamer PDF (cur file) (only .Rmd)         \kl
. Knit and HTML (cur file, verbose) (only .Rmd)      \kh
. Spin (cur file) (only .R)                          \ks
--------------------------------------------------------
. Open PDF (cur file)                                \op
. Search forward (SyncTeX)                           \gp
. Go to LaTeX (SyncTeX)                              \gt
--------------------------------------------------------
. Build tags file (cur dir)                  :RBuildTags
--------------------------------------------------------

Edit
. Insert "<-"                                          _
. Complete object name                              ^X^O
. Complete function arguments                       ^X^A
--------------------------------------------------------
. Indent (line)                                       ==
. Indent (selected lines)                              =
. Indent (whole buffer)                             gg=G
--------------------------------------------------------
. Toggle comment (line, sel)                         \xx
. Comment (line, sel)                                \xc
. Uncomment (line, sel)                              \xu
. Add/Align right comment (line, sel)                 \;
--------------------------------------------------------
. Go (next R chunk)                                  \gn
. Go (previous R chunk)                              \gN
--------------------------------------------------------

Object Browser
. Show/Update                                        \ro
. Expand (all lists)                                 \r=
. Collapse (all lists)                               \r-
. Toggle (cur)                                     Enter
--------------------------------------------------------

Help (plugin)
Help (R)                                            :Rhelp
--------------------------------------------------------

Please see r-plugin-key-bindings to learn how to customize the key bindings
without editing the plugin directly.

The plugin commands that send code to R Console are the most commonly used. If
the code to be sent to R has a single line it is sent directly to R Console,
but if it has more than one line (a selection of lines, a block of lines
between two marks, a paragraph etc) the lines are written to a file and the
plugin sends to R the command to source the file. To send to R Console the
line currently under the cursor you should type <LocalLeader>d. If you want to
see what lines are being sourced when sending a selection of lines, you can
use either <LocalLeader>se or <LocalLeader>sa instead of <LocalLeader>ss.

The command <LocalLeader>o runs in the background the R command print(line),
where line is the line under cursor, and adds the output as commented lines
to the source code.

If the cursor is over the header of an R chunk with the child option (from
Rnoweb, RMarkdown or RreStructuredText document), and you use one of the
commands that send a single line of code to R, then the plugin will send to R
the command to knit the child document.

After the send, sweave and knit commands, Vim will save the current buffer if
it has any pending changes before performing the tasks. After <LocalLeader>ao,
Vim will run "R CMD BATCH --no-restore --no-save" on the current file and show
the resulting .Rout file in a new tab. Please see vimrplugin_routnotab if
you prefer that the file is open in a new split window. Note: The command
<LocalLeader>ao, silently writes the current buffer to its file if it was
modified and deletes the .Rout file if it exists.

R syntax uses " <- " to assign values to variables which is inconvenient to
type. In insert mode, typing a single underscore, "_", will write " <- ",
unless you are typing inside a string. The replacement will always happen if
syntax highlighting is off (see :syn-on and :syn-off). If necessary, it is
possible to insert an actual underscore into your file by typing a second
underscore. This behavior is similar to the EMACS ESS mode some users may be
familiar with and is enabled by default. You have to change the value of
vimrplugin_assign to disable underscore replacement.

When you press <LocalLeader>rh, the plugin shows the help for the function
under the cursor. The plugin also checks the class of the object passed as
argument to the function to try to figure out whether the function is a
generic one and whether it is more appropriate to show a specific method. The
same procedure is followed with <LocalLeader>rp, that is, while printing an
object. For example, if you run the code below and, then, press
<LocalLeader>rh and <LocalLeader>rp over the two occurrences of summary, the
plugin will show different help documents and print different function methods
in each case:

   y <- rnorm(100)
   x <- rnorm(100)
   m <- lm(y ~ x)
   summary(x)
   summary(m)

If the object under the cursor is a data.frame or a matrix, <LocalLeader>rv
will show it in a new tab. If the csv.vim plugin is not installed, the
Vim-R-plugin will warn you about that (see r-plugin-df-view). Specially
useful commands from the csv.vim plugin are :CSVHeader, :ArrangeColumn and
:CSVHiColumn. It can be installed from:

http://www.vim.org/scripts/script.php?script_id=2830

When completing object names (CTRL-X CTRL-O) and function arguments (CTRL-X
CTRL-A) you have to press CTRL-N to go foward in the list and CTRL-P to go
backward (see popupmenu-completion). Note: if using Vim in a terminal
emulator, Tmux will capture the CTRL-A command. You have to do CTRL-A twice to
pass a single CTRL-A to Vim. For rnoweb, rmd and rrst file types, CTRL-X
CTRL-A can also be used to complete knitr chunk options if the cursor is

If R is not running or if it is running but is busy the completion will be
based on information from the packages listed by vimrplugin_start_libs
(provided that the libraries were loaded at least once during a session of
Vim-R-plugin usage). Otherwise, the pop up menu for completion of function
arguments will include an additional line with the name of the library where
the function is (if the function name can be found in more than one library)
and the function method (if what is being shown are the arguments of a method
and not of the function itself). For library() and require(), when completing
the first argument, the popup list shows the names of installed packages, but
only if R is running.

To get help on an R topic, type in Vim (Normal mode):

   :Rhelp topic

The command may be abbreviated to  :Rh  and you can either press <Tab> to
trigger the autocompletion of R objects names or hit CTRL-D to list the
possible completions (see cmdline-completion for details on the various ways
of getting command-line completion). The list of objects used for
completion is the same available for omnicompletion (see
vimrplugin_start_libs). You may close the R documentation buffer by
simply pressing q.

You can source all .R files in a directory with the Normal mode command
:RSourceDir, which accepts an optional argument (the directory to be sourced).
*:Rinsert*
The command  :Rinsert <cmd>  inserts one or more lines with the output of the
R command sent to R. By using this command we can avoid the need of copying
and pasting the output R from its console to Vim. For example, to insert the
output of dput(levels(var)), where var is a factor vector, we could do in
Vim:

   :Rinsert dput(levels(var))

The output inserted by  :Rinsert  is limited to 5012 characters.

The command  :Rformat  calls the function tidy_source() of formatR package
to format either the entire buffer or the selected lines. The value of the
width.cutoff argument is set to the buffer's 'textwidth' if it is not
outside the range 20-180. Se R help on tidy_source for details on how to
control the function behavior.

--------------------------------------------------------
4.2. Edition of Rnoweb files

In Rnoweb files (.Rnw), when the cursor is over the @ character, which
finishes an R chunk, the sending of all commands to R is suspended and the
shortcut to send the current line makes the cursor to jump to the next chunk.
While editing Rnoweb files, the following commands are available in Normal
mode:

[count]<LocalLeader>gn : go to the next chunk of R code
[count]<LocalLeader>gN : go to the previous chunk of R code

The commands <LocalLeader>cc, ce, cd and ca send the current chunk of R code
to R Console. The command <LocalLeader>ch sends the R code from the first
chunk up to the current line.

The commands <LocalLeader>kn builds the .tex file from the Rnoweb one using
the knitr package and <LocalLeader>kp compiles the pdf; for Sweave, the
commands are, respectively <LocalLeader>sw and <LocalLeader>sp. On Linux, if
using Evince, Okular or Zathura, you can jump from the Rnoweb file to the PDF
with the command <LocalLeader>gp. To jump from a specific location in the PDF
to the corresponding line in the Rnoweb, in either Evince or Zathura you
should press <C-LeftMouse>, and in Okular <S-LeftMouse>. No configuration is
required if you use Evince, Gnome-Terminal and the knitr package, and work
with single file Rnoweb documents. Otherwise, see r-plugin-SyncTeX for
configuration details.

--------------------------------------------------------
4.3. Omni completion and the highlighting of functions

The plugin adds some features to the default syntax highlight of R code. One
such feature is the highlight of R functions. However, functions are
highlighted only if their libraries are loaded by R (but see
vimrplugin_start_libs).

Note: If you have too many loaded packages Vim may be unable to load the list
of functions for syntax highlight.

Vim can automatically complete the names of R objects when CTRL-X CTRL-O is
pressed in insert mode (see omni-completion for details). Omni completion
shows in a pop up menu the name of the object, its class and its environment
(most frequently, its package name). If the object is a function, the plugin
can also show the function arguments in a separate preview window (this
feature is disabled by default: see vimrplugin_show_args).

If a data.frame is found, while building the list of objects, the columns in
the data.frame are added to the list. When you try to use omni completion to
complete the name of a data.frame, the columns are not shown. But when the
data.frame name is already complete, and you have inserted the '$' symbol, omni completion will show the column names. Only the names of objects in .GlobalEnv and in loaded libraries are completed, and the clientserver feature is required to get the list of loaded libraries automatically updated. If either R is not running or Vim is running without the clientserver feature, only objects of libraries listed in vimrplugin_start_libs will have their names completed. When you load a new library in R, only the current buffer has the highlighting of function names immediately updated. If you have other buffers open, they will be updated when you enter them. Vim uses one file to store the names of .GlobalEnv objects and a list of files for all other objects. The .GlobalEnv list is stored in the$VIMRPLUGIN_TMPDIR
directory and is deleted when you quits Vim. The other files are stored in the
VIMRPLUGIN_COMPLDIR directory and remain available until you manually delete them. -------------------------------------------------------- 4.4. The Object Browser You have to use <LocalLeader>ro to start the Object Browser. The Object Browser has two views: .GlobalEnv and Libraries. If you either press <Enter> or double click (GVim or Vim with 'mouse' set to "a") on the first line of the Object Browser, you will toggle the view between the objects in .GlobalEnv and the currently loaded libraries. The Object Browser requires the +clientserver feature to be automatically updated and the +conceal feature to correctly align list items. In the .GlobalEnv view, if an object has the attribute "label", it will also be displayed. In the Object Browser window, while in Normal mode, you can either press <Enter> or double click (GVim only) over a data.frame or list to show/hide its elements (not if viewing the content of loaded libraries). If you are running R in an environment where the string UTF-8 is part of either LC_MESSAGES or LC_ALL variables, unicode line drawing characters will be used to draw lines in the Object Browser. This is the case of most Linux distributions. In the Libraries view, you can either double click or press <Enter> on a library name to see its objects. In the Object Browser, the libraries have the color defined by the PreProc highlighting group. The other objects have their colors defined by the return value of some R functions. Each line in the table below shows a highlighting group and the corresponding type of R object: PreProc libraries Number numeric String character Special factor Boolean logical Type list Function function Statement s4 Comment promise (lazy load object) One limitation of the Object Browser is that objects made available by the command data() are only links to the actual objects (promises of lazily loading the object when needed) and their real classes are not recognized in the GlobalEnv view. The same problem happens when the knitr option cache.lazy=TRUE. If you press <Enter> over the name of the object in the Object Browser, it will be actually loaded by the command (ran in the background):  obj <- obj -------------------------------------------------------- 4.5. Commenting and uncommenting lines You can toggle the state of a line as either commented or uncommented by typing <LocalLeader>xx. The string used to comment the line will be "# ", "## " or "### ", depending on the values of vimrplugin_indent_commented and r_indent_ess_comments. You can also add the string "# " to the beginning of a line by typing <LocalLeader>xc and remove it with <LocalLeader>xu. In this case, you can set the value of vimrplugin_rcomment_string to control what string will be added to the beginning of the line. Example:  let vimrplugin_rcomment_string = "# " Finally, you can also add comments to the right of a line with the <LocalLeader>; shortcut. By default, the comment starts at the 40th column, which can be changed by setting the value of r_indent_comment_column, as below:  let r_indent_comment_column = 20 If the line is longer than 38 characters, the comment will start two columns after the last character in the line. If you are running <LocalLeader>; over a selection of lines, the comments will be aligned according to the longest line. Note: While typing comments the leader comment string is automatically added to new lines when you reach 'textwidth' but not when you press <Enter>. Please, read the Vim help about 'formatoptions' and fo-table. For example, you can add the following line to your vimrc if you want the comment string being added after <Enter>:  autocmd FileType r setlocal formatoptions-=t formatoptions+=croql Tip: You can use Vim substitution command :%s/#.*// to delete all comments in a buffer (see :s and pattern-overview). -------------------------------------------------------- *:RBuildTags* 4.6. Build a tags file to jump to function definitions Vim can jump to functions defined in other files if you press CTRL-] over the name of a function, but it needs a tags file to be able to find the function definition (see tags-and-searches). The command :RBuildTags calls the R function rtags() to build the tags file for the R scripts in the current directory. Please read r-plugin-tagsfile to learn how to create a tags file referencing source code located in other directories, including the entire R source code. -------------------------------------------------------- *r-plugin-tmux* 4.7. Tmux usage When running either GVim or Vim in a terminal emulator (Linux/Unix only), the Vim-R-plugin will use Tmux to start R in a separate terminal emulator. R will be running inside a Tmux session, but you will hardly notice any difference from R running directly in the terminal emulator. The remaining of this section refers to the case of starting R when Vim already is in a Tmux session, that is, if you do:  tmux  vim --servername VIM filename.R  exit In this case, the terminal window is split in two regions: one for Vim and the other for Tmux. Then, it's useful (but not required) to know some Tmux commands. After you finished editing the file, you have to type exit to quit the Tmux session. Note: Starting GVim within a Tmux session is not supported. -------------------------------------------------------- *r-plugin-tmux-setup* 4.7.1 Tmux configuration If, as recommended, you always prefer to run Tmux before running you have to create your ~/.tmux.conf if it does not exist yet. You may put the lines below in your ~/.tmux.conf as a starting point to your own configuration file:  # Use <C-a> instead of the default <C-b> as Tmux prefix  set-option -g prefix C-a  unbind-key C-b  bind-key C-a send-prefix  # Options enable mouse support in Tmux  set -g terminal-overrides 'xterm*:smcup@:rmcup@'  # For Tmux < 2.1  set -g mode-mouse on  set -g mouse-select-pane on  set -g mouse-resize-pane on  # For Tmux >= 2.1  set -g mouse on  # Act more like vim:  set-window-option -g mode-keys vi  bind h select-pane -L  bind j select-pane -D  bind k select-pane -U  bind l select-pane -R  unbind p  bind p paste-buffer  bind -t vi-copy v begin-selection  bind -t vi-copy y copy-selection -------------------------------------------------------- 4.7.2 Key bindings and mouse support The Tmux configuration file suggested above configures Tmux to use vi key bindings. It also configures Tmux to react to mouse clicks. You should be able to switch the active pane by clicking on an inactive pane, to resize the panes by clicking on the border line and dragging it, and to scroll the R Console with the mouse wheel. When you use the mouse wheel, Tmux enters in its copy/scroll back mode (see below). The configuration script also sets <C-a> as the Tmux escape character (the default is <C-b>), that is, you have to type <C-a> before typing a Tmux command. Below are the most useful key bindings for Tmux with the tmux.conf shown above: <C-a>arrow keys : Move the cursor to the Tmux panel above, below, at the right or at the left of the current one. <C-a><C-Up> : Move the panel division upward one line, that is, resize the panels. Repeat <C-Up> to move more. <C-Down> will move the division downward one line. If you are using the vertical split, you should use <C-Left> and <C-Right> to resize the panels. <C-a>[ : Enter the copy/scroll back mode. You can use <PgUp>, <PgDown> and vi key bindings to move the cursor around the panel. Press q to quit copy mode. <C-a>] : Paste the content of Tmux paste buffer. <C-a>z : Hide/show all panes except the current one. Note: If you mistakenly press <C-a><C-z>, you have to type fg to get Tmux back to the foreground. While in the copy and scroll back mode, the following key bindings are very useful: q : Quit the copy and scroll mode. <Space> : Start text selection. v<Space> : Start rectangular text selection. <Enter> : Copy the selection to Tmux paste buffer. Please, read the manual page of Tmux if you want to change the Tmux configuration and learn more commands. To read the Tmux manual, type in the terminal emulator:  man tmux Note: Because <C-a> was configured as the Tmux escape character, it will not be passed to applications running under Tmux. To send <C-a> to either R or Vim you have to type <C-a><C-a>. -------------------------------------------------------- 4.7.3 Copying and pasting You do not need to copy code from Vim to R because you can use the plugin's shortcuts to send the code. For pasting the output of R commands into Vim's buffer, you can use the command :Rinsert. If you want to copy text from an application running inside the Tmux to another application also running in Tmux, as explained in the previous subsection, you can enter in Tmux copy/scroll mode, select the text, copy it, switch to the other application pane and, then, paste. However, if you want to copy something from either Vim or R to another application not running inside Tmux, Tmux may prevent the X server from capturing the text selected by the mouse. This can be prevented by pressing the <Shift> key, as it suspends the capturing of mouse events by tmux. If you keep <Shift> pressed while selecting text with the mouse, it will be available in the X server clipboard and can be inserted into other windows using the middle mouse button. It can of course also be inserted into a tmux window using <Shift> and the middle mouse button. -------------------------------------------------------- *r-plugin-remote* 4.7.2 Remote access The Vim-R-plugin can not send commands from a local Vim to a remote R, but you can access the remote machine through ssh and run Tmux, Vim and R in the remote machine. Tmux should not be running in the local machine because some environment variables could pass from the local to the remote Tmux and confuse the plugin. If you need to access Vim in a remote Unix machine through ssh, and if you want to get omnicompletion, syntax highlight of function names and the Object Browser working properly, instead of Vim, it is recommended that you use Neovim because it does not require the X Server to be fully functional. If you cannot use Neovim, then you have to: - Enable X11 Forwarding in the remote machine. - Have Vim in the remote machine compiled with clientserver feature. - Have the X Server running in the local machine. - Pass either the -X or the -Y argument to ssh, as in the examples below:  ssh -X yourlogin@remote.address  ssh -Y yourlogin@remote.address - Start Tmux and, then, Vim with the --servername argument:  tmux  vim --servername VIM script.R With Tmux, you can detach the Vim-R session and reattach it later (but the connection with the XServer could be lost in the process). This is useful if you plan to begin the use the Vim-R-plugin in a machine and later move to another computer and access your previous Vim-R session remotely. Below is the step-by-step procedure to run the Vim-R remotely: - Start Tmux: tmux - Start Vim: vim script.R - Use Vim to start an R session: <LocalLeader>rf - Send code from Vim to R, and, then, detach Vim and R with <C-a>d The command will be <C-b>d if you have not set <C-a> as the escape character in your ~/.tmux.conf. - Some time later (even if accessing the machine remotely) reattach the Tmux session: tmux attach -------------------------------------------------------- *r-plugin-known-bugs* 5. Known bugs and workarounds Known bugs that will not be fixed are listed in this section. Some of them can not be fixed because they depend on missing features in either R or Vim; others would be very time consuming to fix without breaking anything. -------------------------------------------------------- 5.1. R's source() issues The R's source() function of the base package prints an extra new line between commands if the option echo = TRUE, and error and warning messages are printed only after the entire code is sourced. This makes it more difficult to find errors in the code sent to R. Details: https://stat.ethz.ch/pipermail/r-devel/2012-December/065352.html -------------------------------------------------------- 5.2. The menu may not reflect some of your custom key bindings If you have created a custom key binding for the Vim-R-plugin, the menu in GVim will not always reflect the correct key binding if it is not the same for Normal, Visual and Insert modes. -------------------------------------------------------- 5.3. Functions are not always correctly sent to R The plugin is only capable of recognizing functions defined using the <- operator. See: https://github.com/jcfaria/Vim-R-plugin/issues/94 -------------------------------------------------------- 5.4. Wrong message that "R is busy" (Windows only) On Windows, when code is sent from Vim to R Console, the vimcom library sets the value of the internal variable r_is_busy to 1. The value is set back to 0 when any code is successfully evaluated. If you send invalid code to R, there will be no successful evaluation of code and the value of r_is_busy will remain set to 1. If you then try to update the Object Browser, see the R documentation for any function, or do other tasks that require the hidden evaluation of code by R, the vimcom library will refuse to do the tasks to avoid any risk of corrupting R's memory. It will tell Vim that "R is busy" and Vim will display this message. Everything should work as expected again after any valid code is executed in the R Console. The vimcom library is started with the state busy. -------------------------------------------------------- *r-plugin-SyncTeX-win* 5.5. SyncTeX on Windows On Windows, backward search with Sumatra pop ups a console window which quickly disappears (it is vim running the required --remote-expr command). -------------------------------------------------------- *r-plugin-nox* 5.6. Bugs that affect Linux Console and Vim accessed through ssh If you run Vim in the Linux Console or start Vim in a terminal emulator without the command line argument --servername, Vim will not receive remote messages and the vimcom package will display one of the following messages: Vim was built without the 'clientserver' feature. Did you pass the --servername argument to Vim? There is no X Server running. Vim's servername is unknown. To avoid the message, you should start vim with the --servername argument, as below:  vim --servername VIM script.R To avoid having to type this argument every time that you start Vim, please, look at the example in r-plugin-bash-setup. If the --servername argument does not work in your case, you can put the following line in your ~/.Rprofile to suppress the message:  options(vimcom.verbose = -1) When Vim cannot receive messages, the result is: * The Object Browser is not automatically updated. You have to do <LocalLeader>ro to update it manually. * Syntax highlight of function names and the list of objects for omnicompletion are not immediately updated after you load a new R package. For a workaround, see vimrplugin_start_libs. * You cannot see R documentation in a Vim buffer. On Linux you may find Vim binaries without the clientserver feature if you install packages such as vim-nox on Debian/Ubuntu or vim-enhanced on Fedora/Red Hat. If you want to use Vim in a terminal emulator in Fedora/Red Hat, you may want to create a symbolic link to "gvim" named "vim". You still have to explicitly start the server with the argument --servername. The R package vimcom has support only for Windows and X11 interprocess communication systems while MacVim is a Cocoa application. For this reason, on Mac OS X, by default, vimcom is built without support to Vim's clientserver feature. If you prefer to use Vim instead of MacVim in Mac OS X, then, you should: 1. Install XQuartz server (X11.app) 2. Build vimcom with the argument --enable-clientserver. That is, download vimcom from http://www.lepem.ufc.br/jaa/vimcom.html and do in R:  install.packages("vimcom_1.2-1.tar.gz", repos = NULL, type = "source",  configure.args = "--enable-clientserver") 3. Build Vim with X11 support. A user reported success with the following procedure:  brew install vim --with-client-server  tmux  /usr/local/Cellar/vim/7.4.273/bin/vim --servername VIM r_script.R See also: r-plugin-remote. -------------------------------------------------------- 5.7. R must be started by Vim The communication between Vim and R will work only if R was started by Vim through the <LocalLeader>rf command because the plugin was designed to connect each Vim instance with its own R instance. If you start R before Vim, it will not inherit from Vim the environment variables VIMRPLUGIN_TMPDIR, VIMRPLUGIN_COMPLDIR, VIMEDITOR_SVRNM, VIMINSTANCEID, and VIMRPLUGIN_SECRET. The first one is the path used by the R package vimcom to save temporary files used by the Vim-R-plugin to: perform omnicompletion, show R documentation in a Vim buffer, and update the Object Browser. The two last ones are used by the Vim-R-plugin and by vimcom to know that the connections are valid. If you use Vim to start R, but then close Vim, some variables will become outdated. Additionally, the Vim-R-plugin sets the value of its internal variable SendCmdToR from SendCmdToR_fake to the appropriate value when R is successfully started. It is possible to set the values of all those variables manually, but, as you can see below, it is not practical to do so. If you have either started R before Vim or closed Vim and opened it again and really want full communication between Vim and R, you can try the following (not all procedures are necessary for all cases): In Normal mode Vim do:  :echo g:rplugin_tmpdir  :echo g:rplugin_compldir  :echoVIMINSTANCEID
   :echo $VIMRPLUGIN_SECRET  :echo$VIMEDITOR_SVRNM

In R do:

   detach("package:vimcom", unload = TRUE)
   Sys.setenv(VIMRPLUGIN_TMPDIR="T")    # where "T" is what Vim has echoed
   Sys.setenv(VIMINSTANCEID="I")        # where "I" is what Vim has echoed
   Sys.setenv(VIMRPLUGIN_SECRET"="S")   # where "S" is what Vim has echoed
   Sys.setenv(VIMEDITOR_SVRNM"="N")     # where "N" is what Vim has echoed
   Sys.setenv(VIMRPLUGIN_COMPLDIR"="C") # where "C" is what Vim has echoed
   library(vimcom)

If you are running R in a terminal emulator (Linux/Unix) Vim still needs to
know the name of Tmux session and Tmux pane where R is running.

So, in R do:

   Sys.getenv("TMUX_PANE")

and the following Tmux command:

   <Ctrl-A>:display-message -p '#S'<Enter><Enter>

And in Normal mode Vim do:

   :let rplugin_rconsole_pane = "X"
   :let rplugin_tmuxsname = "Y"

Finally, do one of the commands below in Normal mode Vim, according to how R
is running:

   let SendCmdToR = function('SendCmdToR_TmuxSplit')
   let SendCmdToR = function('SendCmdToR_Term')
   let SendCmdToR = function('SendCmdToR_OSX')
   let SendCmdToR = function('SendCmdToR_Windows')

--------------------------------------------------------
*r-plugin-options*
6. Options

vimrplugin_term              External terminal to be used
vimrplugin_term_cmd          Complete command to open an external terminal
vimrplugin_sleeptime         Delay while sending commands in MS Windows
vimrplugin_save_win_pos      Save positions of R and GVim windows
vimrplugin_arrange_windows   Restore positions of R and GVim windows
vimrplugin_assign            Convert '_' into ' <- '
vimrplugin_assign_map        Choose what to convert into ' <- '
vimrplugin_rnowebchunk       Convert '<' into '<<>>=\n@' in Rnoweb files
vimrplugin_objbr_place       Placement of Object Browser
vimrplugin_objbr_w           Initial width of Object Browser window
vimrplugin_tmux_ob           Run Object Browser in Tmux pane
vimrplugin_objbr_opendf      Display data.frames open in the Object Browser
vimrplugin_objbr_openlist    Display lists open in the Object Browser
vimrplugin_objbr_allnames    Display hidden objects in the Object Browser
vimrplugin_objbr_labelerr    Show error if "label" attribute is invalid
vimrplugin_vimpager          Use Vim to see R documentation
vimrplugin_editor_w          Minimum width of R script buffer
vimrplugin_help_w            Desired width of R documentation buffer
vimrplugin_i386              Use 32 bit version of R
vimrplugin_r_path            Directory where R is
vimrplugin_r_args            Arguments to pass to R
vimrplugin_start_libs        Objects for omnicompletion and syntax highlight
vimrplugin_routnotab         Show output of R CMD BATCH in new window
vimrplugin_indent_commented  Indent lines commented with the \xx command
vimrplugin_rcomment_string   String to comment code with \xx and \o
vimrplugin_notmuxconf        Don't use a specially built Tmux config file
vimrplugin_rconsole_height   The number of lines of R Console (Tmux split)
vimrplugin_vsplit            Make Tmux split the window vertically
vimrplugin_rconsole_width    The number of columns of R Console (Tmux split)
vimrplugin_tmux_title        Set Tmux window title to "VimR"
vimrplugin_applescript       Use osascript in Mac OS X
vimrplugin_listmethods       Do vim.list.args() instead of args()
vimrplugin_specialplot       Do vim.plot() instead of plot()
vimrplugin_source_args       Arguments to R source() function
vimrplugin_latexcmd          Command to run on .tex files
vimrplugin_latexmk           Define wether latexmk should be run
vimrplugin_texerr            Show a summary of LaTeX errors after compilation
vimrplugin_sweaveargs        Arguments do Sweave()
vimrplugin_rmd_environment   Environment in which to save evaluated rmd code
vimrplugin_map_r             Use 'r' to send lines and selected text
vimrplugin_ca_ck             Add ^A^K to the beginning of commands
vimrplugin_pdfviewer         PDF application used to open PDF documents
vimrplugin_openpdf           Open PDF after processing rnoweb file
vimrplugin_openhtml          Open HTML after processing either Rrst or Rmd
vimrplugin_strict_rst        Code style for generated rst files
vimrplugin_insert_mode_cmds  Allow R commands in insert mode
vimrplugin_allnames          Show names which begin with a dot
vimrplugin_rmhidden          Remove hidden objects from R workspace
vimrplugin_restart           Restart R if it is already running
vimrplugin_show_args         Show extra information during omnicompletion
vimrplugin_args_in_stline    Set 'statusline' to function arguments
vimrplugin_vim_wd            Start R in Vim's working directory
vimrplugin_after_start       System command to execute after R startup
vimrplugin_user_maps_only    Only set user specified key bindings
vimrplugin_tmpdir            Where temporary files are created
vimrplugin_compldir          Where lists for omnicompletion are stored
r-plugin-df-view             Options for visualizing a data.frame or matrix
r-plugin-SyncTeX             Options for SyncTeX

--------------------------------------------------------
*vimrplugin_term*
6.1. Terminal emulator (Linux/Unix only, but not Mac OS X)

Note: The options of this section are ignored on Mac OS X, where the command
open is called to run the default application used to run shell scripts.

The plugin uses the first terminal emulator that it finds in the following
list:
1. gnome-terminal,
2. konsole,
3. xfce4-terminal,
4. iterm,
5. Eterm,
6. (u)rxvt,
7. aterm,
8. roxterm,
9. terminator,
10. xterm.

If Vim does not select your favorite terminal emulator, you may define it in
your vimrc by setting the variable vimrplugin_term, as shown below:

   let vimrplugin_term = "xterm"

*vimrplugin_term_cmd*
If your terminal emulator is not listed above, or if you are not satisfied
with the way your terminal emulator is called by the plugin, you may define in
your vimrc the variable vimrplugin_term_cmd, as in the examples below:

   let vimrplugin_term_cmd = "gnome-terminal --title R -e"
   let vimrplugin_term_cmd = "terminator --title R -x"

Please, look at the manual of your terminal emulator to know how to call it.
The last argument must be the one which precedes the command to be executed.

--------------------------------------------------------
*vimrplugin_sleeptime*
*vimrplugin_save_win_pos*
*vimrplugin_arrange_windows*
6.2. Options specific to Windows

The plugin gives to R a small amount of time to process the paste command. The
default value is 100 milliseconds, but you should experiment different values. The
example show how to adjust the value of sleeptime in your vimrc:

   let vimrplugin_sleeptime = 30

By default, the Vim-R-plugin will save the positions of R Console and GVim
windows when you quits R with the <LocalLeader>rq command, and will restore
the positions of the windows when you start R. If you do not like this
behavior, you can put in your vimrc:

   let vimrplugin_save_win_pos = 0
   let vimrplugin_arrange_windows = 0

If you want R and GVim windows always in a specific arrangement, regardless of
their state when you have quited R for the last time, you should arrange them
in the way you want, quit R, change in your vimrc only the value of
vimrplugin_save_win_pos and, finally, quit Vim.

Note: the option vimrplugin_Rterm was disabled because the C code to send
strings from Vim to Windows PowerShell is not working.

--------------------------------------------------------
*vimrplugin_rnowebchunk*
*vimrplugin_assign_map*
*vimrplugin_assign*
6.3. Assignment operator and Rnoweb completion of code block

In Rnoweb files, a < is replaced with <<>>=\n@. To disable this feature,
put in your vimrc:

   let vimrplugin_rnowebchunk = 0

While editing R code, _ is replaced with <-. If you want to bind other
keys to be replaced by <-, set the value of vimrplugin_assign_map in your
vimrc, as in the example below which emulates RStudio behavior (may only
work on GVim):

   let vimrplugin_assign_map = "<M-->"

Note: If you are using Vim in a terminal emulator, you have to put in your
vimrc:

   set <M-->=^[-
   let vimrplugin_assign_map = "<M-->"

where ^[ is obtained by pressing CTRL-V CTRL-[ in Insert mode.

Note: You can't map <C-=>, as StatET does because in Vim only alphabetic
letters can be mapped in combination with the CTRL key.

To completely disable this feature, put in your vimrc:

   let vimrplugin_assign = 0

If you need to type many object names with underscores, you may want to change
the value vimrplugin_assign to 2. Then, you will have to type two _ to get
them converted into <-.

--------------------------------------------------------
*vimrplugin_objbr_place*
*vimrplugin_objbr_w*
*vimrplugin_tmux_ob*
*vimrplugin_objbr_opendf*
*vimrplugin_objbr_openlist*
*vimrplugin_objbr_allnames*
*vimrplugin_objbr_labelerr*
6.4. Object Browser options

By default, the Object Browser will be created with 40 columns. The minimum
width of the Object Browser window is 9 columns. You can change the object
browser's default width by setting the value of vimrplugin_objbr_w in your
vimrc, as below:

   let vimrplugin_objbr_w = 30

The Object Browser is created by splitting the Vim script window, but if Vim
is running in a terminal emulator inside a Tmux session, the Object Browser
will be created in an independent Vim instance in a Tmux pane. If you prefer
the Object Browser always created as a Vim split window, put in your vimrc:

   let vimrplugin_tmux_ob = 0

Valid values for the Object Browser placement are "script" or "console" and
"right" or "left" separated by a comma. Examples:

   let vimrplugin_objbr_place = "script,right"
   let vimrplugin_objbr_place = "console,left"

The "console" option is valid only if Vim is running inside of a Tmux session.

Below is an example of setup of some other options in the vimrc that control
the behavior of the Object Browser:

   let vimrplugin_objbr_opendf = 1    " Show data.frames elements
   let vimrplugin_objbr_openlist = 0  " Show lists elements
   let vimrplugin_objbr_allnames = 0  " Show .GlobalEnv hidden objects
   let vimrplugin_objbr_labelerr = 1  " Warn if label is not a valid text

Objects whose names start with a "." are hidden by default. If you want that
they are displayed in the Object Browser, set the value of
vimrplugin_objbr_allnames to 1.

when a data.frame appears in the Object Browser for the first time, its
elements are immediately displayed, but the elements of a list are displayed
only if it is explicitly opened. The options vimrplugin_objbr_opendf and
vimrplugin_objbr_openlist control the initial status (either opened or
closed) of, respectively, data.frames and lists. The options are ignored
for data.frames and lists of libraries which are always started closed.

If an object R's workspace has the attribute "label", it is displayed in
Nvim's Object Browser. If the "label" attribute is not of class
"character", and if  vimrplugin_objbr_labelerr is 1, an error message is
printed in the Object Browser.

--------------------------------------------------------
*vimrplugin_vimpager*
*vimrplugin_editor_w*
*vimrplugin_help_w*
6.5. Vim as pager for R help

6.5.1. Quick setup

If you do not want to see R documentation in a Vim's buffer, put in your
vimrc:

   let vimrplugin_vimpager = "no"

If you want to see R documentation in Vim, but are not satisfied with the way

--------------------------------------------------------
6.5.2. Details and other options:

The plugin key bindings will remain active in the documentation buffer
allowing you to send commands to R as you would do do while editing an R
script. You can, for example, use <LocalLeader>rh to jump to another R help
document.

The valid values of vimrplugin_vimpager are:

"tab"       : Show the help document in a new tab. If there is already a
tab with an R help document tab, use it.
This is the default.
"vertical"  : Split the window vertically if the editor width is large
enough; otherwise, split the window horizontally and attempt
to set the window height to at least 20 lines.
"horizontal": Split the window horizontally.
"tabnew"    : Show the help document in a new tab.
"no"        : Do not show R documentation in Vim.

The window will be considered large enough if it has more columns than
vimrplugin_editor_w + vimrplugin_help_w. These variables control the minimum
width of the editor window and the help window, and their default values are,
respectively, 66 and 46. Thus, if you want to have more control over Vim's
behavior while opening R's documentations, you will want to set different
values to some variables in your vimrc, as in the example:

   let vimrplugin_editor_w = 80
   let vimrplugin_editor_h = 60

--------------------------------------------------------
*vimrplugin_i386*
6.6. Use 32 bit version of R (Windows and Mac OS X only)

If you are using a 64 bit Windows or a 64 bit Mac OS X, but prefer to run the
32 bit version of R, put in your vimrc:

   let vimrplugin_i386 = 1

--------------------------------------------------------
*vimrplugin_r_path*
6.7. R path

Vim will run the first R executable in the path. You can set an alternative R
path in your vimrc as in the examples:

   let vimrplugin_r_path = "/path/to/my/preferred/R/version/bin"
   let vimrplugin_r_path = "C:\\Program Files\\R\\R-3.1.2\\bin\\i386"

On Windows, Vim will try to find the R install path in the Windows Registry.

You can set a different R version for specific R scripts in your vimrc.
Example:

   autocmd BufReadPre ~/old* let vimrplugin_r_path='~/app/R-2.8.1/bin'

--------------------------------------------------------
*vimrplugin_r_args*
6.8. Arguments to R

Set this option in your vimrc if you want to pass command line arguments to
R at the startup. Example:

   let vimrplugin_r_args = "--sdi --no-save --quiet"

On Linux, there is no default value for vimrplugin_r_args. On Windows, the
default value is "--sdi", but you may change it to "--mdi" if you do not like
the SDI style of the graphical user interface.

--------------------------------------------------------
*vimrplugin_start_libs*
6.9. Omnicompletion and syntax highlight of R functions

The list of functions to be highlighted and the list of objects for
omnicompletion are built dynamically as the libraries are loaded by R.
However, you can set the value of vimrplugin_start_libs if you want that
the functions and objects of specific packages are respectively highlighted
and available for omnicompletion even if R is not running yet. By default,
only the functions of vanilla R are always highlighted. Below is the default
value of vimrplugin_start_libs:

   let vimrplugin_start_libs = "base,stats,graphics,grDevices,utils,methods"

You may also want to define the value of vimrplugin_start_libs if you are
running Vim without the clientserver feature.

--------------------------------------------------------
*vimrplugin_routnotab*
6.10. Options for .Rout file file type

After the command <LocalLeader>ao, Vim will save the current buffer if it has
any pending changes, run R CMD BATCH --no-restore --no-save on the current
file and show the resulting .Rout file in a new tab. If you prefer that the
file is open in a new split window, put in your vimrc:

   let vimrplugin_routnotab = 1

By default, the R commands in .Rout files are highlighted with the color of
comments, and only the output of commands has some of its elements highlighted
(numbers, strings, index of vectors, warnings and errors).

If you prefer that R commands in the R output are highlighted as they are in R
scripts, put the following in your vimrc:

   let Rout_more_colors = 1

--------------------------------------------------------
*vimrplugin_indent_commented*
*vimrplugin_rcomment_string*
6.11. Indent commented lines

You can type <LocalLeader>xx to comment out a line or selected lines. If the
line already starts with a comment string, it will be removed. After adding
the comment string, the line will be reindented by default. To turn off the
automatic indentation, put in your vimrc:

   let vimrplugin_indent_commented = 0

What string will be added to the beginning of the line depends on the values
of vimrplugin_indent_commented and r_indent_ess_comments according to the
table below (see r-plugin-indenting):

   vimrplugin_indent_commented   r_indent_ess_comments   string
                 1                        0                #
                 0                        0                #
                 1                        1                ##
                 0                        1                ###

The string used to comment text with <LocalLeader>xc, <LocalLeader>xu,
<LocalLeader>xx and <LocalLeader>o is defined by vimrplugin_rcomment_string.
Example:

   let vimrplugin_rcomment_string = "# "

--------------------------------------------------------
*vimrplugin_notmuxconf*
6.12. Tmux configuration (Linux/Unix only)

GVim (or Vim running R in an external terminal emulator) runs Tmux with a
specially built configuration file. If you want to use your own ~/.tmux.conf,
put in your vimrc:

   let vimrplugin_notmuxconf = 1

If you opted for using your own configuration file, the plugin will write a
minimum configuration which will set the value of four environment variables
required for the communication with R and then source your own configuration
file (~/.tmux.conf).

--------------------------------------------------------
*vimrplugin_rconsole_height*
*vimrplugin_vsplit*
*vimrplugin_rconsole_width*
*vimrplugin_tmux_title*
6.13. Integration with Tmux (Linux/Unix only)

These three options are valid only when Vim is started inside a Tmux session.
In this case, when you type <LocalLeader>rf, the terminal will be split in two
regions and R will run in one of them. By default, the Vim-R-plugin will tell
Tmux to split the terminal window horizontally and you can set in your
vimrc the initial number of lines of the Tmux pane running R as in the
example below:

   let vimrplugin_rconsole_height = 15

If you prefer to split it vertically:

   let vimrplugin_vsplit = 1

In this case, you can choose the initial number of columns of R Console:

   let vimrplugin_rconsole_width = 15

Tmux automatically renames window titles to the command currently running. The
Vim-R-plugin sets the title of the window where Vim and R are running to
"VimR". This title will be visible only if Tmux status bar is "on", and it is
useful only if you have created new windows with the <C-a>c command. You
can change the value of vimrplugin_tmux_title to either set a different title
or let Tmux set the title automatically. Examples:

   let vimrplugin_tmux_title = "Vim-R"
   let vimrplugin_tmux_title = "automatic"

--------------------------------------------------------
*vimrplugin_applescript*
6.14. Integration with AppleScript (OS X only)

In Mac OS X, the plugin will try to send commands to R gui using AppleScript.
If you prefer to run R in an external terminal emulator, put in your vimrc:

   let vimrplugin_applescript = 0

If Vim is running inside Tmux, the terminal will be split in two regions.
Otherwise, R will start in an external terminal emulator.

--------------------------------------------------------
*vimrplugin_listmethods*
*vimrplugin_specialplot*
6.15. Special R functions

The R function args() lists the arguments of a function, but not the arguments
of its methods. If you want that the plugin calls the function
vim.list.args() after <LocalLeader>ra, you have to add to your vimrc:

   let vimrplugin_listmethods = 1

By default, R makes a scatterplot of numeric vectors. The function vim.plot()
do both a histogram and a boxplot. The function can be called by the plugin
after <LocalLeader>rg if you put the following line in your vimrc:

   let vimrplugin_specialplot = 1

--------------------------------------------------------
*vimrplugin_source_args*
6.16. Arguments to R source() function

When you send multiple lines of code to R (a selection of lines, a paragraph,
code between two marks or a R chunk of code), the Vim-R-plugin saves the lines
in a temporary file and, then, sends to R the command source() to read the
temporary file.

You can add arguments to be passed to R's source() function. Example:

   let vimrplugin_source_args = "max.deparse.length = 300"

--------------------------------------------------------
*vimrplugin_sweaveargs*
*vimrplugin_latexcmd*
*vimrplugin_latexmk*
*vimrplugin_texerr*
6.17. LaTeX options

To produce a pdf document from the .tex file generated by either Sweave() or
knit() command, if vimrplugin_latexmk = 1 and both latexmk and perl
(which is required to run latexmk) are installed and in the path, the vimcom
package calls:

   latexmk -pdflatex="pdflatex -file-line-error -synctex=1" -pdf

Otherwise, it calls:

   pdflatex -file-line-error -synctex=1

You can use the options vimrplugin_latexcmd and vimrplugin_latexmk to change
this behavior. Examples:

   let vimrplugin_latexmk = 0
   let vimrplugin_latexcmd = "latex"
   let vimrplugin_latexcmd = 'latexmk -pdf -pdflatex="xelatex %O -synctex=1 %S"'

By default, vimrplugin_latexmk is 0 on Windows and 1 on other systems.
If you want to pass arguments to the Sweave() function, set the value of the
vimrplugin_sweaveargs variable.

If the value of vimrplugin_texerr is 1, a summary of LaTeX errors
and warnings are produced by the compilation of the .tex document into .pdf
file will be output to R Console at the end of the compilation. So, you do not
have to scroll the R Console seeking for these messages.

--------------------------------------------------------
*vimrplugin_rmd_environment*
6.18. Rmd environment

When rendering an Rmd file, the code can be evaluated (and saved) in a
specified environment.  The default value is .GlobalEnv which makes the
objects stored in the Rmd file available on the R console.  If you do not want
the  objects stored in the Rmd file to be available in the global environment,
you can set

    let vimrplugin_rmd_environment = "new.env()"

--------------------------------------------------------
6.19. Never unmake the R menu

Use this option if you want that the "R" menu item in GVim is not deleted when
you change from one buffer to another, for example, when going from an .R file
to a .txt one:

   let vimrplugin_never_unmake_menu = 1

When this option is enabled all menu items are created regardless of the file
type. If you have added R related tool bar buttons (see r-plugin-toolbar)
the buttons also are created at the plugin startup and kept while you go to
different file type buffers.

--------------------------------------------------------
*vimrplugin_map_r*
6.20. Map 'r'

If the variable vimrplugin_map_r exists, the plugin will map the letter 'r'
to send lines to R when there are visually selected lines, for compatibility
with the original plugin. To activate this option, insert the following into
vimrc:

   let vimrplugin_map_r = 1

You may want to add the following three lines to your vimrc which were in
Johannes Ranke's plugin and will increase compatibility with code edited with
Emacs:

   set expandtab
   set shiftwidth=4
   set tabstop=8

--------------------------------------------------------
*vimrplugin_ca_ck*
6.21. Add ^A^K to the beginning of commands

When one types <C-a> in the R Console the cursor goes to the beginning of the
line and when one types <C-k> the characters to the right of the cursor are
deleted. This is useful to avoid characters left on the R Console being mixed
with commands sent by Vim. However, sending <C-a> may be problematic if using
Tmux. The Vim-R-plugin will add <C-a><C-k> to every command if you put
in your vimrc:

   let vimrplugin_ca_ck = 1

--------------------------------------------------------
*vimrplugin_pdfviewer*
*vimrplugin_openpdf*
*vimrplugin_openhtml*
6.22. Open PDF after processing rnoweb, rmd or rrst files

The plugin can automatically open the pdf file generated by pdflatex, after
either Sweave() or knit(). This behavior is controlled by the variable
vimrplugin_openpdf whose value may be 0 (do not open the pdf), 1 (open only
the first time that pdflatex is called) or a number higher than 1 (always
open the pdf). For example, if you want that the pdf application is started
automatically but do not want the terminal (or GVim) losing focus every time
that you generate the pdf, you should put in put in your vimrc:

   let vimrplugin_openpdf = 1

If you use Linux or other Unix and eventually use the system console (without
the X server) you may want to put in your vimrc:

   if DISPLAY != ""  let vimrplugin_openpdf = 1  endif Note: If the pdf is already open, some pdf readers will automatically update the pdf; others will lock the pdf file and prevent R from successfully compiling it again. You can change the value of vimrplugin_pdfviewer in your vimrc to define what PDF viewer will be called. Example:  let vimrplugin_pdfviewer = "zathura" If editing an Rmd file, you can produce the html result with <LocalLeader>kh. The html file will be automatically opened if you put the following in your vimrc:  let vimrplugin_openhtml = 1 -------------------------------------------------------- *vimrplugin_rrstcompiler* *vimrplugin_strict_rst* *vimrplugin_rst2pdfpath* *vimrplugin_rst2pdfargs* 6.23. Support to RreStructuredText file By default, the Vim-R-plugin sends the command render_rst(strict=TRUE) to R before using R's knit() function to convert an Rrst file into an rst one. If you prefer the non strict rst code, put the following in your vimrc:  let vimrplugin_strict_rst = 0 You can also set the value of vimrplugin_rst2pdfpath (the path to rst2pdf application), vimrplugin_rrstcompiler (the compiler argument to be passed to R function knit2pdf), and vimrplugin_rst2pdfargs (further arguments to be passed to R function knit2pdf). -------------------------------------------------------- *vimrplugin_insert_mode_cmds* 6.24. Allow R commands in insert mode Vim-R commands are designed to work in insert mode as well as normal mode. However, depending on your <LocalLeader>, this can make it very difficult to write R packages or Sweave files. For example, if <LocalLeader> is set to the \ character, typing \dQuote in a .Rd file tries to send the command! The option vimrplugin_insert_mode_cmds disables commands in insert mode. To use it, add the following to your vimrc:  let g:vimrplugin_insert_mode_cmds = 0 The default value is 1, for consistency with earlier versions. See also: r-plugin-localleader. -------------------------------------------------------- *vimrplugin_allnames* *vimrplugin_rmhidden* 6.25. Show/remove hidden objects Hidden objects are not included in the list of objects for omni completion. If you prefer to include them, put in your vimrc:  let g:vimrplugin_allnames = 1 Hidden objects are removed from R workspace when you do <LocalLeader>rm. If you prefer to remove only visible objects, put in your vimrc:  let g:vimrplugin_rmhidden = 0 -------------------------------------------------------- *vimrplugin_source* 6.26. Source additional scripts This variable should contain a comma separated list of Vim scripts to be sourced by the Vim-R-plugin. These scripts may provide additional functionality and/or change the behavior of the Vim-R-plugin. If you have such scripts, put in your vimrc:  let vimrplugin_source = "~/path/to/MyScript.vim,/path/to/AnotherScript.vim" Currently, there are only two scripts known to extend the Vim-R-plugin features:  Support to the devtools R package https://github.com/mllg/vim-devtools-plugin  Basic integration with GNU screen https://github.com/ssayols/screenR -------------------------------------------------------- *vimrplugin_restart* 6.27. Restart R if it is already running (Linux/Unix only) When R is already running and you type one of the commands to start R before you have done <LocalLeader>rq, the Vim-R-plugin does one of the following: (a) If R is in an external terminal emulator, the terminal is closed, a new one is opened with the same R session running in it. (b) If both Vim and R are running in different Tmux regions of the same terminal emulator, the plugin warns that R is already running. If instead of the default behavior, you prefer to quit and restart R when you do <LocalLeader>rf, <LocalLeader>rv or <LocalLeader>rc, then, put in your vimrc:  let vimrplugin_restart = 1 -------------------------------------------------------- *vimrplugin_show_args* *vimrplugin_args_in_stline* 6.28. Function arguments If you want that Vim shows a preview window with the function arguments as you do omnicompletion, put in your vimrc:  let vimrplugin_show_args = 1 The preview window is not shown by default because it is more convenient to run <Ctrl-X><Ctrl-A> to complete the function arguments. The preview window will be shown only if "preview" is also included in your 'completeopt'. If you want that function arguments are displayed in Vim's status line when you insert (, put in your vimrc:  let vimrplugin_args_in_stline = 1 The status line is restored when ) is typed. This option is useful only if the window has a status line. See laststatus. If the string with the list of arguments is longer than the status line width, the list is not displayed completely. This argument is incompatible with any plugin that changes the status line because it is always restored to the value that it had at Vim's startup. Functions of .GlobalEnv do not have their arguments displayed. -------------------------------------------------------- *vimrplugin_vimcom_wait* 6.29. Time to wait for vimcom loading The Vim-R-plugin waits 5000 milliseconds for vimcom package to be loaded during R startup. It then checks whether you are using the correct version of vimcom. If 5000 milliseconds is not enough to your R startup, then set a higher value for the variable in your vimrc. Example:  let vimrplugin_vimcom_wait = 10000 Note: You should have the line library(vimcom) in your ~/.Rprofile. -------------------------------------------------------- *vimrplugin_vim_wd* 6.30 Start R in working directory of Vim When you are editing an R file (.R, .Rnw, .Rd, .Rmd, .Rrst) and start R, the R package vimcom runs the command setwd() with the directory of the file being edited as argument, that is, the R working directory becomes the same directory of the R file. If you want R's working directory to be the same as Vim's working directory, put in your vimrc:  let vimrplugin_vim_wd = 1 This option is useful only for those who did not enable 'autochdir'. If you prefer that the Vim-R-plugin does not set the working directory in any way, put in vimrc:  let vimrplugin_vim_wd = -1 -------------------------------------------------------- *vimrplugin_after_start* 6.31 System command to execute after R startup If you want that Vim executes a command right after R startup, set the value of vimrplugin_after_start in your vimrc. For example, if you are using GVim and running R in the Gnome-terminal, ~/bin is in your path, and you want to resize and change the positions of GVim and the Terminal windows, you may create a script ~/bin/after_R_start with the following contents  #!/bin/sh  wmctrl -F -r R -e 0,0,200,1200,800  wmctrl -r GVIM -e 0,300,40,1200,800 make the script executable, and put in your vimrc:  if has("gui_running")  let vimrplugin_after_start = "after_R_start"  endif On Mac OS X, if you are using MacVim and R.app, the ~/bin/after_R_start contents might be:  #!/bin/sh  osascript -e 'tell application "Terminal" to set the bounds of the front window to {0, 200, 1200, 1000}'  osascript -e 'tell application "MacVim" to set the bounds of the front window to {300, 40, 1500, 840}' -------------------------------------------------------- *vimrplugin_user_maps_only* 6.32 Only set key bindings that are user specified The Vim-R-plugin sets many default key bindings. The user can set custom key bindings (r-plugin-key-bindings). If you wish the Vim-R-plugin to only set those key-bindings specified by the user, put in your vimrc:  let vimrplugin_user_maps_only = 1 -------------------------------------------------------- *vimrplugin_tmpdir* *vimrplugin_compldir* 6.33 Temporary files directories You can change the directories where temporary files are created and stored by setting in your vimrc the values of vimrplugin_tmpdir and vimrplugin_compldir, as in the example below:  let vimrplugin_tmpdir = "/dev/shm/R_tmp_dir"  let vimrplugin_compldir = "~/.cache/Vim-R-plugin" The default paths of these directories depend on the operating system. If you want to know they are, while editing an R file, do in Normal mode:  :echo g:rplugin_tmpdir  :echo g:rplugin_compldir -------------------------------------------------------- *r-plugin-df-view* 6.34 View a data.frame or matrix The csv.vim plugin helps to visualize and edit csv files, and if it is not installed, the Vim-R-plugin will warn you about that when you do <LocalLeader>rv. If you do not want to install the csv.vim plugin, put in your vimrc:  let vimrplugin_csv_warn = 0 If you rather prefer to see the table in a graphical viewer, you should set the value of vimrplugin_csv_app in your vimrc. Examples:  let vimrplugin_csv_app = "localc"  let vimrplugin_csv_app = "c:/Program Files (x86)/LibreOffice 4/program/scalc.exe" There is also the option of configuring the Vim-R-plugin to run an R command to display the data. Example:  let vimrplugin_df_viewer = "relimp::showData(%s, font = 'Courier 14')" The value of vimrplugin_df_viewer is a string and the substring %s is replaced by the name of the object under the cursor. -------------------------------------------------------- *r-plugin-SyncTeX* 6.35 SyncTeX support SyncTeX is a set of communication systems used by some PDF viewers and by some text editors which allow users to jump from a specific line in the text editor to the corresponding line in the PDF viewer and vice-versa. The Vim-R-plugin has support for Evince, Zathura and Okular SyncTeX systems. To completely disable SyncTeX support, put in your vimrc:  let vimrplugin_synctex = 0 The application wmctrl is required to raise both the PDF viewer and Vim windows. No configuration is required if you use Evince and the knitr package, and single file Rnoweb documents. Otherwise, keep reading... If you use Sweave() rather than knit(), you must put in your Rnoweb document:  \SweaveOpts{concordance=TRUE} If you work with a master document and child subdocuments, each child subdocument (TeX and Rnoweb alike) should include the following line:  % !Rnw root = master.Rnw where master.Rnw must be replaced with the name of the actual master document. Note: The current knitr package (version 1.7) has at least two limitations: - It has no SyncTeX support for child documents. The correspondence data point to lines just below child chunks in the master document and not to somewhere in the child documents themselves. See: https://github.com/yihui/knitr/issues/225 - It only starts registering the concordance after the first chunk. So, it is recommended that you put the first chunk of R code just after the \begin{document} command. -------------------------------------------------------- 6.35.1 Evince configuration No configuration should be required. Note: If Evince is not started yet when you try to jump to the PDF document for the first time, it will start, but will not jump to desired line; you have to press <LocalLeader>gp again. -------------------------------------------------------- 6.35.2 Okular configuration You have to configure Okular to call Vim during backward searches. In Okular, click in:  Settings  Configure Okular  Editor  Dropdown menu: Custom Text Editor  Command: vim --remote-expr "SyncTeX_backward('%f', %l)" In the command above, replace vim with gvim if you use GVim. If Evince is not installed in your system, the Vim-R-plugin will automatically use Okular as the PDF viewer. Otherwise, you have to set the value of vimrplugin_pdfviewer to "okular":  let vimrplugin_pdfviewer = "okular" Note: If the PDF document is already open the first time that you jump to it, and if Okular was not started with the --unique argument, another instance of Okular will be started. -------------------------------------------------------- 6.35.3 Zathura configuration No configuration should be required if Evince is not installed. If evince is installed, put in your vimrc:  let vimrplugin_pdfviewer = "zathura" Zathura version must be >= 0.3.1. Note: If Zathura is not started yet when you try to jump to the PDF document for the first time, it will start, but will not jump to desired line; you have to press <LocalLeader>gp again. -------------------------------------------------------- 6.35.4 Skim with MacVim configuration (Mac OS X) You have to configure Skim to call MacVim during backward searches. In Skim click in the drop down menu and fill the fields:  Skim  Settings  Sync  Preset: Custom  Command: /path/to/MacVim/mvim  Arguments: --remote-expr "SyncTeX_backward('%file', %line)" -------------------------------------------------------- 6.35.5 Sumatra configuration (Windows) No configuration is required. -------------------------------------------------------- *r-plugin-key-bindings* 7. Custom key bindings When creating custom key bindings for the Vim-R-plugin, it is necessary to create three maps for most functions because the way the function is called is different in each Vim mode. Thus, key bindings must be made for Normal mode, Insert mode, and Visual mode. To customize a key binding you should put in your vimrc something like:  nmap <LocalLeader>sr <Plug>RStart  imap <LocalLeader>sr <Plug>RStart  vmap <LocalLeader>sr <Plug>RStart The above example shows how to change key binding used to start R from <LocalLeader>rf to <LocalLeader>sr. Only the custom key bindings for Normal mode are shown in Vim's menu, but you can type :map to see the complete list of current mappings, and below is the list of the names for custom key bindings (the prefix RE means "echo"; RD, "cursor down"; RED, both "echo" and "down"):  Start/Close R RStart RCustomStart RClose RSaveClose  Clear R console RClearAll RClearConsole  Edit R code RSimpleComment RSimpleUnComment RToggleComment RRightComment RCompleteArgs RIndent RNextRChunk RPreviousRChunk  Send line or part of it to R RSendLine RDSendLine RSendLAndOpenNewOne RNLeftPart RNRightPart RILeftPart RIRightPart RDSendLineAndInsertOutput  Send code to R console RSendSelection RESendSelection RDSendSelection REDSendSelection RSendSelAndInsertOutput RSendMBlock RESendMBlock RDSendMBlock REDSendMBlock RSendParagraph RESendParagraph RDSendParagraph REDSendParagraph RSendFunction RESendFunction RDSendFunction REDSendFunction RSendFile RESendFile  Send command to R RHelp RPlot RSPlot RShowArgs RShowEx RShowRout RObjectNames RObjectPr RObjectStr RViewDF RSetwd RSummary RListSpace  Support to Sweave and knitr RSendChunk RDSendChunk RESendChunk REDSendChunk RSendChunkFH (from the first chunk to here) RBibTeX (Sweave) RBibTeXK (Knitr) RSweave RKnit RMakeHTML RMakeODT RMakePDF (Sweave) RMakePDFK (Knitr) RMakePDFKb (.Rmd, beamer) RMakeRmd (rmarkdown default) RMakeAll (rmarkdown all in yaml) ROpenPDF RSyncFor (SyncTeX search forward) RGoToTeX (Got to LaTeX output) RSpinFile RNextRChunk RPreviousRChunk  Object browser RUpdateObjBrowser ROpenLists RCloseLists The completion of function arguments only happens in Insert mode. To customize its keybind you should put in your vimrc something as in the example:  imap <C-A> <Plug>RCompleteArgs The plugin also contains a function called RAction which allows you to build ad-hoc commands to R. This function takes the name of an R function such as "levels" or "table" and the word under the cursor, and passes them to R as a command. For example, if your cursor is sitting on top of the object called gender and you call the RAction function, with an argument such as levels, Vim will pass the command levels(gender) to R, which will show you the levels of the object gender. To make it even easier to use this and other functions, you could write custom key bindings in your vimrc, as in the examples below:  map <silent> <LocalLeader>rk :call RAction("levels")<CR>  map <silent> <LocalLeader>t :call RAction("tail")<CR>  map <silent> <LocalLeader>h :call RAction("head")<CR> If the command that you want to send does not require an R object as argument, you can create a shortcut to it by following the example:  map <silent> <LocalLeader>s :call g:SendCmdToR("search()") See also: vimrplugin_source. -------------------------------------------------------- *r-plugin-files* 8. License and files The Vim-R-plugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The Vim-R-plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GNU General Public License is available at http://www.r-project.org/Licenses/ The files released with Vim runtime files are distributed under the Vim Charityware license. The following files are part of the plugin and should be in your ~/.vim directory after the installation: autoload/rcomplete.vim doc/r-plugin.txt ftdetect/r.vim ftplugin/r_rplugin.vim ftplugin/rbrowser.vim ftplugin/rdoc.vim ftplugin/rhelp_rplugin.vim ftplugin/rmd_rplugin.vim ftplugin/rnoweb_rplugin.vim ftplugin/rrst_rplugin.vim r-plugin/common_buffer.vim r-plugin/common_global.vim r-plugin/functions.vim r-plugin/gui_running.vim r-plugin/osx.vim r-plugin/r.snippets r-plugin/rmd.snippets r-plugin/setcompldir.vim r-plugin/synctex_evince_backward.py r-plugin/synctex_evince_forward.py r-plugin/windows.vim syntax/rbrowser.vim syntax/rdoc.vim syntax/rout.vim -------------------------------------------------------- *r-plugin-tips* 9. FAQ and tips 9.1. Is it possible to stop R from within Vim? Yes. In Normal mode do :RStop and Vim will send SIGINT to R which is the same signal sent when you press CTRL-C into R's Console. -------------------------------------------------------- 9.2. Html help and custom pager If you prefer to see help pages in an html browser, put in your ~/.Rprofile:  options(help_type = "html") and in your vimrc (see vimrplugin_vimpager):  let vimrplugin_vimpager = "no" -------------------------------------------------------- *r-plugin-showmarks* 9.3. How do marked blocks work? Vim allows you to put several marks (bookmarks) in buffers. The most commonly used marks are the lowercase alphabet letters. If the cursor is between any two marks, the plugin will send the lines between them to R if you press <LocalLeader>bb. If the cursor is above the first mark, the plugin will send from the beginning of the file to the mark. If the cursor is below the last mark, the plugin will send from the mark to the end of the file. The mark above the cursor is included and the mark below is excluded from the block to be sent to R. To create a mark, press m<letter> in Normal mode. We recommended the use of vim-signature which show what lines have marks defined. The plugins are available at: https://github.com/kshenoy/vim-signature -------------------------------------------------------- *r-plugin-snippets* 9.4. Use snipMate You probably will want to use the snipMate plugin to insert snippets of code in your R script. The plugin may be downloaded from: http://www.vim.org/scripts/script.php?script_id=2540 The snipMate plugin does not come with snippets for R, but you can copy the files r.snippets and rmd.snippets that ship with the Vim-R-plugin (look at the r-plugin directory) to the snippets directory. The files have only a few snippets, but they will help you to get started. If you usually edit rnoweb files, you may also want to create an rnoweb.snippets by concatenating both tex.snippets and r.snippets. If you edit R documentation, you may want to create an rhelp.snippets -------------------------------------------------------- *r-plugin-bindings* 9.5. Easier key bindings for most used commands The most used commands from Vim-R-plugin probably are "Send line" and "Send selection". You may find it a good idea to map them to the space bar in your vimrc (suggestion made by Iago Mosqueira):  vmap <Space> <Plug>RDSendSelection  nmap <Space> <Plug>RDSendLine You may also want to remap <C-x><C-o>: http://stackoverflow.com/questions/2269005/how-can-i-change-the-keybinding-used-to-autocomplete-in-vim Note: Not all mappings work in all versions of Vim. Some mappings may not work on GVim on Windows, and others may not work on Vim running in a terminal emulator or in Linux Console. The use of <Shift>, <Alt> and <Fn> keys in mappings are particularly problematic. See: https://github.com/jcfaria/Vim-R-plugin/issues/111 You can also use Vim's 'clientserver' feature to send remote messages to Vim. For example, if you want a keyboard shortcut that sends to Vim the command to send the current line to R and go down to the next line of code, then use your desktop configuration tools to create a global shortcut to the following command:  vim --remote-expr 'SendLineToR("down")' The command above will work properly only if there is a single Vim instance running. Otherwise, the --servername argument would have to be used to send the message to the correct Vim instance. If the command works properly, you will be able to send lines of code from Vim to R even if the window currently focused is not the Vim's window (either the terminal emulator where Vim is running or GVim). -------------------------------------------------------- *r-plugin-localleader* 9.6. Remap the <LocalLeader> People writing Rnoweb documents may find it better to use a comma or other key as the <LocalLeader> instead of the default backslash (see maplocalleader). For example, to change the <LocalLeader> to a comma, put at the beginning of your vimrc (before any mapping command):  let maplocalleader = "," -------------------------------------------------------- *r-plugin-tagsfile* 9.7. Use a tags file to jump to function definitions Vim can jump to a function definition if it finds a "tags" file with the information about the place where the function is defined. To generate the tags file, use the R function rtags(), which will build an Emacs tags file. If Vim was compiled with the feature emacs_tags, it will be able to read the tags file. Otherwise, you can use the vimcom function etags2ctags() to convert the Emacs tags file into a Vim's one. To jump to a function definition, put the cursor over the function name and hit CTRL-]. Please, read tagsrch for details on how to use tags files, specially the section tags-option. You could, for example, download and unpack R's source code, start R inside the ~/.vim directory and do the following commands:  rtags(path = "/path/to/R/source/code", recursive = TRUE, ofile = "RTAGS")  etags2ctags("RTAGS", "Rtags") Then, you would quit R and do the following command in the terminal emulator:  ctags --languages=C,Fortran,Java,Tcl -R -f RsrcTags /path/to/R/source/code Finally, you would put the following in your vimrc, optionally inside an autocmd-group:  autocmd FileType r set tags+=~/.vim/Rtags,~/.vim/RsrcTags  autocmd FileType rnoweb set tags+=~/.vim/Rtags,~/.vim/RsrcTags Note: While defining the autocmd, the Rtags path must be put before RsrcTags. Example on how to test whether your setup is ok: 1. Type mapply() in an R script and save the buffer. 2. Press CTRL-] over "mapply" (Vim should jump to "mapply.R"). 3. Locate the string "do_mapply", which is the name of a C function. 4. Press CTRL-] over "do_mapply" (Vim sould jump to "mapply.c"). -------------------------------------------------------- *r-plugin-indenting* 9.8. Indenting setup Note: In Normal mode, type == to indent the current line and gg=G to format the entire buffer (see gg, = and G for details). These are Vim commands; they are not specific to R code. The Vim-R-plugin includes a script to automatically indent R files. By default, the script aligns function arguments if they span for multiple lines. If you prefer do not have the arguments of functions aligned, put in your vimrc:  let r_indent_align_args = 0 By default, all lines beginning with a comment character, #, get the same indentation level of the normal R code. Users of Emacs/ESS may be used to have lines beginning with a single # indented in the 40th column, ## indented as R code, and ### not indented. If you prefer that lines beginning with comment characters are aligned as they are by Emacs/ESS, put in your vimrc:  let r_indent_ess_comments = 1 If you prefer that lines beginning with a single # are aligned at a column different from the 40th one, you should set a new value to the variable r_indent_comment_column, as in the example below:  let r_indent_comment_column = 30 By default any code after a line that ends with "<-" is indented. Emacs/ESS does not indent the code if it is a top level function. If you prefer that the Vim-R-plugin behaves like Emacs/ESS in this regard, put in your vimrc:  let r_indent_ess_compatible = 1 Below is an example of indentation with and without this option enabled:  ### r_indent_ess_compatible = 1 ### r_indent_ess_compatible = 0  foo <- foo <-  function(x) function(x)  { {  paste(x) paste(x)  } } Notes: (1) Not all code indented by Emacs/ESS will be indented by the Vim-R-plugin in the same way, and, in some circumstances it may be necessary to make changes in the code to get it properly indented by Vim (you may have to either put or remove braces and line breaks). (2) Indenting is not a file type plugin option. It is a feature defined in indent/r.vim. That is why it is documented in this section. -------------------------------------------------------- *r-plugin-folding* 9.9. Folding setup Vim has several methods of folding text (see fold-methods and fold-commands). To enable the syntax method of folding for R files, put in your vimrc:  let r_syntax_folding = 1 With the above option, Vim will load R files with all folds closed. If you prefer to start editing files with all folds open, put in your vimrc:  set nofoldenable Notes: (1) Enabling folding may slow down Vim. (2) Folding is not a file type plugin option. It is a feature defined in syntax/r.vim. Note: Indentation of R code is very slow because the indentation algorithm sometimes goes backwards looking for an opening parenthesis or brace or for the beginning of a for, if or while statement. This is necessary because the indentation level of a given line depends on the indentation level of the previous line, but the previous line is not always the line above. It's the line where the statement immediately above started. Of course someone may develop a better algorithm in the future. -------------------------------------------------------- 9.10. Highlight chunk header as R code By default, Vim will highlight chunk headers of RMarkdown and RreStructuredText with a single color. Chunk headers should contain valid R code when the code is processed by knitr, so you may want to highlight them as such. You can do this by putting in your vimrc:  let rrst_syn_hl_chunk = 1  let rmd_syn_hl_chunk = 1 -------------------------------------------------------- 9.11. Automatically close parenthesis Some people want Vim automatically inserting a closing parenthesis, bracket or brace when an open one has being typed. The page below explains how to achieve this goal: http://vim.wikia.com/wiki/Automatically_append_closing_characters -------------------------------------------------------- 9.12. Automatic line breaks By default, while editing R code, Vim does not break lines when you are typing if you reach the column defined by the 'textwidth' option. If you prefer that Vim breaks the R code automatically put in your vimrc:  autocmd FileType r setlocal formatoptions+=t -------------------------------------------------------- 9.13. Vim with 256 colors in a terminal emulator (Linux/Unix only) If you want 256 colors support in Vim, install the package ncurses-term. Then put in your ~/.bashrc the lines suggested at r-plugin-bash-setup. You have to search the internet for color schemes supporting 256 colors, download and copy them to ~/.vim/colors. You may use the command :colorscheme to try them one by one before setting your preference in your vimrc. -------------------------------------------------------- 9.14. Run your Makefile from within R Do you have many Rnoweb files included in a master tex or Rnoweb file and use a Makefile to build the pdf? You may consider it useful to put the following line in your vimrc:  nmap <LocalLeader>sm :update<CR>:call g:SendCmdToR('system("make")')<CR> -------------------------------------------------------- *r-plugin-Rprofile* 9.15. Edit your ~/.Rprofile You may want to edit your ~/.Rprofile in addition to considering the suggestions of r-plugin-R-setup you may also want to put the following lines in your ~/.Rprofile if you are using Linux:  grDevices::X11.options(width = 4.5, height = 4, ypos = 0,  xpos = 1000, pointsize = 10) The X11.options() is used to choose the position and dimensions of the X11 graphical device. You can also install the application wmctrl and create shortcuts in your desktop environment to the commands  wmctrl -r "R Graphics" -b add,above  wmctrl -r "R Graphics" -b remove,above which will toggle the "always on top" state of the X11 device window. Alternatively, you can right click on the X11 device window title bar and choose "Always on top". This is useful to emulate a feature present in R IDEs which can display R plots in a separate panel. Although we can not embed an R graphical device in Vim, we can at least make it always visible over the terminal emulator or the GVim window. -------------------------------------------------------- 9.16. Debugging R functions The Vim-R-Plugin does not have debugging facilities, but you may want to use the R package "debug":  install.packages("debug")  library(debug)  mtrace(function_name) Once the library is installed and loaded, you should use mtrace(function_name) to enable the debugging of a function. Then, the next time that the function is called it will enter in debugging mode. Once debugging a function, you can hit <Enter> to evaluate the current line, go(n) to go to line n in the function and qqq() to quit the function (See debug's help for details). A useful tip is to click on the title bar of the debug window and choose "Always on top" or a similar option provided by your desktop manager. -------------------------------------------------------- 9.17. Disable syntax highlight of R functions If you want to disable the syntax highlight of R functions put in your vimrc:  autocmd Syntax * syntax clear rFunction -------------------------------------------------------- *r-plugin-latex-box* 9.18. Integration with LaTeX-Box LaTeX-Box does not automatically recognize Rnoweb files as a valid LaTeX file. You have to tell LaTeX-BoX that the .tex file compiled by either knitr() or Sweave() is the main LaTeX file. You can do this in two ways. Suppose that your Rnoweb file is called report.Rnw... You can: (1) Create an empty file called "report.tex.latexmain". or (2) Put in the first 5 lines of report.Rnw: % For LaTeX-Box: root = report.tex Of course you must run either knitr() or Sweave() before trying LaTeX-Box omnicompletion. Please, read LaTeX-Box documentation for more information. See also: vimrplugin_latexcmd. -------------------------------------------------------- *r-plugin-quick-setup* 9.19. Suggested setup for the Vim-R-plugin Please, look at section r-plugin-options if you want information about the Vim-r-plugin customization. Here are some suggestions of configuration of Vim, Bash, Tmux and R. To understand what you are doing, and change the configuration to your taste, please read this document from the beginning. *r-plugin-vimrc-setup*  ~/.vimrc  " Minimum required configuration:  set nocompatible  syntax on  filetype plugin on  filetype indent on  " Change Leader and LocalLeader keys:  let maplocalleader = ","  let mapleader = ";"  " Use Ctrl+Space to do omnicompletion:  if has("gui_running")  inoremap <C-Space> <C-x><C-o>  else  inoremap <Nul> <C-x><C-o>  endif  " Press the space bar to send lines and selection to R:  vmap <Space> <Plug>RDSendSelection  nmap <Space> <Plug>RDSendLine  " The lines below are suggestions for Vim in general and are not  " specific to the improvement of the Vim-R-plugin.  " Highlight the last searched pattern:  set hlsearch  " Show where the next pattern is as you type it:  set incsearch  " By default, Vim indents code by 8 spaces. Most people prefer 4  " spaces:  set sw=4  " Search "Vim colorscheme 256" in the internet and download color  " schemes that supports 256 colors in the terminal emulator. Then,  " uncomment the code below to set you color scheme:  "colorscheme not_defined *r-plugin-R-setup*  ~/.Rprofile  if(interactive()){  options(vimcom.verbose = 1)  # Load the required libraries:  library(colorout)  library(setwidth)  library(vimcom)  # Use the text based web browser w3m to navigate through R docs  # in Linux Console after help.start():  if(Sys.getenv("TMUX") != "" && Sys.getenv("DISPLAY") == "")  options(browser = function(u) system(paste0("tmux new-window 'w3m ", u, "'")))  } *r-plugin-bash-setup*  ~/.bashrc (Linux, Mac OS X, and other Unix systems):  # Change the TERM environment variable (to get 256 colors) even if you are  # accessing your system through ssh and using either Tmux or GNU Screen:  if [ "TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ]  then  export TERM=xterm-256color  export HAS_256_COLORS=yes  fi  if [ "$TERM" = "screen" ] && [ "$HAS_256_COLORS" = "yes" ]  then  export TERM=screen-256color  fi  # Make Vim connect to X Server even if the gui is not running (many of the  # plugin features depend on this).  if [ "x$DISPLAY" != "x" ]
   then
       alias vim='vim --servername VIM'
   fi

Finally, if you want to use vi key bindings in Bash or other shell:

   ~/.inputrc

   set editing-mode vi
   set keymap vi

--------------------------------------------------------

9.20. Syntax highlight of .Rout files

You can set the foreground colors of R output in your vimrc. The example
below is for a terminal emulator that supports 256 colors (see :highlight):

   if &t_Co == 256
       let rout_color_input    = 'ctermfg=247'
       let rout_color_normal   = 'ctermfg=202'
       let rout_color_number   = 'ctermfg=214'
       let rout_color_integer  = 'ctermfg=214'
       let rout_color_float    = 'ctermfg=214'
       let rout_color_complex  = 'ctermfg=214'
       let rout_color_negnum   = 'ctermfg=209'
       let rout_color_negfloat = 'ctermfg=209'
       let rout_color_date     = 'ctermfg=184'
       let rout_color_true     = 'ctermfg=78'
       let rout_color_false    = 'ctermfg=203'
       let rout_color_inf      = 'ctermfg=39'
       let rout_color_constant = 'ctermfg=179'
       let rout_color_string   = 'ctermfg=172'
       let rout_color_error    = 'ctermfg=15 ctermbg=1'
       let rout_color_warn     = 'ctermfg=1'
       let rout_color_index    = 'ctermfg=186'
   endif

To know what number corresponds to your preferred color (among the 256
possibilities), hover you mouse pointer over the table of colors at the end
of http://www.lepem.ufc.br/jaa/colorout.html

If you prefer that R output is highlighted using you current :colorscheme,
put in your vimrc:

   let rout_follow_colorscheme = 1

--------------------------------------------------------
*r-plugin-news*
10. News

1.2.7 (2015-11-27)

* Fix incompatibility with Tmux 2.1.

1.2.6 (2015-06-12)

* Improve support for lazy load objects in the Object Browser.

* Remove option vimrplugin_vim_window (use WINDOWID instead). * Fix bug that prevented GVim 64 bit of finding libVimR.dll. 1.2.5 (2015-05-06) * New command to evaluate selection and get output in newtab: \so * The command \ao no longer blocks Vim. * New command (\rv) and new options (vimrplugin_csv_warn, vimrplugin_csv_app and vimrplugin_df_viewer). * Bring back the "echo" send commands because some users need them. 1.2.4 (2015-04-22) * Deleted r-plugin/global_R_plugin.vim. See: https://github.com/jalvesaq/vimcmdline 1.2.3 (2015-04-09) * Official runtime files were deleted. See: https://github.com/jalvesaq/R-Vim-runtime * News options to control the Object Browser: vimrplugin_objbr_opendf, vimrplugin_objbr_openlist, vimrplugin_objbr_allnames and vimrplugin_objbr_labelerr. * New option to control LaTeX compilation: vimrplugin_texerr. * Fix setting of R working directory on Mac OS X. 1.2.2 (2015-03-24) * Remove option to start R with the --vanilla argument. See vimrplugin_r_args for an alternative. * Minor bug fixes. 1.2.1 (2015-03-05) * Minor bug fixes. * New options: vimrplugin_after_start, vimrplugin_args_in_stline, vimrplugin_save_win_pos and vimrplugin_arrange_windows. * Remove option vimrplugin_maxdeparse, remove the "echo" send commands and add the option vimrplugin_source_args. 1.2 (2015-01-18) * Remove support for Neovim. See: https://github.com/jalvesaq/Nvim-R * Remove command :RpluginConfig. * Remove option vimrplugin_Rterm. * Change commands gn and gN to <LocalLeader>gn and <LocalLeader>gN. * Change default value of vimrplugin_openpdf to 2. * Options vimrplugin_sleeptime now should be in miliseconds. * Replace option vimrplugin_external_ob with vimrplugin_tmux_ob. * Rename vimrplugin_permanent_libs to vimrplugin_start_libs. * Rename vimrplugin_routmorecolors to Rout_more_colors. * New command: :RStop. * No longer require +python feature; require +libcall instead. * Support for SyncTeX on Windows and Mac OS X. * New option: vimrplugin_latexmk 1.1 (2014-11-13) * Version update for Linux/Unix only. May not work on Windows or Mac. * Minor bug fixes. * The option vimrplugin_assign now accepts the values 0, 1 and 2. * SyncTeX support (Evince, Okular and Zathura): - New options: vimrplugin_synctex and vimrplugin_vim_window. - Deprecated option: vimrplugin_openpdf_quietly 1.0 (2014-07-02) * The package now depends on vimcom (which is fully featured and is no longer on CRAN). * Neovim support. * vimrplugin_openpdf now accepts three values: 0, 1 and 2. * New command \o evaluates current line in R and inserts the output in the script. * New options: vimrplugin_vimcom_wait, vimrplugin_vim_wd, and vimrplugin_tmux_title. * Minor bug fixes. 0.9.9.9 (2014-02-01) * Minor bug fixes. * Delete temporary files on VimLeave event. * Support to R package slidify (thanks to Michael Lerch). * New option: vimrplugin_rcomment_string. 0.9.9.8 (2013-11-30) * The list of objects for omnicompletion and the list of functions for syntax highlight now are built dynamically. Deprecated commands and options: :RUpdateObjList, :RAddLibToList, vimrplugin_buildwait. New option: vimrplugin_permanent_libs. * New options: vimrplugin_show_args. * New command \ch: send to R Console all R code from the first chunk up to this line. * Remove toolbar icons (they still may be added back manually by interested users). * If latexmk is installed, use it by default to compile the pdf. 0.9.9.7 (2013-11-06) * Minor bug fixes. 0.9.9.6 (2013-10-31) * Minor bug fixes. 0.9.9.5 (2013-10-12) * Minor bug fixes. 0.9.9.4 (2013-09-24) * Minor bug fixes. * The package now depends on vimcom.plus. * The support to GNU Screen, VimShell and Conque Shell was dropped. The screen plugin no longer is used. * The delete command was removed from the Object Browser. * New options: vimrplugin_vsplit, vimrplugin_rconsole_height and vimrplugin_rconsole_width. * New option: vimrplugin_restart. * Show elements of S4 objects in the Object Browser. 0.9.9.3 (2013-04-11) * Minor bug fixes. * New option: vimrplugin_source. 0.9.9.2 (2013-02-01) * Update vimcom version requirement to 0.9-7 (fix incompatibility with tcltk package on Unix). * Change the default value of vimrplugin_rmhidden to 0. * New option for Windows: vimrplugin_Rterm. * New simpler un/comment commands: <LocalLeader>xc and <LocalLeader>xu. * Remove options vimrplugin_nosingler and vimrplugin_by_vim_instance. 0.9.9.1 (2012-12-11) * Enable mouse on Tmux again. 0.9.9 (2012-12-03) * New commands: :Rinsert and :Rformat. * Automatically update the Object Browser in GVim. * On MS Windows, don't raise the R Console before sending CTRL-V to it. * Search for vimcom in both IPv4 and IPv6 ports (thanks to Zé Loff for writing the patch). 0.9.8 (2012-10-13) * Open PDF automatically after processing Rnoweb file if vimrplugin_openpdf = 1 (thanks to Tomaz Ficko for suggesting the feature). Open it quietly if vimrplugin_openpdf_quietly = 1. Open it manually with \op. * Open HTML automatically after processing either Rmd or Rrst file if vimrplugin_openhtml = 1. Generate strict rst code if vimrplugin_strict_rst = 1. * Remove option vimrplugin_knitargs. * Start last R if there is more than one installed on Windows (thanks to Alex Zvoleff for reporting the bug and writing the patch). * Alex Zvoleff added support to Rrst file type. * michelk added support to Rmd file type. * For Rnoweb, Rmd and Rrst file types, CTRL-X CTRL-A completes knitr chunk options if the cursor is inside the chunk header. * New option: vimrplugin_rmhidden. * New option: vimrplugin_insert_mode_cmds (thanks to Charles R. Hogg III). * New command :RAddLibToList to add the objects of specific libraries to omnicompletion. * Thanks to genrich and NagatoPain for other bug fixes and code improvements. * New option: vimrplugin_assign_map. The option vimrplugin_underscore was renamed to vimrplugin_assign 0.9.7 (2012-05-04) * Use the R package vimcom: - Automatic update of the Object Browser when running R in a Tmux session. - The following options are now set on the vimcom R package and no longer in the Vim-R-plugin: allnames, open_df, and open_list. - New command in normal and visual modes when on the Object Browser: "d" deletes objects and detach libraries. New option: vimrplugin_ob_sleep. * New option, vimrplugin_external_ob, to open the Object Browser in a Tmux pane in the external terminal running R. * New command :Rhelp (thanks for Nir Atias for suggesting the new feature). * Remove the command :RUpdateObjListAll because Vim may not load the syntax file if it is too big. * Add support to knitr package. * New command :RSourceDir. * New key bindings \r<Left> and \r<Right>. * Correctly send selected blocks. 0.9.6 (2011-12-13) * Fix path to R source() command on Windows. * New default value of vimrplugin_vimpager = "tab". * New default value of vimrplugin_objbr_place = "editor,right" * Autocompletion of function arguments with <C-X><C-A>. 0.9.5 (2011-12-07) * Changed the way that blocks are sent to R. * Added "terminal" to the list of known terminal emulators (thanks for "i5m" for the patch). * Use Tmux to start the Object Browser beside the R console if vimrplugin_objbr_place =~ "console". * The file r-plugin/omniList was renamed to r-plugin/omnils because its field separator changed. 111114 (2011-11-14) * Changed key binding for commenting/uncommenting code from \cc to \xx. * Added function SendChunkToR() and its corresponding key bindings: \cc, \ce, \cd and \ca (thanks to Xavier Fernández i Marín for suggesting the feature). * New option (vimrplugin_ca_ck) was created to fix bug reported by Xavier Fernández i Marín: spurious ^A^K being added to lines sent to R. * Don't blink the menu and toolbar buttons when doing omni completion. * Use Tmux to run R in an external terminal emulator. 111014 (2011-10-14) * Fixed spell check bug in R documentation files (.Rd). * Fixed beep bug when sending commands to R. * New option: vimrplugin_notmuxconf. * Fixed bug when starting tmux before vim: the environment variable VIMRPLUGIN_TMPDIR was not being set. Thanks to Michel Lang for reporting the bug and helping to track its source, and thanks to Eric Dewoestine for explaining how to fix the bug. * Fixed bug in code indentation after unbalanced brackets and parenthesis when r_indent_align_args = 0 (thanks to Chris Neff and Peng Yu for reporting the bugs). * Really make the use of AppleScript the default on OS X (thanks for Jason for reporting the bug). 110805 (2011-08-05) * New option: vimrplugin_tmux. * Set Tmux as the default instead of either GNU Screen or Conque Shell. * Document Tmux as the preferred way of running the plugin on Linux. * Vim-LaTeX-suite plugin can be used with Rnoweb files without any additional configuration. The necessary code was added to the ftplugin/rnoweb.vim. * Added count argument to normal mode commands gn and gN (thanks to Ivan Bezerra for the suggestion). 110614 (2011-06-14) * When doing the command \rh, the plugin tries to show the help for the method corresponding to the class of the object passed as argument to the function. The same with \rp (thanks to Thomas Scheike for suggesting the feature). * Removed script rpager.sh. * Added script global_r_plugin.vim to allow the use of the plugin with any file type. 110222 (2011-02-22) * Added syntax/rhelp.vim. * New command for rnoweb files: BibTeX current file (\sb). * New commands for the Object Browser: open visible lists (\r=) and close visible lists (\r-). * Reorganization of the GUI menu. 110208 (2011-02-08) * Fixed bug in "else if" constructions (thanks to Dan Kelley for reporting the bug). * Support for commenting/uncommenting lines. 110203 (2011-02-03) * Fixed bug in :RUpdateObjList when the function arguments included S4 objects (thanks to Gerhard Schoefl for reporting the bug). * Improvements in indentation of R code (thanks to Dan Kelley for finding and reporting indentation bugs and testing many versions of indent/r.vim). * New indentation options: r_indent_align_args, r_indent_ess_comments, r_indent_comment_column, and r_indent_ess_compatible. * New file: indent/rhelp.vim. 110117 (2011-01-17) * Fixed indentation bug in Rnoweb files (thanks to Dan Kelley for reporting the bug). 101217 (2010-12-17) * Renamed the function SendCmdToScreen to SendCmdToR. * Clear the current line in the R console before sending a new line. * Always starts R on the script's directory. * Don't send "^@" as part of a paragraph in rnoweb files (thanks to Fabio
Correa for reporting the bug).
* More useful warning message when PyWin32 isn't installed.
* Initial support to AppleScript on Mac OS X (thanks to Vincent Nijs for
writing and testing the code).

101121 (2010-11-21)
* Fix for when whoami returns domain name on Windows (thanks to "Si" for
fixing the bug).

101118 (2010-11-18)
* New command:  :RUpdateObjListAll.
* New option: vimrplugin_allnames.
* Allow the use of Python 3.1 on Windows.
* Minor improvements in indentation of R code.
* The file r-plugin/omni_list was renamed to r-plugin/omniList because its
field separator changed to ";".
* Fixed bug that was causing ^H to be exhibited in the R documentation in
some systems. (Thanks to Helge Liebert for reporting the problem).

101107 (2010-11-07)
* New feature: complete chunk block when '<' is pressed in rnoweb files.
* New option: vimrplugin_rnowebchunk.
* New key bindings in Normal mode for Rnoweb files: gn (go to next R code
chunk) and gN (go to previous R code chunk).
* New command:  :RBuildTags.
* Added fold capability to syntax/r.vim.
* Improved indentation of rnoweb files: thanks to Johannes Tanzler for
writing the tex.vim indent script and for permitting its inclusion in the
Vim-R-plugin.
* R CMD BATCH now is called with --no-restore --no-save (key binding \ro).
* The file r-plugin/omnilist now has an additional field and was renamed as
omni_list.
* Use 64 bit version of R by default on Windows if the directory bin/x64
exists.
* New Windows only option: vimrplugin_i386.

101025 (2010-10-25)
* New option: vimrplugin_routmorecolors.
* Fixed bug in the Object Browser when a data.frame or list had just one
element (thanks to Jan Larres for reporting the bug).
* Do not copy omnilist and functions.vim to ~/.vim/r-plugin if the directory
where the plugin is installed is writable (thanks to Jan Larres for the
suggestion).

101023 (2010-10-23)
* New options: vimrplugin_objbr_place and vimrplugin_objbr_w.
* New default value: vimrplugin_vimpager = "vertical"
* The R help can now be seen in a Vim buffer on MS Windows.
* Fix width of help text when R version >= 2.12.0.
* Implemented actions in the Object Browser: summary, print, etc...
* Browse libraries objects in Object Browser.

101016 (2010-10-16)
* Minor bug fixes in the Object Browser.

101015 (2010-10-15)
* New feature: Object Browser.
* Conque Shell will be used if installed unless explicitly told otherwise in
the vimrc.
* New valid value for vimrplugin_vimpager: "tabnew"

100923 (2010-09-23)
* New option: vimrplugin_vimpager.
* Do not let Vim translate "File" in R menu.
* Fixed bug when the option vimrplugin_r_path was used (thanks to Asis Hallab
for reporting the bug),
* Fixed bug (E687) when user created custom key binding (thanks to Philippe
Glaziou for reporting the bug).

100917 (2010-09-17)
* Changed the use of vimrplugin_r_path: now the option includes only the
directory part of the path.
* Initial support to Conque Shell plugin. Thanks to "il_principe orange" for
suggesting the use of Conque Shell, "ZyX-I" for writing the initial code to
use Conque Shell, and Nico Raffo for writing the plugin and additional code
to integrate both plugins.
* New options: vimrplugin_conqueplugin and vimrplugin_conquevsplit.
* New option: vimrplugin_r_args.
* Fixed bug when the plugin was installed in a directory other than ~/.vim
* Initial support for Vim-R communication on Windows using Python.

100825 (2010-08-25)
* Minor improvements in syntax highlighting.
* New option: vimrplugin_buildwait.
* New option: vimrplugin_r_path (thanks to Asis Hallab).

100803 (2010-08-03)
* Fixed bug in .Rsource name making in some systems.

100801 (2010-08-01)
* Dropped options vimrplugin_hstart and vimrplugin_browser_time.
* Minor bug fixes.

100730 (2010-07-30)
* Added menu item and key binding for run "R CMD BATCH" and open the
resulting ".Rout" file.
* Fixed bug when more than one Vim instance used the same file to send
multiple lines of code to R (thanks to Bart for reporting the bug).

100728 (2010-07-28)
* Adapted the plugin to allow the creation of a Debian package.

100719 (2010-07-19)
* Added options vimrplugin_listmethods and vimrplugin_specialplot.
* Improved syntax highlight of R batch output (.Rout files).
* No longer uses the external programs grep, awk and sed to build the
additional syntax file containing the list of functions.

100710 (2010-07-10)
* Fixed :RUpdateObjList bug when list had length 0.

100707 (2010-07-07)
* Fixed 'E329: No menu "R"' when more than one file were loaded simultaneously
by calling vim with either -p or -o parameters. Thanks to Peng Yu for
reporting the bug.
* Correctly recognize a newly created file with extension ".R" as an R script
file.

100521 (2010-05-12)
* Replaced "-t" with "--title" to make xfce4-terminal work again.

100512 (2010-05-12)
* Thanks to Tortonesi Mauro who wrote a patch to make the plugin work with
pathogen.vim.
* Added simple syntax highlight for .Rout files.
* Increased the time limit of RUpdateObjList to two minutes.
* Improvement in the syntax highlight based on code written by Zhuojun Chen.
* Thanks to Scott Kostyshak who helped to improve the documentation.
* Iago Mosqueira suggested that the plugin should be able to run one R process
for each Vim instance, and his suggestion was implemented with the option
vimrplugin_by_vim_instance.

091223 (2009-12-23)
* Syntax highlight for R functions.
* Added "info" field to omni completion (thanks to Ben Kujala for writing the
original code).

091016 (2009-10-16)
* The plugin now can run together with screen.vim, thanks to Eric Van
Dewoestine, the author of screen.vim, who added script integration to
screen.vim.
* Andy Choens has made many improvements on the documentation.
* Added the possibility of custom key binding creation to call any R function
with the word under cursor as argument.
* The key bindings related with Sweave are activated even if the file type is
not rnoweb.
* Replaced <Leader> with <LocalLeader> in the key bindings.

091004 (2009-10-04)
* Jose Claudio Faria has begun to work in the project as co-author.
* Some ideas from Tinn-R project were ported to the plugin.
* The main menu has new items and the toolbar new icons.
* Documentation improvements.

090828 (2009-08-28)
* Faster startup.
* Better support for Rnoweb files: the cursor goes to '^<<' if the sent line
is '^@\$'.

090811 (2009-08-12)
* Now use screen instead of funnel.pl. The bugs and limitations related with
funnel.pl are solved.
* Deleted key binding for R-devel.
* Automatically detect available terminal emulators and choose one of them.
* By default, no longer calls help.start() the first time that CTRL-H is
pressed.

090810 (2009-08-10)
* Added R icons for some terminal emulators.
* Removed the script open-gvim-here. You may use Vim's option autochdir.
* Improved indentation script.
* Changed key binding from Shift-Enter, which doesn't work in any terminal, to
Alt-Enter, which at least works in xterm.

090610 (2009-06-11)
* The options expandtab, shiftwidth and tabstop are no longer set by the plugin.
* Better word detection before calling R's help().
* Fixed bug in underscore replacement.
* Fixed small bug in code indentation.
* Added two new plugin options: no underscore replacement and fixed name for
the pipe file instead of random one.

090523 (2009-05-23)
* Key bindings now are customizable.
* Default key binding for calling R's args() changed to Shift-F1.
* New R script rargs.R gives better results for generic functions than R's
args() called directly.

090519 (2009-05-20)
* Don't send large blocks of code to R to avoid xterm freezing.
* Automatically call help.start() after CTRL-H is pressed for the first time,
and wait 4 seconds for the browser start before calling R's help(). These
features are customizable.
* Fixed tags file script.

090516 (2009-05-16)