matze / vim-move

Plugin to move lines and selections up and down

Home Page:http://www.vim.org/scripts/script.php?script_id=4687

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use this Plugin with arrow keys?

maxreuben opened this issue · comments

How can i retool this plugin to make it use arrow keys instead of hjkl? Is it possible? I don't know Vimscript so I can't really tell.

Disable auto-mapping and then bind <Up> and <Down> as usual, i.e.

let g:move_map_keys = 0

vmap <Down> <Plug>MoveBlockDown
vmap <Up> <Plug>MoveBlockUp
nmap <Down> <Plug>MoveLineDown
nmap <Up> <Plug>MoveLineUp

Thank you for your help.

Neither Alt nor Ctrl keys are getting mapped in any of my terminals (alacritty, gnome-terminal, tabby). Is there a way to prevent the terminal from prefixing the ESC character somehow? Or at least a workaround so that that it can be mapped in vim? I tried this:

 map <ESC>[1;5B <A-Down>
 map <ESC>[1;5A <A-Up>
 map! <ESC>[1;5B <A-Down>
 map! <ESC>[1;5A <A-Up>
 
 let g:move_map_keys = 0
 
 vmap <A-Down> <Plug>MoveBlockDown
 vmap <A-Up>   <Plug>MoveBlockUp
 nmap <A-Down> <Plug>MoveLineDown
 nmap <A-Up>   <Plug>MoveLineUp

But it didn't work.

You can see what sequence is sent by going into insert mode, typing C-v and then typing whatever you are interested in. If I type Alt-Up in gnome-terminal I get <M-Up>.

Thanks, I figured it out.