1

Emacs 27

I enable vertico-indexed-mode

Here result: enter image description here

How I can use this numbers (0,1,2,3) ?

0

2 Answers 2

2

As the commentary to the package says it allows to choose a candidate with prefix arguments. For example you can do C-5 RET to select the fifth candidate (as if you'd hit C-n 5 times and do RET).

0

vertico-indexed-mode seems to be an extention just to add sequential numbers, so I made a snippet that allows you to select it, for now bound to function keys (define-key other keys as you like).

(defun my-vertico-select (index)
  (interactive)
  (vertico-next (if (string= vertico-preselect 'prompt) (+ index 1) index)) ;; If `vertico-preselect' is `first' or `prompt', it's mostly working but when `directory' the default value, is described as "Like first, but select the prompt if it is a directory", so the condition switch (the first list item is directory or not) is needed.
  (vertico-exit))

(define-key minibuffer-local-map (kbd "<f1>") (lambda () (interactive) (my-vertico-select 1)))
(define-key minibuffer-local-map (kbd "<f2>") (lambda () (interactive) (my-vertico-select 2)))
(define-key minibuffer-local-map (kbd "<f3>") (lambda () (interactive) (my-vertico-select 3)))
(define-key minibuffer-local-map (kbd "<f4>") (lambda () (interactive) (my-vertico-select 4)))
(define-key minibuffer-local-map (kbd "<f5>") (lambda () (interactive) (my-vertico-select 5)))
(define-key minibuffer-local-map (kbd "<f6>") (lambda () (interactive) (my-vertico-select 6)))
(define-key minibuffer-local-map (kbd "<f7>") (lambda () (interactive) (my-vertico-select 7)))
(define-key minibuffer-local-map (kbd "<f8>") (lambda () (interactive) (my-vertico-select 8)))
(define-key minibuffer-local-map (kbd "<f9>") (lambda () (interactive) (my-vertico-select 9)))
3
  • OK. But why this numbers not works out of box? Why are these numbers needed? Commented Apr 10, 2023 at 10:46
  • I just found out about it, probably C-u <the number> C-n or C-p ? The comment in the source says "It allows you to select candidates with prefix arguments. This is designed to be a faster alternative to selecting a candidate with vertico-next and vertico-previous"
    – roomworoof
    Commented Apr 10, 2023 at 11:01
  • Maybe just displaying it as a (sighting) scale, for the keystroke to repeat of Emacs standard feature?
    – roomworoof
    Commented Apr 10, 2023 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.