Strange vim startup behavior when accessed via cygwin ssh
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Strange vim startup behavior when accessed via cygwin ssh
Weird problem:
Text is automatically entered into my vim session within a few seconds of vim starting up. This is really annoying because when I open an existing document it can cause changes to the document that I then have to undo. If the automatically entered text messes up my automatically generated folds I have to restart vim to get them back. What's really weird is the problem only seems to occur when using vim over ssh.
I run WindowMaker 0.92 on Cygwin X Server 1.7.3 with Windows XP. I ssh in an xterm. The remote host is Debian Testing with Kernel 2.6.30-2-686. The remote VIM is 7.2.
If I press "i" really fast on vim startup I can get a sample of the text that is automatically entered. It appears to be something I typed into vim at some point in the past. It includes LaTeX commands since that's mostly what I use vim to write. Here is a sample copied from Cygwin into XP so the encoding is messed up but it will give you a good idea:
I assume <80>kb (~@kb in the correct encoding) is supposed to be a nonalphanumeric key.
Here is my .vimrc:
Quote:
" Configuration file for vim
set runtimepath=~/.vim,/usr/share/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vimcurrent,/usr/share/vim/vimfiles/after,/usr/share/vim/addons/after,~/.vim/after
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start " more powerful backspacing
" Now we set some defaults for the editor
set autoindent " always set autoindenting on
" set linebreak " Don't wrap words by default
set textwidth=0 " Don't wrap lines by default
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
" 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
" We know xterm-debian is a color terminal
if &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
" set background=dark
if has("autocmd")
" Enabled file type detection
" Use the default filetype settings. If you also want to load indent files
" to automatically do language-dependent indenting add 'indent' as well.
filetype plugin on
endif " has ("autocmd")
" Some Debian-specific things
if has("autocmd")
augroup filetype
au BufRead reportbug.* set ft=mail
au BufRead reportbug-* set ft=mail
augroup END
endif
" Uncomment the following to have Vim jump to the last position when
" reopening a file
" if has("autocmd")
" au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
" \| exe normal g'\"" | endif
" endif
" Set paper size from /etc/papersize if available (Debian-specific)
if filereadable("/etc/papersize")
try
let s:shellbak = &shell
let &shell="/bin/sh"
let sapersize = matchstr(system("cat /etc/papersize"), "\\p*")
let &shell=s:shellbak
if strlen(sapersize)
let &printoptions = "paper:" . sapersize
endif
catch /^Vim\%((\a\+)\)\=:E145/
endtry
endif
" The following are commented out as they cause vim to behave a lot
" different from regular vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
"folding
set foldmethod=syntax
Speculation: Some weird interaction between my cygwin/X settings or xterm settings and my vim settings.
This line looks particularly suspect, but I don't see what my problem has to do with color:
if &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
I'm not a vim expert but I'm sure someone will shoot this down.
Could there be some commands being sent that replay a recording or reload a previous register in vim ?
I see your .vimrc has this line
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
" 50 lines of registers
Maybe it's worth seeing if such a register exists and if its contents match the bad input. At least you'll know it's not a ghost !
Or it could be that your terminal is replaying some old content after vim is opened.
Towards the bottom of the page are the commands for displaying the contents of registers and cleaning them out.
for example @q executes a recording or register. If your terminal is sending such characters unseen then it may cause your problem.
It looks like the problem is coming from the "#Registers" section of my .viminfo. So why is it only getting dumped into my buffer when I use cygwin/ssh? Note some of my registers were very long, probably due to my pressing q and not noticing it.
I don't want to disable my .viminfo file, nor do I want to disable storing registers across sessions. I think the line you pointed out just limits the length of the registers.
In the mean time, I have tried deleting the existing registers. We will see if the problem comes back.
Deleting the existing registers did not help. I was careful to remove them using a program other than vim since editing .viminfo with vim will cause your work to be automatically undone. I think I can rule out a malformed register as the cause. Any new ideas?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.