vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Smart keyboard shortcut for inserting block

Open njspix opened this issue 10 months ago • 0 comments

Is your feature request related to a problem? Please describe. When inserting an R code block in a .rmd notebook using the keyboard shortcut cmd + option + i, the behavior is not 'smart' like it is in Rstudio - it 'nests' blocks rather than 'splitting' them.

```{r}
# some code here

# put cursor here

# more code here
```

For example, if you place your cursor at the location noted in the block above, then press cmd + option + i, you get:

```{r}
# some code here

```{r}
```

# more code here
```

This 'nested' syntax is undefined. Instead, it should produce:

```{r}
# some code here

```

```{r}

# more code here
```

I think this can be accomplished by setting a 'context key' in the extension whenever the cursor is in a block, then creating two keybindings, one for inside a block, another for outside a block.

njspix avatar Apr 01 '25 13:04 njspix