3 **Loccur** is an amazing tool to quickly navigate in a file. It is a minor mode for Emacs acting like **occur** but w/o creating a new window. It just hides all the text excepting lines containing matches.
5 Add to your `.emacs` or `.emacs.d/init.el` following lines:
8 (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
9 ("melpa" . "http://melpa.milkbox.net/packages/")))
12 Press `M-x` in GNU Emacs and write `list-packages`. Find the `loccur` in the list of packages and press `i` to select this package, `x` to install the package.
16 Better to see it once:
18 ![loccur_gui](https://github.com/fourier/loccur/raw/screenshots/gui_emacs_with_loccur.gif "GUI Emacs with loccur")
19 ![loccur_term](https://github.com/fourier/loccur/raw/screenshots/emacs_with_loccur.gif "Emacs in terminal with loccur")
24 To use it, add the following to your .emacs file:
28 ;; defines shortcut for loccur of the current word
29 (define-key global-map [(control o)] 'loccur-current)
30 ;; defines shortcut for the interactive loccur command
31 (define-key global-map [(control meta o)] 'loccur)
32 ;; defines shortcut for the loccur of the previously found word
33 (define-key global-map [(control shift o)] 'loccur-previous-match)
36 Now you can point the cursor to the word and press `Ctrl+o` to hide all lines except those containing this word. Moving cursor to the required line and pressing `Ctrl+o` again will shows all the text. The good thing about this mode is what you can navigate through the buffer easily. `Ctrl+Shift+o` will repeat last search.
38 ### Available commands
39 Below is the list of interactive commands available for user:
41 * `loccur` interactively asks user for regexp to search or toggle search off (if `loccur-mode` is already enabled)
42 * `loccur-current` searches for the current word under the cursor
43 * `loccur-previous-match` repeat previous `loccur` command
44 * `loccur-no-highlight` is the same as `loccur` but not highlighting matches
45 * `loccur-toggle-highlight` toggles highlighting of matches
48 * `loccur-jump-beginning-of-line` variable specifies if move the cursor to the beginning of the matching line. Default `nil`
49 * `loccur-highlight-matching-regexp` variable whenever `loccur` should highlight matching words. Default `t`.
50 * `loccur-face` face to be used while highlighting. Default points to `isearch` face.