1

I'm a happy owner of a TypeMatrix 2030, as well as a happy vim user. On this keyboard the <del> have a central place, while the <esc> is the top-left key as usual. So I would like to remap my <del> key to <esc>. So far I added this lines to my .vimrc:

noremap <del> <esc>
nnoremap <del> <esc>
inoremap <del> <esc>
vnoremap <del> <esc>
xnoremap <del> <esc>
snoremap <del> <esc>
cnoremap <del> <esc>
onoremap <del> <esc>

It almost works fine, except in the command-line mode : entering :cmd<del> will launch the help as would :cmd<enter>, while :cmd<esc> will erase the line and return to normal mode.

Here is the output for :verbose cnoremap <Del>:

c  <Del>       * <Esc>>    
    Last changed in ~/.config/vim/vimrc 

Output for others modes give a similar result, with the strange double chevron >>, but works fine (typing while in insert mode will switch to normal mode).

  • Note: noremap does the same work as the combination of nnoremap, vnoremap, and onoremap. Likewise, noremap! does the work of inoremap plus cnoremap; and vnoremap does the work of xnoremap plus snoremap. If you're not listing all of them just to be super-clear about what you're doing, you could combine them into only three map commands. – echristopherson Apr 10 '14 at 22:34
1

I think this behavior is due to what's described under :help c_Esc (read "macros" as "mappings"; they're closely related):

  <Esc>   When typed and 'x' not present in 'cpoptions', quit
          Command-line mode without executing.  In macros or when 'x'
          present in 'cpoptions', start entered command.

You can work around this by using <C-c> instead:

:cnoremap <del> <C-c>
|improve this answer|||||

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.