7

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

q<number><enter>

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 May 16 '17 at 7:39
12

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
  • Fantastic! That is exactly what I was looking for, thanks! – DJMcMayhem Mar 20 '17 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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