3

I know that the :oldfiles command will show you a history of the files you last had open; but how do I open the last n files in one command...for instance, say I want to open files 0-n in the :oldfiles list, is there a way to do that?

leeand00
  • 3,555
  • 5
  • 24
  • 40
  • Note: Using :browse oldfiles will allow you to pick one from the list, but it doesn't open say the last n files. – leeand00 Jun 07 '17 at 03:09

1 Answers1

4

The files listed by :oldfiles are also available as a list in v:oldfiles, so something like:

for f in v:oldfiles[:10]
    exec "badd" f
endfor

Using an appropriate value instead of 10, of course.

muru
  • 24,838
  • 8
  • 82
  • 143