news@massey.ac.nz (USENET News System) (04/12/91)
A couple of macros, I wanted advice on 1) Go to the beginning of every line and delete the first 25 characters. 2) Find a particular pattern and delete to a particulate pattern for example if you have lines like -a info-mac/app/00app-abstracts.abs -a info-mac/apple/00apple-abstracts.abs and want -a 00app-abstracts.abs -a 00apple-abstracts.abs meaning in every line of the file, delete from info-mac to 00. Thanx Raminder Singh
lewis@tramp.Colorado.EDU (LEWIS WILLIAM M JR) (04/12/91)
In article <1991Apr11.232907.21795@massey.ac.nz> R.Singh@massey.ac.nz (R. Singh) writes: >A couple of macros, I wanted advice on > >1) Go to the beginning of every line and delete the first 25 characters. ==> The easiest solutiuon is to use 'cut', niot 'vi': cut -c26- filename ==> One line at a time 'vi' macro: 25|d^ # you'll have to escape the pipe with one or more ^V ==> Every line with an "ex' command: :%s/^.........................// # that's 25 dots >2) Find a particular pattern and delete to a particulate pattern >for example if you have lines like > >-a info-mac/app/00app-abstracts.abs >-a info-mac/apple/00apple-abstracts.abs > >and want > >-a 00app-abstracts.abs >-a 00apple-abstracts.abs > >meaning in every line of the file, delete from info-mac to 00. ==> Again with 'ex': :%s;^\(-a\) \(.*\)/\(.*)/\(.*)$;\1\4; >Thanx >Raminder Singh ==> your welcome
les@chinet.chi.il.us (Leslie Mikesell) (04/16/91)
In article <1991Apr11.232907.21795@massey.ac.nz> R.Singh@massey.ac.nz (R. Singh) writes: >A couple of macros, I wanted advice on >1) Go to the beginning of every line and delete the first 25 characters. :%s/^.........................// [Note: I would probably type the above line into the edit buffer using i:%s/<ESC>25A.<ESC>A//<ESC> instead of counting the .'s, then delete to a named register and execute with "add@a Besides saving the counting, this method lets you undo the change, yank back the command and modify it if it turns out to be wrong.] >2) Find a particular pattern and delete to a particulate pattern >for example if you have lines like >-a info-mac/app/00app-abstracts.abs >-a info-mac/apple/00apple-abstracts.abs >and want >-a 00app-abstracts.abs >-a 00apple-abstracts.abs >meaning in every line of the file, delete from info-mac to 00. :%s/info-mac.*00/00/ Les Mikesell les@chinet.chi.il.us