Column Text Objects for Evil
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.org
evil-textobj-column.el

README.org

http://melpa.org/packages/evil-textobj-column-badge.svg

About

This package is a port of textobj-word-column.vim. By default, it provides text objects for columns of a width determined by an evil word or WORD. The user can also define their own column text objects. This package is also comparable to vim-vertical-move and may be a convenient way to start a visual block selection.

Currently, there is no outer text object. In many cases, the inner and outer text objects in the vim plugin behaved the same, and I never found myself using the outer text object. If someone wants one, I can try to add one. Another difference from the original plugin is that a word column will never be composed of only whitespace.

This package takes a fairly generic approach for determining what a column is. If you find a situation where you think the selection should be different or there is clearly a bug, please make an issue.

Configuration

No keys are bound by default. Here is some suggested configuration:

(define-key evil-inner-text-objects-map "c" 'evil-textobj-column-word)
(define-key evil-inner-text-objects-map "C" 'evil-textobj-column-WORD)

If you are using a comment text object (for example the one from evil-cleverparens), you may want to use something like k instead.

New Text Objects

This plugin can potentially be used to create other text objects that have a width of something other than a word.

For example, this is how evil-textobj-column-word is defined:

(evil-define-text-object evil-textobj-column-word
  (count &optional beg end type)
  (evil-textobj-column-create-range #'evil-forward-word-begin 
                                    #'evil-backward-word-begin
                                    #'evil-forward-word-end))

This functionality is probably most useful for variants of an evil word (e.g. maybe a camel case word). Using different motions may introduce new edge cases, so please make an issue if you encounter any problems.

Basic Column Explanation

The left column boundary by default is the start of a word. If the point is already at the correct position, calling the backward-begin motion followed by the forward-begin motion should keep the point at the same column position. Otherwise, calling the backward-begin motion should move the point to the left boundary.

The upper and lower column boundaries are determined by moving up or down until the new word (by default) start no longer matches the initial column (or the end or start of the buffer is reached).

The right column boundary is determined by the maximum column reachable by the forward-end motion.