Search for selected text
Frank Fischer
frank-fischer at shadow-soft.de
Tue Oct 14 16:38:21 CEST 2014
Am 14.10.2014 um 15:30 schrieb David Nebauer:
> There are a couple of handy shortcuts in vim that allow you to highlight
> text and then hit '/' or '?' to search forwards or backwards for the
> next occurrence of the selected text. The mappings are:
>
> vnoremap / y/<C-R>"<CR>
>
> vnoremap ? y?<C-R>"<CR>
>
> Is there any way to replicate this functionality in evil?
Actually it is almost possible out of the box. First, you need to use
Evil's own search module (M-x customize-variable RET evil-search-module
RET). Then add the following binding:
(define-key evil-ex-search-keymap "\C-r" 'evil-paste-from-register)
The list of useful bindings in search mode is currently quite sparse and
this one is missing but should just work. Then you can do something
quite similar to Vim:
(define-key evil-visual-state-map "/" "y/\C-r\"\C-m")
Note that Evil (and Emacs) do not support non-recursive remappings. But
in this case it's no problem because {lhs} goes to visual state and the
call `/` in {rhs} is executed in normal state.
Best regards,
Frank
More information about the implementations-list
mailing list