List and open most recently used files

1 Point

Cem Aksoylar Cem Aksoylar

2 months ago

Display most recently used (MRU) files with a keymap (<F3> here), click Enter to open the file under the cursor, while making sure alternate buffer is not affected.

function! MRU() abort
    setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile
    call setline(1, v:oldfiles)
    nnoremap <silent> <buffer> <CR> :keepalt edit <C-r><C-l><CR>

nnoremap <silent> <F3> :call MRU()<CR>