1

I like the option to do C-s C-w and then show all in a separate buffer by using M-s o, but I would really like to keybind the M-s o ('occur) such that I can type C-s C-w C-, or similar-

I have tried the normal keybind:

(global-set-key (kbd "C-,") 'occur)

But it just do the normal occur, not the search buffer occur.

lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
rasmus
  • 125
  • 2
  • 3
  • 11

1 Answers1

2

The command that is bound to M-s o during an isearch isn't the default occur command, but a special version called isearch-occur, that automatically invoke occur on isearch hits.

You can bind this to the C-o (or C-, if you prefer) shortcut without overriding other commands using the define-key command with the isearch-mode-map:

(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)

In this way you can use the sequence C-sC-wC-o.

lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
  • rasmus: Note that `C-h b` whilst isearching displays all isearch bindings. `C-h k` also works in this situation -- so `C-s C-h k M-s o` tells you about `isearch-occur`. (`C-h c` isn't bound to an isearch-variant, OTOH, which may be worth raising a bug report about). – phils Mar 08 '16 at 19:29