I'm writing R scripts in RStudio and I use the code folding a lot. I found that you can see the hierarchy of the folding by pressing cmd + shift + O. This is super helpful.
# to my dear love ---------------------------------------------------------
2+2
# yo man ====
x.2 = function (x) {x+2}
### I do love potatoes ####
See the result by pressing cmd + shift + O.
I don't understand how this is working because when I write the code below, I can create a subsection without text but not when there is text in it (using # ====
but not # yo man ====
).
# to my dear love ---------------------------------------------------------
2+2
# ====
# yo man ====
### I do love potatoes ####
x.2 = function (x) {x+2}
data = "here is some data"
See the result by pressing cmd + shift + O.
You can see that under # to my dear love ---------------------------------------------------------
everything under is shifted to the right! This is cool!
- The question is thus, how could it be possible to create a hierarchy of sections that include text in it?
- Is it a peculiar package or Emac that is doing this? How can I create subsections, with text, and see the hierarchy in the cmd + shift + O box?
- How can I down shift a section (going to a higher section (say section 2) to a lower section (section 1), by decreasing the visual hierarchy in the right box?
EDIT
I wanted to add a comment on a simpler way of doing it now (which is similar to regular markdown (beside the ----
at the end); note that the maximum number of levels seems to be 6):
# Description -------------------------------------------------------------
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
# Created by Me!
# Institution
# Created on DATE
# Why:
# Requires:
# NOTES:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
# Abstract ----
# This is a comment
# Introduction ----
## Important math ----
answer = 2 + 2
# Material and methods ----
## Another function in the wall ----
cement = function(brick) {
log(brick)
}
### Subsection 1.1 ----
#### Subsection 1.1.1 ----
##### Subsection 1.1.1.1 ----
###### Subsection 1.1.1.1.1 ----
####### Subsection 1.1.1.1.1.1 ----
# Results ----
answer
cement(exp(1))
# [...] ----
Gives