Setting up vim for golang

I have been using vim for more than three months. Now I do most of my editing on vim. In this post, I shall be describing setting up vim for golang from scratch. Vim config that I shall be posting here is available here. I play with my vim configuration frequently to increase productivity and improve my experience with vim. Follow below sections to set up your vim.

Set up a plugin manager

There are many available plugin managers like pathogen, vim-plug, vim packages etc. I use pathogen.

  • Run the following command to install pathogen.vim.
  • Create a .vimrc file in the home directory.
  • Add following lines in the .vimrc file.

Set up a file explorer

NerdTree gives ability to browse and open files and directories. It allows us to perform simple file operations like create, delete, rename a file or directory. Run following command to install nerdtree.

  • Add following lines in .vimrc to configure nerdtree

Install a color scheme

Vim colors is a collection of nice color schemes for vim. I like codeschool color scheme. To install a color scheme create directory colors under .vim directory then add your color scheme.vimfile in colors directory and add following lines in the .vimrc file.

Set up support for Go language. Install vim-go plugin

This plugin adds Go language support for Vim. It has many useful features listed here. Run the following command to install vim-go plugin.

After installing vim-go plugin, run following command from vim to install necessary binaries.

After following above sections successfully you should have your vim configured for Golang. Vim is highly configurable. You can configure vim as per your preferences. If you have any suggestions about plugins to use, please let me know.

Product Engineer at Gojek.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store