Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: substituting a linefeed in vi



On Sun, Jul 26, 1998 at 06:26:52PM +0900, Jim Schweizer wrote:
> Hi all,
> 
> I haven't had much luck figuring out how to substitute a DOS
> carriage return with a new linefeed, ASCII code 10, in vi.
> Something along the lines of
> 
> :1,$ s/^M/?/
> 
> where ? is the linefeed. Can this be done?


Hmmm... Let's see... top ten interesting ways of doing it :)

1.vi [file]
  :%s/control-Vcontrol-M$//
  :x

2.vim [file]
  :set notextmode
  :x

3.vim [file]
  :set fileformat=unix
  :x

4.perl -e 'while(<>){s_^M$__;print}'

5.perl -e 'print`dos2unix @example.com`'

6.perl -e 'exec dos2unix,@example.com'

7.perl -pe 's_^M$__;'

8.cat <file> | tr -d '\015' > <tmpfile>

9. dos2unix foo > bar

10. Or how about 
    pico [file]
    [control-O] [enter] [control-X]     (save file then exit)
  
    It works :)


I bet windows can never ever find so many ways of doing it :) 


regards,
Chiew

p/s: By the way, the above is contributed by the computer science club
members over in U of Waterloo :)
--------------------------------------------------------------
Next Meeting: 8 August, Tokyo Station Yaesu central gate 12:30
featuring Linux on multiple platforms:
i386, Sparc, PA-Risc, Amiga, SGI, Alpha, PalmPilot, ...
Next Nomikai: September, 19:30 Tengu TokyoEkiMae 03-3275-3691
--------------------------------------------------------------
Sponsor: PHT, makers of TurboLinux http://www.pht.co.jp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links