added automated error handling if condition on <leader>ee for golang
This commit is contained in:
parent
c961899fac
commit
2dc3c00f98
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue