diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index a3aa9e5..5f5003b 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -130,3 +130,22 @@ inoremap :m .+1==gi " Fix & command to also use last flags nnoremap & :&& xnoremap & :&& + +" see :help i_ctrl-g_u +" Do not break undo sequence when using the arrow keys or home and end in insert +" mode +inoremap U +inoremap U +inoremap col('.') == match(getline('.'), '\S') + 1 ? + \ repeat('U', col('.') - 1) : + \ (col('.') < match(getline('.'), '\S') ? + \ repeat('U', match(getline('.'), '\S') + 0) : + \ repeat('U', col('.') - 1 - match(getline('.'), '\S'))) +inoremap repeat('U', col('$') - col('.')) +" Make insert-mode texts repeatable by `.` with the closing parentheses at the +" right position +inoremap ( ()U +" break undo sequence with every space and newline, making insert mode changes +" revertible in smaller chunks +inoremap u +inoremap u