如何在 Linux 上使用 Vundle 管理 Vim 插件

维姆毫无疑问,它是操作文本文件、管理系统配置文件和编写代码的强大而通用的工具之一。 Vim 的功能可以使用插件扩展到不同的级别。 通常,所有插件和附加配置文件都将存储在 ~/.vim 目录。 由于所有插件文件都存储在一个目录中,因此当您安装更多插件时,来自不同插件的文件会混合在一起。 因此,跟踪和管理所有这些将是一项艰巨的任务。 这是哪里 文德尔 进来帮忙。 Vundle 的首字母缩略词 , 是一个非常有用的管理 Vim 插件的插件。

Vundle 为每个已安装的插件创建一个单独的目录树,并将附加的配置文件存储在相应的插件目录中。 因此,没有文件相互混淆。 简而言之,Vundle 允许您安装新插件、配置现有插件、更新配置的插件、搜索已安装的插件和清理未使用的插件。 所有操作都可以在具有交互模式的单个按键中完成。 在这个简短的教程中,让我向您展示如何安装 Vundle 以及如何在 GNU/Linux 中使用 Vundle 管理 Vim 插件。

内容

  1. 安装 Vundle
    1. 下载 Vundle
    2. 配置 Vundle
  2. 在 Linux 上使用 Vundle 管理 Vim 插件
    1. 添加新插件
    2. 列出已安装的插件
    3. 更新插件
    4. 卸载插件
    5. 帮助我们帮助您:

安装 Vundle

如果你需要 Vundle,我假设你已经安装了 vim 在您的系统上。 如果没有,请安装 vim 和 混帐 (下载vundle)。 这两个包都可以在大多数 GNU/Linux 发行版的官方存储库中找到。 例如,您可以使用以下命令在基于 Debian 的系统上安装这些软件包。

$ sudo apt-get install vim git

下载 Vundle

克隆 Vundle GitHub 存储库:

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

配置 Vundle

要告诉 vim 使用新的插件管理器,我们需要创建 ~/.vimrc 文件。 此文件是安装、更新、配置和删除插件所必需的。

$ vim ~/.vimrc

将以下行放在顶部:

set nocompatible              " be iMproved, required filetype off                  " required  " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here')  " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim'  " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo Plugin 'tpope/vim-fugitive' " plugin from https://vim-scripts.org/vim/scripts.html " Plugin 'L9' " Git plugin not hosted on GitHub Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Install L9 and avoid a Naming conflict if you've already installed a " different version somewhere else. " Plugin 'ascenator/L9', {'name': 'newL9'}  " All of your Plugins must be added before the following line call vundle#end()            " required filetype plugin indent on    " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList       - lists configured plugins " :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line

标记为“必填”的行是 Vundle 的要求。 其余的行只是示例。 如果您不想安装指定的插件,可以删除这些行。 完成后,输入 :wq 保存和 close 文件。

最后,打开vim:

$ vim

并键入以下内容以安装插件。

:PluginInstall

将打开一个新的拆分窗口,我们在 .vimrc 文件中添加的所有插件都将自动安装。