Quantcast
Channel: Active questions tagged user-commands - Vi and Vim Stack Exchange
Viewing all articles
Browse latest Browse all 60

Better "bro ol"

$
0
0

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:

  1. 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.
  2. 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 of vnew produces an E488 error, and e 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.


Viewing all articles
Browse latest Browse all 60


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>