2014-02-08 45 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文件

會讓你快樂。