I want to run a
:command in vim when I exit insert mode. Specifically I want to run
:GoFmt to format my code when I exit insert mode. Currently it runs when I save the file but sometimes I want to format before I do a syntax check (which happens when I save the file).
My current solution was to map
<esc>:GoFmt<enter> but this breaks the behavior of the arrow keys because the arrow keys start with an escape sequence. Is there a better solution?
autocmd FileType go imap <esc> <esc>:GoFmt<enter>