Thursday, April 23, 2015

Re: Open session does not restore position in files

On Thursday, April 23, 2015 at 8:26:05 AM UTC-5, av wrote:
> Hi,
>
> I create tabs and windows with certain positions to files and I try to save session and open it using the gvim toolbar and with the mappings I have:
>
> " Show the session open dialog
> map <tab>[ :browse source!<cr>
>
> " Show the session save dialog
> map <tab>] :browse mksession!<cr>
>
> But for some windows the cursor is at the top of the file and not at the line number when I saved the session.
>
> I have multiple windows opened on the same 2 or 3 same files.
>
> Does somebody know if line numbers should be remembered in sessions? And why it is not keeping them in this case?
>
> Thank you.
>
> Alexandre

See :help 'sessionoptions' for what Vim sessions can remember. Cursor position is not in the list, so I don't think it is remembered.

HOWEVER, the help is confusing me at this point. In :help :mksession is this statement:

9. Restores the Views for all the windows, as with |:mkview|. But
'sessionoptions' is used instead of 'viewoptions'.

Views, unlike sessions DEFINITELY restore the cursor position. So perhaps a session also restores the stuff in a view? I'm not sure, I don't use either very often.

You may have an autocmd in your .vimrc (possibly taken from vimrc_example.vim long ago) to restore cursor position to a position remembered from the last time you edited that file. I think that autocmd will fail for some windows if you had the same file open in multiple windows when you last edited the file.

--
--
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: