Skip to content

Commit e2c8d83

Browse files
committed
patch 8.0.1787: cannot insert the whole cursor line
Problem: Cannot insert the whole cursor line. Solution: Make CTRL-R CTRL-L work. (Andy Massimino, closes #2857)
1 parent b2ac14c commit e2c8d83

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

runtime/doc/cmdline.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,14 @@ CTRL-R CTRL-F *c_CTRL-R_CTRL-F* *c_<C-R>_<C-F>*
175175
CTRL-R CTRL-P *c_CTRL-R_CTRL-P* *c_<C-R>_<C-P>*
176176
CTRL-R CTRL-W *c_CTRL-R_CTRL-W* *c_<C-R>_<C-W>*
177177
CTRL-R CTRL-A *c_CTRL-R_CTRL-A* *c_<C-R>_<C-A>*
178+
CTRL-R CTRL-L *c_CTRL-R_CTRL-L* *c_<C-R>_<C-L>*
178179
Insert the object under the cursor:
179180
CTRL-F the Filename under the cursor
180181
CTRL-P the Filename under the cursor, expanded with
181182
'path' as in |gf|
182183
CTRL-W the Word under the cursor
183184
CTRL-A the WORD under the cursor; see |WORD|
185+
CTRL-L the line under the cursor
184186

185187
When 'incsearch' is set the cursor position at the end of the
186188
currently displayed match is used. With CTRL-W the part of
@@ -192,8 +194,8 @@ CTRL-R CTRL-A *c_CTRL-R_CTRL-A* *c_<C-R>_<C-A>*
192194

193195
*c_CTRL-R_CTRL-R* *c_<C-R>_<C-R>*
194196
*c_CTRL-R_CTRL-O* *c_<C-R>_<C-O>*
195-
CTRL-R CTRL-R {0-9a-z"%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A}
196-
CTRL-R CTRL-O {0-9a-z"%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A}
197+
CTRL-R CTRL-R {0-9a-z"%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}
198+
CTRL-R CTRL-O {0-9a-z"%#:-=. CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}
197199
Insert register or object under the cursor. Works like
198200
|c_CTRL-R| but inserts the text literally. For example, if
199201
register a contains "xy^Hz" (where ^H is a backspace),

src/ex_getln.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3299,7 +3299,8 @@ cmdline_paste(
32993299
/* check for valid regname; also accept special characters for CTRL-R in
33003300
* the command line */
33013301
if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W
3302-
&& regname != Ctrl_A && !valid_yank_reg(regname, FALSE))
3302+
&& regname != Ctrl_A && regname != Ctrl_L
3303+
&& !valid_yank_reg(regname, FALSE))
33033304
return FAIL;
33043305

33053306
/* A register containing CTRL-R can cause an endless loop. Allow using

src/ops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,14 @@ get_spec_reg(
15731573
*allocated = TRUE;
15741574
return TRUE;
15751575

1576+
case Ctrl_L: /* Line under cursor */
1577+
if (!errmsg)
1578+
return FALSE;
1579+
1580+
*argp = ml_get_buf(curwin->w_buffer,
1581+
curwin->w_cursor.lnum, FALSE);
1582+
return TRUE;
1583+
15761584
case '_': /* black hole: always empty */
15771585
*argp = (char_u *)"";
15781586
return TRUE;

src/testdir/test_cmdline.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ func Test_paste_in_cmdline()
306306
call feedkeys("ft:aaa \<C-R>\<C-F> bbb\<C-B>\"\<CR>", 'tx')
307307
call assert_equal('"aaa /tmp/some bbb', @:)
308308

309+
call feedkeys(":aaa \<C-R>\<C-L> bbb\<C-B>\"\<CR>", 'tx')
310+
call assert_equal('"aaa '.getline(1).' bbb', @:)
311+
309312
set incsearch
310313
call feedkeys("fy:aaa veryl\<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx')
311314
call assert_equal('"aaa verylongword bbb', @:)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1787,
764766
/**/
765767
1786,
766768
/**/

0 commit comments

Comments
 (0)