本文介绍了请解释 Vim 的配置目录层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新我的 Vim 配置脚本.我的 ~/.vim 目录中有许多子目录,我不确定它们的具体作用,也不知道为什么有些子目录似乎是多余的.

I am trying to update my Vim configuration scripts. There are a number of sub-directories in my ~/.vim directory and I'm not sure the specifics of what they do, nor why there are some that seem to be redundant.

这是我的 ~/.vim 目录树的样子

Here is what my ~/.vim directory tree looks like

 |-after
 |---ftplugin
 |---syntax
 |-autoload
 |-compiler
 |-doc
 |-ftplugin
 |---latex-suite
 |-----dictionaries
 |-----macros
 |-----packages
 |-----templates
 |---python
 |-indent
 |-plugin
 |-spell
 |-syntax

现在是具体问题.

  1. pluginftplugin 的区别是什么?
  2. pluginautoload 有什么区别?
  3. 我什么时候应该把东西放在 after/... 而不是直接放在 ~/.vim 下的目录中?
  1. What goes in plugin vs ftplugin?
  2. What is the difference between plugin and autoload?
  3. When should I put something in after/... instead of in the directories directly under ~/.vim?

推荐答案

进入 plugin 的任何内容都会在 vim 启动时加载,而你放入 ftplugin 的内容仅用于加载它对应的特定文件类型(所以如果你有一个名为 python 的文件夹,当你打开一个 python 文件时,所有的文件都会被加载.在autoload 中,您应该具有与plugin 中定义的脚本相对应的功能.这里的函数只有在第一次调用时才会加载.

Whatever goes into plugin is loaded whenever vim starts whereas what you put in ftplugin is only loaded for the specific filetype it corresponds to (so if you have a folder there called python all the files there will be loaded when you open a python file.In autoload you should have the functions corresponding to the the scripts defined in plugin. The functions here will only be loaded when called by the first time.

after 中,您应该放置要从正常插件加载中更改的设置.举个例子,假设你喜欢一些 Latex 插件给你的设置,但它重新定义了你在 .vimrc 中的映射.您可以使用自动命令或将正确的定义放在 after 中来还原.

In after you should put settings that you want to change from the normal plugin loading.As an example suppose you like the settings that some plugin for latex gives you, but it redefined a mapping that you had in your .vimrc. You can revert this with autocommands or by putting the correct definitions in after.

这篇关于请解释 Vim 的配置目录层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 18:31