Skip to content

Gain the power to move lines and blocks and auto-indent them! Updated fork of fedepujol/move.nvim

License

Notifications You must be signed in to change notification settings

hinell/move.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

move.nvim

Commands for moving line-wise and block-wise lines and characters, both vertically and horizontally.

Demo

move_block_horizontally.mp4
move_block_vertically.mp4
move_line_vertically.mp4

word

Requirements

This plugin works with NeoVim v0.5 or later.

Installation

use "hinell/move.nvim"
Plug "hinell/move.nvim"
"hinell/move.nvim";
"hinell/move.nvim"

Usage

The plugin provides the following commands. Every command accept [0-9]+ number:

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

Setup

NO keybindings are setup by default.

Lua

Alternatively, you can setup ALT+... hotkeys manually:

local opts = { noremap = true, silent = true }
-- Normal-mode commands
vim.keymap.set('n', '<A-Up>'      ,':MoveLine 1<CR>', opts)
vim.keymap.set('n', '<A-Down>'    ,':MoveLine -1<CR>', opts)
vim.keymap.set('n', '<A-S-Left>'  ,':MoveWord -1<CR>', opts)
vim.keymap.set('n', '<A-S-Right>' ,':MoveWord 1<CR>', opts)

-- Visual-mode commands
vim.keymap.set('x', '<A-Up>'   , ':MoveBlock 1<CR>', opts)
vim.keymap.set('x', '<A-Down>' , ':MoveBlock -1<CR>', opts)
vim.keymap.set('v', '<A-Left>' , ':MoveHBlock -1<CR>', opts)
vim.keymap.set('v', '<A-Right>', ':MoveHBlock 1<CR>', opts)

...

VimScript

Not recommended.

" Normal-mode commands
nnoremap <silent> <A-j> :MoveLine 1<CR>
nnoremap <silent> <A-k> :MoveLine -1<CR>
nnoremap <silent> <A-l> :MoveHChar 1<CR>
nnoremap <silent> <A-h> :MoveHChar -1<CR>

" Visual-selection-mode commands
xnoremap <silent> <A-j> :MoveBlock 1<CR>
xnoremap <silent> <A-k> :MoveBlock -1<CR>
vnoremap <silent> <A-l> :MoveHBlock 1<CR>
vnoremap <silent> <A-h> :MoveHBlock -1<CR>

Thanks

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

vim-move.

Original author: thanks to fedepujol@github.com. Most of the code can be is attributed to him. I made a few impromements over fedepujol's work: added plugin/init.lua for better compatibility and updated media.

See also


September 15, 2023

About

Gain the power to move lines and blocks and auto-indent them! Updated fork of fedepujol/move.nvim

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages

  • Lua 100.0%