diff --git a/R/reshape-addin.R b/R/reshape-addin.R index 9fd153d..69ba68f 100644 --- a/R/reshape-addin.R +++ b/R/reshape-addin.R @@ -1,3 +1,40 @@ +#' Reshape expressions longer or wider +#' +#' @description `addin_reshape()` lets you cycle between different shapes of +#' function calls. For instance, reshaping transforms code from wide to long +#' shape and vice versa: +#' ``` +#' list(a, b, c) +#' +#' list( +#' a, +#' b, +#' c +#' ) +#' ``` +#' Note that for function definitions, `addin_reshape()` cycles through two +#' different long shapes. The traditional L form uses more horizontal space +#' whereas the flat form uses less horizontal space and the arguments are +#' always aligned at double indent: +#' ``` +#' foo <- function(a, b, c) { +#' NULL +#' } +#' +#' foo <- function(a, +#' b, +#' c) { +#' NULL +#' } +#' +#' foo <- function( +#' a, +#' b, +#' c +#' ) { +#' NULL +#' } +#' ``` #' @export addin_reshape <- function() { tryCatch( diff --git a/README.md b/README.md index db5ffc8..a06ad6a 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,22 @@ Not yet implemented: - `Alt + 2`: `addin_move_forwards` +## Using in Visual Studio Code + +`addin_reshape` is available for keybinding in VS Code. See [here](https://github.com/REditorSupport/vscode-R/wiki/RStudio-addin-support#enabling-rstudio-addin-support) for instructions on enabling general addin support. + +Once addins are enabled, add the following to `keybindings.json`: + +```json +{ + "key": "Alt+tab", + "command": "r.runCommand", + "description": "Reshape expressions longer or wider", + "when": "editorTextFocus", + "args": "codegrip::addin_reshape()" +} +``` + ## Roadmap - Forward and backward motions. diff --git a/man/addin_reshape.Rd b/man/addin_reshape.Rd new file mode 100644 index 0000000..e6dccca --- /dev/null +++ b/man/addin_reshape.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reshape-addin.R +\name{addin_reshape} +\alias{addin_reshape} +\title{Reshape expressions longer or wider} +\usage{ +addin_reshape() +} +\description{ +\code{addin_reshape()} lets you cycle between different shapes of +function calls. For instance, reshaping transforms code from wide to long +shape and vice versa: + +\if{html}{\out{