Skip to content

Commit 1195669

Browse files
committed
patch 7.4.2268
Problem: Using CTRL-N and CTRL-P for incsearch shadows completion keys. Solution: Use CTRL-T and CTRL-G instead.
1 parent 44ca54a commit 1195669

File tree

4 files changed

+129
-119
lines changed

4 files changed

+129
-119
lines changed

runtime/doc/cmdline.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*cmdline.txt* For Vim version 7.4. Last change: 2015 Dec 17
1+
*cmdline.txt* For Vim version 7.4. Last change: 2016 Aug 27
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -409,19 +409,11 @@ CTRL-D List names that match the pattern in front of the cursor.
409409
*c_CTRL-N*
410410
CTRL-N After using 'wildchar' which got multiple matches, go to next
411411
match. Otherwise recall more recent command-line from history.
412-
*/_CTRL-N*
413-
When 'incsearch' is set, entering a search pattern for "/" or
414-
"?" and the current match is displayed then CTRL-N will move
415-
to the next match (does not take |search-offset| into account)
416412
<S-Tab> *c_CTRL-P* *c_<S-Tab>*
417413
CTRL-P After using 'wildchar' which got multiple matches, go to
418414
previous match. Otherwise recall older command-line from
419415
history. <S-Tab> only works with the GUI, on the Amiga and
420416
with MS-DOS.
421-
*/_CTRL-P*
422-
When 'incsearch' is set, entering a search pattern for "/" or
423-
"?" and the current match is displayed then CTRL-P will move
424-
to the previous match (does not take |search-offset| into account).
425417
*c_CTRL-A*
426418
CTRL-A All names that match the pattern in front of the cursor are
427419
inserted.
@@ -438,6 +430,19 @@ CTRL-L A match is done on the pattern in front of the cursor. If
438430
'ignorecase' and 'smartcase' are set and the command line has
439431
no uppercase characters, the added character is converted to
440432
lowercase.
433+
*c_CTRL-G* */_CTRL-G*
434+
CTRL-G When 'incsearch' is set, entering a search pattern for "/" or
435+
"?" and the current match is displayed then CTRL-G will move
436+
to the next match (does not take |search-offset| into account)
437+
Use CTRL-T to move to the previous match. Hint: on a regular
438+
keyboard T is above G.
439+
*c_CTRL-T* */_CTRL-T*
440+
CTRL-T When 'incsearch' is set, entering a search pattern for "/" or
441+
"?" and the current match is displayed then CTRL-T will move
442+
to the previous match (does not take |search-offset| into
443+
account).
444+
Use CTRL-G to move to the next match. Hint: on a regular
445+
keyboard T is above G.
441446

442447
The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
443448
a previous version <Esc> was used). In the pattern standard wildcards '*' and

src/ex_getln.c

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,82 +1503,14 @@ getcmdline(
15031503

15041504
case Ctrl_N: /* next match */
15051505
case Ctrl_P: /* previous match */
1506-
#ifdef FEAT_SEARCH_EXTRA
1507-
if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
1508-
{
1509-
pos_T t;
1510-
int search_flags = SEARCH_KEEP + SEARCH_NOOF
1511-
+ SEARCH_PEEK;
1512-
1513-
if (char_avail())
1514-
continue;
1515-
cursor_off();
1516-
out_flush();
1517-
if (c == Ctrl_N)
1518-
{
1519-
t = match_end;
1520-
search_flags += SEARCH_COL;
1521-
}
1522-
else
1523-
t = match_start;
1524-
++emsg_off;
1525-
i = searchit(curwin, curbuf, &t,
1526-
c == Ctrl_N ? FORWARD : BACKWARD,
1527-
ccline.cmdbuff, count, search_flags,
1528-
RE_SEARCH, 0, NULL);
1529-
--emsg_off;
1530-
if (i)
1531-
{
1532-
old_cursor = match_start;
1533-
match_end = t;
1534-
match_start = t;
1535-
if (c == Ctrl_P && firstc == '/')
1536-
{
1537-
/* move just before the current match, so that
1538-
* when nv_search finishes the cursor will be
1539-
* put back on the match */
1540-
old_cursor = t;
1541-
(void)decl(&old_cursor);
1542-
}
1543-
if (lt(t, old_cursor) && c == Ctrl_N)
1544-
{
1545-
/* wrap around */
1546-
old_cursor = t;
1547-
if (firstc == '?')
1548-
(void)incl(&old_cursor);
1549-
else
1550-
(void)decl(&old_cursor);
1551-
}
1552-
1553-
set_search_match(&match_end);
1554-
curwin->w_cursor = match_start;
1555-
changed_cline_bef_curs();
1556-
update_topline();
1557-
validate_cursor();
1558-
highlight_match = TRUE;
1559-
old_curswant = curwin->w_curswant;
1560-
old_leftcol = curwin->w_leftcol;
1561-
old_topline = curwin->w_topline;
1562-
# ifdef FEAT_DIFF
1563-
old_topfill = curwin->w_topfill;
1564-
# endif
1565-
old_botline = curwin->w_botline;
1566-
update_screen(NOT_VALID);
1567-
redrawcmdline();
1568-
}
1569-
else
1570-
vim_beep(BO_ERROR);
1571-
goto cmdline_not_changed;
1572-
}
1573-
else
1574-
#endif
15751506
if (xpc.xp_numfiles > 0)
15761507
{
15771508
if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
15781509
0, firstc != '@') == FAIL)
15791510
break;
1580-
goto cmdline_changed;
1511+
goto cmdline_not_changed;
15811512
}
1513+
/* FALLTHROUGH */
15821514

15831515
#ifdef FEAT_CMDHIST
15841516
case K_UP:
@@ -1722,6 +1654,77 @@ getcmdline(
17221654
goto cmdline_changed;
17231655
}
17241656
beep_flush();
1657+
#endif
1658+
goto cmdline_not_changed;
1659+
1660+
case Ctrl_G: /* next match */
1661+
case Ctrl_T: /* previous match */
1662+
#ifdef FEAT_SEARCH_EXTRA
1663+
if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
1664+
{
1665+
pos_T t;
1666+
int search_flags = SEARCH_KEEP + SEARCH_NOOF
1667+
+ SEARCH_PEEK;
1668+
1669+
if (char_avail())
1670+
continue;
1671+
cursor_off();
1672+
out_flush();
1673+
if (c == Ctrl_G)
1674+
{
1675+
t = match_end;
1676+
search_flags += SEARCH_COL;
1677+
}
1678+
else
1679+
t = match_start;
1680+
++emsg_off;
1681+
i = searchit(curwin, curbuf, &t,
1682+
c == Ctrl_G ? FORWARD : BACKWARD,
1683+
ccline.cmdbuff, count, search_flags,
1684+
RE_SEARCH, 0, NULL);
1685+
--emsg_off;
1686+
if (i)
1687+
{
1688+
old_cursor = match_start;
1689+
match_end = t;
1690+
match_start = t;
1691+
if (c == Ctrl_T && firstc == '/')
1692+
{
1693+
/* move just before the current match, so that
1694+
* when nv_search finishes the cursor will be
1695+
* put back on the match */
1696+
old_cursor = t;
1697+
(void)decl(&old_cursor);
1698+
}
1699+
if (lt(t, old_cursor) && c == Ctrl_G)
1700+
{
1701+
/* wrap around */
1702+
old_cursor = t;
1703+
if (firstc == '?')
1704+
(void)incl(&old_cursor);
1705+
else
1706+
(void)decl(&old_cursor);
1707+
}
1708+
1709+
set_search_match(&match_end);
1710+
curwin->w_cursor = match_start;
1711+
changed_cline_bef_curs();
1712+
update_topline();
1713+
validate_cursor();
1714+
highlight_match = TRUE;
1715+
old_curswant = curwin->w_curswant;
1716+
old_leftcol = curwin->w_leftcol;
1717+
old_topline = curwin->w_topline;
1718+
# ifdef FEAT_DIFF
1719+
old_topfill = curwin->w_topfill;
1720+
# endif
1721+
old_botline = curwin->w_botline;
1722+
update_screen(NOT_VALID);
1723+
redrawcmdline();
1724+
}
1725+
else
1726+
vim_beep(BO_ERROR);
1727+
}
17251728
goto cmdline_not_changed;
17261729
#endif
17271730

0 commit comments

Comments
 (0)