• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

vim randomly pastes yanked content

krawall

Member

Thanks: 13
Messages: 48

#1
Hi,

I've got a strange problem with editors/vim-lite since I think yesterday (but it could be longer): Sometimes if I open vim it just pastes everything that it has saved from the last yank (copy in vim terms). I'm totally at a loss, why it's doing it. I had the same vim config for almost two years (see below) and never had a problem.

I can't reproduce it except to open vim repeatedly. In about twenty start ups it should paste something at least once. I tried to downgrade (after all I upgraded vim yesterday from 8.0.1115 -> 8.0.1141), but even with an older version than 8.0.1115 it still happens.

Here is my /root/vim/.vimrc
Code:
syntax on
colorscheme default
set t_Co=16

let g:is_posix = 1

set relativenumber
set fileencodings=utf-8
set nocompatible
set bs=indent,eol,start
set history=50
set ruler
set hlsearch
set modeline
set mouse-=a
There is no /root/.vimrc nor /usr/local/etc/vim/vimrc.
It seems to happen at all our servers and it doesn't matter if the opened file exists or not.

editors/vim-lite was build by poudriere with DEFAULT_VIMRC: off

It's a bit scary, especially with single characters that I won't be able to catch every time..
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,688

#2
A stuck 'p' key perhaps?
 

krawall

Member

Thanks: 13
Messages: 48

#3
I don't have any other problems with the 'p' or any other key.

I just got another keyboard to try it anyhow but now I can't reproduce it at all. Very strange. I'll leave the other keyboard connected and retry when the problem reappears..
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,688

#4
I just got another keyboard to try it anyhow but now I can't reproduce it at all. Very strange. I'll leave the other keyboard connected and retry when the problem reappears..
Maybe the old keyboard is sending spurious keycodes, mimicking the pressing of 'p'. That could explain the seemingly random pastes. But I would have expected that key to popup in the middle of commands too, not only with vim. It's a weird issue, that's for sure.
 

krawall

Member

Thanks: 13
Messages: 48

#5
Yeah. That's what I thought. The random paste happened again, with both the keyboards.

But this time there wasn't anything yanked so instead of inserting something vim replaced the last character in the first line in the opened file with '2'. Two days ago I also had to fix a /etc/rc.conf that had a '2' instead of a '"' as a last character in the first line..
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,688

#6
Could you try to use vi(1) instead of vim(1)? That may narrow down the possibilities, vi(1) doesn't read vim(1) configuration files but vim(1) does read vi(1) configs.
 

chrbr

Aspiring Daemon

Thanks: 204
Messages: 594

#7
Is it possible that vim(1) picks something from the UART or something which behaves so? As far as I have seen the mouse should be disabled by default. I did a quick search and have no seen a reference about the syntax above, but I did not seek a lot. May be it is correct, may be not. Therefore it might be worth to confirm the syntax or to try to delete the line.
 

ShelLuser

Daemon

Thanks: 806
Messages: 2,014

#8
Also, are you sure it's a put and not something else?

Reason I ask is because you mentioned that it did this when you just started it. Could it have been loading a previous file or something? (doubt it, but I figured I could always mention this).
 

Jeckt

Member

Thanks: 14
Messages: 62

#9
I've been using vim for many years, and despite the fact that it's the most frequently updated program I use, I never had any problems until a month or two ago. While it's solved for me now, when I'd open a file there would be some weird junk inserted at the top I can't recall if it actually changed the file or not. Versions after 8.0.0962 had this problem for a while, but recently it started working for me. This might be a bug that isn't completely sqashed, so you might want to put in a bug report to the vim people. If you use portmaster, you might try looking for an older vim package (pre 8.0.1000) saved in /usr/ports/packages/portmaster-backup/
 

krawall

Member

Thanks: 13
Messages: 48

#10
Hi, sorry, havn't had a lot time this week to take care about this problem. But thank your for all your answers!

SirDice: I'll try vi next time this happens. But are you sure that vim reads vi config files? :version only lists:
Code:
   system vimrc file: "/usr/local/etc/vim/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/etc/vim"
 f-b for $VIMRUNTIME: "/usr/local/share/vim/vim80"
chrbr: I had the same trouble with mouse= but I'll try without my vim config file next time this happens. Mouse should be disabled by default but it was briefly enabled half a year ago and it takes time to put this config on ~500 servers / jails (even with ansible), so I'd prefer to keep it this way :)

ShelLuser: I can paste the same content in every vim file that it happened to with 'p', also this happens at random..

Jeckt: Thanks for this information, do you have a link to the old bug report? I'm using poudriere, but if this is a vim problem that doesn't goes away I might just switch to neovim..
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,688

#11
But are you sure that vim reads vi config files?
That's what I always believed. But looking through the man pages that might indeed not be the case. I was sure that was the case but maybe I'm confusing certain Linux distributions where vi(1) is actually vim(1) in compatibility mode.

But since the yank and paste commands are the same it would still be useful to test if there's a difference.
 

Jeckt

Member

Thanks: 14
Messages: 62

#12
I don't have a link to any bug report, it's just that I noticed there was a problem and after a few upgrades it went away (and hasn't appeared since), so it seems like someone was aware of the problem. Since vim can save buffers after files are closed and pate in new ones, I wonder if something isn't activating it in one of those config files. I know building it with DEFAULT_VIMRC screwed me pretty bad, so I disabled it thereafter. It might be worth trying on a test system if you have one where vim can't find any config files to see if it still happens.
 

JohnnySorocil

New Member


Messages: 6

#14
Are you using vim inside tmux session?
I had some problems with tmux mouse scroll which would insert some text (but not from vim's paste buffers) in vim and shell.
 

krawall

Member

Thanks: 13
Messages: 48

#15
Hi. Sorry for the long delay.

SirDice
After I couldn't reproduce this problem without the vimrc I disabled every config one after another. Strangely enough the colorscheme setting seems to cause the paste.. I would just disable it but here vim loads the 'ron' theme with 256 colors which is not easy on the eyes. The t_Co=16 setting doesn't seem to help (vim still reports 256 on :set t_Co?)
But it doesn't seem to have anything to do with the colorscheme itself. If I put colorscheme ron in the vimrc pastes happen. If I leave it out and 'ron' gets loaded by some vim magic, everything seems to be fine..

Jeckt
editors/vim-lite was build by poudriere with DEFAULT_VIMRC: off
JohnnySorocil
Same problem with and without screen. Never using tmux.
 

krawall

Member

Thanks: 13
Messages: 48

#16
getopt
Yes.

locale
Code:
LANG=de_DE
LC_CTYPE="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_ALL=de_DE.UTF-8
vim --version
Code:
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct  9 2017 13:18:27)
Included patches: 1-1178
Compiled by jonas@pkg.vektorrausch.net
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    +mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     +termguicolors
-browse          -footer          +multi_byte      +terminal
++builtin_terms  +fork()          +multi_lang      +terminfo
+byte_offset     -gettext         -mzscheme        +termresponse
+channel         -hangul_input    +netbeans_intg   +textobjects
+cindent         +iconv           +num64           +timers
-clientserver    +insert_expand   +packages        +title
-clipboard       +job             +path_extra      -toolbar
+cmdline_compl   +jumplist        -perl            +user_commands
+cmdline_hist    +keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       -python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      +startuptime     -xpm
+eval            +mouse_dec       +statusline      -xsmp
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
+farsi           +mouse_netterm   +tag_binary     
   system vimrc file: "/usr/local/etc/vim/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/etc/vim"
 f-b for $VIMRUNTIME: "/usr/local/share/vim/vim80"
Compilation: cc -c -I. -Iproto -DHAVE_CONFIG_H   -DLIBICONV_PLUG -I/usr/local/include  -O2 -pipe  -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: cc   -fstack-protector -L/usr/local/lib -Wl,--as-needed -o vim               -lm -lelf  -lncurses
 

Snurg

Aspiring Daemon

Thanks: 250
Messages: 705

#17
Does this problem happen when you use a PS2->USB adapter or an USB keyboard?

I ask because I found out that when using USB for keyboard, some programs somehow tend to get out of sync with the keyboard regarding the escape scancodes etc.
After some research I found out that this seems to happen when USB renegotiates/reconnects.
If you notice that when you experience "strange mysterious keyboard input from nowhere" and find a keyboard reconnect in the logs registered at just that time, you might try out other USB keyboards and/or PS2->USB adapters which might behave better. But as this problem is USB-inherent, I won't expect too much. I guess a true solution would include some refinements in the uhid stack to avoid partial scancodes to be put into the keypress queue.

For me, the most reliable solution was just not to use USB for keyboard, only PS/2 connector on mainboard or docking station.
 

Oko

Daemon

Thanks: 594
Messages: 1,518

#18
Hi,

I've got a strange problem with editors/vim-lite since I think yesterday (but it could be longer): Sometimes if I open vim it just pastes everything that it has saved from the last yank (copy in vim terms). I'm totally at a loss, why it's doing it. I had the same vim config for almost two years (see below) and never had a problem.
And that is exactly why vim should not be used when you have the best UNIX editor (nvi) in the base. Light reading for people who want to learn more

http://galexander.org/vim_sucks.html
 

forquare

Active Member

Thanks: 74
Messages: 192

#19
editors/vim-lite was build by poudriere with DEFAULT_VIMRC: off
Is this the only build option you’ve changed? I wonder if you see the same issue using editors/vim-lite from the FreeBSD repo?

And that is exactly why vim should not be used when you have the best UNIX editor (nvi) in the base. Light reading for people who want to learn more

http://galexander.org/vim_sucks.html
That article is old, and when I tried it a couple of months ago I found I could not reproduce many of the issues seen when using editors/vim-lite

My issue with nvi(1) is that the line numbers take up so much room, and I like having them on by default.
 

krawall

Member

Thanks: 13
Messages: 48

#20
Snurg
I've only got USB keyboards. But this seems to be a relatively new problem for me, so I still think that there is some misconfiguration here (or even a bug). Also I don't have a PS connector..

Oko
vim works fine for me on every other os / non work related FreeBSD configuration and I quite like stuff like relative line numbers and syntax highlighting. Also most of this rant isn't true (anymore)..

forquare
That's the only option for editors/vim-lite ;)
I get the same problems with vim-lite from the FreeBSD repo.
 

krawall

Member

Thanks: 13
Messages: 48

#23
Not all. But it's more than just gvim disabled, i.e. language bindigs that make vim dependent on their interpreters:
Code:
.if defined(LITE)
OPTIONS_DEFAULT=        DEFAULT_VIMRC
OPTIONS_SLAVE=          CONSOLE
OPTIONS_EXCLUDE:=       ${OPTIONS_DEFINE:NDEFAULT_VIMRC} \
                        ${OPTIONS_SINGLE_UI:NCONSOLE} \
                        ${OPTIONS_GROUP_LANGBIND}
.endif
But DEFAULT_VIMRC is still the only option you can set in theeditors/vim-lite port. I'm not really getting, what you are trying to tell me here lebarondemerde ..
 

lebarondemerde

Aspiring Daemon

Thanks: 372
Messages: 983

#24
krawall

If something fail while using editors/vim it should also fail while using editors/vim-lite, unless the problem is related with something disabled in the -lite version.

So, with you wanna test if the problem is caused by something in your configuration you be better testing it against editors/neovim, to be sure.