(summary at the bottom) I have set up Vim and R using the Vim-R-plugin and it works flawless. I also use the Latex-suite in Vim and can create, compile and view .tex files without any problem. For knitr, I used to use Rstudio but I would really like to stay in Vim. I'm just getting started with the vim-latex-suite so maybe I'm missing something basic, but something is not working in my Vim + Latex-Suite + knitr combination.
Following Associate .Rnw with vim latex suite, I included in my vimrc that .Rnw files should be read as .tex files (although someone stated in a comment in that post that it should be automated in the vim-r-plugin back in 2011 but it didn't: initially filetype was detected as rnoweb and when I tried to compile, it threw an error saying that I was trying to compile a non-.tex file).
Now, if I use the following code as a .Rnw file:
\title{Data analysis}
\begin{document}
\maketitle
\Section{Introduction}
Some text as introduction
\end{document}
It compiles without issue. When I include
<<>>=
1 + 1
@
It compiles, however it prints to
!!?? = 1 + 1
@
without the block colour and the ! and ? turned up side down.
And when I include a comment (# comment
) it returns an error saying
You can't use 'macro parameter character #' in vertical mode
but it does compile and prints as
comment
When I escape it using \
, no error is shown and it prints
# comment
I'm using macvim 7.4 and have updated all the plugins (installed/updating using Bundle) and R 3.1.2 (latest update).
So, in summary: vim + r works, vim + latex works but vim + r + latex doesn't work. R code isn't executed and comments are displayed wrong.
If someone can point me in the right direction, it would be appreciated!