¶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
swiper
->consult-line
counsel-rg
->consult-ripgrep
counsel-switch-buffer
->consult-buffer
. Annotations are better forswitch-to-buffer
?counsel-org-goto
->consult-imenu
orconsult-org-heading
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 locationsconsult-outline
: Show a list of headings in the current file depending on typeconsult-minor-mode-menu
: Show a list of all minor modes, pressi SPC
to narrow to active modesconsult-history
: History for current minibuffer, also works for terminal modesconsult-file-externally
: Open a file in an external programconsult-preview-mode
: Preview selections for various commandsconsult-completion-in-region
: Can be used with thecompletion-in-region-function
variable to do in-buffer completions using Vertico
¶Going up a directory in find-file
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
¶Other resources
- The Consult wiki
- Consult command wishlist - has some good pointers on where to find replacement functionality