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.
Add to your
.emacs.d/init.el following lines:
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") ("melpa" . "http://melpa.milkbox.net/packages/")))
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.
Better to see it once:
To use it, add the following to your .emacs file:
(require 'loccur) ;; defines shortcut for loccur of the current word (define-key global-map [(control o)] 'loccur-current) ;; defines shortcut for the interactive loccur command (define-key global-map [(control meta o)] 'loccur) ;; defines shortcut for the loccur of the previously found word (define-key global-map [(control shift o)] 'loccur-previous-match)
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.
Below is the list of interactive commands available for user:
loccurinteractively asks user for regexp to search or toggle search off (if
loccur-modeis already enabled)
loccur-currentsearches for the current word under the cursor
loccur-no-highlightis the same as
loccurbut not highlighting matches
loccur-toggle-highlighttoggles highlighting of matches
loccur-jump-beginning-of-linevariable specifies if move the cursor to the beginning of the matching line. Default
loccurshould highlight matching words. Default
loccur-faceface to be used while highlighting. Default points to