This is a creation in Article, where the information may have evolved or changed.
Test environment
MacOS 10.12.6
First install Vim
Brew Install Vim
I have installed the Vim 8.0 version
Then install Vundle, which is a VIM package Manager
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
Then edit the ~/.VIMRC file
This is my. vimrc file
You can copy the following configuration contents into your. vimrc file
Set nocompatible "be improved, requiredfiletype off " Requiredset backspace=2set modelines=0syntax onset ts= 4set expandtab%retab! "Set numberautocmd bufwritepre *.go:fmtset rtp+=~/.vim/bundle/vundle/call vundle#rc ()" Let Vundle Manage Vundle "required! Bundle ' Gmarik/vundle ' can be specified by the following four ways to specify the source of the plug-in "a" to specify GitHub in the Vim-scripts warehouse plug-ins, directly specify the plug-in name, plug-in in the white space using "-" instead. Bundle ' L9 ' B) specifies the plug-in for other user repositories in GitHub, using the "username/Plugin Name" method to specify bundle ' tpope/vim-fugitive ' bundle ' lokaltog/ Vim-easymotion ' bundle ' rstacruz/sparkup ', {' RTP ': ' vim/'}bundle ' tpope/vim-rails.git ' bundle ' dgryski/ Vim-godef ' bundle ' blackrush/vim-gocode ' bundle ' Majutsushi/tagbar ' "C" specifies a plugin for a non-GitHub git repository that requires the use of Git address Bundle ' git:// Git.wincent.com/command-t.git ' "D) specifies the plugin in the local git repository" Bundle ' file:///Users/gmarik/path/to/plugin ' filetype plugin indent On "required!
Then start installing the Vundle plugin
Enter at the command line first
Vim
And then enter
: Bundleinstall
See here for some introduction to Vundle http://blog.csdn.net/jiaolongdy/article/details/17889787/
You can add the following line to your. vimrc file, which is automatically formatted each time Vim saves the go source file
Autocmd Bufwritepre *.go:fmt
In fact, do not add, measured added no eggs, excerpted from other information, first mark
Reference here: http://ju.outofmemory.cn/entry/89207
I'm going to write this for a moment, and then I'm ready to write it.