7

I am using zsh, urxvt, tmux and in there vim. I am not 100% sure who causes the effect but I would like to bind something to ctrl and m but not to carriage return in vim. Does somebody how this is done?

Thank you very much in advance!

2
  • I think you might want to read this vi.stackexchange.com/q/7722/1841
    – statox
    Nov 30, 2017 at 14:15
  • nope, does not help me, because when I unmap carriage return, I unmap c-m and vise versa I want to find a way to separate these both (if it is possible - should be when they send two different keycodes), when I map ctrl-m and unbind carriage return i unmap ctrl-m again...
    – baxbear
    Nov 30, 2017 at 14:24

1 Answer 1

13

As far as Vim is concerned, <C-M> and <CR> are the same thing: they are represented in the same way internally.

If your terminal is truly sending different keycodes (mine doesn't) for when you press Ctrl-M vs Enter, then you might be able to map them separately by using their literal values when you set up the mappings.

Replace the following in your vimrc/Vimscript:

nnoremap <CR> [keypresses]
nnoremap <C-M> [other keypresses]

With the following,

nnoremap [actual ctrl-m keycode] [keypresses]
nnoremap [actual CR keycode] [other keypresses]

Where you enter the keycodes by pressing Ctrl-VCtrl-M and Ctrl-VEnter, respectively.

Your Answer

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

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