When I open a *.tex file with Vim, filetypes is read as plaintex (returned by set ft?) by YCM. So I added in .vimrc :

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

But nothing had changed.

Here I want that filetype .tex is read as tex type (set ft=tex). How to define it with YCM options?

有帮助吗?

解决方案

After research (from vim-latex plugin) I found that I have to add following:

" 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'

其他提示

Does YCM set the 'filetype' option? If you want it set to tex, then check where it was set:

:verbose set ft?

I bet it is set in $VIMRUNTIME/filetype.vim, in which case it is my fault. Luckily, I made it configurable. According to :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.

I think that

:let g:tex_flavor = 'latex'

in your vimrc file will make you happy.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top