matze / vim-move

Plugin to move lines and selections up and down
http://www.vim.org/scripts/script.php?script_id=4687
MIT License
1.2k stars 56 forks source link

Custom key mapping not working properly in neovim #69

Open SDA-31 opened 2 years ago

SDA-31 commented 2 years ago

I have several .lua files in the config directory. I remap keyboard shortcuts with let g:move_map_keys = 1 on

local keymap = vim.api.nvim_set_keymap
kemayp("", "C-h", "<Plug>MoveCharLeft", { noremap = true, silent = true })
keymap("", "C-l", "<Plug>MoveCharRight", { noremap = true, silent = true })

and it works only after entering the command :so %.

Also there are my keyboard shortcuts:

keymap("n", "<A-l>", ">>", { noremap = true, silent = true })
keymap("v", "<A-l>", ">gv", { noremap = true, silent = true })
keymap("n", "<A-h>", "<<", { noremap = true, silent = true })
keymap("v", "<A-h>", "<gv", { noremap = true, silent = true })
matze commented 2 years ago

But it does work with regular vim keymaps in neovim?

zeitchef commented 2 years ago

Not sure if this is related, but vim-move doesn't create any mappings for me at all in Neovim 0.8.0. None of these have any effect:

vim.g.move_key_modifier = 'C'
vim.cmd[[let g:move_key_modifier = 'C']]
matze commented 2 years ago

Are you on Mac? Then #71 could be related.

zeitchef commented 2 years ago

@matze I am indeed, though using Kitty not iTerm.

huyz commented 1 year ago

For a Mac and and the latest vim-move https://github.com/matze/vim-move/commit/a4bbedda7ef516b4a1b74d145cd642297e82e800, this is what works for me in 4 scenarios: vim/neovim in iTerm and MacVim/VimR:

if has("mac") && has("gui_running")
  let g:move_normal_option = 1
endif

assuming:

huyz commented 1 year ago

I had to revisit as not everything was working, in particular inside the terminal. Here's my solution: https://github.com/matze/vim-move/issues/73

hui00 commented 1 year ago

kitty.conf -> macos_option_as_alt yes

felipeospina21 commented 10 months ago

for me using command + opt makes the keybindings work. Im using wezterm by the way.

AgustinOrdonez commented 10 months ago

I am using neovim v0.9.2 and neither of this work

vim.g.move_key_modifier = 'C'
vim.cmd[[let g:move_key_modifier = 'C']]

Unlike zeitchef I am running linux