1

When I open up vim, it starts off with :2R already entered into the command line. I tried commenting out my entire .vimrc, and then it opens up starting in replace mode, with the 2 key pre-pressed (in other words, I insert some text, press <ESC>, and the text appears twice), which is the same as if I had pressed 2R upon opening vim.

How should I go about debugging this? I don't think it can be an issue with my .vimrc, so then what could it be?

For reference, I just updated to version 8.2 via ppa:jonathonf/vim.

17
  • 2
    Are you using <Esc> in any mappings in your vimrc? In my answer here notice the reference to 2R... Why does terminal vim enter replace mode with my vimrc file?
    – B Layer
    Commented Dec 2, 2020 at 20:50
  • Thanks for the helpful link. I do use <ESC> in some mappings, but never on the left-hand side. Further, commenting out the whole .vimrc does not stop the 2R from occurring. I opened up vim with a fully-commented .vimrc, and used :scriptnames to find that the only other files loaded are /usr/share/vim/vimrc, ~/.vim/filetype.vim, ~/.vimrc, and some files from /usr/share/vim/vim82/....
    – nullromo
    Commented Dec 2, 2020 at 21:59
  • 1
    What terminal emulator are you using? What is the $TERM environment variable set to?
    – filbranden
    Commented Dec 3, 2020 at 3:20
  • 1
    If you're using the right kind of terminal (e.g. true xterm) and you send it the special character sequence <Esc>[6n (note: <Esc> prints as ^[) the terminal will reply with the cursor's current row and column. (From xterm terminal you can try it yourself with echo -e "\e[6n".) The exact format of the response is <Esc>r;cR. If cursor is on column 2 then you can see where 2R might come from. I'm not sure of exactly how, though, the mix of Vim and a terminal emulator with mediocre xterm emulation results in the output getting into Vim as a command.
    – B Layer
    Commented Dec 4, 2020 at 3:21
  • 1
    From what I read and saw in the code that control sequence is used for just a single check at startup (related to character widths in Unicode encodings like utf-8) and thus shouldn't be a source of further problems.
    – B Layer
    Commented Dec 5, 2020 at 22:50

1 Answer 1

1

To summarize the question comments, this is a terminal emulator control sequence bug. The easiest fix is to install and use WSLTTY. Simply download the latest release and run the installer, then launch WSL from the newly-installed program.

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.