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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Turn Vim into a Powerful Go Development Environment – A Complete Guide

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.vim

Install vim‑go plugin:

git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go

Create 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-plugin

Install 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>MarkSearchCurrentPrev

Install 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 install

Use 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 install

Run inside Vim with :GoLint.

Enable gocode auto‑completion:

cd $GOPATH/src/github.com/gocode/vim
./update.sh

Install 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> :Ack

After 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GoDevelopment EnvironmentVimACKVundleneocompletenerdtreetagbar
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.