Last Updated: February 25, 2016
·
413
· alexparamonov

Move line(s) of text using Ctrl+j/k

In your vimrc add next:

" Move line(s) of text using Ctrl+j/k
nnoremap  <C-j> :m+<CR>==
nnoremap  <C-k> :m-2<CR>==
inoremap  <C-j> <Esc>:m+<CR>==gi
inoremap  <C-k> <Esc>:m-2<CR>==gi
vnoremap  <C-j> :m'>+<CR>gv=gv
vnoremap  <C-k> :m-2<CR>gv=gv