Skip to content

Commit ffd73c5

Browse files
committed
Improve "cnoremap <c-n>" mapping
Closes mhinz#148
1 parent 5021813 commit ffd73c5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2020,13 +2020,16 @@ So far, so good. But `<up>` and `<down>` are even smarter! They recall the
20202020
command-line whose beginning matches the current command-line. E.g. `:echo <up>`
20212021
may change to `:echo "Vim rocks!"`.
20222022

2023-
Of course, I don't want you to reach to the arrow keys, just map it instead:
2023+
Of course, I don't want you to reach for the arrow keys:
20242024

20252025
```vim
2026-
cnoremap <c-n> <down>
2027-
cnoremap <c-p> <up>
2026+
cnoremap <expr> <c-n> wildmenumode() ? "\<c-n>" : "\<down>"
2027+
cnoremap <expr> <c-p> wildmenumode() ? "\<c-p>" : "\<up>"
20282028
```
20292029

2030+
Here we also distinguish between command-line history and the wildmenu. See `:h
2031+
'wildmenu'`.
2032+
20302033
I depend on this behaviour several times a day.
20312034

20322035
## Saner CTRL-L

0 commit comments

Comments
 (0)