boB Rudis
5 years ago
6 changed files with 47 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||||
|
#' Path Split |
||||
|
#' |
||||
|
#' @export |
||||
|
pathSplit <- function() { |
||||
|
|
||||
|
ctx <- rstudioapi::getActiveDocumentContext() |
||||
|
|
||||
|
print(str(ctx$selection)) |
||||
|
|
||||
|
if (!is.null(ctx)) { |
||||
|
|
||||
|
if (ctx$selection[[1]]$text != "") { |
||||
|
|
||||
|
found <- stri_match_first_regex(ctx$selection[[1]]$text, '"([^"]*)"') |
||||
|
|
||||
|
repl <- paste0(sprintf('"%s"', unlist(fs::path_split(found[2]))), collapse = ", ") |
||||
|
|
||||
|
rstudioapi::modifyRange( |
||||
|
ctx$selection[[1]]$range, |
||||
|
stri_replace_first_fixed(ctx$selection[[1]]$text, found[1], repl) |
||||
|
) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/path-split.R |
||||
|
\name{pathSplit} |
||||
|
\alias{pathSplit} |
||||
|
\title{Path Split} |
||||
|
\usage{ |
||||
|
pathSplit() |
||||
|
} |
||||
|
\description{ |
||||
|
Path Split |
||||
|
} |
Loading…
Reference in new issue