diff --git a/config_files/.vimrc b/config_files/.vimrc index 337bf17..d34b42b 100644 --- a/config_files/.vimrc +++ b/config_files/.vimrc @@ -128,6 +128,11 @@ let g:norminette_exec = '~/.local/bin/norminette' " to move lines with Ctrl + arrow " --------------------------------------------------------------------- +" normal mode : ':m+' moves the current line below the next one, +" ':m-2' moves it above the previous one (:help :move), and '>>'/'<<' +" indent / dedent it, keeping the cursor on the line with the +" trailing 'k'. the C-h/j/k/l variants are the same without +" leaving the home row nnoremap :m+ nnoremap :m-2 nnoremap >>k @@ -137,6 +142,10 @@ nnoremap :m-2 nnoremap >>k nnoremap <<k +" insert mode : escape, move the line, then come back to insert +" with 'gi' (resume at the last insert position). since the simple +" mapping loses replace mode, the versions check first if we +" are in replace mode ('R') and resume in the same mode " for insert mode, check if replace mode before (both uses inoremap) "inoremap :m+gi inoremap mode() ==# 'R' ? "\:m+R" : "\:m+gi" @@ -151,6 +160,8 @@ inoremap :m-2gi inoremap >>gi inoremap <<gi +" visual mode : move the whole selection (using the marks '< and '>) +" or indent / dedent it, then reselect it with 'gv' vnoremap :m'>+gv vnoremap :m-2gv vnoremap >gv