From a42155a64bc56746171b425566bc51672df3ee22 Mon Sep 17 00:00:00 2001 From: druckdev Date: Thu, 30 Sep 2021 10:38:58 +0200 Subject: [PATCH] vim:keys: Improve bindings to move lines The old bindings had problems when trying to move further than BOF, EOF. --- .config/vim/vimrc.d/40-keys.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index ae9fe86..8082e1d 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -116,10 +116,14 @@ endif nnoremap Y y$ " Move lines up and down while correcting the indentation -nnoremap ddkP== -nnoremap ddp== -vmap dkPgp=gv -vmap dpgp=gv +" https://vim.fandom.com/wiki/Moving_lines_up_or_down +" (Use arrows, as Alt-{j,k} is used by my terminal for scrollback) +nnoremap :m .-2== +nnoremap :m .+1== +vnoremap :m '<-2gv=gv +vnoremap :m '>+1gv=gv +inoremap :m .-2==gi +inoremap :m .+1==gi " Fix & command to also use last flags nnoremap & :&&