For R code my current emacs ESS style is C++ which results in
worst <- flights_sml %>%
group_by(year, month, day)
I.e. the continuation is indented 4 spaces after %>%
. I'd like it to be 2 spaces.
How can I do that?
It's not entirely clear what you want. If only want 2 spaces in continued statements such as those after a pipe, the following should work
(setq ess-offset-continued '(straight 2))
So, indentation would still be default of 4 spaces as set in the C++ style, eg. results would look like
worst <- flights_sml %>%
group_by(year, month, day)
f <- function(x) {
x
}
Otherwise, if you always want 2 space offsets
(setq ess-indent-offset 2)
You can customize these variables in your mode hook, eg.
(defun my-R-hook ()
(setq-local ess-style 'C++)
(setq-local ess-offset-continued '(straight 2)))
See the documentation for ess-offset-continued
and ess-style-alist
for further details.