How easy would it be to add a comment selector?

Vegard Øye vegard_oye at hotmail.com
Mon Nov 7 12:08:34 CET 2011


On 2011-11-01 14:31 +0100, Nikolai Weibull wrote:

> I was thinking that it would be nice to, for example, be able to
> type gqac and have the current comment be formatted.

As it happens, Evil defines the functions `evil-comment-beginning' and
`evil-comment-end' for finding the beginning and end of a comment
block. Thus, creating a text object for comments is straightforward:

    (evil-define-text-object evil-a-comment ()
      "Select a comment."
      (list (evil-comment-beginning) (evil-comment-end)))

    (define-key evil-outer-text-objects-map "c" 'evil-a-comment)

Please pull the latest commits before using this, because of some
recent bugfixes.

-- 
Vegard



More information about the implementations-list mailing list