I'm having trouble soft wrapping .R source files in the text editor in Rstudio Version 1.4.1717. I have tried to follow advice given online but it dosn't seem to change anything on my screen. It seems it should be fairly simple using the advice here:
Disable horizontal scroll in the Source of RStudio
and here:
wrap code in R Studio text editor
I have tried various things like ticking and unticking "soft wrap R source files check box", selecting all text in the text editor before re-trying, closing and restarting Rstudio etc...but still doesn't seem to work. I'm not sure if I'm missing something really obvious?!
Update: I managed to get it working if I start a new file (File > New File > R script). Please see here:
R studio image
However, this does not seem to work for R scripts that I had already created. The bottom right of the source window, does indeed say "R Script".
Update 2
I managed to get this working if I copy pasted the entire R script to a new file ((File > New File > R script), as opposed to re-saving the current file as a newer version (using File > Save As...")
When I went to save the file, a pop-up box appeared which asked me "Choose Encoding" for which I selected the default. I wonder if the previous file had a different encoding which meant the text wrapping could not work properly? Strangely, much earlier versions of the file did NOT have any problems when when using the wrap text functionality. So it seems that something happened to one of the recent versions that is causing the issue.
Do you remember to click apply before the ok button after checking the box?
You need not restart RStudio to get the change effected.
Related
I´ve updated R on my laptop from version 4.0.3 to version 4.2.0. When I try open some of my old scripts in Rstudio, it shows an empty window. Also when I download some script I have the same problem. It is interesting, that only one script works ok, so there isn´t any problem with installation of R or Rstudio. Could somebody help me? Thanks in advance.
I think this is an encoding issue.
This worked for me (exact same problem with R 4.2.0 in Rstudio on Win11).
"Set the encoding by default to UTF-8:
Click on Tools (2nd option starting by the left on the top menu).
Choose Global Options.
An option box will appear. There choose "code" on the left menu. Under code, choose Savings and change the Default Text Encoding to UTF-8.
Now the files that were open as blank should appear with code."
See: https://github.com/ContinuumIO/anaconda-issues/issues/1609
I've customized a dark theme for Rstudio. The color I've used for comments has odd behavior in .Rmd (R Markdown) documents. It displays nice and bright normally, until I click inside a chunk, then the color dims. It's a small issue, but irritating, and makes the text harder to read. As I scroll down the document, previously dim sections will return to being bright, then return to being dim when I click in the chunk. I have also altered the chunk highlighting for better visibility.
In addition, when selecting themes under Global Options, I need to click on the theme twice for it to display in the example box. For some reason, it seems my system isn't handling the themes as expected.
I'm new to styles/themes/CSS, but I thought there might be an issue with the order my edits were written in.
The edits for the chunk highlighting and comment color are on lines:
101
81
Here is the theme file in question
https://github.com/captaincaed/rstudio/blob/main/vibrant_ink_SB_2.rstheme
Here is a Windows error log (seems to open best in Word, may open in a browser as well)
https://github.com/captaincaed/rstudio/blob/main/Recording_20210119_1453.mht
RStudio
Version 1.4.1103
Windows 10
Thanks in advance!
I like using the RStudio snippets.
I thought it would be great, if i can select code and add it to the snippets by keyboard shortcut.
So i started working on it.
Even if I edit the r.snippets file programmatically, the created snippet seems only to be updated if the r.snippets file will be opened afterwards (in RStudio). As a workaround i call file.edit("~/.R/snippets/r.snippets") at the end of the code.
My question:
Does the file have to be opened or can the changes be recognised by
RStudio in another way as well?
Alternative:
It might be better practise to directly paste the selected code in the r.snippets file for the user(?)
Also asked here:
https://community.rstudio.com/t/rstudio-selected-code-to-snippet-updating-r-snippets-programmatically/20611
I am trying to alter an RStudio Editor Themes so that I can set my own colors. I'm using RStudio version 0.99.473 on Windows 10.
I've reviewed Any way to change colors in Rstudio to something other than default options? which was extremely helpful as well as Editing R Studio them in cashe.css theme file (ACE editor?)
I am trying to identify what the different .ace_ items in the RStudio Editor Theme CSS files (ACE editor code) correspond to. The CSS files are found in /www/rstudio/ within RStudio's install path. An example of the script is found on GitHub for the Tomorrow theme.
In particular, I'm looking to see how to color variables (that I define) differently from functions. For example in x <- rnorm(10,0,10), I'd like x and rnorm to be colored differently. Not sure if that's possible.
For what it's worth, the newest versions of RStudio come with a preference that allow you to ensure that function calls are colored differently from variables -- from RStudio v1.0.44, we have the option
Highlight R function calls
With this option active, function calls will be highlighted differently (for example, with Tomorrow Night Bright):
Hopefully, user-customizable themes will become part of the next RStudio release.
RStudio has a tutorial. Although not specific to your question about coloring variables, I did edit the highlighting of matched brackets in my theme so that they are more visible. Here's how:
Select a theme from this theme editor and save it to your machine as a .tmTheme file. Add the theme in RStudio. RStudio automatically creates an .rstheme file from that. I found the rstheme file in my Users/Eric/Documents/.R/rstudio/themes folder (Windows machine). Open the file in Notepad++ (or your favorite text editor) and find the .ace entry that matches the one you want to change (for me, specifically, .ace_bracket from the RStudio tutorial I mentioned earlier). This will have an rgba value similar to: background-color: rgba(238, 252, 81, 0.8); Note that the last value is the alpha (transparency) value and should be between 0 and 1. The values I used give me a nice bright yellow that is easily seen.
I think you are looking for customising the RStudio theme and I think in that case
You can check out the following link:
This website gives you several options to customize
https://tmtheme-editor.herokuapp.com/#!/editor/theme/Azure
This is how it works
Once you are done customizing download them.
Later you can add the theme in the "add" options while setting a theme in your RStudio
Hope this was helpful
Happy Coding :)
I found (2022) the theme files in
C:\Users\<my user>\AppData\Roaming\RStudio\themes
As the title, i can't find the way to make alignment plugin available with .less file. It's just work on CSS File
I haven't tested this yet, but I have a pretty strong hunch that it might help your case.
Open sublime text, and go to Preferences>Browse Packages
Look for the Alignment plugin folder and enter in it.
Look at the files in there, you will see:
Base File.sublime-settings
CSS.sublime-settings
Javascript.sublime-settings
JSON.sublime-settings
Try your hand at creating a LESS.sublime-settings file in there, copying the contents of another of the settings files, for example, the JSON.sublime-settings contains this:
{ "alignment_chars": ["=", ":"] }
It seems to me, that to enable alignment to work as expected with other filetypes not designed as default with the plugin, one would have to add this settings file to the plugin in order for it to work out.
I am not sure if the file name has to be case sensitive towards the syntax you want align to work with. If you installed the less package, you should see "LESS" shows up in the list as all caps, this is why my guess is to name the file LESS.sublime-settings. You can try different naming if it doesn't go at first...
Open any LESS file in Sublime Text.
Navigate to:
- Preferences
-- Package Settings
--- Alignment
---- Settings-Syntax Specific-User
Alternatively, if you're on a Mac hit Command+Shift+P and start typing 'Alignment' and the option will appear. Once clicked, an empty JSON file will be generated for you: LESS.sublime-settings
As EffectiX mentioned, just type in { "alignment_chars": [":"] } or whatever you want to align on. Save the file. This will work with pretty much any file format if configured correctly.