Vim实用技巧系列 - 开篇
作者使用Vim已经有一段时间了,深深觉得它是一个非常强大的编辑器,使用习惯之后效率很高。最大的缺点是学习曲线比较陡峭。因此作者希望分享一些自己在实际使用中的经验来帮助初学者,同时也帮助作者自己学习。
在这个系列的文章中,作者所使用的Vim是windows系统下的gVim 7.4. 同时,作者在这里不打算涉及Vim的入门知识,包括几种模式等。作者假定阅读本系列文章的读者都具有这些入门知识。
好,闲话少叙。接下来进入正题。
=======================================================
本篇的主题是,在Vim中使用插件。
插件系统是Vim的一个很强大的地方。无数开发者为Vim提供了丰富的插件集,可以实现非常多的功能。但是,默认的插件管理方式不太好用,需要下载插件然后手动拷贝,需要删除的时候就很麻烦。所以,有人就开发了Vim插件来管理Vim插件。本期介绍Vundle用来管理Vim插件。
首先,为什么要用Vundle这个插件来管理Vim插件?因为它使得插件的安装、更新删除都变得很容易。
接下来是Vundle的安装方法。https://github.com/gmarik/Vundle.vim有详细的安装过程,这里做个简单的翻译,同时结合作者本身经验有简单修改,方便读者。
1. Vundle依赖于git. 到http://git-scm.com/去下载git. 然后安装。需要注意的是,在安装过程中,有一步让用户选择路径环境,共有三个选项,这里要选第二项,也就是Run Git from Windows Command Prompt. 如下图所示
2. 创建一个名为curl.cmd的文件,其内容如下,并且将这个文件放到C:\Program Files\Git\cmd\curl.cmd 。这里假定git安装到c:\Program Files\Git
@rem Do not use "echo off" to not affect any child calls.
@setlocal
@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
@curl.exe %*
3. 打开命令行,分别运行git --version和curl --version,如果能够正常显示版本信息,则可以进行下一步。
4. 打开命令行,输入如下命令
cd %USERPROFILE%
git clone https://github.com/gmarik/vundle.git vimfiles/bundle/vundle
5. 在用户目录下,也就是C:\Users\你的用户名 或者 C:\用户\你的用户名, 创建一个文件,名为_vimrc,注意,没有扩展名。然后,在这个文件中输入如下内容。
- set nocompatible " be iMproved, required
- filetype off " required
- " set the runtime path to include Vundle and initialize
- set rtp+=~/vimfiles/bundle/vundle/
- let path='~/vimfiles/bundle'
- call vundle#rc(path)
- " alternatively, pass a path where Vundle should install bundles
- "let path = '~/some/path/here'
- "call vundle#rc(path)
- " let Vundle manage Vundle, required
- Bundle 'gmarik/vundle'
- " The following are examples of different formats supported.
- " Keep bundle commands between here and filetype plugin indent on.
- " scripts on GitHub repos
- Bundle 'tpope/vim-fugitive'
- Bundle 'Lokaltog/vim-easymotion'
- Bundle 'tpope/vim-rails.git'
- " The sparkup vim script is in a subdirectory of this repo called vim.
- " Pass the path to set the runtimepath properly.
- Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
- " scripts from http://vim-scripts.org/vim/scripts.html
- Bundle 'L9'
- Bundle 'FuzzyFinder'
- " scripts not on GitHub
- Bundle 'git://git.wincent.com/command-t.git'
- " git repos on your local machine (i.e. when working on your own plugin)
- Bundle 'file:///home/gmarik/path/to/plugin'
- " ...
- filetype plugin indent on " required
- "
- " Brief help
- " :BundleList - list configured bundles
- " :BundleInstall(!) - install (update) bundles
- " :BundleSearch(!) foo - search (or refresh cache first) for foo
- " :BundleClean(!) - confirm (or auto-approve) removal of unused bundles
- "
- " see :h vundle for more details or wiki for FAQ
- " NOTE: comments after Bundle commands are not allowed.
6. 打开Vim,在命令模式下,输入:BundleInstall(注意要有前面的冒号),就会开始安装插件了
7. 如果要安装其他插件,只需要打开用户目录下的_vimrc文件,然后在文件中添加Bundle '<插件名字或者git路径>',并且在关闭Vim并且重新打开后输入:BundleInstall就会安装插件了。如果需要更新插件,则输入命令:BundleUpdate。如果要删除不用的Vim脚本,则输入:BundleClean命令。
好了,有了Vundle的帮助,就可以很方便的安装各种插件了。开始体验强大的Vim插件吧!
Vim实用技巧系列 - 开篇的更多相关文章
- Vim实用技巧系列 - 搜索
最近发现了一个很好的VIM资源,best of vim tips, 展示了一系列很有用的vim 技巧.博主会逐个翻译介绍这些技巧. 来源: http://rayninfo.co.uk/vimtips. ...
- Vim实用技巧系列 - 代码注释
在写代码时候,有时候需要临时注释掉一部分代码,之后还要取消这些注释.真麻烦.那么,用Vim怎么做这件事呢? 第一种方法,块模式. 再次声明,本系列全部以windows下 ...
- Vim实用技巧系列 - tab和空格的转换
有时候,我们会修改一些代码,而这些代码中的tab设定和我们自己的设定不一样.例如,我们自己的设定是以两个空格来代替tab,而要修改的代码则是使用tab.那么,我们应该怎样快速的将又有的tab转换为空格 ...
- Vim实用技巧系列 - 利用百度云和git实现vim配置多机共享
Vim是一个强大的文本编辑器.良好的配置更能便利对Vim的使用.有时候,我们会在几台不同的电脑上使用Vim. 例如,我们可能在自己的电脑和公司的电脑上都安装了Vim. 有时候,我们需要实现,如果我们配 ...
- ###《VIM实用技巧》
###<VIM实用技巧> #@author: gr #@date: 2015-11-20 #@email: forgerui@gmail.com <VIM实用技巧>阅读笔记. ...
- vim实用技巧总结
1. 单个文件内实用mark来帮助跳转以及一些宏操作.(注意:mark不能用于多文件之间的跳转)mch 设置宏,保存到ch标记(不是ch寄存器)'ch 跳转到标记的行首`ch 跳转到标记的字符处另:为 ...
- 很全面的WinRAR实用技巧系列 - imsoft.cnblogs
WinRAR也可以管理我的桌面时间长了,桌面上堆的东西实在太多,平时该如何管理呢?安装了WinRAR的朋友可以请它来帮忙,用它管理清除无用的桌面文件或图标. 以XP系统为例,系统所在目录是“c:\wi ...
- 《Vim实用技巧》第2版读书笔记
学习前的建议: 一.如果你需要一个功能强大的文本编辑器,速度飞快.使用方便.代码补全.编程强大.定制性强,Vim就是你需要的: 二.学习入门曲线陡峭,但是使用后期异常简单,效率超高: 三.号称可以跟上 ...
- vim实用技巧
<1> 删除空格: :% s/ //gi #正则为一个空格,替换为空,全局匹配. <2> 删除空行: :g /^\n*$/ d #g为global 正则为:行开始+换 ...
随机推荐
- 多参数同时运行docker
docker run --name=newtomcat7 -t -i -p 5000:5000 -v /root/work/docker:/root/hzbtest 93541fa83230 /bin ...
- (并查集) Wireless Network --POJ --2236
链接: http://poj.org/problem?id=2236 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#probl ...
- (匹配 二维建图) Antenna Placement --POJ --3020
链接: http://poj.org/problem?id=3020 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82834#probl ...
- 获取Oracle EBS数据库跟踪文件方法
http://www.orapub.cn/posts/1624.html 一.以下在Oracle APP中执行: 1) Set the Profile Option: ‘Initialization ...
- Text Converted into Speech in Pi
Step 1: Convert any text into uint8 type in matlab : Step 2: Add models in matlab : copy the uint8 n ...
- 程序猿CET4和CET6考试攻略
写在前面: 学习一种语言是一个长期的过程,而且需要合适的语言环境,不是一朝一夕可以熟练掌握的,但是如果单纯地只是为了通过考试的话,就另当别论了 声明:本篇攻略纯属经验之谈,绝非任何性质的广告,仅供参考 ...
- 【LongIntervalRetries】让我们来实现支付宝的异步回调方案
功能说明 LongIntervalRetries是基于Quartz.Net的一个长时间间隔重试的类库,其主要解决何时执行以及执行结果反馈的问题. 产生的原因 简单的说,我们提供了一系列的API供第三方 ...
- VisualStudio神级插件——JetBrains Resharper 2018.2.3 Ultimate完美破解版+教程
ReSharper是一个JetBrains公司出品的著名的代码生成工具,是Visual Studio里面的一个插件.它包括一系列丰富的能大大增加C#和Visual Basic .NET开发者生产力的特 ...
- MPLS 网络中的 MTU
MPLS MTU的大小可以设置为64-65535之间,在MPLS网络中,标签的大小是计入到MTU中的,所以在MPLS网络MTU是一个常见的问题. 在Ethernet接口上,一般数据最长为150 ...
- 782. Transform to Chessboard
An N x N board contains only 0s and 1s. In each move, you can swap any 2 rows with each other, or an ...