vim-visual-multi icon indicating copy to clipboard operation
vim-visual-multi copied to clipboard

mappings like <C-Up> seems won't work with <Plug>(VM-Add-Cursor-Up) together

Open JamesWZM opened this issue 4 years ago • 28 comments

Describe the issue: It is the first day that I have tried vim-visual-multi, so I'm not that familiar with it. I tried to read the tutorial and doc, but

I have no idea why. <C-Up>, <C-Down>, <S-Left>, <S-Right> mapping seems not working for me in neovim.

I've checked the mapping of <C-Up>, it is <Plug>(VM-Add-Cursor-Up), but it just won't work I've tried to map <Plug>(VM-Add-Cursor-Up) to another key, it worked well. Also, map another function to <C-Up> seems working well too! They just won't work together!


  • Operating System: Centos7
  • Vim Version: NVIM v0.4.4
  • commit SHA/branch: master

JamesWZM avatar Oct 14 '20 08:10 JamesWZM

Terminal emulator? Does it work in vim?

mg979 avatar Oct 14 '20 11:10 mg979

Also try to run the tutorial and see if it works there (it uses a minimal vimrc).

mg979 avatar Oct 14 '20 11:10 mg979

Well, I used it on putty, used ssh together with tmux working on a remote server computer.

I'm not sure that does it work one vim. I'm not using them together and the build-in vim version is 7.4.629, an old version.

I've tried to run the tutorial, and also failed to work.

ps: <C-n> worked well and I enjoy it faster than vim-multipul-cursor

JamesWZM avatar Oct 16 '20 03:10 JamesWZM

vim version is 7.4.629

Can you try with the v8.1.X or nVim >= v0.3.4?

savchenko avatar Oct 19 '20 03:10 savchenko

It could be a terminal issue, he should try with another terminal. Vim 7 is not supported anyway.

mg979 avatar Oct 19 '20 10:10 mg979

I have the same problem. <C-down> not work on my neovim my neovim is the latest and I use iterm2 as my terminal

another question

how can I change map to <M-n> or other

rmGFW avatar Oct 22 '20 03:10 rmGFW

@rmGFW if that key combination doesn't work on your terminal try other keys. To remap keys: :help vm-mappings.

mg979 avatar Oct 22 '20 07:10 mg979

Also, I don't know in iterm, but for urxvt you can add this to .Xresources:

URxvt.keysym.Control-Up:    \033[1;5A
URxvt.keysym.Control-Down:  \033[1;5B
URxvt.keysym.Control-Left:  \033[1;5D
URxvt.keysym.Control-Right: \033[1;5C
URxvt.keysym.M-Down:        \033[1;3B
URxvt.keysym.M-Up:          \033[1;3A
URxvt.keysym.M-Left:        \033[1;3D
URxvt.keysym.M-Right:       \033[1;3C

mg979 avatar Oct 22 '20 18:10 mg979

Thanks for the plugin!

I do have the same problem, Option key does not work with nvim:

NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/config -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/src -I/usr/local/include -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/src/nvim/auto -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/include
Compiled by brew@Catalina

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.4/share/nvim"

Run :checkhealth for more info```

palcalde avatar Nov 03 '20 11:11 palcalde

Adding the mapping manually in my .vimrc works fine btw

let g:VM_maps = {}
let g:VM_maps["Add Cursor Down"]    = '<M-j>'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<M-k>'   " new cursor up

palcalde avatar Nov 03 '20 11:11 palcalde

@palcalde terminal emulator?

mg979 avatar Nov 03 '20 21:11 mg979

Iterm2 Build 3.3.12

palcalde avatar Nov 04 '20 09:11 palcalde

Adding the mapping manually in my .vimrc works fine btw

let g:VM_maps = {}
let g:VM_maps["Add Cursor Down"]    = '<M-j>'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<M-k>'   " new cursor up

it does not work on my vim ,

rmGFW avatar Nov 04 '20 11:11 rmGFW

Adding the mapping manually in my .vimrc works fine btw

let g:VM_maps = {}
let g:VM_maps["Add Cursor Down"]    = '<M-j>'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<M-k>'   " new cursor up

it does not work on my vim ,

it works ,but if I change the key binding to <M-n> and <M-p> ,it will not work

rmGFW avatar Nov 04 '20 11:11 rmGFW

@palcalde try MacVim or use different mappings. I'm pretty sure it's a terminal issue.

mg979 avatar Nov 04 '20 16:11 mg979

Oh no worries! Adding the mappings in my vimrc works like a charm 👍 btw thanks for the project, works really well!

palcalde avatar Nov 05 '20 08:11 palcalde

Ok, so in nvim with iterm 2 I do receive <M-j>when I press Option + j keys. However, in vim, it does not work cause I receive ^]j when I press Option + j, so it seems Option key is mapped as ^] which means ESC in VIM.

With this mapping I'm able to use Option key in vim>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim Visual Multi
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:VM_maps = {}
" ESC is ^] which is what iterm sends for Option key in vim
let g:VM_maps["Add Cursor Down"]    = '<ESC>j'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<ESC>k'   " new cursor up

palcalde avatar Nov 10 '20 15:11 palcalde

Have you enabled Use option as meta key? I am not on on Mac atm, so I can't test if this fixes the problem (though it should).

Terminal.app: https://www.shell-tips.com/mac/meta-key/

Iterm2: https://stackoverflow.com/questions/196357/making-iterm-to-translate-meta-key-in-the-same-way-as-in-other-oses

https://iterm2.com/faq.html

Q: How do I make the option/alt key act like Meta or send escape codes?

A: Go to Preferences > Profiles tab. Select your profile on the left, and then open the Keyboard tab. At the bottom is a set of buttons that lets you select the behavior of the Option key. For most users, Esc+ will be the best choice.

Alternatively, if that does no work, you can map option+<key> combinations to send custom escape sequences. [1] IIRC, you should be able to do this in Terminal.app too. However, the downside is that you will have to map each alt+<key> shortcuts,

[1] https://thinkingeek.com/2012/11/17/mac-os-x-iterm-meta-key/

MuhammedZakir avatar Nov 11 '20 17:11 MuhammedZakir

I tried, still does not send <M-j> when pressing Option + j It sends always ^] no matter if I set meta or escape keys option in iterm. I've ended up using <leader>jand <leader>k to add cursor up and down.

Thanks for your help anyway!

palcalde avatar Nov 12 '20 16:11 palcalde

@mg979 Is there a way to remap <Plug>(VM-Add-Cursor-Up) and <Plug>(VM-Add-Cursor-Down)? It interferes with my mappings.

horseinthesky avatar Mar 29 '21 16:03 horseinthesky

Ok, so in nvim with iterm 2 I do receive when I press Option + j keys. However, in vim, it does not work cause I receive ^]j when I press Option + j, so it seems Option key is mapped as ^] which means ESC in VIM.

With this mapping I'm able to use Option key in vim>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim Visual Multi
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:VM_maps = {}
" ESC is ^] which is what iterm sends for Option key in vim
let g:VM_maps["Add Cursor Down"]    = '<ESC>j'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<ESC>k'   " new cursor up

how can map <S-Left>, <S-Right> , ? I can't use Option key in vim

wangwenqiangGitHub avatar Apr 28 '21 01:04 wangwenqiangGitHub

Adding the mapping manually in my .vimrc works fine btw

let g:VM_maps = {}
let g:VM_maps["Add Cursor Down"]    = '<M-j>'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<M-k>'   " new cursor up

works in neovim 0.5, thanks man, you made my day.

i have the remaps this way:

let g:VM_maps["Add Cursor Down"]    = '<C-S-Down>'   " new cursor down
let g:VM_maps["Add Cursor Up"]      = '<C-S-Up>'   " new cursor up

alexzanderr avatar Jun 26 '21 16:06 alexzanderr

I got the same problem that <Ctrl+Up> and <Ctrl+Down> did not work as expected on macOS BigSur + Vim 8.2 + Iterm2. Finally, I realized <Ctrl+Up> and <Ctrl+Down> are system-level shortcut in macOS and this could be conflicting with the shortcuts of vim-visual-multi. In this case, it could be fixed by deactivating these shortcuts in System Preferences -> Keyboard -> Shortcuts -> Mission Control -> <Mission Cotrol> for <Ctrl+Up> and <Application windows> for <Ctrl+Down>. I know the fix could be irrelevant to this issue, but I'd like to post the solution here in case someone needs it.

ldpbuaa avatar Nov 08 '21 07:11 ldpbuaa

I use Terminal.app on Mac and needed to follow these instructions: http://www.blogface.org/2015/03/ctrl-in-emacs-in-mac-terminal.html

richardm-stripe avatar Feb 26 '22 10:02 richardm-stripe

The same here. Ctrl-Down/Ctrl-Up stopped working. But I'm using VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 7 2022 21:31:47) Included patches: 1-4525

thiago-scherrer avatar Mar 08 '22 14:03 thiago-scherrer

I use Terminal.app on Mac and needed to follow these instructions: http://www.blogface.org/2015/03/ctrl-in-emacs-in-mac-terminal.html

This is what worked for me.

neovim 0.8.0
terminal
mac os Ventura 13.0.1

jkahne avatar Dec 01 '22 03:12 jkahne

@ldpbuaa

I got the same problem that <Ctrl+Up> and <Ctrl+Down> did not work as expected on macOS BigSur + Vim 8.2 + Iterm2. Finally, I realized <Ctrl+Up> and <Ctrl+Down> are system-level shortcut in macOS and this could be conflicting with the shortcuts of vim-visual-multi. In this case, it could be fixed by deactivating these shortcuts in System Preferences -> Keyboard -> Shortcuts -> Mission Control -> for <Ctrl+Up> and for <Ctrl+Down>. I know the fix could be irrelevant to this issue, but I'd like to post the solution here in case someone needs it.

I didn't want to turn off my default Mission Control shortcut, instead, I found that I can remap with Meta key like so:

let g:VM_maps["Add Cursor Down"]             = '∆'  "/ M-j
let g:VM_maps["Add Cursor Up"]               = '˚'  "/ M-k

Ref: https://stackoverflow.com/a/5382863/3136861

ApolloTang avatar Mar 01 '23 11:03 ApolloTang

In Iterm2, I fixed this issue by setting my profiles keymappings to use the xterm defaults. Fixed it immediately.

tannersltwtr avatar Apr 22 '24 01:04 tannersltwtr