1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

add mapping: keep cursor position after yanking

This commit is contained in:
jdhao 2021-11-03 22:55:40 +08:00
parent 573f9277cb
commit 49fc7f3dbc

View File

@ -183,3 +183,16 @@ endfor
" insert semicolon in the end
inoremap <A-;> <ESC>miA;<ESC>`ii
" Keep cursor position after yanking
nnoremap y myy
xnoremap y myy
augroup restore_after_yank
autocmd!
autocmd TextYankPost * call s:restore_cursor()
augroup END
function! s:restore_cursor() abort
silent! normal `y
silent! delmarks y
endfunction