-
Notifications
You must be signed in to change notification settings - Fork 21
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 text objects that include surrounding whitespace #24
Comments
I like this idea. I'm glad that you suggested creating a separate text-object as In Practical Vim, I came up with the names delimited and bounded to differentiate between the two styles of text object. The existing |
I'm afraid that I've rather neglected this plugin in recent years, so I'm not too sure where you should start. The plugin has tests, implemented with vspec. Writing a failing test would be a good start... |
Thanks for your comments. Actually I was thinking about suggesting the change to In think |
Yeah, it's fine with me if |
@padde are you aware of the The current implementation of textobj-rubyblock is not great. I've often thought that it would be worthwhile rewriting it, using the implementation of |
Oh I see... you meant one could argue that
Now I am confused what the right thing would be ;-) By the way: bounded text object will not just match one additional space/blank line but actually all of them up to the first non-blank character (or EOF). |
No, I did not! They look nice but for me they feel to specialized. Why restrict myself to selecting just methods and classes when I can have all blocks? However, I really like that they check the syntax groups to find the right boundaries for the text objects.
Don't be so hard on yourself. I've used it daily for quite some time and it works great for me ;-) There's probably some room for refactoring, especially when new very similar text objects are added. I'm however not convinced that the implementation could be improved much without adding a dependency to vim-ruby and using the syntax groups from there. Is that what you are planning to do? |
I suppose one could, but I never said that 😉
Sounds good. I think that's how the |
I like to think of textobj-rubyblock as being a useful catchall, but I'm keen on the more specialized text objects too. I use |
I hadn't thought it through that far. At the moment, textobj-rubyblock has a dependency on matchit.vim, which is included by default, but usually not enabled by default. On the other hand, vim-ruby is usually bundled with Vim distributions, and you don't have to do anything to enable it. So it might be the less awkward of two dependencies. Alternatively, we could copy the syntax groups into the textobj-rubyblock plugin and scope them to this plugin's scripts, so as to avoid conflict. |
Alright, I still think mapping
This sounds exactly like the problem I am trying to solve by integrating textobj-rubyblock with expand-region. I've been recently playing around with Emacs a bit (he said the "E" word!) and was really impressed with the expand-region package. I'm not sold on Emacs for other reasons though, so I am looking for a way to make this work in Vim. In case you're not familiar with the concept of expand-region: it allows you to expand (and also contract) a visual selection by repeatedly extending it to the next bigger matching text object. So if you want to select an
Fair enough, this should not be a big problem then. Anyway, looks like there's quite some work ahead ;-) |
Similar to the way
aw
,ap
etc. also include the surrounding whitespace. This would be useful to delete an entire block e.g.daR
without having to delete the remaining empty lines manually. For example:putting the cursor within the first nested block and pressing
dar
results in:pressing
daR
should then result in:Analogously, pressing
daR
when the cursor is in the second nested block should result in:So the included surrounding whitespace should be:
vaw
does, for exampleThis is also helpful when integrating with the expand-region plugin. It is important here that we have the surrounding whitespace included so that a repeated application of alternating
vir
andvaR
will continue to bubble up to the topmost block. This way the selection will hopefully correctly expand up the hierarchy. Currently it is a big annoyance for me that this does not work properly.I'd love to give it a shot and make a PR, however I'd first like to hear your opinion on whether I missed anything and whether this is deemed useful. Cheers!
The text was updated successfully, but these errors were encountered: