snippet_add: Add a snippet to a .snippets file.

Description Usage Arguments Details Examples

Description

Add a snippet to a .snippets file.

Usage

1

Arguments

name

of the snippet to add

text

text of the snippet to add, as a character vector

language

language of the snippet. Choices are "r", "c_cpp", "html", "css", "java", "javascript", "python", and "sql". Ignored if path is specified.

path

path to .snippets file

Details

Note that a .snippets file for a language may not yet exist. If it does not exist, go to Preferences->Code->Edit Snippets in RStudio, make a trivial change to the language of choice (for example, a new empty line), and click Save. This will create the language file in ~/.R/snippets/<language>.snippets with defaults included.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 

# add a .r snippet
snippet_add("dplyr", "${1:object} <- ${1:object} %>%\n${2:function}")

# update the snippet, adding whitespace
snippet_add("dplyr", "${1:object} <- ${1:object} %>%\n${2:function}")

# add an HTML snippet
snippet_add("copyright", "<span style = 'font-size: 10px'>Copyright 2015</span>", language = "html")


## End(Not run)

dgrtwo/snippr documentation built on May 15, 2019, 7:29 a.m.