The package:snippets
enables you to (add/remove/read) snippets programmatically.
Usage: (assigning a keyboard shortcut is recommended, see: "Combining with keyboard shortcuts:")
Via code:
addSnippet("test", "print('This is long code i dont want to retype everytime')")
readSnippet("test")
snippet test
print('This is long code i dont want to retype everytime')
removeSnippet("test")
Installation
For latest development version:
devtools::install_github('Timag/snippets')
Combining with keyboard shortcuts:
(Usual way so far is to access RStudio snippets via: RStudio - Tools - Global Options - Code - Edit Snippets...)
Open issues:
Snippets seem only to be updated if r.snippets
file will opened afterwards (in RStudio). As a workaround i call
file.edit("~/.R/snippets/r.snippets")
at the end of the functions.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.