2010-02-08

LyX-Sweave - use of Ctrl+Enter

Yihui writes:
I have been wondering if it is possible to use Enter instead of Ctrl+Enter in the Sweave code chunk in LyX. It is not quite convenient to press Ctrl+Enter, what's more, we are not able to copy R code and paste it into LyX from other editors (vice versa). I see we are allowed to use a single carriage return in LaTeX code embedded in LyX. Why must Sweave code use Ctrl+Enter? Thanks!
My reply:
LyX prohibits the use of enter key for anything else than starting a new paragraph - this is default behaviour which is great for writing, but notorious for using Sweave with LyX. When you press enter you get a new paragraph, which would start a new chunk of code or is it new paragraph with default style - I do not remember the details at the moment. I agree that this is far from handy, but I was not able to find a solution for this. However, as you mention, it is possible to use ERT LaTeX boxes, to overcome this.