Haskell has a literal syntax for anonymous functions of
\pattern0 pattern1 [...] patternN -> expression
which interacts oddly with vim's parenthesis text objects when pattern0
starts with a (
.
For example in the line
foldr (\(a,b) c -> a + b * c) 0 [ (0,1), (2,3) ]
^
If my cursor is on the ,
in (a,b)
, I'd like the normal mode command di(
to delete the a,b
and leave the cursor on the )
, like so:
foldr (\() c -> a + b * c) 0 [ (0,1), (2,3) ]
^
However, with cpoptions=aABceFs
, the \
prevents the (
from matching the )
in \(a,b)
, so the entire start of the lambda expression is deleted:
foldr () c -> a + b * c) 0 [ (0,1), (2,3) ]
^
With cpoptions=aABceFsM
, it's a little better as %
works properly, but the entire lambda expression is deleted:
foldr () 0 [ (0,1), (2,3) ]
^
How can I get di(
to just delete a,b
?
:nnoremap di( vT(Ot)d
The only downside is that this doesn't work withci(
,yi(
,vi(
,da(
and the endless variations. – James May 20 '16 at 16:47di(
works as desired in newer versions. – rampion May 20 '16 at 17:58