I've been frustrated for a long time that sometimes comments in R inside Emacs with ESS get indented incorrectly. Turns out I was just using it wrong. From the ESS manual:
By default, comments beginning with###
are aligned to the beginning of the line. Comments beginning with##
are aligned to the current level of indentation for the block containing the comment. Finally, comments beginning with#
are aligned to a column on the right (the 40th column by default, but this value is controlled by the variablecomment-column
) or just after the expression on the line containing the comment if it extends beyond the indentation column.
In other words,
# end of line
## indentation level
### beginning of line
for (i in 1:100) {
# end of line
## indentation level
### beginning of line
print(i)
}
Home |
Back to blog
This work is licensed under CC BY-NC 4.0