Fix centerscroll

This commit is contained in:
Alexander Gehrke 2023-06-27 23:17:19 +02:00
parent aa7cf035ff
commit b3ffefc07c

View file

@ -2,17 +2,4 @@
augroup KeepCentered augroup KeepCentered
autocmd! autocmd!
autocmd CursorMoved * normal! zz autocmd CursorMoved * normal! zz
autocmd TextChangedI * call InsertRecenter()
augroup END augroup END
function InsertRecenter() abort
let at_end = getcursorcharpos()[2] > len(getline('.'))
normal! zz
" Fix position of cursor at end of line
if at_end
let cursor_pos = getcursorcharpos()
let cursor_pos[2] = cursor_pos[2] + 1
call setcursorcharpos(cursor_pos[1:])
endif
endfunction