How to run the last n commands in Vim

I got my answer from here: Using command line history in vim

Here is a summary to execute your command of choice from command history:

  • q: (opens the command history window)
  • use vim browsing keys to go to the command you want to execute. Alternately :n where n is line number of the command to execute, will place you on the line.
  • CR -> (Carriage return) Press enter to execute the command.

If you want to run the last n commands for example:

  • q:
  • yank the number of commands you want to run
  • Press ctrlc twice
  • :@"

How to increase the history limit:

put this line in your vim.rc file: set history 100 (100 will be the history limit)

If this history limit is not taking effect, please read here: How to increase cmdline history size

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s