I would like to have a keystroke to show a list of recently used files to choose one to edit.

  • What do I need to provide that?

And related,

  • How do I manage the history of recently used files to use?
  • This should support excluding filenames or subdirectories.
  • Would you mind expanding a bit on what you mean by "support excluding..."? Do you mean that you'd like to show a list of all files except some matching a pattern, or that you'd like to exclude certain files from ever showing up in the list? (The latter option is what @muru's answer with autocmd does; the former seems like it would be more useful and possibly easier to achieve.) Feb 25, 2015 at 19:29
  • @KyleStrand I was thinking of the first variant, excluding a file if the path matches one of a list of patterns. For example, the patterns could be something like *.tmp,/tmp/*,/mnt/foo/*. Feb 26, 2015 at 7:26

2 Answers 2


You can use the :browse command for that:

:browse oldfiles

For a keystroke, map it:

nnoremap <Leader>o :browse oldfiles<cr>

Then you can press Leader o in normal mode to view a list of files.

From :help v:oldfiles:

                                        v:oldfiles oldfiles-variable
v:oldfiles      List of file names that is loaded from the viminfo file on
                startup.  These are the files that Vim remembers marks for.
                The length of the List is limited by the ' argument of the
                'viminfo' option (default is 100).
                When the viminfo file is not used the List is empty.

So, to limit at, say, 50 files, you can set viminfo:

set viminfo+='50

I don't see an easy way of excluding files from this, other than disabling viminfo using autocmd:

autocmd BufNew *.sh set viminfo=

This has the huge flaw of disabling all history for any session that involves matching files.

  • That's an awesome feature that I'd never heard of. Feb 25, 2015 at 19:30
  • Might it be possible to combine the browse command with unite and/or PipeCmd to achieve the filtering that OP would like? Feb 26, 2015 at 18:33
  • @KyleStrand I have never used either, so I don't know.
    – muru
    Feb 26, 2015 at 18:37

Check out Ctrl-P's MRU feature. Once you've installed it, type :CtrlPMRUFiles and it'll pop open a fuzzy finder at the bottom of the screen that you can fuzzy search through.enter image description here

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.