注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

学习笔记

正确的方法如同学习书法,开始的时候要临摹,临摹好了然后创造自己的风格。

 
 
 

日志

 
 

[Vim笔记]using git submodules and pathogen to manage vim plugins  

2013-04-13 20:44:42|  分类: Vim |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
1、Keep your dotfiles in git
Move the .vimrc and .gvimrc files into the .vim directory:
$ mv .vimrc ~/.vim/vimrc
$ mv .gvimrc ~/.vim/gvimrc
Create symbolic links so that ~/.vimrc points to the ~/.vim/vimrc file:
$ ln -s ~/.vim/vimrc ~/.vimrc
$ ln -s ~/.vim/gvimrc ~/.gvimrc
Change to the .vim directory, and initialize it as a git repository:
$ cd ~/.vim
$ git init
Add all files, and make an initial commit:
$ git add .
$ git commit -m "Initial commit"
I suggest publishing your dotvim files to github: it’s really easy to set up an account, and they host open source projects for free. In the video, I demonstrate how to publish a git repository to github.

2、Keep your plugins in git
The traditional method for installing Vim plugins is to copy each script that is distributed with the plugin into the corresponding .vim subdirectory. For example, if you wanted to install Fugitive.vim (a git wrapper for Vim), you would copy the documentation file into .vim/doc, and copy the plugin file into .vim/plugin. You could then check these in to your git repository, and they could be syncronised across machines as easily as the rest of your configuration files. But you lose something by doing this. The Fugitive plugin itself is kept under version control with git. It would be much better if you could keep it that way.
Pathogen.vim
The pathogen plugin makes it possible to cleanly install plugins as a bundle. Rather than having to place all of your plugins side by side in the same directory, you can keep all of the files for each individual plugin together in one directory. This makes installation more straightforward, and also simplifies the tasks of upgrading and even removing a plugin if you decide you no longer need it.
To install Pathogen, download the script and place it in your .vim/autoload directory (if the directory doesn’t exist, you’ll have to create it).
There are a couple of lines that you should add to your .vimrc file to activate pathogen.
set runtimepath+=$HOME/.vim/bundle/vim-pathogen/
runtime autoload/pathogen.vim
call pathogen#incubate()
call pathogen#helptags()
It is essential that these lines are called before enabling filetype detection, so I would recommend putting them at the top of your vimrc file.

3、Install plugins as submodules
With pathogen installed, it’s now possible to keep the files for each plugin together, which means that every plugin can be kept in its own git repository. The best way to do this is to use git submodules, which are designed especially for the purpose of keeping git repositories within a git repository.
To install the fugitive plugin as a git submodule, take the following steps:
$ cd ~/.vim
$ mkdir ~/.vim/bundle
$ git submodule add http://github.com/tpope/vim-fugitive.git bundle/fugitive
$ git add .
$ git commit -m "Install Fugitive.vim bundle as a submodule."

4、Installing your Vim environment on another machine
Once your vim configuration is under version control, it’s quite straightforward to import your settings to any machine that has git installed. If you followed the instructions above to put your vimrc and plugins in a dotvim directory, then you can follow these steps to synchronise them to another machine:
$ cd ~
$ git clone http://github.com/username/dotvim.git ~/.vim
$ ln -s ~/.vim/vimrc ~/.vimrc
$ ln -s ~/.vim/gvimrc ~/.gvimrc
$ cd ~/.vim
$ git submodule init
$ git submodule update
As Marcin Kulik points out in the comments below, the last two git commands can be rolled in to one: $ git submodule update --init.

5、Upgrading a plugin bundle
At some point in the future, the fugitive plugin might be updated. To fetch the latest changes, go into the fugitive repository, and pull the latest version:
$ cd ~/.vim/bundle/fugitive
$ git pull origin master

6、Upgrading all bundled plugins
You can use the foreach command to execute any shell script in from the root of all submodule directories. To update to the latest version of each plugin bundle, run the following:
$ git submodule foreach git pull origin master

FROM:http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen
  评论这张
 
阅读(1326)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017