一、环境准备:

系统环境说明:

[root@docker golang]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@docker golang]# uname -a
Linux docker 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@docker golang]#

准备一个go文件,用于观察配置插件过程中的变化:

//hellogolang.go
package main
import "fmt"
func main() {
        fmt.Println("Hello Golang!")
}

二、插件配置之路:

1、Vundle.vim:

#mkdir ~/.vim/bundle
#git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

配置vimrc:创建~/.vimrc文件(如果你没有这个文件的话),在文件顶部添加有关Vundle.vim的配置:

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

此时Vim仅安装了Vundle.vim这一个插件。编辑hellogolang.go时与编辑普通文本文件无异,一切都还是Vim的默认属性

2、vim-go

Vim-go是当前使用最为广泛的用于搭建Golang开发环境的vim插件,这里我同样使用vim-go作为核心和基础进行环境搭建的。vim-go利 用开源Vim插件管理器安装,gmarik/Vundle.vim是目前被

go语言环境vim配置详解