Feature request: multi-color commenting

Comments have multiple uses in R, and they serve different purposes. I suggest that Rstudio should be able to easily recognize those different purposes (which it already can do; see below) and also use differently-colored font to emphasize these differences.

Here are three different ways I use comments (or, the pound symbol #):

  1. To comment out bad code
    # x <- deprecatedFunction()
  2. To leave purposeful notes for good documentation
    ## This converts the matrix into a data.frame
  3. To document functions in my package, a la roxygen2 (special case)
    #' @param data A data.frame

In particular, 1. and 2. have very different uses: I want to remove all the 1.'s and keep all the 2.'s. And when I'm visually scanning a program I'm writing, it would be great if it was easy to tell what comments are the helpful type 2.'s and which comments are the type 1.'s.

Practically, Rstudio could perhaps implement this by associating different colors when the comments are of each of these three types:

  1. # for the first type, the least important
  2. #" with a double-quotation symbol to denote a purposeful, important comment
  3. #' with a single-quotation symbol to denote a roxygen2-type function documentation

Then the RStudio IDE might be able to tell the difference between these three symbols and print to the screen with these three colors:

  1. grey
  2. blue
  3. green

This would require that the color schemes have extra values for the new types of comments; but I would imagine this is not the tricky part. Again, this would help to improve readability in RStudio. Of course, if there are other IDE's that do this better in a different manner than what I'm proposing, I'm all ears!

9 Likes

I raised that earlier but your's is a much more eloquent version. Good luck

Yes please! The color optoins for the IDE could use a lot of work.

If anybody wants to submit this as a feature request, here's your starting point!

RStudio IDE Guide: Writing Good Feature Requests