move.nvim icon indicating copy to clipboard operation
move.nvim copied to clipboard

Moving a block vertically results in whole line movement instead

Open Russoul opened this issue 3 years ago • 4 comments

Russoul avatar Jun 20 '22 15:06 Russoul

I can confirm MoveBlock doesn't work, just move the cursor to the bottom and select all the lines.

Mte90 avatar Sep 06 '22 14:09 Mte90

I can't reproduce this on my machine. @Mte90 does this happen on every file? Can you provide a example config on how you're using the plugin?

fedepujol avatar Sep 08 '22 14:09 fedepujol

I changed that line https://github.com/Mte90/dotfiles/blob/master/.config/nvim/lua/mappings.lua#L36 with "MoveBlock" selecting multiple lines and I got the cursor moved with all the selected lines. I don't know if it is related https://github.com/fedepujol/move.nvim/issues/12

Mte90 avatar Sep 08 '22 14:09 Mte90

I've managed to reproduce this issue (thanks @Mte90 for the info!). The problem here is the vim-mode of the mapping to use MoveBlock.

MoveBlock only works in visual-mode, unlike MoveLine which works in normal-mode.

-- This won't work
vim.keymap.set('n', '<A-j>', ':MoveBlock(1)<CR>', opts)
-- This will
vim.keymap.set('v', '<A-j>', ':MoveBlock(1)<CR>', opts)

@Mte90 Try changing the mode to 'v' in your mapping and let me know.

fedepujol avatar Sep 08 '22 16:09 fedepujol

Closing due to inactivity. Feel free to re-open if it's not resolve.

fedepujol avatar Sep 26 '22 12:09 fedepujol

I am also facing this problem now, this is my configuration, i use lunarvim

    {
        "fedepujol/move.nvim",
        config = function()
            local opts = { noremap = true, silent = true }
            local opts = { noremap = true, silent = true }
            -- Normal-mode commands
            -- vim.keymap.set('n', '<S-j>', ':MoveLine(1)<CR>', opts)
            -- vim.keymap.set('n', '<S-k>', ':MoveLine(-1)<CR>', opts)
            -- vim.keymap.set('n', '<S-h>', ':MoveHChar(-1)<CR>', opts)
            -- vim.keymap.set('n', '<S-l>', ':MoveHChar(1)<CR>', opts)
            -- vim.keymap.set('n', '<leader>wf', ':MoveWord(1)<CR>', opts)
            -- vim.keymap.set('n', '<leader>wb', ':MoveWord(-1)<CR>', opts)

            -- Visual-mode commands
            vim.keymap.set('v', '<S-j>', ':MoveBlock(1)<CR>', opts)
            vim.keymap.set('v', '<S-k>', ':MoveBlock(-1)<CR>', opts)
            vim.keymap.set('v', '<S-h>', ':MoveHBlock(-1)<CR>', opts)
            vim.keymap.set('v', '<S-l>', ':MoveHBlock(1)<CR>', opts)
        end,
    },

https://github.com/fedepujol/move.nvim/assets/50194671/d0c1ec65-5e53-4776-a56f-6194fcc5b6f7

https://github.com/fedepujol/move.nvim/assets/50194671/0e5ee3ef-c8bc-4232-9418-017109d0d9de

edte avatar Jan 22 '24 12:01 edte

Will check this out

fedepujol avatar Jan 25 '24 17:01 fedepujol

The only way for me to reproduce this was doing something like:

  1. Select in VisualBlock a block of lines
  2. Trying to move the selected block up or down

That behaviour will clash MoveHBlock with the MoveBlock command. Are you doing something similar @edte?

fedepujol avatar Feb 02 '24 18:02 fedepujol

Closing due to inactivity. Feel free to re-open

fedepujol avatar Feb 11 '24 01:02 fedepujol