LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Strange vim startup behavior when accessed via cygwin ssh (https://www.linuxquestions.org/questions/linux-desktop-74/strange-vim-startup-behavior-when-accessed-via-cygwin-ssh-790272/)

nicklaszlo 02-19-2010 06:34 PM

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:
Quote:


\int g(\oemga)<80>kb<80>kb<80>kb<80>kb<80>kbmega)\d<80>kb<80>kbd\omega
\sum ((`/\hbar\oemg<80>kb<80>kb<80>kbmega
kT^<80>kb

^%2<80>kb<80>kb2\\^M&\approx -`/1
12
`/\int g(\oe<80>kbmega)((`/<80>kb\ESClihbar\<80>kb<80>kb<80>kb<80>kb<80>kb<80>kb{\hbar\oemga<80>kb<80>kb<80>kb<80>kbmega
kT

^2
ESChhlid\omegaESCllli\int g(\omega)d\omega
\\<80>kb<80>kbESC:w^M\lljjjj$a^M`/1
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 s:papersize = matchstr(system("cat /etc/papersize"), "\\p*")
let &shell=s:shellbak
if strlen(s:papersize)
let &printoptions = "paper:" . s:papersize
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"

smoker 02-19-2010 09:13 PM

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.

Anyway, this seems like a useful site for vim commands
http://successtheory.com/tips/vimtips.html

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.

Just speculating myself really.

regards

Alan

nicklaszlo 02-19-2010 11:45 PM

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.

nicklaszlo 02-24-2010 09:31 PM

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?

nicklaszlo 03-13-2010 10:49 PM

Anyone else have any ideas?


All times are GMT -5. The time now is 07:12 PM.