vim - 插件是由vimrc加载还是之后加载?

标签 vim vim-plugin ftplugin

我对Vim加载插件文件的顺序感到困惑,并且似乎在网上找到混合的答案。 Some answers似乎建议在插件之前先加载vimrc,而others建议在vimrc的获取过程中在filetype plugin indent on行加载。有人可以说明一下after /目录中的vimrc,插件和插件的加载顺序,是什么原因导致加载的,以及在vim session 中何时可以重新加载它们(例如,再次采购vimrc时会发生什么情况,何时进行?设置文件类型等)?

最佳答案

Some answers seem to suggest that vimrc is loaded before plugins, while others suggest that they are loaded during the sourcing of vimrc, at the line filetype plugin indent on.



除非您手动获取所有插件,否则它们均在vimrc之后获取(正确的术语)。 filetype plugin indent on行不会更改该顺序。

Can someone please clarify the order in which vimrc, plugins, and plugins in the after/ directory are loaded,



假设您的filetype plugin indent on中包含vimrc:
  • 系统vimrc(如果有)。
  • 您的vimrc
  • 内置插件。
  • 您的插件。
  • 内置的特定于文件类型的插件。
  • 填充到after/目录中。

  • 整个过程在:help startup中进行了解释,并且可以通过:scriptnames清楚地看到。

    what causes each to load,



    一般而言,&runtimepath的值以及特定于文件类型的内容的:filetype命令的值。

    and when each could be reloaded during a vim session (e.g. what happens when sourcing vimrc again, what happens when setting the filetype, etc.)?


  • :source $MYVIMRC重新执行vimrc中的每个命令。
  • 大多数插件的编写方式都可以防止它们两次被获取。如果要重置它们,请阅读其文档/代码。
  • :help :filetype
  • 关于vim - 插件是由vimrc加载还是之后加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42823310/

    相关文章:

    vim - Vim 中的 CamelCase 扩展类似于 Intellij Idea?

    vim - Vims 隐藏特性如何用于简化代码?

    VIM - ftplugin 似乎不起作用

    Vim ftplugin 对 C++ 文件执行 c.vim 而不是 cpp.vim

    vim - 在vim中删除列

    vim - Command-T 不会为 Vim 编译

    vim - 如何使 vim 从系统剪贴板粘贴(并复制到)?

    vim - VsCode VIM - 如何打开 "New Untitled File"

    linux - searchvim 是如何工作的?