1

I'm trying to do a simple replace for all equal signs and subsequent characters until end of line: %s/\=.+\n/\n/. However this gives E866: (NFA regexp) Misplaced =.

If I try instead to simply replace all equal signs with %s/(\=)//, I get pattern not found though I know my text file contains equal signs.

Could someone tell me what I'm doing wrong? Thanks in advance

1 Answer 1

2

Presuming you are using the default and recommend setting of 'magic', you need to use = instead of \=, \+ instead of +, and \r instead of \n in the replacement text:

Try this:

:%s/=.\+\n/\r

But actually, you don't need to match and replace the newline, so this simplifies further:

:%s/=.\+

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.