vim-surround icon indicating copy to clipboard operation
vim-surround copied to clipboard

Repeatable function (ys..f...)-style surrounds

Open simlei opened this issue 5 years ago • 2 comments

Editing a large body of TeX now, and since I was ca. 7 years late to the party of referenced issue, asking for a custom LaTeX \command{...}-surround.


Am I missing something, or does this not work?

let g:surround_{char2nr('c')} = "\\\1command\1{\r}"

Originally posted by @tpope in https://github.com/tpope/vim-surround/issues/47#issuecomment-4254383


It is great that above mentioned snippet works 7 years into this plug-in, even though as tagged "subject to change" in the docs. A poster there originally asked if it was possible to make this kind of surround repeatable -- with reason: ysi)f[...]^m is repeatable including the ellipsed part. The same does not hold for the suggested g:surround_... thing.

Would you kindly and shortly elaborate on the difficulties involved to make this kind of stuff repeatable by default? I am not exactly a novice in VimScript any more and could figure out the rest on my own. Although, with the repeat register and from what I recall quite messy underbelly of repeat operations, a starter would be certainly appreciated! also for educational purpose.

Thanks! :)

simlei avatar Apr 10 '19 04:04 simlei

Big downside of asking about a 7 year old issue is I can't remember shit about it. I recall the HTML t/< repeating was an ordeal, you might want to start by looking at that that and trying to generalize.

tpope avatar Apr 10 '19 06:04 tpope

what I feared :/ sadly, not important enough for me to go through an ordeal for, presently. Thanks, though :)

simlei avatar Apr 10 '19 21:04 simlei