2012-08-30 109 views
1

我在一个系统(linux)上始终将cpp文件(* .cc)识别为tcl文件。我不知道是什么文件类型,但我想覆盖它。如果手动执行:set ft=cpp,则会选择正确的语法高亮显示。但是,我遇到麻烦,自动设置,我不想使用modeline选项。我自己的.vimrc不会干涉(如果我重命名它,结果相同)。如果vim仍然选择错误的语法荧光笔,该怎么办?

             *ftplugin-overrule* 
If a global filetype plugin does not do exactly what you want, there are three 
ways to change this: 

1. Add a few settings. 
    You must create a new filetype plugin in a directory early in 
    'runtimepath'. For Unix, for example you could use this file: 
     vim ~/.vim/ftplugin/fortran.vim 
    You can set those settings and mappings that you would like to add. Note 
    that the global plugin will be loaded after this, it may overrule the 
    settings that you do here. If this is the case, you need to use one of the 
    following two methods. 

我以前使用此选项在另一台机器上,并且工作的VIM帮助(:help ftplugin-override)。我试过

<file> .vim/ftplugin/tcl.vim 
set filetype=cpp 
"au BufRead,BufNewFile *  set filetype=cpp 

第一行设置正确的filetype:set ft?回报CPP),但语法高亮一样,如果我说:set ft=cpp。它仍然是tcl语法突出显示。第二行什么都不做。

2. Make a copy of the plugin and change it. 
    You must put the copy in a directory early in 'runtimepath'. For Unix, for 
    example, you could do this: 
     cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim 
    Then you can edit the copied file to your liking. Since the b:did_ftplugin 
    variable will be set, the global plugin will not be loaded. 
    A disadvantage of this method is that when the distributed plugin gets 
    improved, you will have to copy and modify it again. 

似乎有在我$VIMRUNTIME目录/usr/share/vim/vim72/ftplugin/称为tcl.vim没有文件。

3. Overrule the settings after loading the global plugin. 
    You must create a new filetype plugin in a directory from the end of 
    'runtimepath'. For Unix, for example, you could use this file: 
     vim ~/.vim/after/ftplugin/fortran.vim 
    In this file you can change just those settings that you want to change. 

与1具有相同的效果还有什么我可以尝试吗?提前致谢。

回答

3

cpp默认文件类型为*.cc*.cpp文件。

tcl文件类型只设置*.tcl*.tk*.itcl*.itk*.jacl

我看不出为什么加载*.cc文件,Vim将默认为tcl,但你可以检查,如果论文文件安装:

/usr/shhare/vim/vim7x/filetype.vim 

/usr/share/vim/vim7x/ftplugin/cpp.vim 
/usr/share/vim/vim7x/indent/cpp.vim 
/usr/share/vim/vim7x/syntax/cpp.vim 

,如果正确的检查,在完成

你是唯一在这台机器上工作的人吗?你使用模式?

+0

该死的,有一个模式,我没看到!我的同事为什么这么做?谢谢罗曼! – Sebastian

+0

中线模式很有用,但您的团队必须对某些东西进行标准化。 – romainl