1

I have a habit of copying lines of text across files by yanking it, closing Vim, starting Vim with the target file, then p. However, earlier today Vim started to forget that I yanked whole lines of text and started pasting it after the character.

For example, if I have a file with just one line of abcd, when I hit yy then p, it becomes two lines of abcd. When I hit yy, exit and restart Vim, then p, it becomes one line of aabcdbcd.

I have not touched my vimrc for months and looking in my home directory for recently modified files, I couldn't find anything related to Vim. I have tried deleting ~/.viminfo and the undesired behavior persists. How can I restore Vim to its old behavior?


This is Ubuntu's stock Vim:

# vim --version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled May 03 2024 02:45:42)
Included patches: 1-16

# apt list vim-nox
vim-nox/noble-updates,now 2:9.1.0016-1ubuntu7.1 amd64 [installed,automatic]

I'm working over SSH from a Windows 10 PC, using Windows Terminal and Win10's stock OpenSSH, and this Vim runs inside a tmux session.

4
  • 1
    I was going to recommend checking the viminfo option, but there doesn’t appear to be a tweak for this. I wonder if it could be a bug; are you able to build from source and bisect? What version are you using?
    – D. Ben Knoble
    Commented Sep 4 at 19:04
  • 1
    Ubuntu/WSL or normal Ubuntu? KDE/Gnome/xyz ? What is clipboard manager? Klipper or what? What is "stock vim"? Vim-gtk3 or which one? Your question lacks almost every bit of vital info.
    – Matt
    Commented Sep 5 at 6:24
  • 1
    Does this also happen in vim --clean? I wonder if it might be related to some plug-in or clipboard integration you might have in your vimrc or other initialization config file
    – filbranden
    Commented Sep 5 at 16:37
  • 1
    Actually, under vim -u NONE which disables the initialization via vimrc, perhaps vim -u NONE --noplugin, it turns out -i disables loading viminfo so that wouldn't help, but you can disable vimrc and plugins to see if that has an effect as expected
    – filbranden
    Commented Sep 5 at 16:50

1 Answer 1

2

Thanks to @filbranden's hint, I identified vimtmuxclipboard.vim as the culprit. Disabling this plugin restored Vim's behavior.

I still have no idea why it broke out of the blue. It used to work perfectly and I have touched neither Vim nor tmux.

2
  • To me it looks like there's a bug in this line that implements TextYankPost, it joins a list with newlines but doesn't append a newline at the end, the effect of the bug would be exactly what you described.
    – filbranden
    Commented Sep 5 at 21:04
  • Or, more likely, code in s:on_stdout() which is triggered right at startup, it has the same bug of joining a list with newlines without adding another newline at the end. I don't know if this can be called a bug because Vim has this concept of charwise/linewise registers and I'm not sure the clipboard is the same.
    – filbranden
    Commented Sep 5 at 21:08

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.