Skip to Content
《学习 vi 和 Vim 编辑器》,第 8 版
book

《学习 vi 和 Vim 编辑器》,第 8 版

by Arnold Robbins, Elbert Hannah
May 2025
Beginner to intermediate
548 pages
5h 59m
Chinese
O'Reilly Media, Inc.
Content preview from 《学习 vi 和 Vim 编辑器》,第 8 版

第 15 章 Vim 作为集成开发环境需要一些组装

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

虽然vi 是一个通用的文本编辑器,但 从第一天起,它也是一个程序员的文本编辑器。它具有多种功能,可使编程,尤其是 C 语言编程变得更容易(请考虑showmatch 选项、自动缩进功能,尤其是ctags 功能,以及在troff 文档中进行操作的功能)。

不出所料,Vim 继承了这一传统,但与vi 不同的是,它本身是可编程的,尤其是它支持插件,可以直接在编辑器中加载新代码和添加新功能。

与许多流行的脚本语言一样,这种可扩展性带来了大量与 Vim 配合使用的新功能和新设施,其数量之多是任何一个人都无法单独创造出来的。

同样不足为奇的是,这些插件中有很大一部分都是为了让使用 Vim 进行编程和软件开发变得更加容易。

在本章中,我们将(简要地!)介绍插件管理器,以及软件开发中使用的一些更有趣、更流行的插件。

但是,请注意,Vim 插件的范围非常大。 如果要全面介绍所有可能的插件,就需要另外写一本书,而这本书的篇幅要比这本书大得多!因此,与书中其他章节相比,我们在这里的处理涉及的手把手指导要少得多;请在阅读时牢记这一点。

插件管理器

除了实际执行某些操作的插件外,还有一些插件 可以管理其他插件。 它们的工作是加载和初始化插件,让你无需手动下载插件或在.vimrc文件中添加大量插件专用代码,就能轻松安装和使用插件。

Vim 有自己的插件管理器,可通过:packadd("package add")命令访问。 你可以使用该命令来管理 Vim 标配的插件,也可以使用该命令来管理符合:help packadd 标准的任何其他插件(我们在此就不赘述了)。我们稍后将展示其中一个标准插件,并鼓励你查看 Vim 自带的其他插件。

最流行的插件管理器之一叫做Vundle("Vim bundle "的缩写)。网站上有 "快速入门 "说明,我们在此尝试总结一下,前提是使用 GNU/Linux 或其他 POSIX 类型的系统:

  1. 确保系统已安装 Git 和curl

  2. .vimrc文件和.vim目录的副本保存在安全的地方,以防万一。

  3. 克隆 Vundle 直接取而代之:

    git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  4. 配置插件。 您的.vimrc应该是这样的(也可以从 Vundle 主页复制/粘贴);为了简短起见,我们省略了一些注释:

    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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

《Asterisk:权威指南》第 5 版

《Asterisk:权威指南》第 5 版

Jim Van Meggelen, Russell Bryant, Leif Madsen
图解大模型 : 生成式AI 原理与实战

图解大模型 : 生成式AI 原理与实战

Jay Alammar, Maarten Grootendorst

Publisher Resources

ISBN: 9798341657885