如果我打开一个c文件,而我的缓冲区使用的是"c.vim" ftplugin,那么打开/编辑/源代码我的.vimrc,就会失去"c.vim" ftplugin的功能。
,什么是自动重新加载ftplugin的最好方法?
下面是一个示例:
在获取我的.vimrc:之前,c文件的缓冲区状态
// This line has an existing comment.
// I used 'o' while on the above line to continue that comment.
// Awesome, after pressing return I am still commenting.在获取我的.vimrc:之后,c文件的缓冲区状态
// This line has an existing comment.
I used 'o' while on the above line to try and continue that comment.
After pressing return it is obvious the ftplugin for this filetype is not active.这是我的.vimrc,以防它以某种方式引起问题:
set nocompatible
set backspace=indent,eol,start
filetype plugin indent on
syntax on
set hls
nnoremap <leader>ev :split $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>发布于 2014-02-21 16:45:41
要么我在给出第一个答案时误解了你的问题,要么你的编辑彻底改变了问题。
简短回答:移除线
:set nocompatible从你的vimrc文件。
以下是来自:help 'compatible'的一些相关行
This is a special kind of option, because when it's set or reset,
other options are also changed as a side effect. ...
When a |vimrc| or |gvimrc| file is found while Vim is starting up,
this option is switched off, and all options that have not been
modified will be set to the Vim defaults. ...这意味着在vimrc文件开始时的:set nocompatible是多余的。此外,关于“所有未设置的选项”的部分仅适用于查找vimrc文件的自动效果,而不适用于设置或重置该选项的时间。
正如我在前面的回答中所说的,'formatoptions'选项是困扰您的选项;这是受'compatible'选项影响的众多选项之一。
发布于 2014-02-20 22:29:40
你必须做两件事:
最近我就SuperUser:https://superuser.com/questions/719329/automatic-indentation-with-macvim/719411#719411上的#1给出了建议,在您的例子中,您要更改的选项是'formatoptions' (简写为'fo')。
关于#2,请参见:help ftplugin-overrule。我建议使用这里描述的第三个选项。
https://stackoverflow.com/questions/21920577
复制相似问题