R/insert_dashes.R

Defines functions insert_dashes

Documented in insert_dashes

#' Insert dashes.
#'
#' Call this function as an addin to insert dashes to create a comment section
#'
#' @export

insert_dashes <- function(){

  # Get active document context
  context <- rstudioapi::getActiveDocumentContext()

  # Get column of cursor position
  current_col <- context$selection[[1]]$range[[1]][[2]]

  num_dashes <- 80 - current_col + 1

  # Insert dashes
  rstudioapi::insertText(paste0(strrep("-", num_dashes), "\n"))

}
ldanai/dacol documentation built on May 15, 2020, 5:05 p.m.