1

I'm trying to remap C-o to be 'make new line below' (without going to insert mode, as opposed to o) and C-S-o 'make new line above' (without going to insert mode). I do this a lot when reformatting code. I set a mark so that I end up at the same location:

nnoremap <C-o> mxo<Esc>`x
noremap <C-S-o> mxO<Esc>`x

But it inserts a line above in both cases. Why doesn't it work? Can I make it work?

Using Terminal vim.

2

Because that's not possible inside a terminal, both keychords are interpreted as the same control character

Taken from http://catern.com/posts/terminal_quirks.html

To send a control character to the application running in a terminal, hold down Ctrl while pressing another character. This modifies the sent character code by clearing its 7th and 6th bits (indexed starting at 1).

From this page you can see that both O and o have the binary representation of 00001111 if you clear their 7th and 6th bit. Therefore the terminal can't distinguish between those two. That's a well known problem with vim and all terminal applications. It affects other chords with the control character as well.

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