1 Jan 2009 01:46
Re: swap words
Tony Mechelynck <antoine.mechelynck <at> gmail.com>
2009-01-01 00:46:04 GMT
2009-01-01 00:46:04 GMT
On 31/12/08 05:23, the.dude wrote:
> hi,
> i want to swap words in the following way. original text is
>
> a = b
> daf = dfgdf
> a+b*c = d+e*f
> ab(bc)+{adf} = dfdsf+343=fdf
>
> i want to modify the above text as
>
> b = a
> dfgdf = daf
> d+e*f = a+b*c
> dfdsf+343=fdf = ab(bc)+{adf}
>
> how can this be done in easiest way in vim.
>
> --
> the.dude
:%s/\(.*\)\( = \)\(.*\)/\3\2\1
meaning: whenever a line includes the following three parts:
- zero or more of anything, as many as possible
- space, equal, space
- zero or more of anything, as many as possible
replace them by the same thee parts in the opposite order
(Continue reading)
RSS Feed