0

When running :browse oldfiles, if the output goes longer than one screen then you have to hit <space> for the next screen or <esc> to go to the menu where you can type the number of the old file you want to edit.

I'm trying to create a mapping that automatically enters <esc> for me while the :browse command is still in progress, saving me a keypress. This will leave me in the command mode where I just enter a number. I tried this mapping: nmap <F5> :bro ol \| call feedkeys('<Esc>') but that doesn't work. The feedkeys function call doesn't want to kick in until the browse command finishes. How can I do this?

I could also use FZF, Telescope or another plugin to bring up recently-opened files, but the :browse oldfiles command is faster even if it's more limited than what a plugin can provide

2 Answers 2

1

There's no need in pressing escape. Type simply :e#<X to open old file no. X while browsing through the list.

1
  • Thank you, but I want to seed :e#< ahead of time, so that all I have to do is press a number.
    – Ryan
    Commented Aug 12, 2021 at 17:54
0

I found one solution. In nvim there is the nvim_input() function call. I made a command: command! Bro :call nvim_input('<Esc>') | bro ol. I mapped that command to a key. When I press it, it shows me one screen full of the names of the most recently opened files, and all I have to do is type a number and enter.

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.