Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim changes into replace mode on startup

Tags:

vim

When I open a file with vim, I always start in replace mode.

I figured out, that when I remove this line from my .vimrc, I open files in normal mode again:

nnoremap <esc> :noh<return><esc>

If I exchange <esc> against a different key combination it also works as expected. I don't understand what is going on here.

Here is my complete .vimrc. I use termite, in case that could be a problem.

like image 548
Natjo Avatar asked Jul 17 '18 18:07

Natjo


2 Answers

It was some internal problem, what solved the problem was adding this line:

nnoremap <esc>^[ <esc>^[

Here you can find some details about this solution.

like image 57
Natjo Avatar answered Oct 13 '22 12:10

Natjo


This happened to me connecting to a cray from wsl. My .vimrc is pretty much empty; the distro has a default looking vimrc (no special nohl keymapping).

" FIX: ssh from wsl starting with REPLACE mode
" https://stackoverflow.com/a/11940894
if $TERM =~ 'xterm-256color'
  set noek
endif

Add this to vimrc and it no longer starts in REPLACE mode.

See https://stackoverflow.com/a/11940894 (same thread Jonas mentioned).

like image 23
Yu Feng Avatar answered Oct 13 '22 11:10

Yu Feng