This is a creation in Article, where the information may have evolved or changed.
Original link: Golang Vim plugin settings
In most cases, using vim to write Golang code requires syntax highlighting and automatic format. To do this, add a plugin that supports the Golang syntax to the VIM editor, and the plug-in configuration method is as follows:
1, download vim plugin management tool, if you have git, you can use Git clone directly
Https://github.com/tpope/vim-pathogen
2, in the establishment of folder ~/.vim
mkdir ~/.vim
3, copy Vim-pathogen under the AutoLoad folder to ~/.vim under:
4, under the ~/.vim set up the bundle folder, used to store vim plug-ins, file directory structure:
[Root@bogon. vim]# tree-l 1 *
AutoLoad
└──pathogen.vim
Bundle
├──nerdtree
├──vim-go
└──vundle.vim
5, CD ~/.vim/bundle to bundle under
Execute git clone https://github.com/fatih/vim-go install vim-go plugin
6. Configure your own VIMRC file, Vim ~/.VIMRC, add:
Call Pathogen#infect ()
Syntax on
FileType plugin indent on
Now browse the Golang code, there is syntax highlighting support and save the time of automatic FMT
7, installs the guru, realizes uses the GD command to jump to the function definition:
First create the golang.org/x folder under the $GOPATH/src path and then execute it under this folder:
git clone https://github.com/golang/tools
After the download is complete, perform the following $GOPATH/src/golang.org/x:
Go Install Golang.org/x/tools/cmd/guru
Locate the Guru under $gopah/bin, move it to the/usr/bin directory, or join $gopah/bin directly. BASHRC:
Vim opens the ~/.BASHRC, adding at its last:
Export Gopath= "Here is Gopath settings" Export gobin= $GOPATH/binexport path= $PATH: $GOPATH/bin
Executes the source ~/.BASHRC to make it effective.
To this vim has the vim-go plug-in and guru function jump support, writing Golang code more convenient, development is faster.