在Vim中查看最近的文档列表

original title: "View a list of recent documents in Vim"


Translate

Is there a way to view the list of recent documents you've opened in Vim? I realize I could view the cursor jump list, :ju, and then go to a cursor position in the list but this is not ideal because there will be multiple listings of the same document in the list. Is there another command which would do what I'm looking for?



有没有办法查看您在Vim中打开的最近文档的列表?我意识到我可以查看光标跳转列表:ju,然后转到列表中的光标位置,但这不是理想的选择,因为...

这是翻译后的摘要,如果您需要查看完整的翻译,请单击“Translate”图标


所有的回答
  • Translate

    Don't use a plugin, unless you want a nice menu. From Vim Documentation: Starting (or :help old):

    :ol[dfiles]
    

    Then to open one of the listed files, use: '0, '1, '2, ... '9


    List the files that have marks stored in the viminfo file.

    :bro[wse] ol[dfiles][!]
    

    List file names as with :oldfiles, and then prompt for a number. When the number is valid that file from the list is edited. Use ! to abandon a modified buffer.


  • Translate

    The Most Recently Used (MRU) plugin provides an easy access to a list of recently opened/edited files in Vim. This plugin automatically stores the file names as you open/edit them in Vim.

    http://www.vim.org/scripts/script.php?script_id=521


  • Translate

    Besides :oldfiles, fzf.vim has :History.


  • Translate

    Start Vim and hit Ctrl-o-o to open previously edited file. Keep hitting o (while still pressing the Ctrl key) to cycle back through earlier files. See https://dev.to/jovica/3-little-known-but-useful-vim-tips-1pbg


  • Translate

    vim plugin: minibufexpl may help you. the opened file list is displayed on the top or bottom of the screen:

    enter image description here

    in vim normal mode, type :b${bufid} to jump to the ${bufid}_th buffer, for example: type :b13 to jump to the 13th buffer, ie. ngx_mail_ssl_module.c.

    besidies, you can map some convenient bindings in your vimrc, such as:

    " ------------------------------- minibufexpl mappings -----------------------------------
    "let g:miniBufExplSplitBelow=1
    nnoremap <silent> <leader>bn :bn<cr>
    nnoremap <silent> <leader>bp :bp<cr>
    nnoremap <silent> <leader>bf :bf<cr>
    nnoremap <silent> <leader>bl :bl<cr>
    nnoremap <silent> <leader>bt :TMiniBufExplorer<cr>
    

    Get the plugin from here: https://github.com/fholgado/minibufexpl.vim


  • Translate

    In addition to oldfiles there's a nice thing called tinyMRU.

    Vim-tinyMRU's only purpose is to provide an intuitive alternative to the built-in :oldfile command. Nothing more, nothing less.

    It's very simple:

    https://github.com/romainl/vim-tinyMRU/blob/master/plugin/tinymru.vim


  • Translate

    A good plugin is https://github.com/Shougo/denite.nvim

    You can call :Denite file_old in order to have fuzzy search on the list of old files. In particular, just hitting Enter will re-open the last opened file. Assigning a shortcut to this is useful:

    nnoremap <leader>o :Denite<space>file_old<CR>
    

    This saves few keystrokes compared to :browse oldfiles, q, 1, Enter


  • Translate

    The easiest way for me to access recent files is to add the following to one's .gvimrc file:

    let g:netrw_sort_by           = 'time'
    
    let g:netrw_sort_direction    = 'r'
    

    These lines get netrw to sort files by those most recently modified. Then one simply calls :e. and selects the file one wants.

    This solution presupposes files are saved in one main directory so specified in .gvimrc. E.g.

    cd ~/vim