1

Re: :%s regex question

Ok, getting a little frustrated with substitution in vimEmu.

In gvim I enter it as follows:

:%s/\(this\.\)\?blahblah/adaada/gc

Works there.

I've tried the following in vimEmu:
:%s/\(this\.\)\?blahblah/adaada/g
:s/\(this\.\)?blahblah/adaada/g
:%s/\(this.\)?blahblah/adaada/g

etc...

What escape sequence do I need to do:

s/(this\.)?variable/newvariable/g

Such that:

"this.variable" OR "variable" is replaced with: "newvariable"

2

Re: :%s regex question

Never mind... I guess I'm blind.

:s/\(this.\)\?variable/newvariable/g


works.

3

Re: :%s regex question

Grrr and maybe not:

It did one replace.. then stopped working.

Now, it just highlights the searched for pattern but then fails to replace it with an error of
"pattern not found"

4

Re: :%s regex question

I ended up just cracking open gvim to do this. Somewhat disappointing, I have to say.

5

Re: :%s regex question

Vicegrip,

:%s/\(this.\)\?variable/newvariable/g

works for me. If it doesn't, can you please post a sample text and substitution in which this doesn't work?
Thanks,

-- Isaac

6

Re: :%s regex question

Of corse it will do error: title=""
Insted you can try: title=""

But to do what you want its only:

Text to Find:
title="the title"

Replace with:
title="the title" alt="the title"

If this is what you mean.... I hope it helps...

7

Re: :%s regex question

Thanks for the replies.

The regex I wanted to run replaced a bunch of c# code of the form:

this.myAnnoyingVariableName
myAnnoyingVariableName

with

NewVarName

In gvim I would write:

:%s/\(this.\)?myAnnoyingVariableName/NewVarName/gc


What I was observing in VS2008, was "pattern not found errors".  I grew frustrated, because I would first test with the "/" slash command to have it work and then have the expression fail with :%s.

Finally, I gave up and cracked open gvim to do it.

It could possibly be user error, but as I'm pretty sure I entered exactly the same expression in gVim, so I doubt it. Perhaps an environment difference or a VS bug?

My intellisense is hopelessly broken for this project (don't get my started into a rant about why Microsoft refused to fix it for 2008). Could that have an impact? To clarify: it's the automatic pop-ups and function declaration tips that don't work. Manual invocation of intellisense works outside of function calls. For function calls, I have to invoke the menu goto-class definition command.

Anyways, I like the Vim emulation, but I'm balking a bit at 99$ without flawless Vim regex search /substitution compatibility. I also need similar undo as Vim; undo is not complete in my mind right now in this emulator.

Best regards.