Marks are stored in viminfo
not in a session and the viminfo
file is only written when exiting vim. So if you are closing vim to switch projects then vim will only have marks for the previous project that you were working on. One would potentially have to come up with a plugin that separately reads and stores marks from viminfo
when calling :mksession
and then overwrites them in viminfo
when sourcing the session file.
From :h session
1. Restores global mappings and options, if 'sessionoptions' contains
"options". Script-local mappings will not be written.
2. Restores global variables that start with an uppercase letter and contain
at least one lowercase letter, if 'sessionoptions' contains "globals".
3. Unloads all currently loaded buffers.
4. Restores the current directory if 'sessionoptions' contains "curdir", or
sets the current directory to where the Session file is if 'sessionoptions'
contains "sesdir".
5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos".
6. Restores screen size, if 'sessionoptions' contains "resize".
7. Reloads the buffer list, with the last cursor positions. If
'sessionoptions' contains "buffers" then all buffers are restored,
including hidden and unloaded buffers. Otherwise only buffers in windows
are restored.
8. Restores all windows with the same layout. If 'sessionoptions' contains
"help", help windows are restored. If 'sessionoptions' contains "blank",
windows editing a buffer without a name will be restored.
If 'sessionoptions' contains "winsize" and no (help/blank) windows were
left out, the window sizes are restored (relative to the screen size).
Otherwise, the windows are just given sensible sizes.
9. Restores the Views for all the windows, as with :mkview. But
'sessionoptions' is used instead of 'viewoptions'.
10. If a file exists with the same name as the Session file, but ending in
"x.vim" (for eXtra), executes that as well. You can use *x.vim files to
specify additional settings and actions associated with a given Session,
such as creating menu items in the GUI version.
From :h viminfo
The viminfo file is used to store:
- The command line history.
- The search string history.
- The input-line history.
- Contents of non-empty registers.
- Marks for several files.
- File marks, pointing to locations in files.
- Last search/substitute pattern (for 'n' and '&').
- The buffer list.
- Global variables.
.viminfo
, etc). You could use these (plus autocommands probably) to create a custom solution. Not sure if you're that committed. See my answer here for a glimpse of some of this stuff: vi.stackexchange.com/a/17570/11054