Here is a patch to Vim that adds a , register which is basically access to
Vim's
internal 'redo buffer' used when '.' is used. At a quick look, it seems to
work.
You can thus save your '.' commands to another register and replay them later:
:let @a=@,
@a
I believe @, will have pretty much the same functionality as . except that it
won't automatically change the count or the register number like . does (nor
will
this happen if you save to another register, of course).
I wonder what Bram thinks about including this functionality in standard Vim?
I
think it would be useful. What do others think?
Also, I haven't tested much. Testing and consequent feedback from others
would be
worthwhile. There may be issues with things not being escaped which should
be, etc.
My apologies; that was a poor patch. And I thought I'd tested @, but trying it
again showed it didn't work. I have now made sure it doesn't work. The .
command
is for that purpose, and implementing it isn't trivial!
Revised more robust patch attached.
Ben.
--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---
Index: runtime/doc/change.txt
===
--- runtime/doc/change.txt (revision 607)
+++ runtime/doc/change.txt (working copy)
@@ -1013,7 +1013,7 @@
2. 10 numbered registers 0 to 9
3. The small delete register -
4. 26 named registers a to z or A to Z
-5. four read-only registers :, ., % and #
+5. five read-only registers :, ., ,, % and #
6. the expression register =
7. The selection and drop registers *, + and ~
8. The black hole register _
@@ -1068,6 +1068,9 @@
doesn't work with CTRL-R on the command-line. It works a bit
differently, like inserting the text instead of putting it
('textwidth' and other options affect what is inserted).
+ *quote_,* *quote,*
+ , Contains the commands that will be executed if the . normal
+ command is used.
*quote_%* *quote%*
% Contains the name of the current file.
*quote_#* *quote#*
Index: src/proto/ops.pro
===
--- src/proto/ops.pro (revision 607)
+++ src/proto/ops.pro (working copy)
@@ -18,7 +18,7 @@
int yank_register_mline __ARGS((int regname));
int do_record __ARGS((int c));
int do_execreg __ARGS((int regname, int colon, int addcr, int silent));
-int insert_reg __ARGS((int regname, int literally));
+int insert_reg __ARGS((int regname, int literally, int insert_mode));
int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int
errmsg));
int cmdline_paste_reg __ARGS((int regname, int literally, int remcr));
void adjust_clip_reg __ARGS((int *rp));
Index: src/proto/getchar.pro
===
--- src/proto/getchar.pro (revision 607)
+++ src/proto/getchar.pro (working copy)
@@ -2,6 +2,7 @@
void free_buff __ARGS((struct buffheader *buf));
char_u *get_recorded __ARGS((void));
char_u *get_inserted __ARGS((void));
+char_u *get_old_inserted __ARGS((void));
int stuff_empty __ARGS((void));
void typeahead_noflush __ARGS((int c));
void flush_buffers __ARGS((int typeahead));
Index: src/getchar.c
===
--- src/getchar.c (revision 607)
+++ src/getchar.c (working copy)
@@ -225,6 +225,16 @@
}
/*
+ * Return the contents of the old redo buffer as a single string.
+ * K_SPECIAL and CSI in the returned string are escaped.
+ */
+char_u *
+get_old_inserted()
+{
+return(get_buffcont(old_redobuff, FALSE));
+}
+
+/*
* Add string s after the current block of buffer buf.
* K_SPECIAL and CSI should have been escaped already.
*/
Index: src/edit.c
===
--- src/edit.c (revision 607)
+++ src/edit.c (working copy)
@@ -7626,7 +7626,7 @@
do_put(regname, BACKWARD, 1L,
(literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND);
}
- else if (insert_reg(regname, literally) == FAIL)
+ else if (insert_reg(regname, literally, TRUE) == FAIL)
{
vim_beep();
need_redraw = TRUE; /* remove the '' */
Index: src/normal.c
===
--- src/normal.c(revision 607)
+++ src/normal.c(working copy)
@@ -2427,7 +2427,7 @@
if ((State INSERT) || !mouse_has(MOUSE_NORMAL))
{
if (regname == '.')
- insert_reg(regname, TRUE);
+