Tim's recent post got me looking at \z
I've read :h :syn-ext-match but it's gibberish to me at the moment

the \zs and \ze modifiers are handy ways ot indicating where any replacements start/end. Their documentation can be found at

        :help /\zs
        :help /\ze

The
        :help syn-ext-match

is a red-herring, as you end up in a very different section of the docs if you just do

        :help \z

as you discovered :)

If you want to delete everything after the 2nd comma, you can use
        :%s/,[^,]*,\zs.*/

I get the 'search the whole document for a comma followed by a not- comma followed by whatever then a comma'
then ???

In the above, the ",[^,]*," (which you have correctly understood/described) specifies context. The "\zs" means "when performing the replacement, start the replacement *here*, rather than replacing the entire match thus far". This would be behaviorly identical to

        :%s/\(,[^,]*,\).*/\1

which preserves the "comma, not-a-comma stuff, comma" bit of things rather than deleting them.

Hope this sheds more light than it obscures,

-tim



Reply via email to