Turn Vim into a Powerful Go Development Environment – A Complete Guide
This step‑by‑step tutorial shows how to configure Vim with Vundle, vim‑go, NERDTree, Tagbar, neocomplete, goimports, golint, gocode, ack and custom shortcuts to create a full‑featured Go development environment on Linux.
Before starting, ensure Go is installed and its environment variables (GOPATH, GOBIN, GOROOT, PATH) are correctly set in /etc/profile and sourced.
Install Git: # yum install -y git Install Vundle (Vim plugin manager):
mkdir ~/.vim/bundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vimInstall vim‑go plugin:
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-goCreate or edit ~/.vimrc and add the basic Vundle setup and the required plugins:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'git://github.com/scrooloose/nerdtree.git'
Plugin 'git://github.com/Xuyuanp/nerdtree-git-plugin.git'
Plugin 'Shougo/neocomplete'
Plugin 'Shougo/neosnippet'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'jstemmer/gotags'
Plugin 'majutsushi/tagbar'
Plugin 'mileszs/ack'
call vundle#end()
filetype plugin indent on
let g:go_version_warning = 0
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:neocomplete#enable_at_startup = 1
" NERDTree shortcut
map <F7> :NERDTreeToggle<CR>
" Tagbar shortcut
map <F8> :TagbarToggle<CR>
" Mark plugin shortcuts (see later)Install NERDTree and its git‑integration plugin:
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
git clone https://github.com/Xuyuanp/nerdtree-git-plugin.git ~/.vim/bundle/nerdtree-git-pluginInstall neocomplete and neosnippet (follow the instructions on their GitHub pages) and add to ~/.vimrc: let g:neocomplete#enable_at_startup = 1 Install Tagbar and configure Go tags:
Plugin 'jstemmer/gotags'
Plugin 'majutsushi/tagbar'
let g:tagbar_type_go = {
'ctagstype' : 'go',
'kinds' : ['p:package','i:imports:1','c:constants','v:variables','t:types','n:interfaces','w:fields','e:embedded','m:methods','r:constructor','f:functions'],
'sro' : '.',
'ctagsbin' : 'gotags',
'ctagsargs' : '-sort -silent'
}Install the Mark plugin for quick word highlighting:
git clone https://github.com/vim-scripts/mark.vim.git ~/.vim/bundle/mark.vim
" Add shortcuts to ~/.vimrc
nmap ml <Plug>MarkSet
nmap md <Plug>MarkClear
nmap mn <Plug>MarkSearchAnyNext
nmap mp <Plug>MarkSearchAnyPrev
nmap mf <Plug>MarkSearchCurrentNext
nmap mb <Plug>MarkSearchCurrentPrevInstall goimports:
# Clone the tools repository and build goimports
cd $GOPATH/src
mkdir -p golang.org/x && cd golang.org/x
git clone https://github.com/golang/tools.git
cd tools/cmd/goimports
go installUse it inside Vim with :GoImports.
Install golint for linting Go code:
git clone https://github.com/golang/lint $GOPATH/src/golang.org/x/lint
cd $GOPATH/src/golang.org/x/lint
go installRun inside Vim with :GoLint.
Enable gocode auto‑completion:
cd $GOPATH/src/github.com/gocode/vim
./update.shInstall ack for fast searching and bind it to F4:
# yum install -y ack
git clone https://github.com/mileszs/ack.vim.git ~/.vim/bundle/ack
" Add to ~/.vimrc
Plugin 'mileszs/ack'
map <F4> :AckAfter adding all plugins, launch Vim and execute :PluginInstall; when the command finishes with “Done”, the environment is ready. The final ~/.vimrc combines all configurations, and common shortcuts such as F7 (NERDTree), F8 (Tagbar), gd (go to definition), Ctrl+w w (window switch) are available for efficient Go development.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
