When I put the cursor on a parenthesis in vim:
f = (\x y -> x+y)
^
typing % will move the cursor to the matching parenthesis:
f = (\x y -> x+y)
^
typing %d will delete the parentheses and everything in them
f =
^
but when I have nested parentheses:
g = (\(x,y) -> x+y)
^
typing % makes it jump to the closing inner parenthesis instead of the matching one:
g = (\(x,y) -> x+y)
^
and %d has the same mismatching behavior:
g = (\(x,y) -> x+y)
^
becomes
g = -> x+y)
^
Why? How can I make it match properly?
Oddly, the visual highlighting of matching parentheses does work:






How does this work but then the matching by % doesn't? Are there two brains?
Short answer, from :help %:
:set cpoptions+=M
This prevents vim from ignoring the \( combination and treat it as (.
(The long answer might involve using a similar plugin to matchit, of which I am unaware, that explains to vim that \ means lambda, not backslash.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With