linktohack / evil-commentary

Comment stuff out. A port of vim-commentary
Other
132 stars 4 forks source link

Comment and move down #7

Closed felixSchl closed 9 years ago

felixSchl commented 9 years ago

It would be great to have the ability to quickly comment a line and move to the next line. I thought it would be easy enough but I found that combining operators in evil is not so trivial.

Do you have any thoughts on this?

This is what I have got so far, but it does not work:

  (defun comment-and-move ()
    (interactive)
    (evil-commentary-line) ;; this command needs input - but what?
    (evil-next-line 1))
  (evil-global-set-key 'normal "`" 'comment-and-move)
linktohack commented 9 years ago

What about something like this?

(defun comment-and-move ()
  (interactive)
  (call-interactively 'evil-commentary-line)
  (evil-next-line 1))
linktohack commented 9 years ago

The idea of evil-commentary-line is that it allows us to comment multiple lines at one, so an interactive form maybe better:

(defun comment-and-move (count)
  (interactive "p")
  (let ((current-prefix-arg count))
    (call-interactively 'evil-commentary-line))
  (evil-next-line count))

That way you can still continue doing something like C-u 3 M-x comment-and-move

felixSchl commented 9 years ago

This works! Thank you so much for taking the time to help me out, I would have never guessed that.