Can someone remind me how to do a global replace in VI ??
I want to delete all spaces before End of Line character($)
I'm trying things like:
:g s/ $/$/g
Can't quite get the command right.
Thanks all
P7P
I want to delete all spaces before End of Line character($)
I'm trying things like:
:g s/ $/$/g
Can't quite get the command right.
Thanks all
P7P
:%s/ *$//Quote:> Can someone remind me how to do a global replace in VI ??
> I want to delete all spaces before End of Line character($)
> I'm trying things like:
> :g s/ $/$/g
> Can't quite get the command right.
John Gordon
---
"She even named one city after Robert, her ex-boyfriend, just to annoy
me. I have it in a saved game on my laptop. Every now and then I boot
it up just to let Robertville starve itself off the map." -- Tom Chick
Two spaces before the asterisk:Quote:> Can someone remind me how to do a global replace in VI ??
> I want to delete all spaces before End of Line character($)
> I'm trying things like:
>:g s/ $/$/g
> Can't quite get the command right.
:%s/ *$//
or
:g/ *$/s///
:%s/ *$//Quote:> I want to delete all spaces before End of Line character($)
> I'm trying things like:
> :g s/ $/$/g
> Can't quite get the command right.
(% : you want to do it to all lines in the file;
*$: you want any number of spaces - might as well include 0, no harm done;
//: replace them with nowt.
You don't need a trailling /g as there's only going to be one match per
line, isn't there? ;)
~Tim
--
15:05:06 up 6 days, 19:52, 8 users, load average: 0.14, 0.20, 0.18
http://piglet.is.dreaming.org |Colours ablaze in the evening
> I want to delete all spaces before End of Line character($)
> I'm trying things like:
> :g s/ $/$/g
:%s/[ ]*$//g
Quote:> Can't quite get the command right.
> Thanks all
> P7P
> > Can someone remind me how to do a global replace in VI ??
> > I want to delete all spaces before End of Line character($)
> > I'm trying things like:
> >:g s/ $/$/g
> > Can't quite get the command right.
> Two spaces before the asterisk:
> :%s/ *$//
> or
> :g/ *$/s///
P7P
> > I want to delete all spaces before End of Line character($)
> > I'm trying things like:
> > :g s/ $/$/g
> > Can't quite get the command right.
> :%s/ *$//
> (% : you want to do it to all lines in the file;
> *$: you want any number of spaces - might as well include 0, no harm done;
> //: replace them with nowt.
> You don't need a trailling /g as there's only going to be one match per
> line, isn't there? ;)
> ~Tim
> --
> 15:05:06 up 6 days, 19:52, 8 users, load average: 0.14, 0.20, 0.18
> http://piglet.is.dreaming.org |Colours ablaze in the evening
What do you mean ??
P7P
* is 0-or-more.Quote:>> :%s/ *$//
>> (% : you want to do it to all lines in the file;
>> *$: you want any number of spaces - might as well include 0, no harm done;
>> //: replace them with nowt.
>> You don't need a trailling /g as there's only going to be one match per
>> line, isn't there? ;)
[snip .sig]
> <<might as well include 0, no harm done;>>
> What do you mean ??
~Tim
--
10:28:45 up 7 days, 15:15, 9 users, load average: 0.25, 0.36, 0.37
http://piglet.is.dreaming.org |the predictability of stupidity.
I usually use 2 so that I get an accurate count of how many instances thereQuote:><<Two spaces before the asterisk:>>
>One space before asterisk will do won't it ??
1. vi global replace across lines.
Applogies if this is too off topic.
I have some terrible HTML that I need to tidy up, we are talking mainly
huge tables that have cr (0x0A) scattered all over the place. An example
would be.
<TABLE
<
/TD>
<
etc.
If I was to code in perl I would you something like this
s/<TD\n>/\n<TD>/g;
now I want to do this without leaving vi
I tried
%s/<TD\n>/\n<TD>/g
also
%s/<TD^V^M>/<TD>/g
also
%s/<TD^V^J>/<TD>g
nothing worked.
There has to be a way to do this?
Am I just using the wrong control codes?
Or should I just give up and do it in perl.
thanks.
--
TheMartian
AIM: OrigMartian
www.ozetechnology.com
www.marsfirst.org
2. wanted : termcap entry for TeleVideo 905
3. Global search and replace using vi -c?
5. global search+replace a newline with J in vi?
9. Re :global find/replace in vi
10. global search/replace in vi?
12. ??? global search&replace ???