vi editor prefixes lines with # upon paste

I've been away from Unix and the vi editor for a while, and now I'm using vi (actually vim) in a Cygwin bash shell. When I copy-and-paste code examples (I'm playing with perl now) any time I paste code with lines beginning with the # character, vi inserts a # character at the beginning of every line after that point. I'm hoping one of you is familiar with this oddity.

Example of code I copied:

#!/usr/bin/perl -w
use warning;
use XML::Simple

Example of what I get from the paste operation:

#!/usr/bin/perl -w
#use warning;
#use XML::Simple
#

output of :set in vi:

  background=dark     hlsearch            mouse=a             ruler               showmatch
  backup              incsearch           number              shiftwidth=4        ttyfast
  history=50          modified            report=1            showcmd             ttymouse=xterm
  backspace=indent,eol,start

Thanks,
greenmangroup
(just me and my multiple personalities:D)

That's vims autoformatting at work. Enter ':set fo' to show your current format options and then set it to the same sans the 'r' and 'o' option (from here)

Thank you. I wonder why I cannot find that in the vim man page? And there wasn't an example line in the /usr/share/vim/vimrc to modify. I had to create the line myself.
Thanks again :slight_smile: