For a few weeks, I have the strangest issue, on a single computer. On this computer, when I open a file with Vim, the yank register have a low chance of being pasted on the current position of the cursor, with the number "2" after it.

Eg :


#include <algorithm>
#include <iterator>
#include <set>
#include <cmath>

my yank register

irrelevant code

myFile.cxx after i open it with vim myFile.cxx in xterm.

irrelevant cod2
#include <algorithm>
#include <iterator>
#include <set>
#include <cmath>

I suspected a bug in my .vimrc configuration so i minimized it, but the bug is still present. Here is my current .vimrc, without any .vim folder present.

:syntax on        "Turn on syntax highlighting
:set laststatus=2 "Always show status line
:set tabstop=2    "Number of spaces a TAB in the text stands for
:set shiftwidth=2 "Number of spaces used for each step of (auto)indent
:set hlsearch     "Have vim highlight the target of a search
:set incsearch    "Do incremental searching
:set ruler        "Show the cursor position all the time
:set number       "Show line numbers
"Converting tabs to spaces
:set expandtab

The bug appears only after some time of usage after booting and using vim. Once it starts appearing, the chance of seeing it are quite low, but not negligeable, however I have a hard time reproducing it voluntarily.

  • what vim version is this? Does it only happen in a certain terminal or in either vim/gvim? Oct 19, 2017 at 7:48
  • Also, how are you opening the file? With a command in your terminal? By double-cllicking? Using a Vim command in an existing instance of Vim? If you're using a command, what is the precise command?
    – Rich
    Oct 19, 2017 at 8:33
  • sorry, I'm using vim in terminal, not gvim. The command i use is only : vim myFile.cxx without alias defined. Oct 19, 2017 at 9:23

1 Answer 1


Thanks to this reddit thread i was able to fix it by adding

 set t_RS=

in my .vimrc.

The root cause of the problem have not been determined, but it has something to do with vim misinterpreting a terminal answer to one of its request, since the default value : t_RS=^[P1$r2 q^[\ was the command doing the yanking.

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.