diff --git a/zh/01.4.md b/zh/01.4.md index 95e9f5e3..2f9d5c64 100644 --- a/zh/01.4.md +++ b/zh/01.4.md @@ -310,10 +310,66 @@ Gogland是JetBrains公司推出的Go语言集成开发环境,是Idea Go插件 ## Vim Vim是从vi发展出来的一个文本编辑器, 代码补全、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。 +vim-go是vim上面的一款开源的go语言使用最为广泛开发环境的的插件 + +插件地址:[github.com/fatih/vim-go](https://github.com/fatih/vim-go) + +vim的插件管理主要有[Pathogen](https://github.com/tpope/vim-pathogen)与[Vundle](https://github.com/VundleVim/Vundle.vim) +,但是其作用的方面不同。 +pathogen是为了解决每一个插件安装后文件分散到多个目录不好管理而存在的。vundle是为了解决自动搜索及下载插件而存在的。 +这两个插件可同时使用。 + +1.安装Vundle + +```sh +mkdir ~/.vim/bundle +git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim +``` + +修改.vimrc,将Vundle的相关配置置在最开始处([详细参考Vundle的介绍文档](https://github.com/VundleVim/Vundle.vim)) + +```sh +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() + +" let Vundle manage Vundle, required +Plugin 'gmarik/Vundle.vim' + +" All of your Plugins must be added before the following line +call vundle#end() " required +filetype plugin indent on " required + +``` +2.安装Vim-go + +修改~/.vimrc,在vundle#begin和vundle#end间增加一行: + +```sh + +Plugin 'fatih/vim-go' +``` + +在Vim内执行: PluginInstall + +3.安装YCM(Your Complete Me)进行自动补全 +在~/.vimrc中添加一行: +```sh + +Plugin 'Valloric/YouCompleteMe' +``` +在Vim内执行: PluginInstall + + ![](images/1.4.vim.png?raw=true) 图1.9 VIM编辑器自动化提示Go界面 +接着我们继续配置vim: + 1. 配置vim高亮显示 cp -r $GOROOT/misc/vim/* ~/.vim/