4

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

For example, if I do:

:! ls 

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

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

1 Answer 1

4

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:

:new
:redir @a
:!ls
:redir END
:put a
1
  • 2
    I should note that for shell commands, it's easier just do do ":new" and then ":r!ls", but the :redir trick works for internal Vim commands that produce output.
    – Heptite
    May 30, 2011 at 1:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .