I use the oldfiles and browse oldfiles commands all the time. I find them extremely useful, because it's easier to hit my leader mapping, scan through the files really quickly, and hit


rather than typing out a really long directory path to a specific file. (Especially since sometimes I don't remember which directory it's in)

However, there's only one downside. Since I use vim so frequently, sometimes the file I'm looking for is dozens and dozens of rows down, so it takes a really long time to find. Is there any way I could filter the list of files given by oldfiles to show only a certain extension?

For example, a command like:

browse oldfiles *.py

that shows a list of .py files I've recently opened, prompts for a number, and then opens that file.

If there's no way to do this, are there plugins with similar functionality?

  • You could use the :CtrlPMRU command of CtrlP with fuzzy search but that might be somewhat different from you're looking for.
    – Rolf
    Commented May 16, 2017 at 7:39

2 Answers 2


Assuming you have Vim 8 you can use :filter

:browse filter /pattern/ oldfiles

For more help see:

:h :browse
:h :filter
:h oldfiles
:h new-items-8
  • 1
    Fantastic! That is exactly what I was looking for, thanks!
    – DJMcMayhem
    Commented Mar 20, 2017 at 19:20
  • 1
    :h cmd_name is another gem we didn't expect to get, but is super good to know. "The hero we needed, but not the one we asked for" Commented May 21, 2023 at 19:48
:filter /pattern/ oldfiles

returns a list of oldfiles matching the pattern, indexed, and waits for a command, then enter:

:e #<...

replace ... with the wanted file index.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.