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

Text object movement #23

Closed
Julian opened this issue Jan 5, 2014 · 5 comments
Closed

Text object movement #23

Julian opened this issue Jan 5, 2014 · 5 comments

Comments

@Julian
Copy link

Julian commented Jan 5, 2014

Hey!

@JosephFerano noticed on a vim-textobj-variable-segment ticket that there are parameters to plugin that allow defining a function / pattern for moving to the next text object.

I've been playing around a bit with trying to hook that up, but haven't had much success, and can't really find any other text objects that use move-[n|p](-function).

From the docs, it seems like the API these functions are supposed to return is the same as the select functions, i.e. type, start_position, end_position, but I'm not sure I see how that should be necessary – it seems like move-n should want type, end_position and move-p should want type, start_position, and further, it seems like they should not really need defining separately, they're inferable from the select functions. Have I misunderstood something?

(If I add a move-n-function which is just my select-a-function I see something happen, the appropriate range looks like it's being found, but oddly, I just see it get visual selected, and the cursor doesn't keep moving if I keep move-n'ing.)

@JosephFerano
Copy link

So I guess no progress has been made here? I miss this feature from Sublime :(

@kana
Copy link
Owner

kana commented Feb 6, 2014

Sorry for a late response. And sorry about the document. The current document is wrong. There is no support for move-[npNP]-function at the moment. Also the current implementation is wrong as you described. move-[npNP]-function acts like select-[ai]-function. I'll review the move-[npNP]-function specification later.

@Julian
Copy link
Author

Julian commented Feb 6, 2014

Cool, thanks for confirming -- I haven't taken a closer look at this since the original ticket, but I can if I can be of any help.

@kana
Copy link
Owner

kana commented Feb 6, 2014

From the docs, it seems like the API these functions are supposed to return is the same as the select functions, i.e. type, start_position, end_position, but I'm not sure I see how that should be necessary – it seems like move-n should want type, end_position and move-p should want type, start_position, and further, it seems like they should not really need defining separately, they're inferable from the select functions. Have I misunderstood something?

Almost right. But move-n means a command to move the cursor to the first character of the next text object, so that it requires start_position.

And generally move-[npNP]-function are not inferrable from select-[ai]-function. For example, vim-textobj-variable-segment's s:select_i searches a left boundary then searches a right boundary. It mostly selects the text object under the cursor, but sometimes selects the nearest text object before the cursor if the cursor is between two WORDs like foo {cursor} bar. Since move-n-function requires start_position of the text object next to the cursor, vim-textobj-variable-segment's s:select_i is not reusable as move-n-function.
(I just took a quick look the implementation of vim-textobj-variable-segment for the example. I might misunderstand about the exact behavior of s:select_i. But I think select functions usually have similar problems.)

@kana kana closed this as completed in 777dfb7 Feb 8, 2014
@Julian
Copy link
Author

Julian commented Feb 9, 2014

Awesome. I'll see if I can try and give this another shot at some point.

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

No branches or pull requests

3 participants