branch: elpa/evil-nerd-commenter
commit 3eadae264f613c6f02a797aea2ef48078ca45045
Author: Dickby <[email protected]>
Commit: Felix Dick <[email protected]>
new evil-mode operator "evil-copy-and-comment-operator"
---
README.org | 2 ++
evil-nerd-commenter-operator.el | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/README.org b/README.org
index 6fbfa884d8..b6ae13e100 100644
--- a/README.org
+++ b/README.org
@@ -197,6 +197,8 @@ Example 6: ",,w" comment to the beginning of the next word,
",,e" to the end of
Example 7: ",,it", comment the region inside html tags (all html major modes
are supported , *including [[http://web-mode.org/][web-mode]]*)
+"evilnc-copy-and-comment-operator" is another evil-mode operator. Instead of
commenting out the text in the operator-range, it inserts an copy of the text
in the range and comments out that copy.
+
* Tips
** Tip 1, Yank in evil-mode
You can yank to line 99 using hotkey "y99G" or "y99gg". That's the feature
from evil-mode.
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 8052995f6f..d12a24c0f4 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -29,7 +29,7 @@
;;; Commentary:
;;
-;; Provides an operator for evil-mode.
+;; Provides operators for evil-mode.
;;; Code:
@@ -65,5 +65,16 @@
(eq type 'line))
(evil-first-non-blank)))
+(evil-define-operator evilnc-copy-and-comment-operator (beg end)
+ "Inserts an out commented copy of the text from BEG to END."
+ :move-point nil
+ (interactive "<r>")
+ (let ((p (point)))
+ (evil-yank-lines beg end nil 'lines)
+ (comment-region beg end)
+ (goto-char beg)
+ (evil-paste-before 1)
+ (goto-char p)))
+
(provide 'evil-nerd-commenter-operator)
;;; evil-nerd-commenter-operator.el ends here