Move lines in Neovim

Riley Tomasek

These Neovim key mappings enable a more efficient workflow for moving lines in visual mode.

-- Move selected lines down in Visual mode
vnoremap J :m '>+1<CR>gv=gv

-- Move selected lines up in Visual mode
vnoremap K :m '<-2<CR>gv=gv

You can now use J and K to move lines up and down in visual mode without having to yank and paste.

asciicast