Always run gofmt in vim
If you write go it's important to run gofmt before sharing it with others. If you're using vim add this to your .vimrc
au BufWritePost *.go !gofmt -w %
It will run gofmt on your file after you save it, but it doesn't refresh the buffer so you won't see your code suddenly change while your coding (if you want to refresh just do :e)
Written by Matt Williams
Related protips
2 Responses
Perhaps this is interesting to you http://stackoverflow.com/questions/10969366/vim-automatically-formatting-golang-source-code-when-saving
over 1 year ago
·
The default Vim plugin (that comes with the Go source) adds a :Fmt function that will do the same to the current buffer.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#