hide-lines icon indicating copy to clipboard operation
hide-lines copied to clipboard

Commands for hiding lines based on a regexp

  • Library Information Readme.org --- Commands for hiding lines based on a regexp
  • Filename :: [[file:hide-lines.el][hide-lines.el]]
  • Description :: Commands for hiding lines based on a regexp
  • Author :: Mark Hulme-Jones
  • Maintainer :: Joe Bloggs [email protected]
  • Version :: 20130623.1701
  • Last-Updated :: 2013-06-22 22:38:04
  •       By :: Joe Bloggs
    
  • URL :: https://github.com/vapniks/hide-lines
  • Keywords :: convenience
  • Compatibility :: GNU Emacs 24.3.1
  • Commentary

The simplest way to make hide-lines work is to add the following lines to your .emacs file:

=(autoload 'hide-lines "hide-lines" "Hide lines based on a regexp" t) (global-set-key "\C-ch" 'hide-lines)=

Now, when you type C-c h, you will be prompted for a regexp (regular expression). All lines matching this regexp will be hidden in the buffer.

Alternatively, you can type C-u C-c h (ie. provide a prefix argument to the hide-lines command) to hide all lines that do not match the specified regexp.

If you want to make all of the hidden areas re-appear again, type: M-x hide-lines-show-all Or you can bind show-all-invisible to a key and use that to show all the hidden areas again.

If you prefer the opposite behaviour either use =hide-lines-not-matching= or set =hide-lines-reverse-prefix= to t.

=hide-lines= is useful in the Messages buffer or Packages buffer (M-x list-packages). In the Packages buffer the following regular expression can be used to limit the display to all packages marked for installation/uninstallation

  • Installation Put hide-lines.el in a directory in your load-path, e.g. ~/.emacs.d/ You can add a directory to your load-path with the following line in ~/.emacs (add-to-list 'load-path (expand-file-name "~/elisp")) where ~/elisp is the directory you want to add (you don't need to do this for ~/.emacs.d - it's added by default).

Add the following to your ~/.emacs startup file.

(require 'hide-lines)

  • Commands & keybindings

Below is a complete list of commands:

  • hide-lines : Hide lines matching the specified regexp.\ Keybinding: =M-x hide-lines=
  • hide-lines-not-matching : Hide lines that don't match the specified regexp.\ Keybinding: =M-x hide-lines-not-matching=
  • hide-lines-matching : Hide lines matching the specified regexp.\ Keybinding: =M-x hide-lines-matching=
  • hide-lines-show-all : Show all areas hidden by the filter-buffer command.\ Keybinding: =M-x hide-lines-show-all=
  • hide-blocks-not-matching Hide text that is not between lines matching START-TEXT and END-TEXT. Keybinding: =M-x hide-blocks-not-matching=
  • hide-blocks-matching Hide text that is between lines matching START-TEXT and END-TEXT. Keybinding: =M-x hide-blocks-matching=
  • hide-lines-kill-hidden Kill or delete all hidden areas. Keybinding =M-x hide-lines-kill-hidden=
  • Customizable Options

Below is a list of customizable options:

  • hide-lines-reverse-prefix : If non-nil then - hide-lines : will call - hide-lines-matching : by default, and - hide-lines-not-matching : with a single prefix.\ default value: =nil=