How to get Rmd text to soft wrap at 80 character margin

I'm writing markdown text (not R code) in an RMarkdown document in the source pane of RStudio and I have the margin set at 80 characters in Global Options > Code > Display. I was looking for a way to make the text I'm writing get automatically soft wrapped at the margin. Just for readability and neatness reasons.

The text wraps at the width of the pane, not at the margin. I would like to keep the pane at its current width (or whatever) and still have control over where the text wraps.

How can I achieve this, please?

1 Like

There's an addin for that

2 Likes

I wonder if RStudio shortcut Ctrl+Shift+/ (reflow comment in code menu) can do the job :thinking:
It seems to work for me.

1 Like

Not for me. It turned my whole document into one long comment with no syntax highlighting!

Oh strange. What I do is I select the text I want to wrap, then apply the beyboard shortcut.

2 Likes

Ah - my bad. I just had the cursor on the line, I hadn't selected the text. It does work - thank you!

Thanks - addin works. But so does @cderv's solution (misleading name for that function, it doesn't just reflow comments).

EDIT: hmm, not sure now. The reflow comment function seems to lose any markdown syntax highlighting within the paragraph. I'll cross-check with the addin and report back.

1 Like

WrapRmd closed issue where Mara found the same as me, that the wrapping breaks markdown hyperlinks etc. Will try the experimental version of the add-in and see if that works better.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.