R-Vim-runtime icon indicating copy to clipboard operation
R-Vim-runtime copied to clipboard

Add switch for recommended format options

Open axelf4 opened this issue 5 years ago • 1 comments
trafficstars

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.

axelf4 avatar Nov 30 '19 17:11 axelf4

@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.

jalvesaq avatar Dec 01 '19 00:12 jalvesaq

Friendly ping :)

axelf4 avatar Sep 02 '23 17:09 axelf4

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.

jalvesaq avatar Sep 11 '23 01:09 jalvesaq

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.

axelf4 avatar Sep 11 '23 19:09 axelf4