VIM: How do you get the last ex command you used?

Solution 1:

The : register contains the last :-command (ex command) you ran, so you can simply type the command ":p (with the double quote) to paste that register into the current buffer. See:

:help registers
:help ":

Note that there are registers for the last search, the current buffer's name, etc.

Solution 2:

Try the q: command. (That's two characters, first q and then :.) This is a normal mode command that will open up your ex-command history in a special Vim buffer. You can review the history, yank anything you want just as always, and/or edit a line and press <enter> on it to execute it.