I've the following sample INI file:


and my goal is to set all options to 0 except Foo.

To disable one selected line, I know that I can run:


Test command in shell:

$ ex +"%s/Foo=\zs.*$/0/p" -scwq file.ini

How can I negate substitution pattern, for example disabling every other option apart of Foo?

I'm also open for suggestions to use different commands instead to achieve the same result.

  • 5
    Does it have to be done with a substitute command? If you're OK using a different command, you could use global, e.g. :g!/Foo/norm f=lC0
    – DJMcMayhem
    Commented Feb 5, 2017 at 0:38
  • @DJMcMayhem Yes, it can be different command as well. If you put it into the answer, it would be great.
    – kenorb
    Commented Feb 5, 2017 at 1:54

1 Answer 1


You can use :v, e.g. something like this should work: :v/^Foo/s/.*=\zs\d$/0/g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.