5 ms·
I use an Atom extension called "gofmt" which automatically calls goimports[1] every time I save. So any unused imports will be removed and if I start to use new
by treigerm 10y ago
I use an Atom extension called "gofmt" which automatically calls goimports[1] every time I save. So any unused imports will be removed and if I start to use new imports that are in my GOPATH or the standard library then it automatically adds them.
[1] https://godoc.org/golang.org/x/tools/cmd/goimports https://godoc.org/golang.org/x/tools/cmd/goimports
- millstone 10y agoHow does that work with undo?
- buro9 10y agogoimports guesses the one you want and adds it back.
- millstone 10y agoMy question was, since goimports modifies your document (and gofmt even more so), is your undo stack preserved across saves? If so, how?
- buro9 10y agoThat's a question for your text editor. I use Sublime Text 3 with GoSublime and have noticed that the undo stack is just my changes (makes sense, the goimports is an external process), but that's cool because any CTRL+S is going to trigger goimports and so the correction of the imports is invisible and always there.
- _asummers 10y agoIn Eclipse, this is true. The import was considered an "action" that got put into your undo stack. It was just triggered by the editor, not you.
- Leon 10y agoI believe it has worked well for me for undo. However some other Atom formatters have broken my undo in weird ways, namely the formatter for Node JS I had turned on to auto format on saves. I had to turn it off.
- anezvigin 10y agoI can't speak for Atom, but here's what it's like in VIM: http://i.imgur.com/GkP4Yk9.gif http://i.imgur.com/GkP4Yk9.gif
- joshka 10y agoWorks the same in Atom.