Inspired by a nice solution on a Stack Overflow, the following was put in my vimrc
:
command! Bro :vnew +setl\ buftype=nofile | 0put =v:oldfiles
\| nnoremap <buffer> <CR> :e <C-r>=getline('.')<CR><CR>
There are two problems with it I'd like to fix:
- I want to view the list from the top (most recent) rather than the bottom, as is currently the case. I've tried adding
1G
to the script, but to no avail. - I would rather the list be open in the current window, so I don't have to come back to close it later. Using
enew
instead ofvnew
produces an E488 error, ande
puts the list of files in current file.
Thanks.
Update. Since the purpose of this exercise is to make the file list searchable, it's probably a good idea to append :noh<CR>
to the nnoremap
so that once you've searched, found your file, and opened it by pressing Enter, search terms are not highlighted in the file.
1G
doesn't work here because you are basically in command-line mode (or ex-mode for purists) and1G
is a normal mode command. – Tumbler41 Jun 8 '16 at 22:421G
was a command-line mode, too. Somehow, although I never did:1G
, I thought it would work until I tried just now. – bongbang Jun 9 '16 at 16:06