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

Feature Request: Next & Last Object Motion #6353

Closed
bhilburn opened this issue Jun 17, 2016 · 6 comments
Closed

Feature Request: Next & Last Object Motion #6353

bhilburn opened this issue Jun 17, 2016 · 6 comments
Labels
- Mailling list - Feature request stale marked as a stale issue/pr (usually by a bot)

Comments

@bhilburn
Copy link

This may already exist for emacs, but I haven't been able to find anything on it.

In Vim, there is a snippet from Steve Losh that provides motion for next and last text objects. As an example of how this works:

    this_is_some_func(arg1, arg2, arg3);
      ^
      cursor

If the cursor was on the character indicated, the user could press c i n ( and the result would be:

    this_is_some_func( );
                      ^
                      cursor

Where that command sequence is change-in-next-(. So just as you usually have change-in-( and change-around-(, for example, it understands the concept of next and last instances of those text objects for motion.

You can see the code that does this here: https://github.com/bhilburn/dotfiles/blob/master/vim/vimrc#L1313

@TheBB
Copy link
Contributor

TheBB commented Jun 17, 2016

https://github.com/wellle/targets.vim

We should just port this, sounds like what you're asking for and more.

“Just”

@bhilburn
Copy link
Author

@TheBB - Oh wow, I didn't know that existed. But yes! A port of that would be fantastic. It really is tremendously useful.

@ninrod
Copy link

ninrod commented Feb 3, 2017

behold: https://github.com/noctuid/targets.el. Courtesy of @noctuid, the master of evil.

But it is not ready yet. (although I'm using it for precisely the case stated by the thread opener and it is working wonderfully already).

And you don't have to even use n. Just ci( will do.

Enjoy.

@bhilburn
Copy link
Author

@ninrod - Thanks so much for sharing this! It is, indeed, exactly what I was looking for.

Perhaps when it's done it can be pulled into Spacemacs =)

@ninrod
Copy link

ninrod commented Feb 22, 2017

No problem. Here's how I use it:

(use-package avy
  :ensure t
  :config
  (use-package targets
    :load-path "lisp/ninrod/targets.el"
    :init
    (setq targets-user-text-objects '((pipe "|" nil separator)
                                      (paren "(" ")" pair :more-keys "b")
                                      (bracket "[" "]" pair :more-keys "r")
                                      (curly "{" "}" pair :more-keys "c")))
    :config
    (targets-setup t
                   :inside-key nil
                   :around-key nil
                   :remote-key nil)))

this package will be a big hit on the evil community. @noctuid is packing a lot of awesome features in it. stay tuned.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Mailling list - Feature request stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

3 participants