In Spacemacs, is there an easy way to make * (which calls the function
spacemacs/enter-ahs-forward) work like it does in Vim?
That is, I want * to perform forward searching like in Vim, without opening up the "Symbol Highlight Transient State".
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
Evil-visualstar is a package that provides the feature, but I am not sure of the compatibility with spacemacs.
After some searching I have figured this out.
Evil actually already has the search-forward functionality just like vim. Here is where the mapping to * is defined:
However, it appears that spacemacs overrides this mapping:
Spacemacs is using
use-package to load the
auto-highlight-symbol package, and in the
:config section it is overwriting the mapping for *.
So in order to overwrite this mapping, it is neccesary to call
auto-highlight-symbol has already been loaded. The following code can be put in your
(defun dotspacemacs/user-config () (with-eval-after-load 'auto-highlight-symbol (define-key evil-motion-state-map (kbd "*") 'evil-search-word-forward)))
The following can be used if you want to overwrite both forward search and backward search:
(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)))