VIM session files treated as 'file list database'?

19 views
Skip to first unread message

Bill Hudacek

unread,
Aug 16, 2021, 2:36:57 PM8/16/21
to vim...@googlegroups.com

Trying to use sessions as 'database' using gvim. I hope this makes sense.

E.g., I'm reviewing 25 text notes/files - most are discarded, but some
are 'hits'. These files, I leave open (control-w to split window,
switch to the lower 'window' on the same file, and go to the next file
in the filelist).

At the end of the buffer list, I have 7 open buffers/'windows' out of
the original 25 files.

I run 'mksession a.vim', and in that file, I see these kinds of entries:

$argadd (25 times)
edit (1 time - current being edited)
balt (7 times)

Now, a simple linux pipe on the cmd-line prints the file names from
the 'balt' specifications/lines in the VIM session file.

BUT - I then realized that those files are NOT the files that open if
I use 'vim -S a.vim'. I can't figure it out. Is this documented other
than in the source code?

FYI, my .vimrc has:
set sessionoptions=buffers,help,resize,winpos,winsize,

(Hope it's obvious once I find the files in vim, I want to copy them
to another subtree so I can annotate, etc. I don't want to write them
one-at-a-time in VIM, even using a macro, as I'm really talking about
more than 600 files, not the measly 25 I use here in my example.)

I can't share the session file, because of the file names included
(legal reasons). BUT if no one knows what to do, I can dummy up
something with a few dozen fake file names to create a kind of example
showing this behavior; it'll just take a bit of time).

Thanks for any help -


--
/Bill

bill.h...@gmail.com

unread,
Aug 17, 2021, 9:18:15 AM8/17/21
to vim_use
There's one more tag in the vim session file: after $argadd, after edit, after balt, there are 'badd' specifications. If there are 100 $argadd, then I found 99 'badd'. Since I'm looking for those few that I 'selected' by leaving a buffer/window open/active, 'badd' didfn't help either. The 'edit' single spec mentions a file that also appears in 'balt' list, BTW. 

I can only think that based on 'balt' specs, open tabs/windows/buffers  are re-opened, then there must be some sense of 'logical operations being applied' which then changes what files actually appear in the open GVim editor window. 

What got me across the finish line was good old 'redirect' - along with 'ls' or 'history' - with option 'a', you only get a list of active/open buffers. 

So:  in my .vimrc I mapped Alt-S thusly:

map ó :set nomore<CR>:redir >> /tmp/chosen-files<CR>:ls a <CR>:redir END <CR>:set more<CR>-

This command, I used, not once per file but once per GVim window (per 'session', if you will) - and in the end had that list of filenames in /tmp/chosen-files.

Bob's your uncle. Hope this helps someone else in the future. 

[Posted from browser on groups web site since this group does not send my own posts back to me - resulting in horrible confusion in distant past. Sorry about that.]

/Bill

Eike Rathke

unread,
Aug 17, 2021, 1:25:54 PM8/17/21
to vim...@googlegroups.com
Hi bill.h...,

On Tuesday, 2021-08-17 06:18:15 -0700, bill.h...@gmail.com wrote:

> There's one more tag in the vim session file: after $argadd, after edit,
> after balt, there are 'badd' specifications.

Filename added to buffer list.

> If there are 100 $argadd, then
> I found 99 'badd'. Since I'm looking for those few that I 'selected' by
> leaving a buffer/window open/active, 'badd' didfn't help either.

It would, if instead of "leaving" (however you're doing that) you
deleted the buffer of the currently open file with :bd (:bdelete) or
even :bw (:bwipeout), after which :mks stores only the still active
buffers in the list with badd (plus the Session.vim buffer).

Eike

--
OpenPGP/GnuPG encrypted mail preferred in all private communication.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
Use LibreOffice! https://www.libreoffice.org/
signature.asc
Reply all
Reply to author
Forward
0 new messages