Monday, March 17, 2014

Re: How can I restore the current session in VIM

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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: