When I started editing a sweave file with .Rnw extention, at the beginning it seemed everything is honky-dory. The latex-suite was loaded with the menus along with R functionalities but ran into a wicked problem. Here in the tex.stackexchange.com forum I posted the problem:
http://tex.stackexchange.com/questions/130436/latex-suite-autocompletion-feature-not-working-with-rnw-file
http://tex.stackexchange.com/questions/130436/latex-suite-autocompletion-feature-not-working-with-rnw-file
I have been a great fan of Vim with its awesome Vim-latex suite providing extremely useful keybindings and autocompletion features. Then I installed vim-r-plugin and opened a .Rnw Sweave file. While syntax highlighting and other R related features such as key shortcuts are working fine, LaTeX shortcuts no longer works. For example, if I type SSE it longer gives "\section{}". But if I instead I open a .tex file, those shortcuts works just fine.
It's not that .Rnw files not detecting latex-suite in Vim. My latex suite is loaded with .Rnw files with all the menu and stuff. I can get the short cuts work with F5, F7 and alt keys. It's just that short cuts do not work in the insert mode. It's bugging me a lot and I have been on the hunt for a solution the whole day but could not find a fix yet.
I got this heavenly response with an elegant solution from an user named FvD:
You need to associate the .Rnw files with tex.
The most direct way to do this is to issue the following command with the open .Rnw file:
:set filetype=tex
As soon as you have done that the vim-latex behaviour you are used to should be back. To incorporate this in a nice way in your vimrc is described here in a stackoverflow question. To wit:
autocmd BufRead,BufNewFile *.Rnw set filetype=tex
As per the vim-latex recommendations I also have
let g:tex_flavor="latex"
in my .vimrc, but that should not impact on the behaviour of the plugin itself (the filetype certainly does).
That was sweet indeed!
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন