I have neovim 0.4.2 running in a session of kiTTY 0.17.4 on OSX. I have pasted a long url while in insert mode.

After doing this, every time I type BKSPC vim adds ^? to my document. Every time I type ESC vim adds ^[ to my document. Because I cannot type ESC I cannot save or exit the document.

How do I get vim to exit insert mode?

~> nvim -v
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20191107-13403-1or2rj3/neovim-0.4.3/build/config -I/tmp/neovim-20191107-13403-1or2rj3/neovim-0.4.3/src -I/usr/local/include -I/tmp/neovim-20191107-13403-1or2rj3/neovim-0.4.3/deps-build/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/tmp/neovim-20191107-13403-1or2rj3/neovim-0.4.3/build/src/nvim/auto -I/tmp/neovim-20191107-13403-1or2rj3/neovim-0.4.3/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.3/share/nvim"

Vim Session

  • 2
    did you paste something? Looks like you are stuck in bracketed paste mode. Don't know of a way out, except for killing it (perhaps entering the bracketed paste end sequence helps) Commented Jul 11, 2020 at 17:11
  • Yes, I did indeed paste a long URL. Commented Jul 13, 2020 at 18:43

2 Answers 2


How to exit insert mode if pressing escape merely types "^["?

I am working on mintty on Windows with WSL and neovim. I can reproduce the "bracketed paste mode" (or what I started calling "caret mode") after pasing multiline text from a website using middle mouse button into neovim in INSERT mode. This is also reprodible with nvim -u NONE, but not that often.

I found out, that pasting the text again makes it "unstuck" from "bracketed paste mode". Try pasting the text again as you did and then typing exit.


For Lua, you can use the following:

vim.api.nvim_set_keymap("i", "jk", "<Esc>", { noremap = true, silent = true })

For Vimscript:

inoremap jk <Esc>

The code goes in ~/.config/nvim/init.vim or .lua.

  • This provides a mapping, but no default way. If you’re already stuck in insert mode, it’s too late to try to add a new mapping to trigger esc.
    – D. Ben Knoble
    Commented Jan 6 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.