我在系统(linux)上始终将cpp文件(* .cc)识别为tcl
个文件。我不知道是什么文件类型,但我想覆盖它。如果我手动执行:set ft=cpp
,则会选择正确的语法突出显示。但是,我遇到麻烦自动设置,我不想使用modeline
选项。我自己的.vimrc
不会干扰(如果我重命名它会产生相同的结果)。
从vim帮助(:help ftplugin-override
)
*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.
我之前在另一台机器上使用过这个选项并且有效。我试过了
<file> .vim/ftplugin/tcl.vim
set filetype=cpp
"au BufRead,BufNewFile * set filetype=cpp
第一行正确设置了filetype
(:set ft?
返回 cpp ),但语法高亮显示不与我说{相同} {1}}。它仍然是: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
与1具有相同的效果。还有什么我可以尝试的吗?非常感谢。
答案 0 :(得分:3)
cpp
是*.cc
和*.cpp
文件的默认文件类型。
tcl
文件类型仅针对*.tcl
,*.tk
,*.itcl
,*.itk
和*.jacl
设置。
我认为没有理由在加载tcl
文件时Vim默认为*.cc
,但您可以检查这些文件是否已安装:
/usr/share/vim/vim7x/ftplugin/cpp.vim
/usr/share/vim/vim7x/indent/cpp.vim
/usr/share/vim/vim7x/syntax/cpp.vim
如果在:
中完成了正确的检查/usr/shhare/vim/vim7x/filetype.vim
你是唯一一个在这台机器上工作的人吗?你使用模特儿吗?