Skip to content

runtime/syntax/rmd.vim: code blocks mishighlighted #21328

Closed

Description

@ivankra

Steps to reproduce

.qmd or .Rmd file with a non-executable code block:

text

```sh
code
```

text

Expected behaviour

Highlighting breaks at the code block's terminating ```

Version of Vim

9.2.1116

Environment

all

Logs and stack traces

Activity

  1. ivankra commented on Sep 17, 2026

    @ivankra
    ContributorAuthor

    There's a typo at rmd.vim:137 - missing escape in .+.

    I also suggest fixing the regexp for end= there to highlight code blocks with an indent (e.g. in lists)

    Patch:

    --- a/runtime/syntax/rmd.vim
    +++ b/runtime/syntax/rmd.vim
    @@ -134,7 +134,7 @@ endif
     " Step_3: Highlight code blocks.
     
     syn region rmdCodeBlock matchgroup=rmdCodeDelim start="^\s*```\s*{.*}$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend
    -syn region rmdCodeBlock matchgroup=rmdCodeDelim start="^\s*```.+$" matchgroup=rmdCodeDelim end="^```$" keepend
    +syn region rmdCodeBlock matchgroup=rmdCodeDelim start="^\s*```.\+$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend
     hi link rmdCodeBlock Special
     
     " Now highlight chunks:
  2. chrisbra commented on Sep 29, 2026

    @chrisbra
    Member

    thanks, I include it. Next time please create a PR for the fix.

  3. added a commit that references this issue on Sep 29, 2026
    4505de4
  4. added a commit that references this issue on Sep 30, 2026
    fbe8211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions