Announcing ‘mini.move’
Originally posted on Reddit
Hello, Neovim users!
Let me introduce you to mini.move - new module of mini.nvim which adds ability to move current visual selection or current line in all four directions (left, right, down, up). It can also be installed using separate GitHub repository.
To be perfectly honest, I didn’t plan to write this module, as most of its functionality can be replicated using basic Vim actions. But while doing research for another upcoming module, I stumbled upon this kind of functionality in a form of simple mappings. It worked only for vertical movement in Visual mode and had several “quality of life” drawbacks (lack of v:count
support, handling of undo, etc.). So of course it got me thinking if I can make it better without much complications (there are plugins with this functionality already, but their implementation feels disproportionally complex). Several couples of days later we got this module and I can appreciate visual feedback of this movement approach :)
Main features:
- Works in two modes:
- Visual mode. Select text (charwise with
v
, linewise withV
, and blockwise withCTRL-V
) and press customizable mapping to move in all four directions (left, right, down, up). It keeps Visual mode. - Normal mode. Press customizable mapping to move current line in all four directions (left, right, down, up).
- Vertical linewise movement gets reindented with
=
. Horizontal linewise movement is same as indent with>
and dedent with<
.
- Visual mode. Select text (charwise with
- Provides both mappings and Lua functions for motions.
- Respects
v:count
. Movement mappings can be preceded by a number which multiplies command effect. - All consecutive moves (regardless of direction) can be undone by a single
u
. - Respects preferred column for vertical movement. It will vertically move selection as how cursor is moving (not strictly vertically if target column is not present in target line).
For more information, see help file.
Please, check it out and tell me what you think! Either here in comments or in dedicated beta-testing issue.
Thanks!