I have the following line in my .vimrc:
inoremap kj <Esc>
It had been working fine, ie it returned me to normal mode. But now it inserts the string "< Esc>" (I use the initial space here just so my post displays properly) into the file at the cursor and I remain in insert mode.
My full .vimrc is as follows
syntax on
set smartindent
set shiftwidth=4
set expandtab
set tabstop=4
inoremap kj <Esc>
nnoremap zz :update<cr>
nnoremap qq :wq<cr>
nnoremap mm :vsplit<cr><C-w><C-w>
" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts."
nnoremap <silent><C-j> m`:silent +g/\m^\s*$/d<CR>``:noh<CR>
nnoremap <silent><C-k> m`:silent -g/\m^\s*$/d<CR>``:noh<CR>
nnoremap <silent><A-j> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-k> :set paste<CR>m`O<Esc>``:set nopaste<CR>
nnoremap <Enter> i<Enter><Esc>
nnoremap <S-Enter> o<Esc>
nnoremap <S-tab> i<tab><Esc>l
nnoremap <C-x> ^i#<Esc>
nnoremap <C-d> yy^i#<Esc>p
Why has this started happening and how can I fix it?
EDIT: output of the following commands
:set compatible?
nocompatible
:set cpoptions?
cpoptions=aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>;
EDIT2: I'm running Arch Linux, 4.19.56-1-lts, and the latest version of Vim. Output of "vim --version":
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 4 2019 23:02:48)
Included patches: 1-1635
Compiled by Arch Linux
Huge version without GUI. Features included (+) or not (-):
+acl -farsi -mouse_sysmouse -tag_any_white
+arabic +file_in_path +mouse_urxvt +tcl/dyn
+autocmd +find_in_path +mouse_xterm +termguicolors
+autochdir +float +multi_byte +terminal
-autoservername +folding +multi_lang +terminfo
-balloon_eval -footer -mzscheme +termresponse
+balloon_eval_term +fork() +netbeans_intg +textobjects
-browse +gettext +num64 +textprop
++builtin_terms -hangul_input +packages +timers
+byte_offset +iconv +path_extra +title
+channel +insert_expand +perl/dyn -toolbar
+cindent +job +persistent_undo +user_commands
-clientserver +jumplist +postscript +vartabs
-clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap +python/dyn +visual
+cmdline_info +libcall +python3/dyn +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap +ruby/dyn +wildmenu
+cursorbind +lua/dyn +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con +mksession +smartindent -X11
+diff +modify_fname -sound -xfontset
+digraphs +mouse +spell -xim
-dnd -mouseshape +startuptime -xpm
-ebcdic +mouse_dec +statusline -xsmp
+emacs_tags +mouse_gpm -sun_workshop -xterm_clipboard
+eval -mouse_jsbterm +syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim -lm -ltinfo -lelf -lnsl -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
inoremap kj <Esc>
but it doesn't appear in your vimrc? (There is an equivalent lineinoremap jj <Esc>
).:set compatible?
and:set cpoptions
. (Edit the question to include the output.) Thanks!:verbose set cpoptions?
:verbose set cpoptions?
showsLast set from /usr/share/vim/vim81/syntax/vim.vim line 989
, (in addition to the list of characters above). The offending line in the listed file readslet &cpo = s:keepcpo
So maybe this means that, when compatible mode is later switched off because of my vimrc, the cpoptions don't change to the Vim options as they normally would, but instead remain as the Vi options?