[ESS] rstudio-outline

Stephen Eglen @je30 @end|ng |rom c@m@@c@uk
Mon Nov 16 23:43:14 CET 2020


Here's a little snippet I wrote to generate comments of the form



## Create some journal names ###########################################

These are recognised by rstudio (among others) as section delimeters.

https://support.rstudio.com/hc/en-us/articles/200484568-Code-Folding-and-Sections




You start with a comment like:

## Create some journal names 

(with a trailing space) and then with point anywhere on that line,
M-x rstudio-outline will add the trailing #.

Or, if you start with a long header like:

## Create some very long journal names ###########################################

so that the comment is over 72 chars, it will trim it down to 72 chars

## Create some very long journal names #################################


Code:

(defun rstudio-outline ()
  "Add trailing #s up to column 72 to make an rstudio outline.
If you already have more than 72 chars on a line, delete the excess chars."
  (interactive)
  (save-excursion
    (end-of-line)
    (while (< (current-column) 72)
      (insert "#"))
    (while (> (current-column) 72)
      (delete-char -1))))



Stephen



More information about the ESS-help mailing list