Mac – Vim – Viewing Command line history


Is there a way in vim to view the output of old commands.

For example, if I do:

:! ls 

Gemfile         Gemfile.lock    Rakefile        autotest       doc             log             script          vendor
Gemfile.backup  README          app             config          db              lib             public          tmp   

How can I recall this output once I have closed it?

Best Answer

  • Once you have closed that output it is lost. If you want semi-permanent access to that kind of data you should probably use :redir. See:

    :help :redir

    For example, open a new window with a blank buffer, redirect all :-command output to register "a", get the output of the "ls" shell command, end redirection, and paste register "a" into the buffer:

    :redir @a
    :redir END
    :put a