history for dot operator

216 views
Skip to first unread message

Enno

unread,
Nov 14, 2014, 6:44:45 AM11/14/14
to vim...@googlegroups.com
Is there, perhaps via a Plugin, a way to recover the second last text editing operation in normal mode ? The dot '.' operator keeps only the last operation.

Ben Fritz

unread,
Nov 14, 2014, 10:10:42 AM11/14/14
to vim...@googlegroups.com
On Friday, November 14, 2014 5:44:45 AM UTC-6, Enno wrote:
> Is there, perhaps via a Plugin, a way to recover the second last text editing operation in normal mode ? The dot '.' operator keeps only the last operation.

Nope. This would not be possible, unless every single key is remapped in every single mode, or if somehow macros were being recorded constantly. But what are you trying to accomplish, exactly? I.e. why do you want this or what problem are you encountering?

Enno

unread,
Nov 17, 2014, 12:58:30 PM11/17/14
to vim...@googlegroups.com
Hello Ben,

It's my lack of foresight. Let's say I search for "Loch Ness", have a couple of matches, and replace the first match by "Love Nest" by placing my cursor on `v` and typing `ceve<esc>ert`. Then on the next match, I cannot repeat this operation by placing my cursor on `v` and hitting `.` because this is `rt`.

It would be nice go back and forth between the last edit operations by <c-p>/<c-n> say right after hitting `.` to compensate for this lack of foresight. But perhaps there is a better way from the outset to handle this.

Enno

Ben Fritz

unread,
Nov 17, 2014, 2:05:50 PM11/17/14
to vim...@googlegroups.com
I think, as soon as I realize "whoops, I needed to repeat more than one thing!" I'd record a macro. The effort needs to be repeated one extra time but after that you can just run the macro.

http://vim.wikia.com/wiki/Macros

Efraim Yawitz

unread,
Nov 18, 2014, 7:20:56 AM11/18/14
to vim_use


On Fri, Nov 14, 2014 at 5:10 PM, Ben Fritz <fritzo...@gmail.com> wrote:
On Friday, November 14, 2014 5:44:45 AM UTC-6, Enno wrote:
> Is there, perhaps via a Plugin, a way to recover the second last text editing operation in normal mode ? The dot '.' operator keeps only the last operation.

Nope. This would not be possible, unless every single key is remapped in every single mode, or if somehow macros were being recorded constantly.

Actually, maybe he should just record continuously, say type qz and work for a while and then type q and spit out the z reg to somewhere and take what he likes from it.  Doesn't sound like it would take a lot of resources.

kls....@gmail.com

unread,
Nov 18, 2014, 8:31:46 AM11/18/14
to vim...@googlegroups.com
or maybe a plugin that stores an array of 5-10 "last used" operations and updates this FILO list each time one exists insert mode. One could access these edit operations with, say, `N<leader>.` where `N` is the index of the operation.

Bram Moolenaar

unread,
Nov 19, 2014, 7:22:06 AM11/19/14
to kls....@gmail.com, vim...@googlegroups.com
Plugins having to install a lot of maps to be able to know what was
typed before the key that triggers an action is clumsy.

How about Vim keeping a list of the last N typed keys?
Suppose there is a function keyhistory(1), where the argument is how far
back you look.

I wonder how that would be used in a plugin.

--
ARTHUR: No, hang on! Just answer the five questions ...
GALAHAD: Three questions ...
ARTHUR: Three questions ... And we shall watch ... and pray.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Enno

unread,
Nov 19, 2014, 3:18:41 PM11/19/14
to vim...@googlegroups.com, kls....@gmail.com
For the implementation of the dot operator VIM keeps track where an editing operation starts and ends in the stream of characters the user types.

This information together with keyhistory(N) allows to build a plugin that keeps a history of the last editing operations.

kls....@gmail.com

unread,
Nov 21, 2014, 4:23:13 AM11/21/14
to vim...@googlegroups.com, kls....@gmail.com
wasn't implying that it has to install a lot of maps, just one map is enough the N is just used as an index, much like the way "1z=" takes the first suggestion to fix a spelling error.

Or maybe i don't understand what you're meaning by what you said

Enno

unread,
Nov 21, 2014, 11:01:00 AM11/21/14
to vim...@googlegroups.com, kls....@gmail.com
Supposedly the installation of maps refers to a lot of keys having to be remapped to keep track of the edit operation history and not to the keys that eventually access this history.
Reply all
Reply to author
Forward
0 new messages