1

Re: reg exp help

Hi,
How can I make this:

foo( p1 , p2); bar(p3);

into

foo( p1 , p2);
bar(p3);

I tried

s/; bar/;\n bar

but that did not work.

2

Re: reg exp help

In the replacement string, you need to use '\r' to introduce a newline. This should work then:

s/; bar/;\r bar

Although you probably don't want the space after '\r'.

Why \r? Historical reasons lost in the mists of time (vim does it this way).

3

Re: reg exp help

thanks,
sooo vim regular expression are not standard regular expresion? ( if there is such thing).

4

Re: reg exp help

The case above is not really a regular expression, it is actually the "replacement string" in the :s command. It supports a few special codes (& to repeat the whole match, \1..\9 to repeat the parenthesized submatches, \u \U \l \L to alter the case, \r to introduce a newline, etc...), but apart from that it's just a regular string.

But, indeed, there doesn't seem to be a "standard" regex format, really. The basic syntax of the original vi is standardized in POSIX, but the many extensions (in vim, in perl, etc...) are often different.

I implemented the regex engine in ViEmu from scratch, following vim's documentation to follow it as closely as possible. There are a few obscure features not implemented yet in my engine, but it's an almost complete reimplementation of vim's regular expressions.

5

Re: reg exp help

Thanks,
Also I am trying to add a tab with \t but it does not work.

6

Re: reg exp help

Kroiz, you're right, \t is missing there - I'll add it to the next build. In any case, you can just type it directly (the command line will show it as ^I, it's just the same thing).

7

Re: reg exp help

cool thanks

8

Re: reg exp help

You're very welcome!