Determine what the code section does in rstudio

Rstudio has changed the way code is defined. In version 0.99.902, sections of code should have some text behind the hash symbol. But now in version 1.0.136, if there are 5 hashes per line, it will define a new section.

Is there a way to get it back to the old way of defining partitions? This is not a big deal, except that I would mark sections with hashes above and below the name, and now it creates 3x sections.

Old version:

enter image description here

A new version:

enter image description here

+7
r rstudio
source share
2 answers

I don't know if there is a way to restore the previous behavior, but instead you can use + . Alternatively, you can put this in a piece of code (if you haven't already). In the "Settings" section, go to the Code tab, scroll down the page and click the Edit Snippets button. Then add something like the following:

 snippet hd `r "# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ### HEAD ########## # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"` 

Then, when you type hd followed by a tab (actually two tabs, since the first tab displays a few options starting with hd , but hd will be at the top, so you can just double-click the tab) in the R script file, will appear following:

 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ### HEAD ########## # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

Even better, you can create a snippet that takes the title text as an argument:

 snippet hd `r paste("# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "### ", "${1:HEAD}", " ##########\n", "# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", sep="")` 

Then, when you type hd followed by two tabs, the HEAD text will be highlighted, and you can simply enter the text of the actual title.

+2
source share

Unfortunately, this behavior has changed between RStudio v0.98.1091, v0.99.903 and the current version v1.0.136.

In RStudio v0.98.1091 “empty” headers, such as ##### , were recognized as section headers.

This behavior was briefly modified with v0.99.903, so some source code was defined to receive them, which would be recognized as section headers. A number of users were unhappy, as this effectively violated code addition for users who explicitly used standalone ##### blocks to create partitions.

Because of this, the behavior was canceled in RStudio v1.0.136, and now the standalone ##### blocks are again recognized as section headers.

+1
source share

All Articles