Nov 22

Go Syntax in Vim

Go comes with a syntax file for vim (in misc/vim). I had to tweak ~/.vimrc a bit to make it work nicer. noexpandtab will force vim to insert tabs instead of spaces, smartindent makes the editor keep new lines at the same level of indendation as the previous line.

augroup golang
  au!
  au BufRead,BufNewFile *.go set filetype=go
  au FileType go set noexpandtab
  au FileType go set smartindent
  au FileType go set equalprg=gofmt
augroup END


Simon Pantzare
Simon Pantzare, also available on
Facebook,
Twitter,
Google+,
Reddit,
Github (dev blog).
Ask me anything.