如何打开 vim 中旧文件列表中的文件?

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

在 vim 中,我可以键入 :oldfiles 来查看我之前编辑过的文件列表。很棒的功能!

但现在我想将该列表中的一个或多个文件打开到缓冲区中。我该怎么做?

如果您使用 :help oldfiles,您会发现命令 :browse oldfiles 应该可以执行您想要的操作。

: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}

一旦您位于列表的底部,您应该按 : 并使用此 "weird" 符号发出命令:

:command #<91

其中 command 可以是任何类似编辑的命令(:edit:tabedit:split:vsplit:next:args, 等等) 而 #< 表示 "old file number…".

要编辑条目 91,请使用:

:e #<91

要编辑条目 18、42 和 93,请使用:

:args #<18 #<42 #<93