Tom Short <[email protected]> writes:

> In normal state, if I type r then hit <return>, I get the following:
>
> ;; This^Mbuffer is for notes you don't want to save, and for Lisp evaluation.
>
> Instead of inserting ^M, I expected a new line like the following:
>
> ;; This
> buffer is for notes you don't want to save, and for Lisp evaluation.

I noticed this as well and tried to implement the behaviour specified in

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html

(search for Replace Character)

Wolfgang

>From 0607ce03be295e5362c4e2afd78e39f81c19defd Mon Sep 17 00:00:00 2001
From: Wolfgang Jenkner <[email protected]>
Date: Thu, 22 Sep 2011 21:50:59 +0200
Subject: [PATCH] Fix some issues with POSIX and traditional behavior of the r
 operator.

In particular, r<return> inserted a literal \C-m  but it should do the
same thing as r<newline>.
---
 evil-replace.el |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/evil-replace.el b/evil-replace.el
index a8e1f1e..fa84e0b 100644
--- a/evil-replace.el
+++ b/evil-replace.el
@@ -45,19 +45,29 @@
   "Replace text from BEG to END with CHAR."
   :motion evil-forward-char
   (interactive "<R>"
-               (list (evil-save-cursor
-                       (evil-set-cursor evil-replace-state-cursor)
-                       (evil-read-key))))
-  (if (eq type 'block)
-      (save-excursion
-        (evil-apply-on-block 'evil-replace beg end nil char))
-    (goto-char beg)
-    (while (< (point) end)
-      (if (eq (char-after) ?\n)
-          (forward-char)
-        (delete-char 1)
-        (insert-char char 1)))
-    (goto-char (max beg (1- end)))))
+              (list (evil-save-cursor
+                      (evil-set-cursor evil-replace-state-cursor)
+                      (let ((char (evil-read-key)))
+                        (cond
+                         ((= char ?\r) ?\n)
+                         ((= char ?\C-v) (evil-read-key))
+                         ((/= char ?\e) char))))))
+  (when char
+    (if (eq type 'block)
+       (save-excursion
+         (evil-apply-on-block 'evil-replace beg end nil char))
+      (goto-char beg)
+      (while (< (point) end)
+       (if (eq (char-after) ?\n)
+           (forward-char)
+         (delete-char 1)
+         (if (= char ?\n)
+             (newline)
+           (insert-char char 1))))
+      (if (= char ?\n)
+         (when evil-auto-indent
+           (indent-according-to-mode))
+       (goto-char (max beg (1- end)))))))
 
 (provide 'evil-replace)
 
-- 
1.7.6.1


_______________________________________________
implementations-list mailing list
[email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list

Reply via email to