Skip to content
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

Request: Delete surrounding function #157

Open
wellle opened this issue Feb 1, 2015 · 7 comments · May be fixed by #309
Open

Request: Delete surrounding function #157

wellle opened this issue Feb 1, 2015 · 7 comments · May be fixed by #309

Comments

@wellle
Copy link

wellle commented Feb 1, 2015

Currently we have a way to surround foo via ysiwftest to test(foo).

I would like to go back from test(foo) to foo by typing dsf. It just has to act like dsb, except that it needs to also delete the word in front of the target. That would be super useful!

@imomaliev
Copy link

+1 for this feature. I see there is wrap implementation with ysiwf. Would also be very useful if we could delete surrounding function.

@wellle
Copy link
Author

wellle commented Mar 1, 2018

I was just made aware of https://gist.github.com/romgrk/35186f3b5a71a7d89b2229b6f73e4f32 which seems to implement this perfectly. Maybe it can be added to vim-surround?

@romgrk: Would that be fine with you?

@romgrk
Copy link

romgrk commented Mar 1, 2018

I have no problem with that. I've cleaned up a bit the gist and added comments (it was extracted from many parts of my RC files), so it should be more readable now.

I'm here if you have any questions, but mostly it piggybacks on vim-surround. The main part is s:findFunc that handles finding the closest function call, then calling vim-surround through an uggly feedkeys(...). Could be made better if it had access to vim-surround internals.

It will still need to be tested in a clean environment, because maybe there are still some assumptions that I made knowing it was meant to execute in my own environment, but I've been using that for years without problems.

@philipjhj
Copy link

I'll make an attempt to implement this, if no one else has already begun?

@imomaliev
Copy link

@philipjhj there already is #118

@wellle
Copy link
Author

wellle commented Mar 22, 2020

Since this issue seems pretty abandoned, I just want to let you know that a similar plugin has support for deleting surrounding functions, see https://github.com/machakann/vim-sandwich/wiki/Magic-characters#function-surroundings.

xbe added a commit to xbe/vim-surround that referenced this issue Sep 5, 2020
csf = Change surround function to specified one.
dsf = Remove surrounding function.

The deleted function name is stored in the unnamed register.
Closes tpope#157.
@xbe xbe linked a pull request Sep 5, 2020 that will close this issue
@Matt-A-Bennett
Copy link

Matt-A-Bennett commented Jan 21, 2022

I just made vim-surround-funk to do that. You can also then 'grip' some text object with the function call. So dsf will delete the surrounding function, and then the gs operator will 'grip' a text object. And since I included text object for a function call, you can grip one function call (using gsaf i.e. 'grip/surround a function) with the one you just deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants