0

Is there a way to jump between beginning and end of a markdown based code chunk?

I know I can use / to search for the code chunk markers (e.g. /```) but I was hoping there was a way to do like we can do with % for open/closing parenthesis or I understand there is some tag functionality too - but not sure if it can be adopted for the below use case.

```{r} (<< I want to be able to jump between here and ...)

Some code text

Some more code text

``` (<< here)
4
  • Those things are called "fenced code blocks". Anyway, did you even consider taking a look at :help %? It has all the needed pointers.
    – romainl
    Jan 11 at 17:02
  • Why would I consider looking at the specific % help page? There are 100s of help page topics — how would I know to start there? It’s unclear if your comment is serious or if you’re trying at all to be helpful. Jan 12 at 20:41
  • Because you essentially want % for fenced code blocks. From there, the first logical step would be to see if % can be tweaked some way or another and… where else to look than :help %?
    – romainl
    Jan 12 at 20:44
  • I gave % as example of a functionality to mimic. I also referenced \. As you know from your rating there are many ways to do things in vim including remapping key bindings. Furthermore different users have different level of familiarity with vim and vims functionality. Jan 12 at 20:46

1 Answer 1

1

I would use the matchit plugin that comes in modern version of Vim.

You can install it with:

packadd! matchit

Or from GitHub and vim-plug with:

Plug 'chrisbra/matchit'

To match the ``` fence you have to add ```.\+:``` to b:match_words

You can do that by adding the following code into: ~/.vim/after/ftplugin/markdown.vim

if match(b:match_words, '```') == -1
  let b:match_words = b:match_words . ',```.\+:```'
endif
2
  • Thank you for the thoughtful and straightforward answer. Jan 12 at 20:47
  • 1
    Thanks for the feedback. I'm glad I could help you :-) Jan 12 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.