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
Related
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.
Is it possible to replace/overwrite my markdown document in the RPubs?
There is a option of republish once you select the option Knit to HTML for the same file once again. In that, it has option Update Existing. If its selected file gets updated without the URL being changed.
I dont think there is a direct way to update a file. But this is what you can do:
You can delete the file and upload a new one and insert the same slug during the upldoad. If you do this, the url of the file wont change.
I am running Brackets on a macbook pro and when I press cmd+, and try to edit the defaultPreferences.json file, it does not allow me to make any changes to the file (nothing happens when I type). If I restart Brackets I can edit the file, but after closing and re-opening the preferences file, the changes are reverted.
I have tried editing the json file with TextEdit while Brackets is closed, but Brackets still likes to reverse the changes.
I had similar issue , and i did open issue at Bracket's GitHub repository and here is the solution from its developers:-
defaultPreferences.json is a read-only file: take the options you
want to modify and copy them to the brackets.json file on the other
pane. This will override the defaults. You will also see code hints
while typing the values in to brackets.json which will help picking
the correct options.
Now it is also available to install brackets-preferences plugin and edit from there. Once installed go to View -> Preferences in your Brackets interface to edit preferences.
I have installed Brackets with Tern Intelligence.
Inside my file Main.js, I type the following thing
Math.
And press ctrl-enter. I imagine I should see pow,max,etc, show up. What am I missing?
Code hints should appear automatically - no need to press anything. (If you do want to trigger them manually though, it's Ctrl-Space, not Ctrl-Enter).
What's in the rest of your Main.js file? If you make a new, blank JS file does it work? When I type Math. in an empty .js file, I see a list of code hints both while I'm typing Math and the appropriate list of options after typing the .
Also, try using Debug > Reload Without Extensions to make sure you don't have an extension installed that could be causing a problem.
I've spent a couple of days searching the bowels of the internet to find out the answer to my question, so since I can't find the answer I'm throwing it out to the masses...
Within my Qt application I'm able to open a PDF using the OS default viewer thru the following command:
QDesktopServices::openUrl(QUrl("file:////C:help.pdf", QUrl::TolerantMode));
This works fine because all I'm wanting to do is display a help file to a user, but when I try to add a "#page=20" parameter to my URL, the document still only opens to the first page, not page 20. If I cut and paste the command into a browser it jumps correctly.
So -- my questions are:
Would poppler or another viewing tool allow me to jump to a page?
Is there another way with Qt to jump to a page? Or maybe another command to open the file instead of with QDesktopServices?
edit: I tried with QProcess and that doesn't jump to the page either -- not that I expected it to...
Use QProcess with one of the answers from Adobe Reader Command Line Reference :
<path to Adobe Reader> /A "page=100" "<Path To PDF file>"
Yes. evince, for example, takes option --page-index which you can set page number
No. QDesktopServices::openUrl() ends up calling one of helper commands, such as xdg-open or kfmclient, without any arguments.
Of cause, you can always use libpoppler in your app to open your PDFs. Poppler::Document::page() is your friend.
Another solution I was able to work out was to convert my PDF to HTML, create a QWebView, and display the HTML there. I then added an ID attribute to the HTML doc, and when I tacked that ID to my URL it loaded into the widget at the location of the attribute...
scott