capturing matches

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

capturing matches

beau-3-2
Hi all,

I don't know the proper term for this, and thus have not had any luck
searching for it.  There is a way to parenthesize part of a match so
that part of the match can be reused as a variable.  I'm sure I'm
saying that wrongly; here's what I thought should work:

:%s/(sucks) (syntax)/$1 $2/

to yield, "syntax sucks"

Happy to read the help docs if someone can help me figure out where I
should be looking.  :help search lead me to pattern but not this
tidbit.  Many thanks.
--
Robert Thomas ("beau") Hayes Link
(c)2005ISR http://www.semanticrestructuring.com/
Discussion, News and Chat at http://lawboards.semanticrestructuring.com/ 
"In dreams we are not tethered to earthly limitations"---G.T.Snail
Reply | Threaded
Open this post in threaded view
|

Re: capturing matches

Mikołaj Machowski
Dnia czwartek, 15 wrze?nia 2005 07:31, beau napisa?:

> Hi all,
>
> I don't know the proper term for this, and thus have not had any luck
> searching for it.  There is a way to parenthesize part of a match so
> that part of the match can be reused as a variable.  I'm sure I'm
>
> saying that wrongly; here's what I thought should work:
> :%s/(sucks) (syntax)/$1 $2/
>
> to yield, "syntax sucks"
>
:%s/\(sucks\) \(syntax\)/\2 \1/

m.

Reply | Threaded
Open this post in threaded view
|

RE: capturing matches

vishnu-3
In reply to this post by beau-3-2
Hi beau,

:%s/\(first\) \(second\)/\2 \1/

:h \(
:h \1


~Vishnu

-----Original Message-----
From: beau [mailto:[hidden email]]
Sent: Thursday, September 15, 2005 11:01 AM
To: [hidden email]
Subject: capturing matches

Hi all,

I don't know the proper term for this, and thus have not had any luck
searching for it.  There is a way to parenthesize part of a match so
that part of the match can be reused as a variable.  I'm sure I'm
saying that wrongly; here's what I thought should work:

:%s/(sucks) (syntax)/$1 $2/

to yield, "syntax sucks"

Happy to read the help docs if someone can help me figure out where I
should be looking.  :help search lead me to pattern but not this
tidbit.  Many thanks.
--
Robert Thomas ("beau") Hayes Link
(c)2005ISR http://www.semanticrestructuring.com/
Discussion, News and Chat at http://lawboards.semanticrestructuring.com/

"In dreams we are not tethered to earthly limitations"---G.T.Snail

Reply | Threaded
Open this post in threaded view
|

Re: capturing matches

c.lina
In reply to this post by beau-3-2
On Thu, 15 Sep 2005 01:31:28 -0400
beau <[hidden email]> wrote:

> Hi all,
>
> I don't know the proper term for this, and thus have not had any luck
> searching for it.  There is a way to parenthesize part of a match so
> that part of the match can be reused as a variable.  I'm sure I'm
> saying that wrongly; here's what I thought should work:
>
> :%s/(sucks) (syntax)/$1 $2/
>
> to yield, "syntax sucks"

This should be
:%s/\(sucks\) \(syntax\)/\2 \1/

The search matches all occurences of "sucks syntax" (without
the quotes) in your text, and then replaces them by
"syntax sucks".

see :he pattern
also try :he toc, and then go to usr_27.txt

Regards, Catherine.



--
==================================================
Cras vives? Hodie iam vivere, Postume, serum est.