> Ok. So a possible shortcut to type this could be:
>    *:%s/<C-R>//&_/gc
> Then: yn to accept/reject substitutions.

Definitely, if that's good with your workflow.  I find
it disturbing to jump to another location (triggered by
the initial "*") so I tend not to use it, but your way
is certainly parsimonious with the keystokes :)  I've
been known to use

  :%s/\<<C-R><C-W>\>/&_/gc

where ^R followed by ^W pulls in the word under the
cursor.  However, if I already have used */# to search
forward/backward, and I know it's in my search
register, I do exactly as you describe.

Sometimes, having the "\<" and "\>" aren't that
important, so it just becomes

  :%s/<c-r><c-w>/&_/gc

The nice thing about vim is that there are a number
ways to do things, and you can use whatever suits you
at the time.

>>   :%s/\<wonderfulFoo\>/wonderfulBar/g
>
> Makes sense.
> Yet I liked the alternative:
>
>> [...]  For your second example, you have to do a
>> little tweaking, as you want to be 3 characters from
>> the end, you have to use
>>
>>   /someIdentifier/e-2
>
> Nice!  Damn, I remember reading about this flag,
> but I failed to think of using it !
> So here, the "find + replace end of word" can be
> typed as:   */<C-R>//e-2<CR>ceBar<ESC>
> Then: n.n to accept/reject substitutions.

While I occasionally use the "/e" modifier, I rarely
use the "/e{offset}" modifier because it requires too
much thought on my part...but again, the limitation
is my wetware, not my software :)

> I like the simplicity/predictability of "n.",
> especially when reworking a function/small block
> within a larger file.  But I am not petrified by
> regular expressions either -- I have been doing some
> perl programming (though I really am a C++ veteran).

Heh, if you can handle Perl, Vim's regexps are a walk
in the park. :)

If you're already comfortable with regexps, it's just
coming to the realization of "Hmmm...a good regexp here
would save me a lot of time", and learning to recognize
those times.

> After 8 months of vimming (I started with
> http://www.viemu.com/), it is time for me to get more
> fluent with Ex commands.

like opening a tool-chest, seeing a power-drill, and
not knowing what it's for, so you stick with your
manual screw-driver.  beware the dark side ;)

Sorry for the long ramble on :s stuff in my previous
post...just showing a little of what Ex can do. :)

> Just let me first enjoy the /../e trick for a couple
> of weeks...

As mentioned above...use what works best for you and
your workflow.  Some folks work best with macros, some
[myself included] use Ex commands, and some use
whatever they know or works for them.  You don't seem
daunted by trying new things, so experiment away! :)

-tim





Reply via email to