TL;DR: I want to persist :Man windows in sessions

I am obsessed with sessions, and use tpope's vim-obsession for managing them. Coupled with a scripted tmux, sessions make for a perfect "quit, go home, come back" workflow.

Recently, I decided to embark on learning perl. Perl wonderfully ships with a massive amount of documentation, all of which is accessible via perldoc. But, these pages are also available via manpages.

Perfect, says I: I can run vim, :Man perl to view the documentation, then :term to have a shell for experimenting with the scripts I'm writing as I write them.

I do this, then :Obsession to save the session, and quit and restart (vim -S) to see if it works the way I thought.

Unfortunately, the session didn't save my open :Man window: it's not even present in the Session.vim code.

I suspect this is a result of :Man setting 'buftype'=nofile. I also suspect that what I am asking may be fundamentally impossible: I could edit the session code by hand, but there are so many cases and this is so error prone that even a one-time attempt to script this edit seems... unwieldy. By hand, I'm not even sure I'd know where to start, and it will just get overwritten by the next session save.

Obsession isn't really necessary to try this out yourself; all you need is mksession.

  • 2
    Yeah, you have a buffer with no swapfile associated, tied to a file that doesn't exist (e.g. ~/find.1~ for man find) and then a buffer type of nofile added for good measure. They couldn't have done much more to make that buffer as vapor to the session mechanism...short of waving their hands over it while chanting magic incantations..."you are not a real buffer....you do not exist". – B Layer Jul 10 '19 at 23:15
  • 2
    BTW, that non-buffer gets loaded with :r !man ... and I'm not sure if :mks would know how to deal with that even if it were an everyday, girl-next-door type of buffer. (I haven't tested that, though.) – B Layer Jul 10 '19 at 23:22
  • 1
    @BLayer it’s a little more involved than :r! man, though only because we have to explicitly request cat as the manpager. – D. Ben Knoble Jul 10 '19 at 23:28
  • 1
    Explicitly request cat as the manpager? I thought that was just a system-specific workaround to the real goal of unsetting manpager envvar...maybe I skimmed to quickly. Anyways, I think my point stands independently from that part...the mks vs load-by-shell-command problem. – B Layer Jul 10 '19 at 23:30
  • 2
    @BLayer If I unset MANPAGER, man fails. But yes your point stands – D. Ben Knoble Jul 10 '19 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.