Skip to content

Instantly share code, notes, and snippets.

@gnepud
Created October 23, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnepud/7e4166f3141173c28ee9 to your computer and use it in GitHub Desktop.
Save gnepud/7e4166f3141173c28ee9 to your computer and use it in GitHub Desktop.
用 git submodule 同步 vim-plugins
首先,你的 vim 配置文件得先有一个 git repository。
当我们为vim安装插件时,我们需要复制不同的文件到不同的目录,这让更新插件操作非常困难。
但现在很多vim的插件都有一个github repository。我们可以使用git submodule和pathogen插件来让这个操作变得容易点。
为 Vim 添加 bundle 支持
Tim Pope写了一个 vim 插件名叫 pathogen 。这个插件可以让事情变得容易点。
这个插件,让你在你的.vim/bundle目录下管理你的插件,你可以在这个目录下对插件进行 unzip/untar/svn-checkout/git-clone 操作。
这样,每一个插件不必被分裂复制到不同的目录,它们会待在同一个目录里,方便管理。
添加一个 Submodule
如果在add submodule之前,你已经用了一个插件(比如:vim-fugitive),那么你得先把它删掉:
git rm -r bundle/vim-fugitive
否则,你就会得的 'vim-fugitive' already exists in the index 的错误。
然后,我们添加 vim-fugitive 作为 submodule:
git submodule add git://github.com/tpope/vim-fugitive.git bundle/vim-fugitive
添加 submodule 之后,你还得 register 一下:
git submodule init
然后 push 就完成了。需要注意的是,以上所有命令操作都是在 .vim目录下进行的。
更新 submodule
更新submodule,使用:
git submodule update
更新 submodule 下的所有扩展
cd ~/.vim
git submodule foreach git pull origin master
删除 submodule
删除submodule,没有太有效率的方法,只能手动进行:
1. 手动删除 .gitmodules 和 .git/config 中的相关引用;
2. git rm --cached bundle/vim-fugitive
更多参考
- Tips – Using git submodule keep your vim plugin up-to-date
- github guides about submodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment