1

For some reason, in my VIM there is a difference in behaviour of Ctrl+Arrow keys in normal mode and in insert mode. To demonstrate this, I edit the file which contents are:

aaa.aaa,aaa/aaa!aaa@aaa#aaa$aaa%aaa^aaa&aaa aaa*aaa(aaa)aaa{aaa}aaa[aaa]aaa-aaa=aaa_aaa"aaa'aaa

In insert mode, when I press Ctrl+Right key, here is where the cursor stops:

aaa.aaa,aaa/aaa!aaa@aaa#aaa$aaa%aaa^aaa&aaa aaa*aaa(aaa)aaa{aaa}aaa[aaa]aaa-aaa=aaa_aaa"aaa'aaa

In normal mode, here is where the cursor stops:

aaa.aaa,aaa/aaa!aaa@aaa#aaa$aaa%aaa^aaa&aaa aaa*aaa(aaa)aaa{aaa}aaa[aaa]aaa-aaa=aaa_aaa"aaa'aaa

I'd like to make it work in normal mode just like it currently works in insert mode.

What I know so far is that :map and :map! don't contain any maps for Ctrl+Arrows keys. Also, VIM recognises Ctrl+Arrows sequences right, i checked that by doing

:nmap <C-Right> :echo 'Normal mode Ctrl+Right'<CR>
:imap <C-Right> <ESC>:echo 'Insert mode Ctrl+Right'<CR>

And I see the effect when I try pressing Ctrl+Arrows How can I fix this?

Update: I've tried the same with a new user who has no ~/.vimrc or ~/.vim, and it reproduces Update2: I'm not remapping the key either

2
  • FWIW I can reproduce this behavior with neovim but not with vim. It might be worth checking if it's part of a new config in neovim.
    – statox
    Commented Apr 26, 2022 at 14:28
  • 1
    I think the difference is basically w (insertmode) vs W in normal mode and this seems to be an inconsistency in the source. In edit.c fwd_word() is called and in normal mode nv_wordcmd() Commented Apr 26, 2022 at 14:57

1 Answer 1

1

OK looks like @ChristianBrabandt is right. The answer is,

:nmap <C-Left> b
:nmap <C-Right> w
3
  • Welcome to Vim!. If you build your answer from comments left by others we encourage you to post it as a community answer (or ask the author of the comment to post an answer himself). Commented Apr 26, 2022 at 16:26
  • @VivianDeSmedt sure, how do I post an answer as a community answer?
    – CoderFF
    Commented Apr 26, 2022 at 17:28
  • I believe there is check box for that at the bottom of the editing screen. Commented Apr 26, 2022 at 17:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.