search

Home  >  Q&A  >  body text

How to set gvim to automatically load the files opened when it was closed last time every time the editor is started?

RT, so you can continue the last work

某草草某草草2773 days ago690

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 16:44:25

    Add the following content to the configuration file:

    " Go to last file(s) if invoked without arguments.
    autocmd VimLeave * nested if (!isdirectory($HOME . "/.vim")) |
        \ call mkdir($HOME . "/.vim") |
        \ endif |
        \ execute "mksession! " . $HOME . "/.vim/Session.vim"
    
    autocmd VimEnter * nested if argc() == 0 && filereadable($HOME . "/.vim/Session.vim") |
        \ execute "source " . $HOME . "/.vim/Session.vim"

    Reference: Open the last edited file

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:44:25

    If you use terminal, it is recommended to use the following two aliases:

    alias lgvim='gvim -c "normal '\''0"'
    alias lvim='vim -c "normal '\''0"'
    

    Here is a detailed introduction

    I prefer to use mru plug-in

    reply
    0
  • Cancelreply