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