On Thu, 7 Sep 2006, A.J.Mechelynck wrote: > > To do something when closing down, place it in an autocommand for the VimLeave > autocommand (as above). To do it during startup, place it in your vimrc. To do > it at the cery end of startup, put it in an autocommand dor the VimEnter > autocommand. And read the help (not the man page) if you can: for some reason > my Vim won't read the help for me at this time. > I solved my problem, based on the code you provided: I put this in my .vimrc: :au VimLeave * if exists("run_from_tread") | exe "mksession! ./session.vim" | endif The variable run_from_tread is set at start, because vim is invoked with -S Session.vim. The perl script changes directory to a directory dependent on the text file to read. Hence, Session.vim is exclusive to that file. On exit, the session is written to session.vim, and the parent script concatenates ":let run_from_tread=1" with session.vim into Session.vim.
It works, and the normal behaviour of vim (regarding other files) is not affected. > If you want to always start with the same session files, use ":mksession" once > (see ":help mksession") and maybe make an alias: "alias vim='vim -S > ~/session.vim'" in your shell. > Thanks. Regards, Jorge