Option to adjust Visual Editor Linting for Semantic Line Breaks

Hello, I am writing a book in RStudio using Quarto. I mostly use the Source editor, rather than the Visual editor. However, if I ever accidentally open my .qmd files in the source editor, some changes are enforced on my code. Most are harmless, however, one that I can't seem to disable is that the Visual editor removes semantic line breaks from my code.

This is really frustrating because the semantic breaks are very useful for diff version control in RStudio/Git, which doesn't work well if whole paragraphs are contained in one line of code.

Is there a way to either entirely disable the visual editor (so I can't accidentally open files with it and thus ruin my semantic line breaks) or check a box to disable this behavior in the visual editor? Please note that this is a different issue from this one, which seeks to introduce semantic line breaks via the visual editor. I simply want it to not remove the semantic line breaks that I create manually in the source editor.

This sounds like a small issue but it's actually a frustrating blocker for effective writing in Quarto and RStudio using version control.

2 Likes

Apparently you can do that with the options in RStudio.

Image from this issue: Automatic line breaks by sentence gets confused by citations · Issue #11110 · rstudio/rstudio · GitHub

Thanks. Yes, the automatic text wrapping by sentence is the best workaround, because it somewhat approximates semantic breaks. However, switching the setting you highlighted to none does not produce the behavior I am requesting—it simply reverts to the default behavior (coerce paragraphs into a single line of code any time the visual editor is opened).

In my view, that text wrapping behavior should be renamed to paragraph or similar and the none setting should leave alone any line breaks that are manually introduced in the source editor.

1 Like

Yes, you can disable the Visual Editor in RStudio to prevent accidental formatting changes.

  1. Disable Visual Mode for All Quarto Documents:

    • Go to Tools > Global Options > R Markdown
    • Uncheck "Enable Visual Editor"
  2. Disable for a Specific File:

    • Open the .qmd file in Source Editor
    • Add this to the document YAML:
      editor: source
      

This will force RStudio to open the file in Source mode and preserve your semantic line breaks.