I am programming go and I want to run gofmt with a shortcut and replace the content of the current source file with the output of gofmt.
I have the following mapping defined in my vimrc:
map <C-r> :r ! gofmt %<CR> but this does simply append the output to the current file. Is there a way to override it?
vim-go. It does this alreadygoimportsinstead ofgofmt..vimrcfile.:autocmd BufWritePost *.go silent ! go fmt % 2>&1 >/dev/null