@@ -130,6 +130,7 @@ function! s:wrap(string,char,type,removed,special)
130
130
let s: input = " "
131
131
let type = a: type
132
132
let linemode = type == # ' V' ? 1 : 0
133
+ let mp = split (&matchpairs , ' [:,]' ) " assumes it's well-formed
133
134
let before = " "
134
135
let after = " "
135
136
if type == # " V"
@@ -144,6 +145,7 @@ function! s:wrap(string,char,type,removed,special)
144
145
let extraspace = ' '
145
146
endif
146
147
let idx = stridx (pairs,newchar)
148
+ let mpidx = index (mp , newchar)
147
149
if newchar == ' '
148
150
let before = ' '
149
151
let after = ' '
@@ -241,6 +243,11 @@ function! s:wrap(string,char,type,removed,special)
241
243
let idx = idx / 3 * 3
242
244
let before = strpart (pairs,idx+ 1 ,1 ) . spc
243
245
let after = spc . strpart (pairs,idx+ 2 ,1 )
246
+ elseif mpidx >= 0
247
+ let spc = (mpidx % 2 ) == 1 ? " " : " "
248
+ let mpidx = mpidx / 2 * 2
249
+ let before = mp [mpidx] . spc
250
+ let after = spc . mp [mpidx+ 1 ]
244
251
elseif newchar == " \<C-[> " || newchar == " \<C-]> "
245
252
let before = " {\n \t "
246
253
let after = " \n }"
@@ -391,6 +398,8 @@ function! s:dosurround(...) " {{{1
391
398
return s: beep ()
392
399
endif
393
400
endif
401
+ let mp = split (&matchpairs , ' [:,]' ) " assumes it's well-formed
402
+ let mpidx = index (mp , char)
394
403
let cb_save = &clipboard
395
404
set clipboard -= unnamed clipboard -= unnamedplus
396
405
let append = " "
@@ -406,6 +415,13 @@ function! s:dosurround(...) " {{{1
406
415
exe ' norm! l'
407
416
endif
408
417
exe ' norm! dt' .char
418
+ elseif mpidx >= 0
419
+ let mpidx = mpidx / 2 * 2
420
+ if getline (' .' )[col (' .' )-1 ] == mp [mpidx]
421
+ exe ' norm! l'
422
+ endif
423
+ exe ' norm! T' .mp [mpidx]
424
+ exe ' norm! dt' .mp [mpidx+ 1 ]
409
425
else
410
426
exe ' norm! d' .strcount.' i' .char
411
427
endif
@@ -433,6 +449,9 @@ function! s:dosurround(...) " {{{1
433
449
elseif char = ~# ' [[:punct:][:space:]]' && char !~# ' [][(){}<>]'
434
450
exe ' norm! F' .char
435
451
exe ' norm! df' .char
452
+ elseif mpidx >= 0
453
+ exe ' norm! F' .mp [mpidx]
454
+ exe ' norm! df' .mp [mpidx+ 1 ]
436
455
else
437
456
" One character backwards
438
457
call search (' \m.' , ' bW' )
0 commit comments