In Vim, is there any way to repeat the last command regardless of whether it was an edit or not, and without having the foresight to first record a macro?
E.g. say I type :bn
, and want to do it again (it was the wrong file). Pressing .
obviously doesn't do it. Or maybe I'm doing gE
and want to repeat that (with one keystroke since clearly gE
is kinda painful to type).
Perhaps there are some plugins? Similar to this question.
(Even cooler would be to retroactively bind a number of commands to a macro, so one could type 5qa@a
or something to repeat the last 5 commands...)
To repeat a command-line command, try @:
, To repeat a normal/insert-mode command, try .
,
Add below mapping to your .vimrc if you want to shortcut the same:-
:noremap <C-P> @:<CR>
- This will map Ctrl+P to previous command-line command. You can map any other combo.