abo-abo / avy

Jump to things in Emacs tree-style
1.73k stars 110 forks source link

Go to word(-0) in line? #361

Closed ghosty141 closed 1 year ago

ghosty141 commented 1 year ago

Is there a way to go to a word in the same line the cursor currently is in right now? This already exists with char but not with word-0.

ghosty141 commented 1 year ago

Nevermind, figured it out! Maybe this could be included @abo-abo.

(defun avy-goto-word-0-in-line (arg &optional beg end)
    "Jump to a word start in the in the current line.
The window scope is determined by `avy-all-windows'.
When ARG is non-nil, do the opposite of `avy-all-windows'."
    (interactive "P")
    (avy-with avy-goto-word-0-regexp
      (avy-jump avy-goto-word-0-regexp
                :window-flip arg
                :beg (line-beginning-position)
                :end (line-end-position))))