Function: evil-ex

evil-ex is an interactive and byte-compiled function defined in evil-ex.el.

Signature

(evil-ex &optional INITIAL-INPUT)

Documentation

Enter an Ex command.

The Ex command line is initialized with the value of INITIAL-INPUT. If the command is called interactively the initial input depends on the current state. In Normal state if a prefix count is given then the initial input is ".,.+count", otherwise it is empty. In Visual state the initial input is the visual region '<,'> or `<,`>. The variable evil-ex-initial-input, if non-nil, is appended to the line.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-ex.el
(evil-define-command evil-ex (&optional initial-input)
  "Enter an Ex command.
The Ex command line is initialized with the value of INITIAL-INPUT. If
the command is called interactively the initial input depends on the
current state. In Normal state if a prefix count is given then the
initial input is \".,.+count\", otherwise it is empty. In Visual state
the initial input is the visual region '<,'> or `<,`>. The variable
`evil-ex-initial-input', if non-nil, is appended to the line."
  :keep-visual t
  :repeat abort
  (interactive
   (let ((s (concat
             (cond
              ((and (evil-visual-state-p)
                    evil-ex-visual-char-range
                    (memq (evil-visual-type) '(inclusive exclusive)))
               "`<,`>")
              ((evil-visual-state-p) "'<,'>")
              (current-prefix-arg
               (let ((arg (prefix-numeric-value current-prefix-arg)))
                 (cond ((< arg 0) (setq arg (1+ arg)))
                       ((> arg 0) (setq arg (1- arg))))
                 (if (= arg 0) "." (format ".,.%+d" arg)))))
             evil-ex-initial-input)))
     (list (unless (string= s "") s))))
  (let ((buffer (current-buffer))
        (previous-command (when evil-want-empty-ex-last-command
                            (car evil-ex-history)))
        s evil--ex-cmd evil--ex-argument-handler evil--ex-shortcut-command)
    (minibuffer-with-setup-hook
        (lambda ()
          (setq-local evil-ex-original-buffer buffer)
          (evil-ex-setup)
          (if initial-input (evil--ex-update)
            (when previous-command
              (add-hook 'pre-command-hook #'evil-ex-remove-default nil t))))
      (setq s (read-from-minibuffer
               ":"
               (or initial-input
                   (and previous-command (propertize previous-command 'face 'shadow)))
               evil-ex-completion-map nil 'evil-ex-history)))
    (if evil--ex-shortcut-command
        (call-interactively evil--ex-shortcut-command)
      (when (string= s "") (setq s previous-command))
      (unless (string= s "") (evil-ex-execute s)))))