Assuming this is a new installation of vim. If not, you may want to backup your .vimrc
and $HOME/.vim/
directory.
- Install vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- Setup an initial .vimrc
curl -o .vimrc https://gist.githubusercontent.com/lpabon/5d8baa164a82674e7f86ffc4055d059e/raw/b47df06f7464a61ce1c31f0d424d1d5c7e813b7c/.vimrc
- Start vim to install the plugins, then type:
:PluginInstall
This will take a little while.
Type :qa
to quit when done.
Now, we need to setup YouCompleteMe:
- Install the necessary requirements: https://github.com/Valloric/YouCompleteMe#linux-64-bit
- Now build it:
$ cd .vim/bundle/YouCompleteMe/
$ ./install.sh --go-completer
You will need to rebuild this every time you run :PluginUpdate
in Vim.
Go to your golang project, or open vim when your $GOPATH
variable is set, then type:
:GoInstallBinaries
:qa
Open a golang file using Vim.
- Autocompletion will be supported when a
.
is typed. Accept usingTAB
. Autocompletion will also accept appromixations. - Type
gd
on a variable/function to see its definition. TypeCTRL-T
to go back up the stack. GoBuild
to build that single fileGoTest
to run all the tests in that package
- Type
gb
then some matching file name
- Automatically collapse a line longer than 80 chars and collapse it to multiple lines of 80 chars max by typing
gq
.
- Git commands use vim-fugitive. Examples:
:Gblame
for git blame:Gdiff
for git diff