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

Add surrounding function name delete/change #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LeszekSwirski
Copy link

Adds f/F support to s:dosurround, to allow changing/deleting the name of a surrounding function call. As with t, f preserves whitespace while F removes it. For example,

Old text                  Command      New text
func(arg1, ar*g2)         dsf          arg1, arg2
func(  arg1, ar*g2  )     csf)         (  arg1, arg2  )
func(  arg1, ar*g2  )     csF)         (arg1, arg2)

@wellle
Copy link

wellle commented Feb 1, 2015

Oh I just opened #157 to request exactly what you did here.

@tpope: Do you think this could get merged? 🙏

@Hotschke
Copy link

Hotschke commented Nov 4, 2015

The mentioned regex [\i.]\+\s*( is not possible in vim. \i does not work inside of a collection []. This is documented in vim: see second last note in :h /collection

...
- The following translations are accepted when the 'l' flag is not
  included in 'cpoptions' {not in Vi}:
    \e  <Esc>
    \t  <Tab>
    \r  <CR>    (NOT end-of-line!)
    \b  <BS>
    \n  line break, see above |/[\n]|
    \d123   decimal number of character
    \o40    octal number of character up to 0377
    \x20    hexadecimal number of character up to 0xff
    \u20AC  hex. number of multibyte character up to 0xffff
    \U1234  hex. number of multibyte character up to 0xffffffff
  NOTE: The other backslash codes mentioned above do not work inside
  []!

Python identifiers can be defined as:

identifier ::=  (letter|"_") (letter | digit | "_")*

from https://docs.python.org/2/reference/lexical_analysis.html#identifiers

A working regex for python is: [_[:alnum:].]\+\s*(

@kiryph
Copy link

kiryph commented Jan 25, 2016

A working vim regex would be: \(\i\+\.\=\)\+\s*(

@zdcthomas
Copy link

I was about to open the same PR but found this one from a while back. Is there anything left to do here that I can help with to get it merged?

@wellle
Copy link

wellle commented Mar 22, 2020

Since this PR 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.

@tpope
Copy link
Owner

tpope commented Mar 22, 2020

Candidly, Surround just doesn't make the cut for things I have time to work on these days. Years of experience have taught me that blindly clicking the merge button on PRs I don't have time to audit just creates a giant mess. I'll leave this open in case my priorities shift, but until then, Surround is essentially in a feature freeze.

Sandwich has been on my radar for a while and does seem cool, even if the default s map doesn't work for me.

@wellle
Copy link

wellle commented Mar 22, 2020

Thanks for the update! No worries, this is totally understandable. We owe you a lot for creating all these immensely useful and influential plugins in the first place. 🙌 Take care!

oncomouse added a commit to oncomouse/vim-surround that referenced this pull request Sep 30, 2020
@Matt-A-Bennett
Copy link

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 this pull request may close these issues.

None yet

7 participants