2012-08-30 133 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