Prevent Vim from breaking up inline code blocks in (r)markdown

2017-05-12 12:10:51

I edit R-markdown files a lot, and this entails writing inline code blocks, such as

`r sum(mylongvectorname)`

I usually have my text hard-wrapped at 80 chars, and this causes problems for the inline blocks, since they aren't allowed to split. I found the answer for this question helpful in preventing the split from happening when writing in insert mode.

However, if I want to wrap a paragraph in normal mode with gq, the r inline code is split. Is there any solution that would allow me to wrap the paragraph by gq and

a) leave the lines with `r .* ` untouched

or (better)

b) treat `r .* ` as a single word so that if it is moved, the whole block is moved together