将.Rnw与vim乳胶套件相关联 [英] Associate .Rnw with vim latex suite

查看:92
本文介绍了将.Rnw与vim乳胶套件相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信这确实是基本的东西.我刚刚开始使用gvim和乳胶套件.但是,当我编辑带有.Rnw扩展名的sweavefile时,我希望加载乳胶套件.

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.

我的.vimrc看起来像这样

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+=:

我想我可以在此处设置一些选项,使vim将Rnw视为.tex?

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

推荐答案

将名为Rnw.vim的文件放在/usr/share/vim/vimfiles/ftdetect(对于全局)或.vim/ftdetect(对于本地)中像这样的东西:

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

我很确定您也可以在.vimrc中放入该自动命令,因为该命令是在加载任何文件之前在程序启动时加载的,但这是检测文件类型的自然位置.

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.

如果要对这些文件进行不同于TeX的处理,则可以将文件类型设置为rnw,根据需要将脚本添加到ftplugin,indent和语法目录中,最有可能购买TeX脚本,然后做你自己的东西.

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.

这篇关于将.Rnw与vim乳胶套件相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆