In vi/vim, when you execute commands or searches they get added to a list of previous commands. And, just like in shell, they can be retrieved via the up or down arrow keys. These are very inconvenient, is there any other way to traverse the history without using the arrows keys?
In vi you hit esc once and then k or n will move you backward or forward through the commands. For emacs and gmacs, use control-p or control-n each time. To view more of your history, type "history", and a list of your most recent commands will be displayed along with numbers.
The vim editor is derived from vi. It also utilizes the same hjkl keys to replace the functionality of arrow keys. Among vim users, hjkl keys are preferred and advantageous to use. You never have to leave the first row, allowing you to be speedier while working in vim editor.
vi does not support arrow keys in insert mode. Use vim. Although your vi may just be a link to vim, it may be configured to behave like the "original" vi and thus disables the arrow keys. Just invoke vim directly.
Press Ctrl+F in command mode to open the command history window. Then, you can use / , ? , and other search commands. Press Enter to execute a command from the history.
Yes. In normal mode q:
opens a vim window with the command history. You can work in it like any other vim buffer. Enter executes a command. q/
and q?
do the same for searches.
Also, while you are typing a command, you can press Ctrl-F to open the command-line window and continue editing the command there.
You can use ctrl-n
and ctrl-p
in the command line to traverse the history and to move between wild card matches. See :help c_CTRL-N
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With