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

How can I restore the current session in VIM

Expand Messages
  • Arup Rakshit
    I am reading vim manual *usr_04.txt* from my vim terminal. I daily read tutorial in a small chunk. But I want to book mark to the page, currently I am reading,
    Message 1 of 14 , Mar 14, 2014
      I am reading vim manual *usr_04.txt* from my vim terminal. I daily read tutorial in a small chunk. But I want to book mark to the page, currently I am reading, but still not finished. Next day, I want to resume from the line/page where I stopped today. How to save/bookmark this. I am in Gvim.

      --
      --
      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/d/optout.
    • Marcin Szamotulski
      ... You have a few choices: 1. use sessions: with :mks (see :help :mks). You can add a file name where to save the session. Then you can open the session
      Message 2 of 14 , Mar 15, 2014
        On 16:46 Fri 14 Mar , Arup Rakshit wrote:
        > I am reading vim manual *usr_04.txt* from my vim terminal. I daily read tutorial in a small chunk. But I want to book mark to the page, currently I am reading, but still not finished. Next day, I want to resume from the line/page where I stopped today. How to save/bookmark this. I am in Gvim.

        You have a few choices:

        1. use sessions: with :mks (see :help :mks). You can add a file name
        where to save the session. Then you can open the session when starting
        vim with "vim -S" or "vim -S mysession.vim" (if you don't specify name
        the default will be used which is Session.vim).

        2. you can check :oldfiles, and then use ":e #<10" to open 10th file in
        the oldfile list.

        Cheers,
        Marcin

        --
        --
        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/d/optout.
      • Matteo Cavalleri
        ... you can use an uppercase mark. Uppercase marks A to Z include the file name. You can use them to jump from file to file. The line number of the mark
        Message 3 of 14 , Mar 15, 2014
          > I am reading vim manual *usr_04.txt* from my vim terminal. I daily read tutorial in a small chunk. But I want to book mark to the page, currently I am reading, but still not finished. Next day, I want to resume from the line/page where I stopped today. How to save/bookmark this. I am in Gvim.

          you can use an uppercase mark.

          "Uppercase marks 'A to 'Z include the file name. You can use them to jump from file to file. The line number of the mark remains correct, even if you insert/delete lines or edit another file for a moment. When the 'viminfo' option is not empty, uppercase marks are kept in the .viminfo file. See viminfo-file-marks."

          --
          --
          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/d/optout.
        • Eike Rathke
          Hi Arup, ... In your .vimrc have au BufReadPost * if line( ) 1 && line( )
          Message 4 of 14 , Mar 15, 2014
            Hi Arup,

            On Friday, 2014-03-14 16:46:51 -0700, Arup Rakshit wrote:

            > [... jump to the last position when reopening a file ...]

            In your .vimrc have

            au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif

            Taken from :h last-position-jump
            Works like a charme.

            Eike

            --
            OpenPGP/GnuPG encrypted mail preferred in all private communication.
            Key ID: 0x65632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
            Support the FSFE, care about Free Software! https://fsfe.org/support/?erack
            Use LibreOffice! https://www.libreoffice.org/
          • Arup Rakshit
            Hi, From the doc I got the line : ... How to set * mark is set* ? ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your
            Message 5 of 14 , Mar 15, 2014
              Hi,

              From the doc I got the line :

              This autocommand jumps to the last known position in a file just after opening it, if the '" mark is set:
              :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif

              How to set *'" mark is set* ?

              On Saturday, March 15, 2014 5:55:21 PM UTC+5:30, Eike Rathke wrote:
              > Hi Arup,
              >
              >
              >
              > On Friday, 2014-03-14 16:46:51 -0700, Arup Rakshit wrote:
              >
              >
              >
              > > [... jump to the last position when reopening a file ...]
              >
              >
              >
              > In your .vimrc have
              >
              >
              >
              > au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
              >
              >
              >
              > Taken from :h last-position-jump
              >
              > Works like a charme.
              >
              >
              >
              > Eike
              >
              >
              >
              > --
              >
              > OpenPGP/GnuPG encrypted mail preferred in all private communication.
              >
              > Key ID: 0x65632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
              >
              > Support the FSFE, care about Free Software! https://fsfe.org/support/?erack
              >
              > Use LibreOffice! https://www.libreoffice.org/



              On Saturday, March 15, 2014 5:55:21 PM UTC+5:30, Eike Rathke wrote:
              > Hi Arup,
              >
              >
              >
              > On Friday, 2014-03-14 16:46:51 -0700, Arup Rakshit wrote:
              >
              >
              >
              > > [... jump to the last position when reopening a file ...]
              >
              >
              >
              > In your .vimrc have
              >
              >
              >
              > au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
              >
              >
              >
              > Taken from :h last-position-jump
              >
              > Works like a charme.
              >
              >
              >
              > Eike
              >
              >
              >
              > --
              >
              > OpenPGP/GnuPG encrypted mail preferred in all private communication.
              >
              > Key ID: 0x65632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
              >
              > Support the FSFE, care about Free Software! https://fsfe.org/support/?erack
              >
              > Use LibreOffice! https://www.libreoffice.org/



              On Saturday, March 15, 2014 5:55:21 PM UTC+5:30, Eike Rathke wrote:
              > Hi Arup,
              >
              >
              >
              > On Friday, 2014-03-14 16:46:51 -0700, Arup Rakshit wrote:
              >
              >
              >
              > > [... jump to the last position when reopening a file ...]
              >
              >
              >
              > In your .vimrc have
              >
              >
              >
              > au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
              >
              >
              >
              > Taken from :h last-position-jump
              >
              > Works like a charme.
              >
              >
              >
              > Eike
              >
              >
              >
              > --
              >
              > OpenPGP/GnuPG encrypted mail preferred in all private communication.
              >
              > Key ID: 0x65632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
              >
              > Support the FSFE, care about Free Software! https://fsfe.org/support/?erack
              >
              > Use LibreOffice! https://www.libreoffice.org/

              --
              --
              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/d/optout.
            • Arup Rakshit
              ... Nice tips.. :-) ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For
              Message 6 of 14 , Mar 15, 2014
                On Saturday, March 15, 2014 2:33:18 PM UTC+5:30, coot_. wrote:
                > On 16:46 Fri 14 Mar , Arup Rakshit wrote:
                >
                > > I am reading vim manual *usr_04.txt* from my vim terminal. I daily read tutorial in a small chunk. But I want to book mark to the page, currently I am reading, but still not finished. Next day, I want to resume from the line/page where I stopped today. How to save/bookmark this. I am in Gvim.
                >
                >
                >
                > You have a few choices:
                >
                >
                >
                > 1. use sessions: with :mks (see :help :mks). You can add a file name
                >
                > where to save the session. Then you can open the session when starting
                >
                > vim with "vim -S" or "vim -S mysession.vim" (if you don't specify name
                >
                > the default will be used which is Session.vim).

                Nice tips.. :-)

                > 2. you can check :oldfiles, and then use ":e #<10" to open 10th file in
                >
                > the oldfile list.
                >
                >
                >
                > Cheers,
                >
                > Marcin

                --
                --
                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/d/optout.
              • Ben Fritz
                ... From elsewhere in the help (:help ) you can see that this mark gets set automatically whenever you quit a buffer. It stores the last position in the
                Message 7 of 14 , Mar 15, 2014
                  On Saturday, March 15, 2014 9:00:59 AM UTC-5, Arup Rakshit wrote:
                  > Hi,
                  >
                  > From the doc I got the line :
                  >
                  > This autocommand jumps to the last known position in a file just after opening it, if the '" mark is set:
                  > :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
                  >
                  > How to set *'" mark is set* ?
                  >

                  From elsewhere in the help (:help '") you can see that this mark gets set automatically whenever you quit a buffer. It stores the last position in the buffer before quitting it. By default, this mark gets stored in your .viminfo file when you exit Vim, so it gets remembered between editing sessions also.

                  --
                  --
                  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/d/optout.
                • John Little
                  -- -- 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
                  Message 8 of 14 , Mar 15, 2014
                    --
                    --
                    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/d/optout.
                  • John Little
                    ... If I use an upper-case mark in the help, upon returning to that point the help file is not opened in a help buffer, but has an ordinary file, even though
                    Message 9 of 14 , Mar 15, 2014
                      On Saturday, March 15, 2014 10:49:11 PM UTC+13, Matteo Cavalleri wrote:

                      > you can use an uppercase mark.

                      If I use an upper-case mark in the help, upon returning to that point the help file is not opened in a "help" buffer, but has an ordinary file, even though it has file type "help". It looks ok but the hypertext linking doesn't work.

                      Is there a way to set "helpness" for a buffer?

                      Regards, John Little

                      --
                      --
                      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/d/optout.
                    • Tim Chase
                      ... You might look into the buftype , filetype , and syntax settings. In a help window, those are all set to help . That said, I don t notice an issue
                      Message 10 of 14 , Mar 15, 2014
                        On 2014-03-15 19:06, John Little wrote:
                        > If I use an upper-case mark in the help, upon returning to that
                        > point the help file is not opened in a "help" buffer, but has an
                        > ordinary file, even though it has file type "help". It looks ok
                        > but the hypertext linking doesn't work.
                        >
                        > Is there a way to set "helpness" for a buffer?

                        You might look into the 'buftype', 'filetype', and 'syntax'
                        settings. In a help window, those are all set to "help".

                        That said, I don't notice an issue dropping an upper-case mark in the
                        help, leaving the window, and then using tags upon returning to that
                        mark.

                        -tim


                        --
                        --
                        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/d/optout.
                      • John Little
                        ... set buftype=help is what is needed, thank you. I searched eval.txt, I should have looked in options.txt. ... You are not exiting vim altogether, coming
                        Message 11 of 14 , Mar 16, 2014
                          On Sunday, March 16, 2014 3:28:26 PM UTC+13, Tim Chase wrote:
                          > On 2014-03-15 19:06, John Little wrote:
                          > > If I use an upper-case mark in the help, upon returning to that
                          > > point the help file is not opened in a "help" buffer, but has an
                          > > ordinary file, even though it has file type "help". It looks ok
                          > > but the hypertext linking doesn't work.
                          >
                          > > Is there a way to set "helpness" for a buffer?
                          >
                          > You might look into the 'buftype', 'filetype', and 'syntax'
                          > settings. In a help window, those are all set to "help".

                          set buftype=help is what is needed, thank you. I searched eval.txt, I should have looked in options.txt.

                          > That said, I don't notice an issue dropping an upper-case mark in the
                          > help, leaving the window, and then using tags upon returning to that
                          > mark.

                          You are not exiting vim altogether, coming back to vim the next day like the OP, leaving the window is not enough to see what I was talking about.

                          Regards, John Little

                          --
                          --
                          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/d/optout.
                        • Tim Chase
                          ... Ah, gotcha. My .viminfo on this machine doesn t persist marks across sessions, so I d have had to tweak that setting too. -tim -- -- You received this
                          Message 12 of 14 , Mar 16, 2014
                            On 2014-03-16 03:11, John Little wrote:
                            > You are not exiting vim altogether, coming back to vim the next day
                            > like the OP, leaving the window is not enough to see what I was
                            > talking about.

                            Ah, gotcha. My .viminfo on this machine doesn't persist marks across
                            sessions, so I'd have had to tweak that setting too.

                            -tim


                            --
                            --
                            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/d/optout.
                          • Arup Rakshit
                            ... Hi, ... Now upon exiting, when I open the vim and try : , I didn t get the file back, which I wanted resume. What wrong am I doing? Any pointer please. --
                            Message 13 of 14 , Mar 16, 2014
                              On Saturday, March 15, 2014 8:20:49 PM UTC+5:30, Ben Fritz wrote:
                              > On Saturday, March 15, 2014 9:00:59 AM UTC-5, Arup Rakshit wrote:
                              > > Hi,
                              > >
                              > > From the doc I got the line :
                              > >
                              > > This autocommand jumps to the last known position in a file just after opening it, if the '" mark is set:
                              > > :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
                              > >
                              > > How to set *'" mark is set* ?
                              > >
                              >
                              > From elsewhere in the help (:help '") you can see that this mark gets set automatically whenever you quit a buffer. It stores the last position in the buffer before quitting it. By default, this mark gets stored in your .viminfo file when you exit Vim, so it gets remembered between editing sessions also.

                              Hi,

                              I put the line in my ~/.vimrc file :

                              :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif

                              Now upon exiting, when I open the vim and try :"", I didn't get the file back, which I wanted resume.

                              What wrong am I doing? Any pointer please.

                              --
                              --
                              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/d/optout.
                            • Ben Fritz
                              ... First, the command you wanted is a single quote followed by a double quote in NORMAL MODE to take you to the mark. Second, this mark is set
                              Message 14 of 14 , Mar 17, 2014
                                On Sunday, March 16, 2014 9:37:44 PM UTC-5, Arup Rakshit wrote:
                                > >
                                > > From elsewhere in the help (:help '") you can see that this mark gets set automatically whenever you quit a buffer. It stores the last position in the buffer before quitting it. By default, this mark gets stored in your .viminfo file when you exit Vim, so it gets remembered between editing sessions also.
                                >
                                > Hi,
                                >
                                > I put the line in my ~/.vimrc file :
                                >
                                > :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
                                >
                                > Now upon exiting, when I open the vim and try :"", I didn't get the file back, which I wanted resume.
                                >
                                > What wrong am I doing? Any pointer please.

                                First, the command you wanted is a single quote ' followed by a double quote " in NORMAL MODE to take you to the " mark.

                                Second, this mark is set per-buffer. Whenever you load a file, Vim will consult .viminfo to figure out the last place you edited in that buffer, then will set the " mark to that location. This mark will NOT take you TO a file. But once you are already IN the file, it will take you to the place you were when you quit that file. This will happen for multiple files.

                                Finally, the autocmd you added means you don't actually need to do anything manually to jump to the mark. Just load the file and Vim should jump to where you left off.

                                --
                                --
                                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/d/optout.
                              Your message has been successfully submitted and would be delivered to recipients shortly.