-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for "surround copy (yank)" and "surround paste" #1325
Comments
Thanks for the suggestion! This is indeed an interesting feature. In my mind it might be implemented a bit differently:
One thing to consider here is that it will be a breaking feature:
All in all, I think this has good chances of being implemented. And in that case, I also would like to do this myself, if you don't mind. |
I quite like your idea of sy (surround yank) storing the the spec in a special character than can then be used with the other operators. I gave it some thought overnight, and I think it would make the most sense to assign it to and then reading the spec from a register. This would require allowing termcodes as surrounds, but it has several benefits:
I updated my implementation to reflect my comment above. A followup from your answer above:
How would
All good man, whatever is easiest for you to maintain :) |
My initial impression is that I don't really like the idea of mixing registers here. Can't really put that into words, though. Mostly a combination of "it introduces another abstraction", "register is for contiguous charwise/linewise/blockwise text region", and "requires more code", but maybe something else.
Same as user prompt and would find surrounding with that exact yanked left and right edges. |
I like registers (and so I'll likely stick with my fork), but implement it however you see fit :) A suggestion that could be in the line of what you're thinking:
e.g. This way, you only need to implement the "yank" operator, and it will automatically work with any other operator by using the recorded output char. |
Contributing guidelines
Module(s)
mini.surround
Description
I was playing with my mini.surround config the other day, and I realized that occasionally I want to "copy" a surround, particularly complex ones like "f", and "paste" the same text in another piece of code.
Thinking about it conceptually, executing a command such as "syf" over a function call like
vim.print(my_variable)
, so it would internally store{ left = "vim.print(", right = ")" }
. Then it should be possible to executespiw
overmy_other_variable
to getvim.print(my_other_variable)
.I it a go in implement this feature, and it was easier to implement than I anticipated. If there's interest, I can format it and open a proper pull request.
The text was updated successfully, but these errors were encountered: