Moving Lines Up and Down in Vim without Using the Clipboard
In this video we'll go over moving 1 line up or down in normal mode and also moving multiple lines in visual mode without plugins.
Quick Jump: Going Over the Mappings
I recently added these mappings to my dotfiles and it’s been a nice quality of life improvement for moving variables or blocks of code up and down 1 or more lines.
In some use cases it ends up being faster than using
dd and this also has the added benefit of not overwriting your system clipboard if you happen to be using the
set clipboard=unnamedplus setting in Vim.
Going Over the Mappings
- 0:09 – Moving 1 or more lines up and down with K and J
- 0:43 – At the moment there’s no mapping for insert mode
- 0:57 – I found these mappings on the Vim Fandom page
- 2:13 – They’re referenced in my dotfiles
- Vim mappings in my dotfiles
Are you going to be using these mappings? Let us know below.