diff --git a/vim/.vim/after/ftplugin/go.vim b/vim/.vim/after/ftplugin/go.vim index df0fb7f..6286364 100644 --- a/vim/.vim/after/ftplugin/go.vim +++ b/vim/.vim/after/ftplugin/go.vim @@ -7,3 +7,15 @@ let g:ale_linters = { " let g:ale_completion_enabled = 1 +" Map ee to insert Go error handling if condition +nnoremap ee :call InsertGoErrorHandling() + +function! InsertGoErrorHandling() + let err_handling = "if err != nil { \r return err \r}" + + let save_cursor = getpos(".") + execute "normal! a" . err_handling + normal! jjj$ + normal! $o + startinsert +endfunction