23

Is there anyway to change the color schemes for Rstudio? It comes with 6 or 7 default, pre-packaged themes. I'm wondering if theres anyway for me to customize these or some add-in that lets me make my own.

runningbirds
  • 6,235
  • 13
  • 55
  • 94
  • In new preview version there are more color schemes - http://www.rstudio.com/products/rstudio/download/preview/ – Jot eN Feb 19 '15 at 22:24
  • As of the current [RStudio Preview](https://www.rstudio.com/products/rstudio/download/preview/) release (1.2.1013-1), custom, user-defined themes are (finally!) possible. For details, see the issue [Allow for the use of user-defined editor themes #1571](https://github.com/rstudio/rstudio/issues/1571) and the PR [Adding UI features to support adding and removing custom themes. #3171](https://github.com/rstudio/rstudio/pull/3171). – egnha Sep 29 '18 at 06:50

6 Answers6

21

There's a much faster way to deal with this and 100% doable.

  1. Open RStudio with your favourite Editor theme and open an .R script

  2. Inspect the Source layout (Right-click>Inspect) and Ctrl + f an unique class selector such as .ace_comment. In the matched CSS rules box in the side pane copy an attribute as unique as possible (i.e. color: #0088FF; I use Cobalt theme).

  3. Go to RStudio's install path and dive into /www/rstudio/. As jorloff rightly said, you'll find a bunch of files like this: VERYUGLYNAME.cache.css. Open all of them with your favourite text editor as administrator.

  4. Find in files: Ctrl+ Shift + f (in sublime text) and type the unique attribute value you previously chosed. BOOM, there you have it.

  5. Now delight yourself editing your crazy style, but remember to back it up first!

As Jonathan said, RStudio's editor is based on ACE themes, so all clases have the ace_ prefix. Take your time inspecting and understanding the editor hierarchy. I recommend you to take some time inspecting the html code to understand its structure. The editor starts in id="rstudio_source_text_editor"

I'm using RStudio Desktop 0.99.892 Release for Windows

Carlos Araya
  • 861
  • 2
  • 10
  • 17
  • 4
    You made my day ! Still simpler: when inspecting, have a look at the end of the source, and you'll get the name of the css file, in a `link` tag. No need to search. –  Jul 19 '16 at 15:01
  • OK, I've found the file. Now I would like to change something but I can't find the keyword. When you select any word on the text every occurrence of that word is highlighted but very slightly, it's almost impossible to detect it. I would like to change the color of that matches. – skan Jan 21 '17 at 13:39
  • Step 2-4 is actually much easier (now): within the inspector go to the Resources tab - Frames - some ip - Stylesheets (this shows you which .css file it is) – sedsiv Jan 04 '18 at 14:01
9

Unfortunately there's not currently a way to do this. RStudio's themes are based on themes for the ACE text editor, which it embeds. It can generate internal themes based on ACE themes, so if you have an ACE theme you'd really like to use with RStudio, you can submit a pull request to RStudio (which is hosted on GitHub) for consideration.

Jonathan
  • 8,497
  • 41
  • 35
3

i am new to R Studio and i would like to share how i was able to customize the color scheme of R Studio:

How to change the color of comments in Rstudio

  1. Rstudio Pane Appearance > Set editor theme to monokai
  2. Right click on editor pane > Inspect > find the specific file name (i.e. 838C7F60FB885BB7E5EED7F698E453B9.cache.css)
  3. Open drive C > open Progam Files folder > open Rstudio folder
  4. Open www folder > rstudio folder > find the 838C7F60FB885BB7E5EED7F698E453B9.cache.css (name of the theme you want to change)
  5. Make a backup copy of the original
  6. Change .ace_comment {color: #75715E} to .ace_comment {color: #F92672} > save to another location (don't change file name)
  7. Copy the recently saved code and paste it in rstudio folder (step 4) > replace the original 838C7F60FB885BB7E5EED7F698E453B9.cache.css file with the modified 838C7F60FB885BB7E5EED7F698E453B9.cache.csss file
  8. Click continue
  9. Quit Rstudio
  10. Open Rstudio
  11. Check if the color of comment has changed from nightsand(#75715E) to orchid(#F92672)
palangga
  • 31
  • 2
  • 2
    OK, I've found the file. Now I would like to change something but I can't find the keyword. When you select any word on the text every occurrence of that word is highlighted but very slightly, it's almost impossible to detect it. I would like to change the color of that matches – skan Jan 21 '17 at 13:39
3

Not able to add a comment. Having read all the replies and comments, and tried a few things seems interesting. Here is what works for me.

I am using RStudio 1.0.136. According to all the posts, right click on the Editor -> Inspect. The Web Inspector comes up and shows the Elements tab. Then click the Sources tab, select "Only enable for this session", click "Enable Debugging" button. You will see the code for the theme xxxxxxx.cache.css file. If nothing in the editor, try the left top "Show Navigator" button right under the "Elements" menu. Select the .css file in the list and it should open.

My line number seems dim. So changed color: #222; to color: #818222; in this section: (forgive my bad color sense). And you can see the color change right away! How amazing!

.ace_gutter {
  background-color: #3d3d3d;
  background-image: -moz-linear-gradient(left, #3D3D3D, #333);
  background-image: -ms-linear-gradient(left, #3D3D3D, #333);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#3D3D3D), to(#333));
  background-image: -webkit-linear-gradient(left, #3D3D3D, #333);
  background-image: -o-linear-gradient(left, #3D3D3D, #333);
  background-image: linear-gradient(left, #3D3D3D, #333);
  background-repeat: repeat-x;
  border-right: 1px solid #4d4d4d;
  text-shadow: 0px 1px 1px #4d4d4d;
  color: #818222;
}

@skan mentioned selected words are too dim. I have the same problem. So here I found it:

.ace_marker-layer .ace_selected-word {
  border-radius: 4px;
  border: 8px solid #ff475d;
  box-shadow: 0 0 4px black;
}

I changed border: 8px solid #ff475d;. It is now very bright, or may be too bright. Anyway, it works. Thanks for every one. And hope this can help.

This is for current session only. Now you know which .css to modify and what you should do, it will be easy to modify the original .css file to keep it permanent.

Bing
  • 1,083
  • 1
  • 10
  • 20
2

I found a hack to do this in RStudio 0.99.879 on the Mac.

In /Applications/RStudio.app/Contents/Resources/www/rstudio/ there are a bunch of files with extension .cache,.css. These are the files holding the themes' formats. Since the names aren't descriptive I had to experiment to find which one went with the theme I wanted to edit.

I wanted to modify the TextMate theme, so here are my steps:

  1. In RStudio Preferences > Appearance set the editor theme to TextMate.
  2. Open an R file in the editor pane. It should have enough code to cover the formatting you want to change, e.g. comments, functions, keywords, lists...
  3. Quit RStudio.
  4. Then repeat the following procedure till you find the right file.
    • Open a .cache.css file.
    • Edit the .ace_comment to be yellow, i.e.
      • .ace_comment {color: rgb(255,255,0);}
    • Open RStudio and see if the comments are yellow.
  5. Once I had the TextMate .cache.css file I had to play with it by editing the file, quitting and reopening RStudio in order to figure out which css properties controlled the formats I wanted to change.
Rao
  • 20,781
  • 11
  • 57
  • 77
jorloff
  • 21
  • 1
  • 1
    OK, I've found the file. Now I would like to change something but I can't find the keyword. When you select any word on the text every occurrence of that word is highlighted but very slightly, it's almost impossible to detect it. I would like to change the color of that matches – skan Jan 21 '17 at 13:39
1

For skan & others, useful intel can be had in the links posted elsewhere in the thread; on linux I found (backing up & then) opening your nearest-favourite theme in /usr/lib/rstudio/resources/themes/ as admin and editing colours to suit worked great. Chaos theme, for example, lacks the highlighting element whereby selecting a group of characters will highlight other instances of those in the file (e.g. an object). Textmate theme has this so I copied the block & changed the colour accordingly. If anyone's interested, at line55,

.ace_marker-layer .ace_selected-word {
  background: #141414;
  border: 1px solid #FF0000;
}

If you make a backup of your file (in linux, /usr/lib/rstudio/resources/themes/chaos.rstheme), RStudio may magically switch to the backup, meaning any changes you make don't get applied. Evidently it doesn't populate the themes list based on filenames in the folder.

Also, colours given as #123 will accept #123456 HEX. I'm not sure what the #123 format is.

dez93_2000
  • 1,730
  • 2
  • 23
  • 34