Quick and dirty way of "storing a list of open files", as requested in your comment. (I don't have enough reputation to answer a comment).
:tabs
gives all currently open filenames, arranged by tab number.
So if you do something like
command! SaveTabs :execute "redir! > tabs_" . v:servername . ".txt
\ | echo v:servername strftime(\"%c\") | pwd | tabs | redir END"
you will have a new command
:SaveTabs
which will create a file named something like tabs_GVIM27.txt
(yeah that's how many servers I have open...) containing all the filenames, with a "header" at the top with the:
- servername
- current working directory
- date/time that the list was created.
When in a new/different session later on, you can open the tabs file in a window and <c-w>f
on any of those filenames to open a new split on the file, effectively "importing" it into your current session.
Variations:
- If you want you could put the date/time in the filename itself, see
:help strftime()
- Put the list on the clipboard instead of in a file: use
redir @+
instead of redir! >
Other explanatory notes:
- The working directory is because
:tabs
shows relative paths, so files in the working directory do not have their paths (but others do)
:execute
is needed because :redir
won't allow variables in its argument
- The command doesn't have to be split over two lines, I just did that so it would be easier to read here
Insane variation for importing all the files at once:
If you want to import all the files at once you can probably do something like
grep "^ " tabs_OLD.txt | xargs | vim --servername NEW --remote-silent
(untested but you get the idea)
(actually if you got that working, you could then just define it as an alias in your shell, so you could in future just type
addfiles foo bar
to add all the files from a previous vim server "foo" to a currently-running vim server called "bar")
:mksession
is a whole session. If there was a way to load a session into an active session it would replace existing buffers and do all kinds of things that would mess it up. Sessions are only meant to be used with the-S
argument at startup.:e
on every file. If you also want to restore paste registers and cursor position, etc, then you might write a wrapper around:mkview
which loops over every window to export a view for it.