Snippets files are not searchable as opened in RStudio, and as I have lots of snippets I often need to search through them, particularly my lesser used snippets. Is there an efficient way to search snippets within RStudio?
Since all snippets are saved by default in ~/.R/snippets, they can be viewed by executing
ls ~/.R/snippets
I then wrote this convenience function so I can open and search my snippets in RStudio:
snippet_search <- function(language=c('r', 'sql', 'python', 'markdown'), dir = '~/.R/snippets'){
file <- glue::glue('{dir}/{language}.snippets')
file.edit(file)
}
snippet_search('r')