Move visual block up or down easily.

54 Points

Chris Penner Chris Penner

10 years ago

Rebinds J and K in visual mode to move block up or down in relation to the other lines, while keeping the selection.

This version also re-indents the line to match indentation rules in its new position. (if you don't like that, remove the 'gv=' in the middle :D)

" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv

Sævar Berg

Sævar Berg 10 years ago

This is friggin' awesome!

mesrine

mesrine 10 years ago

/sign

craigp

craigp 9 years ago

This is an epic tip

Jay

Jay 9 years ago

I <3 you. (in the straightest way possible)

Ahmed El Moden

Ahmed El Moden 7 years ago

There is a plugin for this https://github.com/matze/vim-move