14

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.

2
  • Thanks, I found the answer somewhere in a discussion in your linked question!
    – Natjo
    Commented Jul 17, 2018 at 19:21
  • The question you linked is about the same topic, but the accepted answer to it did not solve my problem, that's why I added an answer here as well, stating the proper solution.
    – Natjo
    Commented Jul 17, 2018 at 19:26

2 Answers 2

13

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.

2
  • 3
    Duh, how is this answer not the accepted one? Works perfectly for me on WSL1 and properly keeps arrow keys working.
    – kubanczyk
    Commented Sep 24, 2020 at 12:03
  • 1
    Thanks for the feedback! I answered myself here, but it didn't feel like an adequate solution. But if it helped you, too, I guess it should be the accepted answer.
    – Natjo
    Commented Sep 24, 2020 at 13:09
10

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).

1
  • 2
    this resets "nocompatible" for me with the effect that I cannot use backspace or arrow keys in insert mode (it just inserts ABCD etc. -- it is a known problem in vimwiki). Any solution for combining the both?
    – niid
    Commented Sep 5, 2020 at 21:38

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