Function: evil-forward-word-begin
evil-forward-word-begin is an interactive and byte-compiled function
defined in evil-commands.el.
Signature
(evil-forward-word-begin &optional COUNT BIGWORD)
Documentation
Move the cursor to the beginning of the COUNT-th next word.
If BIGWORD is non-nil, move by WORDS.
If this command is called in operator-pending state it behaves differently. If point reaches the beginning of a word on a new line point is moved back to the end of the previous line.
If called after a change operator, i.e. cw or cW,
evil-want-change-word-to-end is non-nil and point is on a word,
then both behave like ce or cE.
If point is at the end of the buffer and cannot be moved then
end-of-buffer is signaled.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
(evil-define-motion evil-forward-word-begin (count &optional bigword)
"Move the cursor to the beginning of the COUNT-th next word.
If BIGWORD is non-nil, move by WORDS.
If this command is called in operator-pending state it behaves
differently. If point reaches the beginning of a word on a new
line point is moved back to the end of the previous line.
If called after a change operator, i.e. cw or cW,
`evil-want-change-word-to-end' is non-nil and point is on a word,
then both behave like ce or cE.
If point is at the end of the buffer and cannot be moved then
`end-of-buffer' is signaled."
:type exclusive
(let ((thing (if bigword 'evil-WORD 'evil-word))
(orig (point))
(count (or count 1)))
(evil-signal-at-bob-or-eob count)
(cond
;; default motion, beginning of next word
((not (evil-operator-state-p))
(evil-forward-beginning thing count))
;; the evil-change operator, maybe behave like ce or cE
((and evil-want-change-word-to-end
(memq evil-this-operator evil-change-commands)
(< orig (or (cdr-safe (bounds-of-thing-at-point thing)) orig)))
;; forward-thing moves point to the correct position because
;; this is an exclusive motion
(forward-thing thing count))
;; operator state
(t
(prog1 (evil-forward-beginning thing count)
;; if we reached the beginning of a word on a new line in
;; Operator-Pending state, go back to the end of the previous
;; line
(when (and (> (line-beginning-position) orig)
(looking-back "^[[:space:]]*" (line-beginning-position)))
;; move cursor back as long as the line contains only
;; whitespaces and is non-empty
(evil-move-end-of-line 0)
;; skip non-empty lines containing only spaces
(while (and (looking-back "^[[:space:]]+$" (line-beginning-position))
(not (<= (line-beginning-position) orig)))
(evil-move-end-of-line 0))
;; but if the previous line is empty, delete this line
(when (bolp) (forward-char))))))))