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.
<Esc>in any mappings in your vimrc? In my answer here notice the reference to2R... Why does terminal vim enter replace mode with my vimrc file? – B Layer Dec 02 '20 at 20:50<ESC>in some mappings, but never on the left-hand side. Further, commenting out the whole.vimrcdoes not stop the2Rfrom occurring. I opened up vim with a fully-commented.vimrc, and used:scriptnamesto 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 Dec 02 '20 at 21:59--clean? If no issues with that then one of those files you listed has to be the culprit (assuming Vim launch is otherwise normal) – B Layer Dec 02 '20 at 22:13$TERMenvironment variable set to? – filbranden Dec 03 '20 at 03:20xterm(check$TERM). Make sure to use a recent vim version (not sure ifjonathonf/vimis still maintained). Might also try to use:set t_u7=and see if this fixes it. – Christian Brabandt Dec 03 '20 at 10:38--clean, but it does not when running with-u NONE. I am using WSL, andecho $TERMgives "xterm-256color.":set t_u7showed me that it was^[[6nby default. Addingset t_u7=to my.vimrcseems to fix the problem. Still not fully understanding what t_u7 is, even after readingterm.txt, but thanks for the help!! – nullromo Dec 03 '20 at 18:16<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 withecho -e "\e[6n".) The exact format of the response is<Esc>r;cR. If cursor is on column 2 then you can see where2Rmight 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 Dec 04 '20 at 03:21t_u7you tell Vim not to use that special sequence anymore even though your TERM envvar indicates you are using some kind of terminal emulator compatible with xterm. – B Layer Dec 04 '20 at 03:28t_u7? Based on a bit of digging it seems to me that OPs TE is responding properly to theCSI 6 nrequest sent in src/term.c:may_req_ambiguous_char_width()but that response is being treated as typed characters. – B Layer Dec 04 '20 at 06:29;to:, so it makes sense that some bug would cause#;2Rto enter command mode as:2R. Also, with regard to the timing issue, I didn't mention it but ~1-2% of the times I opened vim, the issue wouldn't happen at all. Makes sense with the race condition mentioned. I will look into updating WSL and possibly switching to mintty. Thanks for educating me about some basic concepts here, like the fact that there are escape sequences handled by terminal emulators. In the meantime, would other parts of vim maybe break due to settingt_u7=? – nullromo Dec 04 '20 at 19:05