Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for addin_reshape #18

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading