简体   繁体   中英

How can I search my snippets files in RStudio?

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM