R-Vim-runtime
R-Vim-runtime copied to clipboard
Add switch for recommended format options
Adds the option g:r_recommended_style to set Vim indentation settings
to conform to the R style conventions (i.e. use 2 spaces for indent), as
also done by rust.vim.
@jranke, what do you think? If the proposed change makes Vim closer to R recommended style, shouldn't the new behavior be the default?
@axelf4, it seems that you forgot to include the deletion of b:r_set_style in the b:undo_ftplugin variable.
Friendly ping :)
According to Paul E. Johnson, the default R indentation is four spaces (Rstyle.pdf, section 3.1). He has found this information in the R documentation itself:
The R Core Team recommends to use a basic indentation of 4 for R and C (and most likely also Perl) code, and 2 for documentation in Rd format. (R Internals, section "9 R coding standards").
This is also the indentation used when a function is printed in the R Console.
I was only looking at the tidyverse; Google's; the Advanced R book; and Henrik Bengtsson's style guides, the top search results at the time, before concluding that 2 spaces was the way to go. Should've known better than to assume that a language like R at least had the common decency of having a prevalent formatting style.