Monday, March 15, 2010

Setup the Vim Editor for Go in Linux

1. Complete Go Installation

2. After completing the installation of the Go code base and building you need to copy the vim syntax file into your vim syntax file directory. There are many other places you could put the go.vim syntax file. This is the way I did it.

sudo cp $GOROOT/misc/vim/go.vim /usr/share/vim/vim72/syntax/

3. Now we have to tell vim what kind of files to use the go syntax for. There are many ways to do this, this is what I did.

mkdir ~/.vim/ftdetect
echo "au BufRead,BufNewFile *.go set filetype=go" > ~/.vim/ftdetect/go.vim

Now you should be setup to begin writing your Go code in vim with syntax highlighting.

EDIT: This is all irrelevant. The readme inside of $GOROOT/misc/vim explains one of the best ways to do this.

There is also a file in the $GOROOT/misc/bash directory that enables bash tab completion for the go compilers and linkers. Copy this into /etc/bash_completion.d/

sudo cp $GOROOT/misc/bash/go /etc/bash_completion.d/

No comments:

Post a Comment