Multiline Comment Workarounds?

A neat trick for RStudio I've just discovered is to use #' as this creates an self-expanding comment section (when you return to new line from such a line or insert new lines into such a section it is automatically comment).


You can do this easily in RStudio:

select the code and click CTR+SHIFT+C to comment/uncomment code.


This does come up on the mailing list fairly regularly, see for example this recent thread on r-help. The consensus answer usually is the one shown above: that given that the language has no direct support, you have to either

  • work with an editor that has region-to-comment commands, and most advanced R editors do
  • use the if (FALSE) constructs suggested earlier but note that it still requires complete parsing and must hence be syntactically correct

Tags:

Comments

R

R Faq