Last Updated: February 25, 2016
·
464
· gravis

Import go package in vim

The vim golang official plugin comes with a handy macro to add a package import, at the top of the file:

:Import os

To import with a package alias:

:ImportAs {localname} {path}

And finally, to remove a package:

:Drop {package}

will add the "os" package inside the "import" block, at the right sorted position.
More info: http://golang.org/misc/vim/ftplugin/go/import.vim