0

I am using find-file with vertico. After running find-file and typing filename and when I press <TAB> it selects the current line.

TAB runs the command vertico-insert (found in vertico-map), which is an
interactive byte-compiled Lisp function in ‘vertico.el’.

It is bound to TAB.

(vertico-insert)

enter image description here

Instead, is it possible to bing <TAB> as to toggle inside the list of find filenames?

4
  • maybe (define-key vertico-map (kbd "<tab>") 'vertico-next)
    – roomworoof
    Commented Apr 28, 2023 at 12:14
  • @roomworoof it did not helped , like it still remains as (vertico-insert):-(
    – alper
    Commented Apr 28, 2023 at 12:58
  • As for this setting, I tried it in my environment and it worked, but I also have had the same experience as you, I could not overwrite keymap in another case. I wonder what the cause is.
    – roomworoof
    Commented Apr 28, 2023 at 13:21
  • @roomworoof Its impossible to find the cause of it :-)
    – alper
    Commented Apr 29, 2023 at 6:47

2 Answers 2

1

Try TAB instead of <tab> and it will work.

(define-key vertico-map (kbd "TAB") 'vertico-next)

Since TAB (not <tab>) is used in the source (defvar-keymap vertico-map ...), this should overwrite it correctly. I just learned for the first time that TAB and <tab> are different things...

  1. <tab> = Tab (GUI only)

  2. TAB = C-i = Tab (Terminal, or GUI if <tab> is not set)

They say it's for historical reasons, see StreakyCobra's comment (referred by another questioner @Håkon Hægland on this site: What is the difference between TAB and <tab>?)

2
  • It works! Not sure but can it toggle cycle like back to top if the selected line is at bottom?
    – alper
    Commented Apr 29, 2023 at 10:29
  • (setq vertico-cycle t)?
    – roomworoof
    Commented Apr 29, 2023 at 10:32
1

If you don't want to go back to the prompt line by setting vertico-cycle, define another function like this:

(defun my-vertico-next (&optional n)
  "Circulate without returning to the prompt line"
  (interactive "p")
  (let ((index (+ vertico--index (or n 1))))
    (vertico--goto
     (if (= vertico--total 0) -1 (mod index vertico--total)))))

(define-key vertico-map (kbd "TAB") 'my-vertico-next)
1
  • 1
    Awesome, thanks for the seconds answer as well!
    – alper
    Commented Apr 29, 2023 at 20:20

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.