Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/fedepujol/move.nvim

Gain the power to move lines and blocks and auto-indent them!
https://github.com/fedepujol/move.nvim

lua move neovim nvim plugin vim

Last synced: 12 days ago
JSON representation

Gain the power to move lines and blocks and auto-indent them!

Lists

README

        

# move.nvim

Gain the power to move lines and blocks!

## Vertical Movement

![vert_line](https://user-images.githubusercontent.com/26419570/214643592-9c7ae7bf-c26f-4698-986b-883c2b7a1206.gif)

![vert_block](https://user-images.githubusercontent.com/26419570/214643489-07ed1aa3-354c-457c-81c2-466bf84b2332.gif)

## Horizontal Movement

![hor_char](https://user-images.githubusercontent.com/26419570/214643419-461da2ce-bd98-4946-99a3-b063300d438c.gif)

![hor_block](https://user-images.githubusercontent.com/26419570/214643129-e013b118-e438-4dee-a82c-a98a1a4aadfa.gif)

## Word Movement

![word](https://user-images.githubusercontent.com/26419570/227013070-6c5e041c-c500-4944-8c83-79d5d54f6394.gif)

## :zap: Requirements

This plugin works with Neovim v0.5 or later.

## :package: Installation

- [lazy](https://github.com/folke/lazy.nvim)

```lua
{
'fedepujol/move.nvim',
opts = {
--- Config
}
}
```

- [paq](https://github.com/savq/paq-nvim)

```lua
'fedepujol/move.nvim';
```

## :gear: Configuration
You can use the default's (leaving the setup function empty)
```lua
require('move').setup({})

```

or customizing it
```lua
require('move').setup({
line = {
enable = true, -- Enables line movement
indent = true -- Toggles indentation
},
block = {
enable = true, -- Enables block movement
indent = true -- Toggles indentation
},
word = {
enable = true, -- Enables word movement
},
char = {
enable = false -- Enables char movement
}
})

```
:information_source: By default, every option is enabled except char movement.
:warning: Disabling line/block/word/char movements, will not generate the commands.

## :rocket: Usage

The plugin provides the following commands:

| Command | Description | Mode |
| ---------- | --------------------------------------------------------- | ------ |
| MoveLine | Moves a line up or down | Normal |
| MoveHChar | Moves the character under the cursor, left or right | Normal |
| MoveWord | Transpose the word under the cursor forwards or backwards | Normal |
| MoveBlock | Moves a selected block of text, up or down | Visual |
| MoveHBlock | Moves a visual area, left or right | Visual |

## :keyboard: Mappings

### VimScript

```vim-script
" Normal-mode commands
nnoremap :MoveLine(1)
nnoremap :MoveLine(-1)
nnoremap :MoveHChar(1)
nnoremap :MoveHChar(-1)
nnoremap wf :MoveWord(1)
nnoremap wb :MoveWord(-1)

" Visual-mode commands
vnoremap :MoveBlock(1)
vnoremap :MoveBlock(-1)
vnoremap :MoveHBlock(1)
vnoremap :MoveHBlock(-1)
```

### Lua

```lua
local opts = { noremap = true, silent = true }
-- Normal-mode commands
vim.keymap.set('n', '', ':MoveLine(1)', opts)
vim.keymap.set('n', '', ':MoveLine(-1)', opts)
vim.keymap.set('n', '', ':MoveHChar(-1)', opts)
vim.keymap.set('n', '', ':MoveHChar(1)', opts)
vim.keymap.set('n', 'wf', ':MoveWord(1)', opts)
vim.keymap.set('n', 'wb', ':MoveWord(-1)', opts)

-- Visual-mode commands
vim.keymap.set('v', '', ':MoveBlock(1)', opts)
vim.keymap.set('v', '', ':MoveBlock(-1)', opts)
vim.keymap.set('v', '', ':MoveHBlock(-1)', opts)
vim.keymap.set('v', '', ':MoveHBlock(1)', opts)
```

## :electric_plug: Integration

### [Legendary.nvim](https://github.com/mrjones2014/legendary.nvim)

Thanks to [hinell](https://github.com/hinell) to point this out:

> **Note**: Don't set up the keys like above if you're using legendary

```lua
local opts = { noremap = true }
require('legendary').setup({
keymaps = {
{ "", ":MoveLine -1", description = "Line: move up", opts },
{ "", ":MoveLine 1", description = "Line: move down", opts },
...
}
})
```

## Mention

There is an original and more feature rich plugin (written in VimScript):

[vim-move](https://github.com/matze/vim-move).