vi editor prefixes lines with # upon paste


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers vi editor prefixes lines with # upon paste
# 1  
Old 04-03-2009
Power 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:
Code:
#!/usr/bin/perl -w
use warning;
use XML::Simple

Example of what I get from the paste operation:
Code:
#!/usr/bin/perl -w
#use warning;
#use XML::Simple
#

output of :set in vi:
Code:
  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 personalitiesSmilie)
# 2  
Old 04-03-2009
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)
# 3  
Old 04-03-2009
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 Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove prefixes before dot

Shell : Bash shell I have a text file with entries like below srv.sr_num sr_number, atvx.ATTRIB_37 Product_Name, ktx.X_ATTRIB_52 Product_Type, mkx.created sr_created_date, nbv.sr_cat_type_cd sr_type, bkrx.sr_area sr_category, .. frx.order_id, des.stats_name , fpxg.current_id_name, ...... .... (3 Replies)
Discussion started by: John K
3 Replies

2. UNIX for Dummies Questions & Answers

Copy/paste in vi editor

Hello guys, I am trying to copy a line in vi editor and paste it with below commands but paste command is not working and instead of paste action prints the p character!! I should also mention that the server is Solaris... 1) crontab -e 2) j to move down 3) yy to copy the line 4) o to... (4 Replies)
Discussion started by: Newman
4 Replies

3. UNIX for Dummies Questions & Answers

Copy Lines between Keywords & paste them to another file

hi, I have Multiple files with the following data : File1 100414 DR1 END XXXXX Test1 Test2 Test3 Test4 Test5 Test6 END 100514 DR2 END XXXXX Test7 Test8 Test9 Test10 Test11 Test12 END 100614 DR3 (5 Replies)
Discussion started by: newageBATMAN
5 Replies

4. Shell Programming and Scripting

How to paste lines below certain text (Script)

Hello Guys, I know the command echo " " > filenamehere ; would erase everything in the document. Can the same be done, to paste words below certain text? For example, lets say i want to paste a line below the line Server name: in apache.conf . What should be added in the script? (8 Replies)
Discussion started by: xxxx
8 Replies

5. Shell Programming and Scripting

Vi Editor - How to paste the line concatenated with current line

I generally use yy to copy a line and then p to paste the line at end of current line. But is there a way to paste the copied line in concatenation with the current line with out going to next line. (3 Replies)
Discussion started by: paragkalra
3 Replies

6. Shell Programming and Scripting

counting prefixes of files

Hello, at the moment I'm on with programming some kind of version history script for network devices. The configration files are uploaded in the form: devicename-confg_date_time. For keeping the last 10 configurations I want to split the devicename from the rest. This works well with... (5 Replies)
Discussion started by: Sally[-_-]
5 Replies

7. UNIX for Dummies Questions & Answers

Copy/Paste in Vi editor

Dear All, I have a file containing 12 lines. First 3 lines have 9 values and the remaining 9 lines with no values. I was trying to copy and paste these 9 values of the first 3 lines into last 9 lines simultaneously as A=1.491331, B=1.539000 ..... but I don't know how to cope with this... (9 Replies)
Discussion started by: sullah
9 Replies

8. UNIX for Dummies Questions & Answers

copy and paste certain many lines of huge file in linux

Dear All, I am working with windoes OS but remote a linux machine. I wonder the way to copy an paste some part of a huge file in linux machine. the contain of file like as follow: ... dump annealling all custom 10 anneal_*.dat id type x y z q timestep 0.02 run 200000 Memory... (2 Replies)
Discussion started by: ariesto
2 Replies

9. Shell Programming and Scripting

awk/grep copy and paste and insert in between lines.

Hi all, I'm a unix newb andI'm trying to write a script that can copy some text paste it in a certian place and then add a number. It's not really clear but I'll show an example. what the file looks like right now: Linux 2.6.24-24-generic (abc) 07/15/09 23:25:01 CPU ... (6 Replies)
Discussion started by: the1hand3r
6 Replies

10. Shell Programming and Scripting

Need helpl in scripting read 2 lines and paste to one single line.

Hi All, I need to create script which will accept one file as i/p and give me o/p file described as below. 1) i/p log file named abc.log contents several lines but i am interested in lines like below. #FILE..... /oracle/XYZ/sapdata1/undo_7/undo.data7 #SAVED.... BACKINTID001 2) o/p... (4 Replies)
Discussion started by: paragp1981
4 Replies
Login or Register to Ask a Question