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

Add Counts for Replacement Arguments

Open frankplow opened this issue 3 years ago • 3 comments

This PR adds support for repeating replacement arguments by beginning the argument with a count.

Examples:

  Old text            Command           New text
  hello               ysW2*             **hello**
  hello               ysW2]             [[hello]]

Repeated delimeters are used by markdown a lot as well as some other languages. Many of the posed use cases of #97 involve repeated delimeters and I think this PR is a more intuitive way to support them.

frankplow avatar Jan 26 '22 12:01 frankplow

I think #226 (almost the exact same PR) implements a better count detection (not limited by 0-9)?

There is also a bug where if you do a line selection and then a surround with a multiplier you get something like this:

*
	*
    I typed VS2* on this line
**

TeaWhyDee avatar May 12 '22 10:05 TeaWhyDee

Have to admit I didn’t see that PR.

Limiting to 0-9 was actually intentional. It means you can do, for example, ysiw11 to surround a word with a pair of 1s - I thought it was more likely to want to surround something with a pair of numbers rather than 10+ instances of something. Happy to change it if people disagree though.

frankplow avatar May 12 '22 12:05 frankplow

Oh, I didn't realize that. I also saw not being able to surround with numbers as a problem. Sounds like a little bit of a hack, but I do prefer your solution.

TeaWhyDee avatar May 12 '22 12:05 TeaWhyDee