Any way to change colors in Rstudio to something other than default options?

后端 未结 6 428
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 11:46

Is there anyway to change the color schemes for Rstudio? It comes with 6 or 7 default, pre-packaged

相关标签:
6条回答
  • 2021-01-30 12:11

    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.

    0 讨论(0)
  • 2021-01-30 12:20

    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

    0 讨论(0)
  • 2021-01-30 12:21

    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)
    0 讨论(0)
  • 2021-01-30 12:24

    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.

    0 讨论(0)
  • 2021-01-30 12:24

    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.

    0 讨论(0)
  • 2021-01-30 12:27

    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.
    0 讨论(0)
提交回复
热议问题