Skip to content

Commit

Permalink
Documentation for addin_reshape (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimgar authored Dec 23, 2023
1 parent 840fb6b commit 82d164e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
37 changes: 37 additions & 0 deletions R/reshape-addin.R
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
46 changes: 46 additions & 0 deletions man/addin_reshape.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82d164e

Please sign in to comment.