I did SPC-s-p to search inside a project using Projectile. A list of candidates are shown in the minibuffer. I selected one candidate and hit C-SPC to do preview, which I see is mapped to +vertico/embark-preview, and the preview of the file is shown in the main buffer with the line flashed and highlighted. I’d like to center it like how helm does it, but I couldn’t get it working using any of these settings in my config.el file.
Hm, I cannot repdocue this. For me, the line is centered (if possible) when pressing C-SPC. I do not have any extra configuration with respect to vertico or consult.
What happens exactly in your case? Where is the line? At the top/bottom?
I double checked my configuration file and the only vertico customization is a keymap change .
Just to be super sure, are you visiting files longer than the buffer height? (otherwise they appear to be “centered” by virtue of not being able to be scrolled)
Yes, the visited files are longer than buffer height. Matched line is shown enough in the buffer where it is visible so it could be top, almost middle, or bottom and if the second matched line from the same file is visible in the same view, it’s highlighted so it means it could be anywhere without being recentered.
@aisamu I found out that if I click on the buffer after C-SPC and then do C-L to do recenter-top-bottom, I could get it centered, but it’s really cumbersome to do that every time when you’ve multiple files to go through and will lose cursor focus from switching buffers.
In case of SPC s p (+default/search-project), +vertico/embark-preview delegates preview to consult, which runs consult-after-jump-hook after preview jump and has recenter command hooked up by default.
Thanks @aisamu@organic-bookworm! Your solutions work! I tried with nav-flash and I also tried with nav-flash and adding in the hook to consult-after-jump-hook. Doom Emacs community is great, and I really appreciate the fast solutions! Many thanks!