(Created page with "==Request: make text insert atomic for undo/redo and repeating== When I use paredit (in Clojure), my insertions of text seem to be broken up into multiple commands, as eviden...") |
(Document mechanism for making undo/redo/repeat work intuitively.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{ScriptComments|paredit mode: structured editing of Lisp S-expressions}} |
||
⚫ | |||
⚫ | |||
When I use paredit (in Clojure), my insertions of text seem to be broken up into multiple commands, as evidenced by the behavior of undo/redo and repeating (i.e. the <code>.</code> command). |
When I use paredit (in Clojure), my insertions of text seem to be broken up into multiple commands, as evidenced by the behavior of undo/redo and repeating (i.e. the <code>.</code> command). |
||
Line 7: | Line 8: | ||
<code>(def foo (+ 1 2))</code> |
<code>(def foo (+ 1 2))</code> |
||
− | ...then escape back to normal mode. If I then hit <code>.</code>, I would expect the same text to be inserted again, but instead, only <code>+ 1 2</code> is inserted. In a similar vein, I have to hit |
+ | ...then escape back to normal mode. If I then hit <code>.</code>, I would expect the same text to be inserted again, but instead, only <code>+ 1 2</code> is inserted. In a similar vein, I have to hit <code>u</code> (undo) 3 times to fully undo my insert. |
So, my request is, can you make text insertion atomic with respect to these commands? |
So, my request is, can you make text insertion atomic with respect to these commands? |
||
+ | |||
+ | '''Update 2014-08-05''' |
||
+ | |||
+ | I've identified a way to do this. The <code><C-R>=</code> command, which inserts an expression while remaining in insert mode. For example, from normal mode, typing this: |
||
+ | |||
+ | <code>ihe^R=repeat('l', 2)^Mo^[</code> |
||
+ | |||
+ | ...inserts the string <code>hello</code>. Then, <code>u</code> undoes the entire insertion, <code><C-R></code> redoes it, and <code>.</code> repeats the whole thing. (Credit to {{script|id=1849|text=Karl Guertin's AutoClose plugin}} for the technique.) |
||
+ | |||
+ | So I think redesigning the paredit.vim plugin around this mechanism should make this work in a way that's fully compatible with what users expect from undo/redo and repeat. |
||
+ | --[[User:Kyptin|Kyptin]] ([[User talk:Kyptin|talk]]) 16:40, February 17, 2014 (UTC) |
||
+ | |||
+ | :There is a plugin at {{script|id=2136|text=repeat.vim}} which the author of this script might find useful for that, although it requires remapping "<code>.</code>". [[User:JohnBeckett|JohnBeckett]] ([[User talk:JohnBeckett|talk]]) 05:16, February 26, 2014 (UTC) |
||
+ | |||
+ | ==Comments== |
Revision as of 19:06, 5 August 2014
Use this page to discuss script 3998 paredit mode: structured editing of Lisp S-expressions
- Add constructive comments, bug reports, or discuss improvements (see the guideline).
- Do not document the script here (the author should do that on vim.org).
- This page may be out of date: check the script's vim.org page above, and its release notes.
Request: make text insert atomic for undo/redo and repeating
When I use paredit (in Clojure), my insertions of text seem to be broken up into multiple commands, as evidenced by the behavior of undo/redo and repeating (i.e. the .
command).
For example, I enter insert mode and insert the following text:
(def foo (+ 1 2))
...then escape back to normal mode. If I then hit .
, I would expect the same text to be inserted again, but instead, only + 1 2
is inserted. In a similar vein, I have to hit u
(undo) 3 times to fully undo my insert.
So, my request is, can you make text insertion atomic with respect to these commands?
Update 2014-08-05
I've identified a way to do this. The <C-R>=
command, which inserts an expression while remaining in insert mode. For example, from normal mode, typing this:
ihe^R=repeat('l', 2)^Mo^[
...inserts the string hello
. Then, u
undoes the entire insertion, <C-R>
redoes it, and .
repeats the whole thing. (Credit to Karl Guertin's AutoClose plugin for the technique.)
So I think redesigning the paredit.vim plugin around this mechanism should make this work in a way that's fully compatible with what users expect from undo/redo and repeat. --Kyptin (talk) 16:40, February 17, 2014 (UTC)
- There is a plugin at repeat.vim which the author of this script might find useful for that, although it requires remapping "
.
". JohnBeckett (talk) 05:16, February 26, 2014 (UTC)