Reputation: 291
I can search a regex with no problem, e.g.
/["']
but in an if statement it fails, e.g.
:let c = "w"
:if c !~ ["']
:echo "OK"
:endif
producing these error messages
E114: Missing quote: "']
E15: Invalid expression: c !~ ["']
I've tried it umpteen different ways, bristling with backslashes, single and double quotes and 'very magic', but all I get is variation in the error messages. How should I write this 'if' statement?
Upvotes: 1
Views: 502
Reputation: 544
I've personally had some problems with searching for [
and an opposing ]
with Vim. Often times you can search either one independently with no problems, but when you combine both together, they need to be escaped.
So, try this: \["'\]
and see if that works.
Upvotes: 0