[PLUG] To the VI Question

Stafford A. Rau srau at rauhaus.org
Mon Jul 15 20:12:38 UTC 2002


* Matt Alexander <m at netpro.to> [020715 12:54]:
> Here's how I generated the list:
> 
> I have a text file with email addresses and a bunch of other information
> separated by semi-colons.  The email address is the first field, so I used
> cut to pull it out like this:
> 
> cut -f1 -d\; myfile > newfile
> 
> So when I use :%s/\n/,/ it doesn't work.  I'm using vi (vim) on a RH 7.3
> box.  I can still get what I want by doing this, however:
> 
> :%s/$/,/

I'm guessing that your original text file doesn't terminate with lines
with newline, but rather (DOS-style) carriage return+linefeeds.

Here's a text file created with notepad on a Winders machine:

srau at slobyj:~$ cat dostext.txt 
nothing
space 
tab     
srau at slobyj:~$ od -c dostext.txt
0000000   n   o   t   h   i   n   g  \r  \n   s   p   a   c   e      \r
0000020  \n   t   a   b  \t  \r  \n
0000027
srau at slobyj:~$ 

The octal dump (od -c) command is useful for showing the non-printing
characters, and show that the lines are terminated with \r \n rather
than the most more sane \n.

--Stafford




More information about the PLUG mailing list