Function: evil-forward-char

evil-forward-char is an interactive and byte-compiled function defined in evil-commands.el.

Signature

(evil-forward-char &optional COUNT CROSSLINES NOERROR)

Documentation

Move cursor to the right by COUNT characters.

Movement is restricted to the current line unless CROSSLINES is non-nil. If NOERROR is non-nil, don't signal an error upon reaching the end of the line or the buffer; just return nil.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
;;; Motions

;; Movement commands, or motions, are defined with the macro
;; `evil-define-motion'. A motion is a command with an optional
;; argument COUNT (interactively accessed by the code "<c>").
;; It may specify the :type command property (e.g., :type line),
;; which determines how it is handled by an operator command.
;; Furthermore, the command must have the command properties
;; :keep-visual t and :repeat motion; these are automatically
;; set by the `evil-define-motion' macro.

(evil-define-motion evil-forward-char (count &optional crosslines noerror)
  "Move cursor to the right by COUNT characters.
Movement is restricted to the current line unless CROSSLINES is non-nil.
If NOERROR is non-nil, don't signal an error upon reaching the end
of the line or the buffer; just return nil."
  :type exclusive
  (interactive "<c>" (list evil-cross-lines
                           (evil-kbd-macro-suppress-motion-error)))
  (cond
   ((not crosslines)
    ;; For efficiency, narrow the buffer to the projected
    ;; movement before determining the current line
    (evil-with-restriction nil (min (+ (point) (or count 1) 1) (point-max))
      (condition-case err
          (evil-narrow-to-line (forward-char count))
        (error
         ;; Restore the previous command (this one never happened).
         ;; This preserves the current column if the previous command
         ;; was `evil-next-line' or `evil-previous-line'.
         (setq this-command last-command)
         (unless noerror (signal (car err) (cdr err)))))))
   (noerror (ignore-errors (evil-forward-char count crosslines)))
   (t (evil-motion-loop (nil (or count 1))
        (forward-char)
        ;; don't put the cursor on a newline
        (or evil-move-beyond-eol
            (evil-visual-state-p) (evil-operator-state-p)
            (not (eolp)) (bolp)
            (forward-char))))))