0

I have two mappings like this:

nnoremap <s-c> zz
inoremap <s-c> <esc>zza

As you can see, I just want to use <s-c> to redraw the current line to the middle of the windows in both normal and insert mode. But, surprisingly, after that mapping, I cannot enter the uppercase C in insert mode any more. Why?

Is it because that the uppercase C by default mapped (recursively) to the <s-c>? (I guess this because in many keyboard pressing <s-c>has the same effect as pressing a uppercase C, that is, you get a C in your buffer.)

If so, how can I unmap it?

  • 5
    Because mapping <s-c> in insert mode means Shift-c or an uppercase letter c. Thus, you cannot type an uppercase letter c in insert mode. – EvergreenTree Aug 1 '15 at 1:26
4

By mapping a character in insert mode (or any mode) you overwrite the default behaviour. In your case, mapping nnoremap <s-c> <esc>zza overwrites the default behaviour of inserting a capital C.

The *noremap commands (e.g. nnoremap,inoremap,etc) do not use recursive mapping, i.e. all keys in the mapping act as though they have the default behaviour. If you would like to insert a capital C as well as using the previously mentioned mapping simply by adding it to the mapping. nnoremap <s-c> C<esc>zza should work.

Finally, no, you can't unmap the default behaviour for keys, only override it with other actions (including doing nothing, with <nop>).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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