Freedom_Ben
Freedom_Ben

Reputation: 11943

How do I open files from my oldfiles list in vim?

In vim, I can type :oldfiles to see a list of files I've previously edited. Awesome feature!

But now I want to open one or more files from that list into a buffer. How can I do that?

Upvotes: 27

Views: 7111

Answers (3)

Freedom_Ben
Freedom_Ben

Reputation: 11943

Nearly 8 years later I stumbled on this old question and thought I'd update with what I do now (which is miles ahead of where this question ended).

I use fzf.vim and just type :History and then get an awesome fuzzy search over :oldfiles !

Upvotes: 1

romainl
romainl

Reputation: 196556

Once you are at the bottom of the list you are supposed to press : and issue a command, using this "weird" notation:

:command #<91

where command could be any edit-like command (:edit, :tabedit, :split, :vsplit, :next, :args, etc.) and #< means "old file number…".

To edit entry 91, use:

:e #<91

To edit entries 18, 42 and 93, use:

:args #<18 #<42 #<93

Upvotes: 34

merlin2011
merlin2011

Reputation: 75565

If you use :help oldfiles, you will find the command :browse oldfiles which should do what you want.

:bro[wse] ol[dfiles][!]
                        List file names as with |:oldfiles|, and then prompt
                        for a number.  When the number is valid that file from
                        the list is edited.
                        If you get the |press-enter| prompt you can press "q"
                        and still get the prompt to enter a file number.
                        Use ! to abandon a modified buffer. |abandon|
                        {not when compiled with tiny or small features}

Upvotes: 26

Related Questions