0

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.

2
  • What is your IdeaVim version? There was an old bug with restoring selection after moving lines, but it's already fixed in latest releases. Commented Dec 4, 2023 at 16:03
  • Yes needed to update to latest version of Android Studio to have the fixes thank you. Commented Dec 13, 2023 at 7:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.