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

______________________________________________
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Reply via email to