On Tuesday, November 19, 2013 2:25:48 PM UTC-5, Daniel "paradigm" Thau wrote:
> I noticed a common pattern when using Vim:
> - I want to operate on a text object that is not under/around the cursor
> - The cursor is not over/in a text object of this type.
>
> For example, with the cursor on the "x" and a desire to operate on the
> conditional part of the if-statement:
>
> x = 1;
> ...
> if (...) {
> ...
> }
>
> In these situations I have been moving the cursor to the object then
> selecting the object with something like "/(<cr>vi(" or "5jf(vi(".
>
> However, in that situation the text-object commands don't do anything. We
> could have Vim do something useful in this context - jump to the desired text
> object. If the given text-object command is valid - if the cursor is already
> in a ()-block - then what Vim normally does should happen. However, if Vim
> is about to "return FAIL" could simply search the buffer for the object and,
> if it finds it, use that object instead.
>
> Moreover, block text-objects (parens, {}, [], <>) have two (or three!) ways
> to access them. This could be used to indicate direction. "vi(" will select
> the ()-block under/around the cursor or, if no such block exists in that
> area, searches forward for a ()-block. "vi)" will do the same except it will
> search in reverse. "vib" will just act as it always has. Similar actions
> will be used on {}, [], and <>.
>
> Attached is a patch (both in the context and unified formats) to implement
> this. It seems relatively simple/clean to me, but people looking over and
> testing would be benficial in case I failed to consider something.
Attached is a newer version of the same patch with reworked code to be a bit
cleaner. It includes Christian's suggestion for the search direction.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.