Difference between revision 56 and current revision

Summary: Rollback to 2013-08-24 11:21 UTC

No diff available.


Standard Emacs command ‘occur’ lists all lines of the current buffer that match a regexp that you give it. The matching lines are listed in buffer ‘*Occur*’, and you can click them there to navigate to the corresponding lines in the original buffer. That is, buffer ‘*Occur*’ acts as a hypertext index to your buffer.

This is so useful that you might want to use a keybinding in your init file for it. For example:

 (global-set-key (kbd "C-c o") 'occur)

Starting with Emacs 24, you can use ‘C-o’ within isearch to run ‘occur’.

In Emacs 23, you can also use ‘M-s o’ within isearch to run ‘occur’.

Starting with Emacs 22, you can also use `C-x `’ (‘next-error’) or ‘M-g p’ (‘previous-error’) to navigate to the next or previous occurrence. You can also turn on ‘next-error-follow-minor-mode’ in the Occur buffer, which binds ‘C-n’ and ‘C-p’.

I bind next-error and previous-error to the keypad / and * keys, since I don’t use them otherwise. It’s handy and much easier on the fingers than chording Control+X. – TedZ?

See also: OccurKey, HideSearch.

Enhancements to Occur: Replace+

Library replace+.el