Is there a way to search the list of recently used file in Vim? The list can be displayed using
browse old
but /
does not work. I am aware of some plugins (e.g. MRU) but would prefer to not use a plugin.
Here's a short scriptlet that opens the file list in a scratch buffer. As a bonus, it defines a local <Enter>
mapping to :edit
the current file. With this, you can search with all built-in commands like /
:
:new +setl\ buftype=nofile | 0put =v:oldfiles | nnoremap <buffer> <CR> :e <C-r>=getline('.')<CR><CR>
If you really want to avoid a plugin:
:new
The old files will be printed into this buffer:redir @X
where X is a temporary register`:silent echo(v:oldfiles)
'Silent' is there to not actually print onto your screen:redir END
"Xp
paste the temporary registerPut the above into a function and voila. Also :help redir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With