Question

This I am sure is really basic stuff. I am just beginning using gvim and latex-suite. However I would like latex-suite to load when I edit a sweavefile with.Rnw extension.

my .vimrc looks like this

" These settings are needed for latex-suite
filetype indent on
filetype plugin on
filetype on
let g:tex_flavor='latex'
set grepprg=grep\ -nH\ $*
"let g:Tex_Folding=0 "I don't like folding.
set iskeyword+=:

and I guess there is some option I can set here that makes vim treat Rnw as .tex?

Was it helpful?

Solution

Put a file in /usr/share/vim/vimfiles/ftdetect (for global) or .vim/ftdetect (for local) called Rnw.vim that looks something like this:

" Vim filetype detection plugin
" Language:    sweavefile

autocmd BufRead,BufNewFile *.Rnw set filetype=tex

Edit: I'm pretty sure you could put this autocommand in your .vimrc too, since that's loaded on program start, before any files are loaded, but this is directory the natural place for filetype detection.

Edit: If you would like to give these files some treatment different from TeX, you could instead set the filetype to rnw, add scripts to the ftplugin, indent, and syntax directories as necessary, most likely sourcing the TeX scripts and then doing your own stuff.

OTHER TIPS

Hope these pointers will help:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top