On 4/22/07, Tim Chase <[EMAIL PROTECTED]> wrote:
> Is it possible to do the following, or maybe some plugin
> already exist. If not, how would I script it. Let's say I have
> some long identifier EXPECTED_GCONFIG scattered around the
> file. I put cursor after _ and change it to EXPECTED_CONTENTS
> somehow, maybe char-by-char, not necessarily in one optimal
> op.
>
> Now I'd like to auto-convert the last word change into s///
> command, automatically, so I can use & to change remaining
> occurencies. How could I script such thing ?

I'm not sure there's an easy way to do this "automatically", as
you have to be able to identify *when* you've begun the above
process, what portion you want to change, and when you're done
changing.

I occasionally have need to do something similar, so here's what
I do (whether it's helpful or not... ;-)

1) search for an instance of my target by using #/*

        :help *
        :help #

2) change one of them to my desired result (in as many operations
as you need)

3) without moving the cursor off the new results, create a s//
command using those two pieces:

        :%s/^R//^R^W/g

where "^R/" is control+R followed by a slash, and "^R^W" is
control+R followed by control+W.  This composes the command by
using the previous search item (stored in the "/" register, and
handily includes the "\<...\>" thanks to the */# searching) and
the word currently under the cursor.

        :help c_CTRL-R
        :help c_CTRL-R_CTRL-W

It's not exactly what you describe, but close enough that I find
it easy to do in situations like what you describe.

Nice. This is helpful. Thanks

Yakov

Reply via email to