How easy would it be to add a comment selector?
I was thinking that it would be nice to, for example, be able to type gqac and have the current comment be formatted. I don’t know Emacs well enough to set this up, however, and was wondering if anyone had any input on this. Thanks!
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
(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)
This works for emacs lisp comments but not for C/C++ comments at all, it would nice if this can be fixed. York
participants (3)
-
Nikolai Weibull -
Vegard Øye -
York Zhao