0

I often press ESC/^[ to ensure that I've left insert mode and entered normal mode. However, if I'm already in normal mode, Vim displays an annoying flashy screen effect:

enter image description here

How can I prevent Vim from making this flashy screen effect, when pressing ESC/^[ in normal mode?

Bonus: I guess it has no effect of pressing ESC/^[ in normal mode, other than cancelling the current command e.g. d, so why does Vim makes this flashy screen effect?

2
  • You can also often configure how bells work in your terninal emulator (sound, flash, nothing, etc.)
    – D. Ben Knoble
    Jan 14, 2020 at 14:00
  • @D.BenKnoble - yeah, I’ve disabled the sound in Terminal on macOS, but this doesn’t stop Vim from making flashy screen.
    – Shuzheng
    Jan 14, 2020 at 17:41

1 Answer 1

3

That's a bell (a visual bell). You can turn off bells for Esc in normal mode using belloff:

                        *'belloff'* *'bo'*
'belloff' 'bo'      string  (default "")
            global
    Specifies for which events the bell will not be rung. It is a comma
    separated list of items. For each item that is present, the bell
    will be silenced. This is most useful to specify specific events in
    insert mode to be silenced.

    item        meaning when present    ~
    all     All events.
    [...]
    esc     hitting <Esc> in |Normal-mode|.

So:

set belloff=esc
5
  • Does set belloff=esc both cover ESC and ^[ (Ctrl-[), because I most often use the latter form to escape insert mode (if so, why?). Can you say why anyone would want this bell in normal mode?
    – Shuzheng
    Jan 14, 2020 at 7:17
  • Ctrl-[ is Esc, so yes. Presumably because someone pressing Esc in normal mode is usually trying to get into normal mode already, this tells you when you have reached normal mode and can start a command. (See also, original vi's help for Esc.)
    – muru
    Jan 14, 2020 at 7:22
  • Sorry, if this is too off-topic, but where do you see that Ctrl-[ is ESC? But will pressing ESC not always get you into normal mode? Could there be a situation, where I needed to press ESC multiple times to get into normal mode?
    – Shuzheng
    Jan 14, 2020 at 7:25
  • @Shuzheng vi.stackexchange.com/a/3570/205. Say you've used Ctrl-R = in insert mode, you'll need two Esc to get back to normal mode.
    – muru
    Jan 14, 2020 at 7:31
  • @Shuzheng bestasciitable.com made by a former mod here
    – D. Ben Knoble
    Jan 14, 2020 at 17:49

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.