# require(stringr)
# require(magrittr)
#
# get_indentation = function( pos = NULL ){
# if (is.null( pos ))
# pos = rstudioapi::getActiveDocumentContext()$selection[[ 1 ]]$range
# rng = rstudioapi::document_range( c(pos$start[ 1 ], 1), c(pos$start[ 1 ], Inf) )
# previous_position = rstudioapi::getActiveDocumentContext()
# rstudioapi::setSelectionRanges( rng )
# indentation = rstudioapi::getActiveDocumentContext()$selection[[ 1 ]]$text
# indentation = stringr::str_extract( indentation, "^[:blank:]*" )
# rstudioapi::setCursorPosition( pos )
# indentation
# }
insert_pipe = function(){
# rstudioapi::insertText( rstudioapi::getActiveDocumentContext()$selection[[ 1 ]]$range,
# paste0( "%>%\n",
# get_indentation(),
# "\t") )
rstudioapi::insertText( '%>%' )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.