In my attempt to have * and # work in Spacemacs as they do in Vim, I've followed the solution posted at this question.

Those keys now work, but there's one hurdle more to overcome: the searched term does not populate the search history.

As an example, suppose you:

  • do /aaa
  • position yourself over another word, say "bbb" and hit *
  • hit n

Spacemacs will search for "aaa" rather than "bbb". Is there a way to fix this behaviour?

You can use evil-symbol-word-search to accomplish what you want by adding the following to you init.el after loading evil

(setq-default evil-symbol-word-search t)
  • I added that line under dotspacemacs/user-init () to no avail. Should it go somewhere else? – Jir Oct 11 at 12:12
  • I'm not familiar with spacemacs, though I would also try customizing that variable through M-x customize – Felipe Lema Oct 11 at 12:17
  • I tried that, too, but it looks as if the variable does not have any effect (though being set to t) – Jir Oct 11 at 12:21
  • What are <kbd>*</kbd> and <kbd>/</kbd> mapped to? It says in the answer that you linked that this mapping is overriden in spacemacs: github.com/syl20bnr/spacemacs/blob/… – Felipe Lema Oct 11 at 13:21
  • They are bound to evil-search-word-forward and backward: (defun dotspacemacs/user-config () (with-eval-after-load 'auto-highlight-symbol (define-key evil-motion-state-map (kbd "*") 'evil-search-word-forward) (define-key evil-motion-state-map (kbd "#") 'evil-search-word-backward))) – Jir Oct 11 at 13:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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