Loading ...
Sorry, an error occurred while loading the content.

Re: Always restore buffer list from .viminfo file

Expand Messages
  • Adrian Luff
    I use the following lines in my .vimrc… ... This automatically saves a session when GUI Vim leaves and loads the session file if it exists on start up. It
    Message 1 of 8 , Feb 26 8:21 AM
    • 0 Attachment
      I use the following lines in my .vimrc…

      > " Auto save/load session
      > function! CheckSessionFile()
      > if filereadable(expand("$HOME/.vim/session/default.vim"))
      > source $HOME/.vim/session/default.vim
      > endif
      > endfunction
      >
      >
      > if has('gui_running')
      > autocmd VimLeave * mksession! $HOME/.vim/session/default.vim
      > autocmd VimEnter * nested call CheckSessionFile()
      > autocmd * SessionLoadPost source $MYVIMRC
      > endif

      This automatically saves a session when GUI Vim leaves and loads the session file if it exists on start up. It may not work well for you since it sounds like you're always in terminal Vim but I thought I'd pass it along.

      -Adrian

      On Feb 20, 2013, at 1:26 AM, Arvid Warnecke <arvid@...> wrote:

      > Hello,
      >
      > is there any chance to recover all opened buffers in vim from the
      > ~/.viminfo file somehow?
      > I understood that vim trashes the buffers list when vim is started with
      > a specific file to edit. But as I use vim in mutt as my default editor
      > as well, I always loose my buffers because mutt opens it like this:
      >
      > `vim /tmp/mutt-archbookPro-1000-895-3021467551525290154`
      >
      > So it does not help when I try to use only one vim instance running on
      > my workstation to keep all buffers around.
      >
      > I read something about v:oldfiles, but I have no clue how this file
      > might be of any help, because I just have a list of all old files in a
      > new buffer. I am not able to restore the buffers from it.
      >
      > Best regards,
      > Arvid
      >
      > --
      > [ Arvid Warnecke ][ arvid (at) nostalgix (dot) org ]
      > [ IRC/OPN: "madhatter" ][ http://www.nostalgix.org ]
      > ---[ ThreePiO was right: Let the Wookiee win. ]---

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Arvid Warnecke
      Hello Emmanuel, ... Thank you. This seems to be a solution, I will give it a try. The only thing that might cause some trouble is that I will still have
      Message 2 of 8 , Feb 26 11:17 AM
      • 0 Attachment
        Hello Emmanuel,

        On Tue, Feb 26, 2013 at 11:01:10AM +0100, Emmanuel GALLOIS wrote:
        > On 20/02/13 10:26, Arvid Warnecke wrote:
        > >is there any chance to recover all opened buffers in vim from the
        > >~/.viminfo file somehow?
        > >I understood that vim trashes the buffers list when vim is started with
        > >a specific file to edit. But as I use vim in mutt as my default editor
        > >as well, I always loose my buffers because mutt opens it like this:
        > >
        > >`vim /tmp/mutt-archbookPro-1000-895-3021467551525290154`
        > >
        >
        > Maybe :mksession is the right answer for you...
        >
        > :h mksession
        >
        > see point #7.
        >
        >
        Thank you. This seems to be a solution, I will give it a try. The only
        thing that might cause some trouble is that I will still have multiple
        vim sessions, because mutt, crontab and others won't use the vim I
        always have open for coding.

        Cheers,
        Arvid

        --
        [ Arvid Warnecke ][ arvid (at) nostalgix (dot) org ]
        [ IRC/OPN: "madhatter" ][ http://www.nostalgix.org ]
        ---[ ThreePiO was right: Let the Wookiee win. ]---
      • Arvid Warnecke
        Hello Adrian, ... Thank you. I think some function like that might be helpful. ... No, I don t believe in GUIs. Cheers, Arvid -- [ Arvid Warnecke ][ arvid (at)
        Message 3 of 8 , Feb 26 11:54 AM
        • 0 Attachment
          Hello Adrian,

          On Tue, Feb 26, 2013 at 08:21:23AM -0800, Adrian Luff wrote:
          > I use the following lines in my .vimrc…
          >
          > > " Auto save/load session
          > > function! CheckSessionFile()
          > > if filereadable(expand("$HOME/.vim/session/default.vim"))
          > > source $HOME/.vim/session/default.vim
          > > endif
          > > endfunction
          > >
          > >
          > > if has('gui_running')
          > > autocmd VimLeave * mksession! $HOME/.vim/session/default.vim
          > > autocmd VimEnter * nested call CheckSessionFile()
          > > autocmd * SessionLoadPost source $MYVIMRC
          > > endif
          >
          > This automatically saves a session when GUI Vim leaves and loads the
          > session file if it exists on start up.
          >
          Thank you. I think some function like that might be helpful.

          > It may not work well for you since it sounds like you're always in
          > terminal Vim but I thought I'd pass it along.
          >
          No, I don't believe in GUIs.

          Cheers,
          Arvid

          --
          [ Arvid Warnecke ][ arvid (at) nostalgix (dot) org ]
          [ IRC/OPN: "madhatter" ][ http://www.nostalgix.org ]
          ---[ ThreePiO was right: Let the Wookiee win. ]---
        Your message has been successfully submitted and would be delivered to recipients shortly.