How to Exit Insert Mode in Vim

How to Exit Insert Mode in Vim

by Heinz Tschabitscher | Jun 8, 2026 | Useful Tech

Stuck in Vim inserting text, frantically pressing keys — and all you get is unwanted characters flooding the screen? Vim’s insert mode can feel like an inescapable trap if you don’t know how to get out. Find out here how to exit “insert mode” in Vim and Neovim ⤓, including temporary exits, alternatives to “Esc” and custom key mappings.

How to Exit Insert Mode in Vim and Neovim

Time needed: 1 minute

To exit insert mode in Vim and Neovim, returning to normal mode so you can navigate and manipulate text:

  1. Optional: Verify you are in insert mode.

    Here’s how to tell: With its default configuration, Vim displays -- INSERT -- in the bottom left corner of its window, i.e. in the command line where you also enter commands when you are in command-line mode.
    Also replace”: In addition to insert mode, Vim and Neovim know replace mode (-- REPLACE -- in the status bar); with this mode, typing overwrites existing text, but everything else works as in insert mode — Including how to exit it.

  2. Press Esc.

    With insertmode”: If Vim is set up for insertmode, pressing Esc will do nothing and ring the audible or visual bell; see below how to exit insertmode insert mode.
    Alternative keys: If the Esc key does not work or is not available, you can resort to other keys; see below.

Escaped insert mode?

Buy La De Du a tea

Tips help fuel these email and tech how-tos.

Exit Vim Insert Mode Temporarily

You can exit insert mode for just one command in Vim and Neovim. Use this to run a command such as deleting whole words without having to re-enter insert mode.

To run an individual command from normal mode (exit insert mode temporarily):

  1. Press Ctrl O in Vim insert mode.
    Command line: -- INSERT -- in the command line will be replaced with -- (insert) -- while temporary normal mode is in effect.
    You can exit insert mode temporarily in Vim using Ctrl O
  2. Type the desired command in normal mode
    Examples:
    Type di( to delete everything within the enclosing brackets (which you could just as well do with Escci(, of course).
    Enter gqap to re-flow the current paragraph (such as a comment).
    Type :%y* to copy all text to the system clipboard (provided Vim was compiled with the * register).
    Press ~ to toggle the case of the just-typed character (the character just left of the insertion cursor).
  3. Continue typing (back) in insert mode.
    Their word: Vim help includes information on running commands from within insert mode in the FAQ section.

Advanced: Exit Vim Insert Mode with the “insertmode” Option Set

Vim includes a somewhat archaic option to make insert mode the default. With that “insertmode” option set, to exit insert mode:

  1. Optional: Check the “insertmode” option is set.
    Here’s how: Press Ctrl O, then type :set insertmode? and press Enter; if you see insertmode, the option is active.
    Vim only: Neovim does not include the “insertmode” option.
  2. Press Ctrl L to exit insert mode to normal mode.
    Back to insert: Press Esc to return to insert mode.
    One command: Ctrl O also works for executing one normal mode command, of course.

You can also turn off insertmode. To disable it:

  1. Press Ctrl O.
  2. Type :set noinsertmode.
  3. Press Enter.

This will exit insert mode and disable “insertmode”.

How to Exit Insert Mode in Vim and Neovim: FAQ

How do I know I’m in Vim insert mode?

You can usually tell that insert mode is active in Vim using the following criteria:

  • -- INSERT -- is shown in the left of the bottom status bar,
    Replace: Replace mode displays -- REPLACE --.
    Not insert: Normal mode shows -- NORMAL -- or nothing, visual mode is distinguished with -- VISUAL LINE -- etc.
  • a distinct text cursor and
    Here’s how: In many a Vim mode’s default setup, the text cursor changes from a block for normal mode to a slender bar for insert mode, for example.
  • pressing : inserts the character : instead of launching command mode (where you type a command in the status bar).

If you’re in doubt, you can always just press Esc to escape.

Is there an alternative to pressing “Esc”?

Yes.

As an alternative to Esc, you can also press Ctrl C or Ctrl [ to exit insert mode.

Can I set up another key to exit insert mode?

Yes.

Most typically, you will remap another key to act as the Esc key. To do so with the Caps Lock key, for example, add the following to your .vimrc file:

inoremap <CapsLock> <Esc>

Here, you can replace <CapsLock> with a different key, of course. For instance, you can set up jj or ii to exit insert mode:

inoremap ii <Esc>

This lets you exit insert mode by pressing I twice in a row quickly.

Does “Esc” to exit insert mode work in the VSCode Vim extension?

Yes.

The mappings of Esc and Ctrl C both work to exit insert mode in Visual Studio Code with the Vim extension.

(Tested with Vim 9.0–9.1 and Neovim 0.9–0.12; first published March 2024, last updated June 2026)

Home » Useful Tech » How to Exit Insert Mode in Vim