1

I have been using vim for a short time, so I may not know a lot, please forgive me.

There is a problem with my vim. It cannot enter normal mode from insert mode by pressing esc/ctrl-[ only once, but needs to press esc/ctrl-[ twice.

When I first press esc/ctrl-[ show command remind me I entered ^[. I have tried to turn off all the plugins I use, but it doesn't solve.

There is my vimrc file:

syntax enable

set showcmd
set relativenumber
set shiftwidth=4 tabstop=8
set notimeout
set autowrite

call plug#begin('~/.vim/plugged')

Plug 'vim-airline/vim-airline'
Plug 'ycm-core/YouCompleteMe'
Plug 'raimondi/delimitmate'

call plug#end()

System: Ubuntu 20.04, terminal vim, local

6
  • 1
    The first thing you should try is running with sane defaults in place of your vimrc. Add the Vim flag --clean when you launch. Next you could turn off your three plugins then turn them on/off one at a time to see if any are the cause. Basically you want to debug your vimrc. Here's a full treatment of that topic: How do I debug my vimrc file? Welcome to Vi&Vim SE. – B Layer Apr 17 at 1:21
  • @BLayer Thank u! – BreezyMain Apr 17 at 1:36
  • No problem. If you narrow things down but don't fully solve the problem edit your question and add whatever new information you've found. – B Layer Apr 17 at 2:06
  • Does :imap <ESC> show any mappings that might be defined starting with the ESC key? – filbranden Apr 17 at 4:35
  • 1
    @BreezyMain By "yes", do you mean you did find such a mapping? Would you care to expand on what the mapping was? Like Ben mentioned on his answer, run it with :verbose to see where it was defined... Cheers! – filbranden Apr 17 at 20:00
3

As sussed out in the comments, you have mappings that begin with <esc> somewhere (and the surprise indicates you didn’t ask for them). You can use :verbose imap <esc> to find out where the mappings are coming from; in general, mappings with a prefix cause a delay whenever the prefix is entered, as vim has to distinguish between the prefix starting a mapping and not. In other words, vim has to wait for the keypress after the prefix (or a fixed amount of time; there are options to control it) to know what to do next.

I suggest getting rid of the mappings if possible. If you can identify what they are/where they come from, I can provide suggestions on how to remove them.

1

Thank you for answering the question. Although no body found what the problem is, I still be thank to you.

The reason is timeout and ttimeout is off as the same time. It caused my vim waiting a operation forever. The solution is open the timeout. If you want to let your vim to be faster, you can turn on ttimeout and set ttimeoutlen to a low value. my is 100.

1
  • Good catch! For some reason I guess we didn't think of ttimeout, which surely explains this... Also note that ttimeout (and a ttimeoutlen of 100) is set in defaults.vim, consider sourcing that file from your vimrc. See :help defaults.vim for more details on how to do that. – filbranden May 1 at 15:57

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.