¶Replacing Ivy and Counsel with Vertico and Consult
If you tried out Vertico after the video on Monday, you probably wondered how you can get back to the level of functionality you had with Ivy.
Today we’re going to survey the set of commands that come with the Consult package to figure out which will be useful for the transition away from Ivy.
I’ll be making a video on this soon, but today we’ll be figuring it out together!
¶Mapping Ivy/Swiper/Counsel to Consult
consult-buffer. Annotations are better for
TIP: You should set
consult-project-root-function to something like this if you use Projectile:
(defun dw/get-project-root () (when (fboundp 'projectile-project-root) (projectile-project-root)))
¶Other useful commands
consult-mark: Show a list of previous mark locations
consult-outline: Show a list of headings in the current file depending on type
consult-minor-mode-menu: Show a list of all minor modes, press
i SPCto narrow to active modes
consult-history: History for current minibuffer, also works for terminal modes
consult-file-externally: Open a file in an external program
consult-preview-mode: Preview selections for various commands
consult-completion-in-region: Can be used with the
completion-in-region-functionvariable to do in-buffer completions using Vertico
¶Going up a directory in
One bit of functionality I got used to in Ivy was how the
counsel-find-file command would go up a directory whenever I pressed Backspace. Here’s how to replicate it in Vertico!
(defun dw/minibuffer-backward-kill (arg) "When minibuffer is completing a file name delete up to parent folder, otherwise delete a character backward" (interactive "p") (if minibuffer-completing-file-name ;; Borrowed from https://github.com/raxod502/selectrum/issues/498#issuecomment-803283608 (if (string-match-p "/." (minibuffer-contents)) (zap-up-to-char (- arg) ?/) (delete-minibuffer-contents)) (delete-backward-char arg))) ;; This is not a full config, just an example of the :bind! (use-package vertico :bind (:map minibuffer-local-map ("<backspace>" . dw/minibuffer-backward-kill)))
¶Other Consult packages
- The Consult wiki
- Consult command wishlist - has some good pointers on where to find replacement functionality