1. 到GITHUB (https://github.com/)的官网去注册账号。
2. 登陆以后完善自己的相关配置,尤其是安全方面的。
3. 到自己的Linux主机上去安装GIT和VIM,这个大家应该很熟悉了, 这里我以Ubuntu为例。
sudo apt-get install git-core
sudo apt-get install vim
4. mkdir ~/.vim
5. 初始化本地GIT仓库。
cd ~/.vim
git init
git add .
git commit -m " init git repository"
6. 到GITHUB网站创建一个远程仓库,这里我以simont-vim为例。
7. 同步本地仓库和远程仓库。
cd ~/.vim
git remote add origin https://github.com/simont-1/simont-vim.git 或者
git remote add origin git@github.com:simont-1/simont-vim.git
可以通过git remote -v查看本地仓库下同步了多少个远程仓库, 例如
simont@ubuntu:~/test$ git remote -v
origin https://github.com/simont-1/simont-vim.git (fetch)
origin https://github.com/simont-1/simont-vim.git (push)
关于git remote add的官方解释如下:
如果你希望分享一个本地创建的仓库,或者你想要获取别人的仓库中的贡献 —— 如果你想要以任何方式与一个新仓库沟通,最简单的方式通常就是把它添加为一个远端仓 库。 执行 git remote add [alias] [url] 就可以。 此命令将 [url] 以 [alias] 的别名添加为本地的远端仓库。(http://gitref.cyj.me/zh/remotes/)
8. 在~/.vim目录里添加文件vimrc
cd ~/.vim
touch vimrc
git add vimrc
git commit vimrc -m "VIM configuration file"
9. 同步vimrc到远程仓库,如果成功的话,你会在github的网页上仓库看到你的同步。
git push origin master
如果同步的时候碰到如下错误:
error: The requested URL returned error: 403 while accessing https://github.com/simont-1/simont-vim.git/info/refs
表明主机和github服务器的https连接有问题,解决方案如下:
可以不用https而用ssh,首先要创建SSH security keys,官方链接:https://help.github.com/articles/generating-ssh-keys
然后到本地仓库~/.vim下去更改git配置文件:
vi ~/.vim/.git/config
把url = https://github.com/simont-1/simont-vim.git 改成 url = ssh://git@github.com/simont-1/simont-vim.git
10. 安装插件vim-pathogen,很好的插件管理工具。
cd ~/.vim
mkdir -p autoload bundle
git add autoload bundle
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
git add ~/.vim/autoload/pathogen.vim
11. 配置~/vimrc如下:
call pathogen#infect()
syntax on
filetype plugin indent on
12. 添加链接到HOME目录
cd
ln -sf ~/.vim/vimrc .vimrc
到目前为止,所有的准备工作都做好了。接下来就开始装功能性插件,第一个要安装的是NERD Tree。
13. 安装NERD Tree
cd ~/.vim "必须在本地仓库的顶级目录去添加git模块
git submodule add git@github.com:scrooloose/nerdtree.git bundle/nerdtree
vi vimrc “ 配置vimrc添加如下设置
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif "关闭vim,如果nerdtree是最后一个窗口
git push origin master
14. 安装taglist
安装这个插件前别忘了安装ctags(sudo apt-get install ctags)。
cd ~/.vim
git submodule add git@github.com:vim-scripts/taglist.vim.git bundle/taglist.vim
vi vimrc “ 配置vimrc添加如下设置
let g:Tlist_Use_Right_Window = 1 "0:Taglist窗口位于左边
"1:Taglist窗口位于右边
let g:Tlist_Show_One_File = 1 "0:同时显示打开的多个文件的tags
"1:只显示当前编辑的文件的tags
let g:Tlist_GainFocus_On_ToggleOpen = 1 "0:打开Taglist时光标停留在原窗口
"1:打开Taglist时光标停留在Taglist窗口
let g:Tlist_Auto_Open = 0 "0:启动Vim时不自动打开Taglist窗口
"1:启动Vim时自动打开Taglist窗口
let g:Tlist_Exit_OnlyWindow = 1 "0:当Vim只剩下Taglist窗口时,不自动退出Vim
"1:当Vim只剩下Taglist窗口时,自动退出Vim
let g:Tlist_Close_On_Select = 1 "0:当打开Taglist窗口中的某条tag之后,不关闭Taglist窗
"1:当打开Taglist窗口中的某条tag之后,关闭Taglist窗口
git push origin master
15. 安装winmanager,管理窗口NerdTree和Taglist
cd ~/.vim
git submodule add git@github.com:vim-scripts/winmanager.git bundle/winmanager
vi vimrc “ 配置vimrc添加如下功能
* 打开VIM自动加载winmanager, (这个是参照别人的方法)
let g:AutoOpenWinManager = 1 ”加在vimrc里
然后更改winmanager.vim ,加入以下功能:
"set auto open Winmanager
if g:AutoOpenWinManager
autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd c
endif
* 自动关闭winmanager (如果winmanager 是最后的窗口),这个函数是我自己写的。
let g:WM_Auto_Exit_OnlyWindow = 1 ”加在vimrc里
然后更改winmanager.vim ,加入以下功能:
function! <SID>Exit_Only_One_Window()
if winnr("$") == 2 && IsWinManagerVisible() “只有NERDTree和Taglist的时候,自动关闭窗口
call s:CloseWindowsManager()
return 0
end
endfunction
if g:WM_Auto_Exit_OnlyWindow
autocmd WinEnter * nested call s:Exit_Only_One_Window()
endif
16. 安装BufExplorer,这个没啥说的了,winmanager会依赖于它。
17. 到目前为止,基本的插件就安装完毕了,来看看效果吧。
所有的改动都放在这里了(https://github.com/simont-1/simont-vim),我会慢慢完善vimrc的,谢谢。