added automated error handling if condition on <leader>ee for golang

This commit is contained in:
Stefan Friese 2024-02-29 17:22:45 +01:00
parent c961899fac
commit 2dc3c00f98
1 changed files with 12 additions and 0 deletions

View File

@ -7,3 +7,15 @@ let g:ale_linters = {
" let g:ale_completion_enabled = 1
" Map <Leader>ee to insert Go error handling if condition
nnoremap <Leader>ee :call InsertGoErrorHandling()<CR>
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