Vim "show my last command" command?
Is there a command which shows what was the last command in normal mode?
Suppose I accidently hit random key and got some unexpected result. Sure I can undo it, but could I reveal what key was pressed and how it was interpreted?
Hit the colon (:
) and then use the up arrow to start going back through previous commands. You can use the up/down arrows too to move around the list.
q:
will show you command history in Vim.q/
will show you history of searches.
And must importantly, :q
will quite the mode.
The text from the last command is stored in the .
register. You can see all registers by :display. Unfortunately it doesn't say what the started the normal command.
To see commands from :
(command mode) you can use :hist or q: which is limited to the last 20 (by default).
Another ability is to save the undo buffer :wundo undo.bin -- but the undo buffer is binary.
But none of these actually answer your question. I'm curious if it can be done.
Entering colon :
then ctrl+p
shows your previous command, i.e., moving backward through your vim command history. ctrl+n
moves forward.
This is very convenient if you're used to using the command line and prefer not to change your keyboard hand positioning to use arrow keys.