If you're working on a project in Go, and you're using vim, then you really need to check out path:
Add this to you .vimrc:
Just don't dare navigate the directory using the arrow keys!
Here's a very quick tour.
:help path
Add this to you .vimrc:
** tells path to include all subdirectories. By adding your projects GOPATH entry it opens up access to two rather cool features that are useful in navigating your project.
set path +=/your/projects/gopath/src/**
:find
You can use :find to open a file instead of using :e. But :find will look in all of your project's directories to find the file. So rather than having to do:You just need:
:e /package/v10/another-dir/god.go
You also get tab-completion for free - just in case you can't remember the file's name.
:find god.go
gf
gf is the useful little command that goes to the file under the cursor. Well providing you've set your path correcly you can navigate your project's imports with ease:By "gf"ing over the import vim will open the directory, giving you the list of files in that package.
package main
import (
"code.google.com/p/go.net/websocket"
)
Just don't dare navigate the directory using the arrow keys!
Update: 8th Jan 2012
On the subject of vim and Go it's worth remembering this little gem:Whenever a Go file is saved gofmt will be run against it.
au BufWritePost *.go !gofmt -w %