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

Re: VIM Q again



On Sunday 01 June 2008, Cameron Simpson wrote:
>On 01Jun2008 21:26, Gene Heskett <gene heskett verizon net> wrote:
>| On Sunday 01 June 2008, Cameron Simpson wrote:
>| >On 01Jun2008 20:19, Gene Heskett <gene heskett verizon net> wrote:
>| >| So what am I doing wrong when in the command mode, I type
>| >| /s/L1BAE/isspace/&g, or :s/L1BAE/isspace/&g
>| >
>| >What do you think each of the "&" and the "g" do in your line?
>| >
>| >Next. What does:
>| >  :s/L1BAE/isspace/g
>| >
>| >do? That's for a single line.
>|
>| which has not done anything here even to a single instance of L1A8E
>
>Um, I should have mentioned that that does only the "current" line.
>Move your cursor to a line with L1BAE and retry.
>
>And it seems I typed "L1BAE" and you typed "L1A8E". Sorry, that will
>have wasted your time. Corrected in the examples below.
>
Mochs Nichs, it worked, and about 450-500 bytes of junk code has now been 
removed from a 6k relocatable object.  The original coder from 25 years ago was 
either fighting with a broken assembler, or somehow used the z-80 as a model 
for 6809 code, there was z-80 coding style trash all over it, and strings of 
code 10 to 40 bytes long that had an rts or a bra to someplace else above them 
with no label, meaning it will never be executed, so why is it there?  I can 
only guess 25 years after the fact.

Having programed in assembly or even just a hex monitor on the RCA-1802, the 
z-80, and the motorola 6809 which hitachi turned into a much smarter 6309, the 
1802 is ok but different, the 6809's are 1.5 star genius's, the 6309 is a 2 
star, and z-80 I can only describe as drain bamaged.

>| Every line:
>| >  :%s/L1BAE/isspace/g
>|
>| The use of the % sign doesn't seem to be mentioned in the :help I have
>| been able to get to.
>
>Maybe not. It's a shorthand for "1,$" i.e. from the first line to the
>
>last line. I see someone else has suggested:
>  :g/L1A8E/s//isspace/g
>
>which in this case is semanticly equivalent but internally different.

And that syntax is what I used for the last 4 hours.  I'm not done by a long 
shot, but this sure helps.  If I can get it to build and run exactly as before, 
but without all this guys trash, a printout will be a lot more useful in terms 
of deciphering what its doing.
>
>It says "for each line (g) that contains L1A8E (/L1A8E/) replace that 
>(L1A8E, or more generally: what was matched in the first //) with isspace,
>globally (g: every time it occurs on the line)".
>
>For your task these two things are the same. There are other circumstances
>where the "g/ptn/something" idiom has specific advantages.
>
>| When I figure out what a piece of code is doing, I would like to be able
>| to globally replace the L1A8E label it now carries as an entry point,  as
>| found and labeled by our disassembler, with something more in line with
>| what the routine actually does, like "s/L1A8E/printerr/g" which with
>| another editor I use on that machine will globally replace every instance
>| of L1A8E with printerr.
>
>Ok. You might also want to beef up the regexp, thus:
>  :%s/\<L1A8E\>/isspace/g
>
>The causes the L1A8E to have "word boundaries" at each end, so that
>FOOL1A8EBAR will not match the regexp. It looks like your disassembler
>generated labels won't have this trouble, but I like to be cautious.

Thanks for the warning, although I did get an example of that while searching 
for a marker I had added, 5 dashes forgetting a previous editor had wrapped 
some of his comments in ;---------------------- style markers, so I had to 
change the search string to -----L which only matched the label I'd marked.

>Cheers,

And to you too Cameron, and thanks for the help.

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
No act of kindness, no matter how small, is ever wasted.
		-- Aesop


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