2014-02-08 47 views
0

当我用Vim打开* .tex文件时,YCM将文件类型读为plaintex(由set ft?返回)。 所以我加入.vimrc:Vim YouCompleteMe启用.tex文件类型

let g:ycm_filetype_blacklist = {'plaintex' : 1} 

但没有什么改变。

在这里,我希望文件类型.tex读取为tex类型(set ft=tex)。 如何用YCM选项来定义它?

回答

0

研究之后(从VIM乳胶插件)我发现我必须添加以下内容:

" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to 
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded. 
" The following changes the default filetype back to 'tex': 
let g:tex_flavor='latex' 
1

是否YCM设置'filetype'选项?如果你想将其设置为tex,然后检查它被设置:

:verbose set ft? 

我敢打赌,它被设置在$VIMRUNTIME/filetype.vim,在这种情况下,它是我的错。幸运的是,我让它可配置。据:help ft-tex-plugin

If the first line of a *.tex file has the form 
    %&<format> 
then this determined the file type: plaintex (for plain TeX), context (for 
ConTeXt), or tex (for LaTeX). Otherwise, the file is searched for keywords to 
choose context or tex. If no keywords are found, it defaults to plaintex. 
You can change the default by defining the variable g:tex_flavor to the format 
(not the file type) you use most. Use one of these: 
    let g:tex_flavor = "plain" 
    let g:tex_flavor = "context" 
    let g:tex_flavor = "latex" 
Currently no other formats are recognized. 

我认为

:let g:tex_flavor = 'latex' 
在vimrc文件

会让你快乐。