11

I installed Counsel/Ivy/Swiper and so far everything works fine. But when I call counsel-M-x via key bind M-x an "^" char is always added. I have no clue why this is happening and how to get rid of it (it does not interfere with the counsel-M-x command, it is just annoying). I'm using emacs on OS X and remapped the Meta key to the Command key (setq mac-command-modifier 'meta), but even with Alt as standard Meta key "^" is automatically inserted when calling counsel-M-x.

Counsel-M-x

I use the basic settings provided here

(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(global-set-key (kbd "M-x") 'counsel-M-x)
14

ivy-initial-inputs-alist is a variable that controls the default minibuffer contents when using ivy (which is used by counsel).

The default "^" string means that if you type something immediately after this string only completion candidates that begin with what you typed are shown.

You can remove this default string in counsel-M-x command with:

(setcdr (assoc 'counsel-M-x ivy-initial-inputs-alist) "")

Or to remove this initial input in all commands:

(setq ivy-initial-inputs-alist nil)
  • Just to be clear: if you do remove this, it will change the search behavior to match substrings. I think the default of matching only the beginning is useful, and you can just hit space if you do want to search for a ^ substring. – glucas Feb 15 '18 at 13:09
  • 1
    @glucas I think your wording is a bit exaggerated - the search behaviour doesn't change (search behaviour is controlled by ivy--regex-function), it's the default initial input that changes. Everyone is free to their preferences there. I, for example, only keep the initial ^ for man/woman. – Basil Feb 15 '18 at 15:16
  • 1
    @Basil Fair point, thanks. I mostly wanted to make clear that this is not just a cosmetic change as the OP implies in the question. – glucas Feb 15 '18 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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