ESS set tab whitespace level?
Asked Answered
H

1

8

I thought you set the level of indentation with

(setq ess-indent-level 2)

But I keep getting 4 spaces. For instance, I used to write

foo <- function(x)
  x + 2

But now, ESS puts the second line 4 spaces away from the left margin

foo <- function(x)
    x + 2

Has something changed between the new and old versions? I used to use ESS 5.11 and just upgraded to 13.05(!).

Hartal answered 12/7, 2013 at 6:43 Comment(0)
H
18

Yes, many things have changed since 5.11. The default indentation style now follows R standard 4 spaces for indentation. Choose the best style from ess-style-alist and set ess-default-style:

(setq ess-default-style 'OWN)

To return to old default and make the settings honor individual variables like ess-indent-level add this:

(setq ess-default-style 'DEFAULT)

Somewhat confusing, the name DEFAULT comes from default-value, that is the style is build from the default settings of indentation variables like ess-indent-level, ess-arg-function-offset, ess-brace-offset etc.

FWIW, you can change indentation syles interactively with C-c . (C-c C-e C-s as of 2014).

Hanhhank answered 12/7, 2013 at 8:40 Comment(3)
as of 2019 you would use (setq ess-style 'Rstudio)Pharynx
Now it is also possible to customize ess-default-style.Helenahelene
@Pharynx Should that be (setq ess-style 'RStudio) (i.e., capital 'S')?Centiliter

© 2022 - 2024 — McMap. All rights reserved.