Ideavim - Cannot re-select with 'gv' after using ':m' move command

65 Views Asked by At

In my .ideavimrc I am currently trying to implement a macro that allows me to move a selected block of code multiple time using J and K.

The problem is that gv doesn't give me back my old selection after doing a move command with :m

Do you know if there is any way to use gv after doing a move command (:m) with ideavim ?

I used this command in neovim and it worked :

vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")

It moved the selected block of code down and then give me back the selection so I can move it again.

Now I want to translate it to vimscript but with the limitations of ideavim.
I tried few things that look approximately like this:

vnoremap K :m '<-2<CR>gv=gv
vnoremap J :m '>+1<CR>gv=gv

But it doesn't work so I tried manually and I seems like after doing :m '<-2 the gv command doesn't give the last selection back.

0

There are 0 best solutions below