gvim search and replace

30 views
Skip to first unread message

Melvin Simon

unread,
Jul 27, 2015, 7:05:48 AM7/27/15
to vim_use
Hi,

I am new to gvim editor. Needed a small help regarding gvim search and replace.

I needed to search and replace as:-

AIO_P71_TSD0_CTRL with AIO_PRI_TSD0_CTRL
AIO_P71_TSD1_CTRL with AIO_PRI_TSD1_CTRL
AIO_P71_TSD2_CTRL with AIO_PRI_TSD2_CTRL

I tried the below:-

>s/AIO_P71_TSD\.*_CTRL/AIO_PRI_TSD\0_PRI_CTRL/g

i.e. I was guessing \0 would print the characters (here 0,1,2) matched by .* however looks like its matching the entire word. Can some one tell me how to accomplish the above search and replace.

Thanks in advance
Melvin

Tim Chase

unread,
Jul 27, 2015, 7:54:58 AM7/27/15
to vim...@googlegroups.com
You're close. Try

:%s/AIO_\zsP71\ze_TSD.*_CTRL/PRI/g

You can read up about \zs and \ze at

:help /\zs
:help /\ze

-tim



Melvin Simon

unread,
Jul 27, 2015, 9:18:21 AM7/27/15
to vim_use, v...@tim.thechases.com

Thank you Tim! Perfect!

Elimar Riesebieter

unread,
Jul 27, 2015, 1:38:50 PM7/27/15
to vim...@googlegroups.com
* Melvin Simon <wherei...@gmail.com> [2015-07-27 04:05 -0700]:

> Hi,
>
> I am new to gvim editor. Needed a small help regarding gvim search and replace.
>
> I needed to search and replace as:-
>
> AIO_P71_TSD0_CTRL with AIO_PRI_TSD0_CTRL
> AIO_P71_TSD1_CTRL with AIO_PRI_TSD1_CTRL
> AIO_P71_TSD2_CTRL with AIO_PRI_TSD2_CTRL
>
> I tried the below:-
>
> >s/AIO_P71_TSD\.*_CTRL/AIO_PRI_TSD\0_PRI_CTRL/g

Hmm, wouldn't just

:%s/P71/PRI/c

do the job?

Elimar
--
.~.
/V\ L I N U X
/( )\ >Phear the Penguin<
^^-^^
Reply all
Reply to author
Forward
0 new messages