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.
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
Timestamps
- 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
Reference Links
- Vim mappings in my dotfiles
- https://vim.fandom.com/wiki/Moving_lines_up_or_down
- https://github.com/microsoft/terminal/issues/6722
- https://stackoverflow.com/a/10216459
Are you going to be using these mappings? Let us know below.