Hi Bram,
another patch fixing an issue from the todo list:
,----
| - Make it possible to enter "r<C-E>" and "r<C-Y>" (get character
| from line below/above).
`----
regards,
Christian
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/edit.c b/src/edit.c
--- a/src/edit.c
+++ b/src/edit.c
@@ -248,7 +248,7 @@
#ifdef FEAT_DIGRAPHS
static int ins_digraph __ARGS((void));
#endif
-static int ins_copychar __ARGS((linenr_T lnum));
+int ins_copychar __ARGS((linenr_T lnum));
static int ins_ctrl_ey __ARGS((int tc));
#ifdef FEAT_SMARTINDENT
static void ins_try_si __ARGS((int c));
@@ -9761,7 +9761,7 @@
* Handle CTRL-E and CTRL-Y in Insert mode: copy char from other line.
* Returns the char to be inserted, or NUL if none found.
*/
- static int
+ int
ins_copychar(lnum)
linenr_T lnum;
{
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -7050,7 +7050,16 @@
for (n = cap->count1; n > 0; --n)
{
State = REPLACE;
- ins_char(cap->nchar);
+ if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)
+ {
+ int c = ins_copychar(curwin->w_cursor.lnum + (cap->nchar == Ctrl_Y ? -1 : 1));
+ if (c != NUL)
+ ins_char(c);
+ else
+ ++curwin->w_cursor.col; /* will be decremented later down */
+ }
+ else
+ ins_char(cap->nchar);
State = old_State;
if (cap->ncharC1 != 0)
ins_char(cap->ncharC1);
@@ -7072,7 +7081,16 @@
* line will be changed.
*/
ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);
- ptr[curwin->w_cursor.col] = cap->nchar;
+ if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)
+ {
+ int c;
+ c = ins_copychar(curwin->w_cursor.lnum + (cap->nchar == Ctrl_Y ? -1 : 1));
+ /* only insert a char, if there was one 1 line above/below */
+ if (c != NUL)
+ ptr[curwin->w_cursor.col] = c;
+ }
+ else
+ ptr[curwin->w_cursor.col] = cap->nchar;
if (p_sm && msg_silent == 0)
showmatch(cap->nchar);
++curwin->w_cursor.col;
diff --git a/src/proto/edit.pro b/src/proto/edit.pro
--- a/src/proto/edit.pro
+++ b/src/proto/edit.pro
@@ -39,4 +39,5 @@
int hkmap __ARGS((int c));
void ins_scroll __ARGS((void));
void ins_horscroll __ARGS((void));
+int ins_copychar __ARGS((linenr_T lnum));
/* vim: set ft=c : */