5

Hi I am having some issue trying to unmap this key in my .vimrc. I've tried a lot of suggestions and remapping but it seems to be resetting itself every time.

unamp <Esc> 
unmap! <Esc>
map <Esc>^[ <Esc>^[
map <Esc> <Nop>

Everytime I open a file in vim and type the following in command mode:

:map <Esc>

The following shows up and I want to get rid of the n <Esc> *:bprevious<CR> mapping completely, that is not in my .vimrc file but it keeps resetting.

n <Esc>     * :bprevious<CR>
  <Esc>^[     <Esc>^[
ov <Esc>      <Nop>

The out from the command suggested in the comment:

:verbose :map <Esc>

Result:

n  <Esc>     * :bprevious<CR>
       Last set from ~/.vimrc
   <Esc>^[   [Esc]^[
       Last set from ~/.vimrc
ov <Esc>     <Nop>
   Last set from ~/.vimrc 

I've checked my .vimrc and I definitely don't have it set.

2
  • 2
    use :verbose :map <Esc> to find out, what created that map. If this is some plugin, you can disable it. Dec 11, 2015 at 8:30
  • @ChristianBrabandt I've added the result to the original question. I definitely don't have that set in the .vimrc, so I'm not sure whats going on here. Dec 11, 2015 at 9:34

2 Answers 2

6

Ctrl-[ is the the same as ESC, as mentioned in :help <Esc>:

notation    meaning         equivalent  decimal value(s)    ~
-----------------------------------------------------------------------
<Nul>       zero            CTRL-@    0 (stored as 10) *<Nul>*
<BS>        backspace       CTRL-H    8 *backspace*
<Tab>       tab         CTRL-I    9 *tab* *Tab*
                            *linefeed*
<NL>        linefeed        CTRL-J   10 (used for <Nul>)
<FF>        formfeed        CTRL-L   12 *formfeed*
<CR>        carriage return     CTRL-M   13 *carriage-return*
<Return>    same as <CR>                *<Return>*
<Enter>     same as <CR>                *<Enter>*
<Esc>       escape          CTRL-[   27 *escape* *<Esc>*
2
  • 1
    Thanks, I was trying to bind Control-[ and right ] to move through the buffers. Glad I learnt it the hard way cheers. Dec 11, 2015 at 10:50
  • 1
    Can this not be undone?? Apr 24, 2020 at 18:08
0

I think I found the 'potentially' culprit. I would love an explanation if anyone can explain it.

These two lines when I comment them out the first entry gets erased.

nnoremap <C-]> :bnext<CR>
nnoremap <C-[> :bprevious<CR>

I'm not sure why that would affect the <Esc> key but it seems to have 'fixed' the issue.

2
  • 1
    That's the traditional escape sequence, and more so in Vim: :h i_CTRL-[
    – VanLaser
    Dec 11, 2015 at 10:12
  • 1
    @VanLaser thanks, I learnt it the hard way :) Dec 11, 2015 at 10:51

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.