Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colour coding comments in RStudio

Tags:

rstudio

I am a very visual person and would like a distinction between #a command I commented out and a ##message for myself or co-worker on the file. I had a look around if RStudio supports different kinds of comments but it doesn't seem like it. Does anyone know a way around this?

Thanks!

like image 864
Bipa Avatar asked Aug 10 '16 22:08

Bipa


People also ask

How do you change the color of code in R?

In RStudio under tools -> Options -> Appearance you can change the color of your R console and also change the fonts.

Can you highlight code in RStudio?

If you go to Tools > Global Options > Appearance, you can choose different themes, which can effect how RStudio highlight pieces of code.


2 Answers

You can use

#'* some colorfull comment *

to comment in color.

-R version 3.6.3 -RStudio ‘1.2.5033 "Orange Blossom"

like image 71
user12256545 Avatar answered Sep 25 '22 13:09

user12256545


As noted, this isn't an R question but an RStudio question (I've edited as such). RStudio doesn't currently have user-modifiable themes, just the built-in ones. That is apparently an in-development feature.

In the meantime, apparently you can hack away at the .css file that defines a theme to perhaps add what you're after - https://support.rstudio.com/hc/en-us/community/posts/200644098-appearance-Editor-theme

Otherwise, you could use a different editor that allows you to specify your desired syntax highlighting.

like image 29
Jonathan Carroll Avatar answered Sep 26 '22 13:09

Jonathan Carroll