Function: evil-a-word
evil-a-word is an interactive and byte-compiled function defined in
evil-commands.el.
Signature
(evil-a-word &optional COUNT BEG END TYPE)
Documentation
Select a word.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
;;; Text objects
;; Text objects are defined with `evil-define-text-object'. In Visual
;; state, they modify the current selection; in Operator-Pending
;; state, they return a pair of buffer positions. Outer text objects
;; are bound in the keymap `evil-outer-text-objects-map', and inner
;; text objects are bound in `evil-inner-text-objects-map'.
;;
;; Common text objects like words, WORDS, paragraphs and sentences are
;; defined via a corresponding move-function. This function must have
;; the following properties:
;;
;; 1. Take exactly one argument, the count.
;; 2. When the count is positive, move point forward to the first
;; character after the end of the next count-th object.
;; 3. When the count is negative, move point backward to the first
;; character of the count-th previous object.
;; 4. If point is placed on the first character of an object, the
;; backward motion does NOT count that object.
;; 5. If point is placed on the last character of an object, the
;; forward motion DOES count that object.
;; 6. The return value is "count left", i.e., in forward direction
;; count is decreased by one for each successful move and in
;; backward direction count is increased by one for each
;; successful move, returning the final value of count.
;; Therefore, if the complete move is successful, the return
;; value is 0.
;;
;; A useful macro in this regard is `evil-motion-loop', which quits
;; when point does not move further and returns the count difference.
;; It also provides a "unit value" of 1 or -1 for use in each
;; iteration. For example, a hypothetical "foo-bar" move could be
;; written as such:
;;
;; (defun foo-bar (count)
;; (evil-motion-loop (var count)
;; (forward-foo var) ; `var' is 1 or -1 depending on COUNT
;; (forward-bar var)))
;;
;; If "forward-foo" and "-bar" didn't accept negative arguments,
;; we could choose their backward equivalents by inspecting `var':
;;
;; (defun foo-bar (count)
;; (evil-motion-loop (var count)
;; (cond
;; ((< var 0)
;; (backward-foo 1)
;; (backward-bar 1))
;; (t
;; (forward-foo 1)
;; (forward-bar 1)))))
;;
;; After a forward motion, point has to be placed on the first
;; character after some object, unless no motion was possible at all.
;; Similarly, after a backward motion, point has to be placed on the
;; first character of some object. This implies that point should
;; NEVER be moved to eob or bob, unless an object ends or begins at
;; eob or bob. (Usually, Emacs motions always move as far as possible.
;; But we want to use the motion-function to identify certain objects
;; in the buffer, and thus exact movement to object boundaries is
;; required.)
(evil-define-text-object evil-a-word (count &optional beg end _type)
"Select a word."
(evil-select-a-restricted-object 'evil-word beg end type count))