[vim-go] Add Go imports automatically on save

Created on November 29, 2026

With vim-go, you can set goimports as the formatter in .vimrc. When vim-go formats a Go file on save, goimports adds missing imports for packages used in the file and removes unused imports.

let g:go_fmt_command = "goimports"

This setting requires goimports and vim-go's format-on-save feature.

Reference

vim-go