Recent file history in Vim?

后端 未结 14 1400
悲&欢浪女
悲&欢浪女 2021-01-29 18:44

I would like to access recent files that I had opened and then closed in GVim. I open and close GVim frequently. I would like to access recent files from previous sessions as we

相关标签:
14条回答
  • 2021-01-29 19:12

    The CtrlP plugin lets you search through your recently used files as well as files in the current directory with this command:

    nnoremap <c-p> :CtrlPMixed<cr>
    

    This saves you the hassle of having to deal with built in Vim commands and the MRU plugin, neither of which let you do fuzzy file searching, which is critical when working on larger projects.

    0 讨论(0)
  • 2021-01-29 19:13

    At least terminal vim stores the previous ten files into ~/.viminfo in the filemarks section. You can use '0, '1, '2, ... '9 to jump among them.

    (Probably only useful for '0 to get back to the last file you were editing, unless your memory is stronger than mine.)

    You can also use the :browse oldfiles command to get a menu with numbers.

    0 讨论(0)
  • Adding my 2 cents here because fzf was was not mentioned earlier, which is such a wonderful tool:
    fzf.vim has a :History command that lets you search the most recent used files in a fuzzy and search while you type manner.
    I customize the (default) behavior of this command by not letting fzf reorder the search results list to the best match: I want the order of all matching filenames to keep being the order in which these files were last used.
    To accomplish this customization, I added the following in my .vimrc to override the default History command defined by the fzf.vim plugin:

        command! -bang -nargs=* History
          \ call fzf#vim#history({'options': '--no-sort'})
    
    0 讨论(0)
  • 2021-01-29 19:17

    Very late answer here ... expounding on @sarnolds answer - You can view the file history with the oldfiles command @see :h oldfiles or :h viminfo

    :oldfiles 
    

    Furthermore, you can have fine-grained file management with views and sessions ... @see :h mkview and :h mksession for specifics ...

    0 讨论(0)
  • 2021-01-29 19:17

    As seen in the comments here (http://stackoverflow.com/questions/571955/undo-close-tab-in-vim), your file is probably still open in a buffer:

    :ls " get the buffer number
    :tabnew +Nbuf " where N is the buffer number
    

    For example you can reopen the third buffer in a new tab (use :e instead if you don't use tabs):

    :tabnew +3buf
    
    0 讨论(0)
  • 2021-01-29 19:21

    The best way that I use is

    :browse oldfiles
    

    Easiest way on vim.

    0 讨论(0)
提交回复
热议问题