How to get swiper to search for the last searched term , much like (default)
isearch-forward does when pressing
When you invoke swiper press
M-p to search for previously searched thing.
M-n will let you search for the word under cursor.
C-s will search for the next occurence.
UPD, thx @Basil
After you invoke the
C-s to search for a previously searched string. Press
C-s again to go to the next occurrence.
For what is worth, here is my swiper config right now.
- I can search the rightmost expression(s) by pressing repeatedly
- I can search the "last term" by pressing
C-f C-s(thanks @maxim-kim) and ;
- I can access both recent files and opened buffers by pressing f4 :)
- And I still have C-s bound to
isearchfor macros and such.
(use-package ivy-hydra :ensure t) (use-package swiper :ensure try :bind (([f4] . ivy-switch-buffer) ([(control c) (f)] . counsel-ag) ([(control c) (g)] . counsel-git) ([(control c) (j)] . counsel-git-grep) ([(control c) (l)] . counsel-locate) ([(control d)] . swiper-ag) ([(control f)] . swiper) ([(control h) (control f)] . counsel-describe-function) ([(control h) (control v)] . counsel-describe-variable) ([(control o)] . counsel-find-file) ([(control shift o)] . counsel-recentf) ([f9] . counsel-rhythmbox) :map ivy-minibuffer-map ([(control f)] . ivy-yank-word) :map read-expression-map ([(control r)] . counsel-expression-history)) :config (progn (define-key ivy-switch-buffer-map [(control w)] (lambda () (interactive) (ivy-set-action 'kill-buffer) (ivy-done)))) :init (setq ivy-use-virtual-buffers t ivy-ignore-buffers '("\\` " "\\`\\*") ivy-display-style 'fancy ivy-count-format "(%d/%d) " ivy-initial-inputs-alist nil ivy-extra-directories nil)) (use-package try :ensure t)