Move lines up and down in all modes

4 Points

junk junk

8 years ago

Move lines up and down in all modes, auto-indenting to match scope

nnoremap <leader>lj :m .+1<CR>==
nnoremap <leader>lk :m .-2<CR>==
inoremap <leader>lj <Esc>:m .+1<CR>==gi
inoremap <leader>lk <Esc>:m .-2<CR>==gi
vnoremap <leader>lj :m '>+1<CR>gv=gv
vnoremap <leader>lk :m '<-2<CR>gv=gv''

Sævar Berg

Sævar Berg 8 years ago

I have no issue with entering normal mode to move a line, and in normal mode(unless I'm mistaken), you can only move one line at a time using this binding, no? In which case ddP and ddp are fine for me. I have the visual move binding, however.