View your history from command mode


When you enter command mode in Vim with : you can type commands such as s for substitution, e to open a file, or any of hundreds of commands from native Vim or plugins. From file opening to text manipulation, and more, Vim command mode is where power users get stuff done.

As you come to rely on commands more, you may find yourself constructing complex commands, then later wanting to rerun them. There is a simple way to see your history of commands from within command mode: ctrl-f. Immediately you’re plopped into a history of all the commands you’ve run in Vim. Use jk to move down and up the list and press Enter to execute a command again. Or to hop back out of the list, press ctrl-c. You could then press Esc or ctrl-c again to exit command mode entirely. Here’s a short screencast:

Here’s what’s happening in the screencast:

  • : to enter command mode
  • ctrl-f to open the command history
  • k to arrow up and select a previous command
  • Enter to run the command
  • : to enter command mode again
  • ctrl-f to open the command history
  • ctrl-c to close the command history
  • Esc to exit command mode

How useful was this tip?

Average rating 2.9 / 5. Vote count: 1081

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts