paradigm / TextObjectify

TextObjectify is a Vim plugin which improves text-objects
100 stars 6 forks source link

ds" to delete surrounding quotes #10

Open shurane opened 9 years ago

shurane commented 9 years ago

Is there a way to get ds" work delete surrounding quotes? For example, putting the cursor on either of the 2 middle lines and then running ds".

"
some example code.
section is multiple lines
"
paradigm commented 9 years ago

Oooh, interesting. Yes, that should be possible. First thing that comes to mind is:

nmap ds" yi"va"p

Essentially that uses yi" to copy the part inside of the quotes, va" to select the entire region then p to paste the copied content over the entire thing.

That overwrites the "" register, which may not necessarily be desirable. And that may be a bit fragile and break in some situation I've not considered. I'll have to play with it to get a more solid solution. This can probably be generalized with a generic s family of objects. I certainly didn't think of having this compete with tpope's vim-surround, but if can be cleanly extended to that may be a decent idea.

I've not been able to work on this plugin for quite some time for various reasons that might be clearing up soon. If/when I am able to, I'd like to do a big overhaul which may include official support for this kind of thing, or at the very least mention it in the :help/README after more thorough testing.

If you use that for a bit, let me know how it works out for you.