gist.github是一个类似pastie的代码存储服务。最近Github的博客上介绍了几个在vim、emaces和textmate中使用gist.github的插件。emacs我不怎么用,而textmate我也没有Mac,单介绍一下vim的这个插件Gist.vim。
首先可以从vim的网站或者gihub repo下载这个vim插件,然后复制到vim的plugin目录里面。启动vim,如果你之前没有设定git的环境变量的话需要首先通过下面命令设置:
git config --global github.user yourname
git config --global github.token your API Token
你可以在https://github.com/account这个页面的Global Git Config连接找到你的设置命令。
gist.vim提供了一些命令可以在vim中提交或者查询你在gist中的文件:
:Gist
post whole text to gist.
:'<,'>Gist
post selected text to gist.
:Gist -p
post whole text to gist with private.
:Gist XXXXX
edit gist XXXXX.
:Gist -l
list gists from mine.
:Gist -la
list gists from all.
当然如果你在安装了gist.vim运行vim的以后vim提示你缺少git或者curl命令的时候你需要首先安装这两个命令。
sudo apt-get install git
sudo apt-get install curl