Skip to content

Smart keyboard shortcut for inserting block #1594

Open

Description

@njspix

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.

Activity

  1. ThomasSoeiro commented on Sep 23, 2026

    @ThomasSoeiro
    Collaborator

    @njspix You should have shared your keybindings.json, as the shortcut you described is not included out of the box. I guess you’re using the shortcuts from the wiki?

    The described behavior seems expected.

    @eitsupi @Fred-Wu @grantmcdermott Perhaps it can be closed?

  2. eitsupi commented on Sep 23, 2026

    @eitsupi
    Member

    While I don't think it's impossible to implement this functionality, in my opinion, I would recommend using the Quarto extension.
    The traditional Rmd syntax is hacky, and I think Quarto is more robust and has more room to add such functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions