Re: VIM Q again

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


On 01Jun2008 21:26, Gene Heskett <[email protected]> wrote:
| On Sunday 01 June 2008, Cameron Simpson wrote:
| >On 01Jun2008 20:19, Gene Heskett <[email protected]> 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.

| 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:


which in this case is semanticly equivalent but internally different.

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:


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.

Cameron Simpson <[email protected]> DoD#743

C makes it easy for you to shoot yourself in the foot.  C++ makes that
harder, but when you do, it blows away your whole leg.
- Bjarne Stroustrup

fedora-list mailing list
[email protected]
To unsubscribe:

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux