Vim: command-line grep-like search with Ctrl-P and Ctrl-N
Basically, I don't want to use my arrow keys completely.
But for that to happen the Ctrl-P needs to have the same functionality in the command-line as my Up arrow key.
For Example, I type
:so
then I press Up, it turns like so
:source $MYVIMRC
but when I press Ctrl-P, it o开发者_如何学Pythonnly goes to the last executed command
:h camelcasemotion
Can anyone help me with this? It would be much appreciated.
In command mode, <Up> does “move to the previous command in the history that matches the string entered so far”.
In command mode, CTRL-P has two functions.
- After a Tab completion that has multiple possibilities, it does “show the previous matching value”.
Think of it as backward Tab. Most terminals do not distinguish Tab from Shift-Tab, but it and CTRL-P are the same mapping in GUI versions of Vim. - Without a preceding Tab completion, it does “move to the previous command in the history” (without trying to match the text entered so far).
You can remap CTRL-P to be the same as <Up> if you really want to:
:cmap <C-P> <Up>
You might also want to remap CTRL-N, too:
:cmap <C-N> <Down>
精彩评论