首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在访问.vimrc之后,如何正确地重新加载ftplugin?

在访问.vimrc之后,如何正确地重新加载ftplugin?
EN

Stack Overflow用户
提问于 2014-02-20 21:59:59
回答 2查看 715关注 0票数 0

如果我打开一个c文件,而我的缓冲区使用的是"c.vim" ftplugin,那么打开/编辑/源代码我的.vimrc,就会失去"c.vim" ftplugin的功能。

,什么是自动重新加载ftplugin的最好方法?

下面是一个示例:

在获取我的.vimrc:之前,c文件的缓冲区状态

代码语言:javascript
复制
// 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文件的缓冲区状态

代码语言:javascript
复制
// 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,以防它以某种方式引起问题:

代码语言:javascript
复制
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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-02-21 16:45:41

要么我在给出第一个答案时误解了你的问题,要么你的编辑彻底改变了问题。

简短回答:移除线

代码语言:javascript
复制
:set nocompatible

从你的vimrc文件。

以下是来自:help 'compatible'的一些相关行

代码语言:javascript
复制
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'选项影响的众多选项之一。

票数 1
EN

Stack Overflow用户

发布于 2014-02-20 22:29:40

你必须做两件事:

  1. 找到最重要的选择。
  2. 覆盖ftplugin。

最近我就SuperUser:https://superuser.com/questions/719329/automatic-indentation-with-macvim/719411#719411上的#1给出了建议,在您的例子中,您要更改的选项是'formatoptions' (简写为'fo')。

关于#2,请参见:help ftplugin-overrule。我建议使用这里描述的第三个选项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21920577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档