Skip to content

Range types

A `type' is a transformation acting on a pair of buffer positions. Evil defines the types inclusive, line, block and exclusive, which are used for motion ranges and visual selection. New types may be defined with the macro `evil-define-type'.

Emacs Lisp Autofunction: (evil-define-type TYPE DOC [[KEY FUNC]...])

Define type `TYPE'. `DOC' is a general description and shows up in all docstrings.

Optional keyword arguments:

  • :expand - expansion function. This function should accept two positions in the current buffer, BEG and END,and return a pair of expanded buffer positions.
  • :contract - the opposite of :expand. Optional.
  • :one-to-one - non-nil if expansion is one-to-one. This means that :expand followed by :contract always return the original range.
  • :normalize - normalization function. This function should accept two unexpanded positions and adjust them before expansion. May be used to deal with buffer boundaries.
  • :string - description function. Takes two buffer positions and returns a human-readable string. For example “2 lines”

If further keywords and functions are specified, they are assumed to be transformations on buffer positions, like :expand and :contract.