Skip to content

Instantly share code, notes, and snippets.

@tbrisbout
Created April 13, 2020 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbrisbout/a91ac3419440cde40c5f54dc32c94427 to your computer and use it in GitHub Desktop.
Save tbrisbout/a91ac3419440cde40c5f54dc32c94427 to your computer and use it in GitHub Desktop.
Gofmt on save in vim without plugins
function! CustomGoFmt()
let file = expand('%')
silent execute "!gofmt -w " . file
edit!
set filetype = go
endfunction
command! CustomGoFmt call CustomGoFmt()
augroup go_autocmd
autocmd BufWritePost *.go CustomGoFmt
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment