Wikia

Vim Tips Wiki

Script:3998

Talk0
1,613pages on
this wiki

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 repeatingEdit

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)
repeat.vim seems to be supported by paredit.vim now, and most issues I've had are fixed by it, however commands such as ct. still seem to be broken up into a separate delete and insert, so the dot command does not work. I don't know enough about vimscript to hazard an attempt at a pull-request - can anyone help? @rsslldnphy, 6 October, 2014

CommentsEdit

Around Wikia's network

Random Wiki