3

When I have netrw and some files open in vim, only the file panels are displayed when I restore the session using .mksession.

Is it possible to restore the netrw file browser panel from a saved session?

Bas Peeters
  • 3,269
  • 4
  • 33
  • 49

1 Answers1

5

A saved Vim session contains the list of open buffers, window layout, and changed options. The netrw plugin (like many others) uses scratch buffers to display its user interface in a Vim window. These contents are not persisted, but instead generated and updated by the plugin. There's no mechanism for Vim to recognize these and ask the plugin to restore on session load. Vim just sees that the netrw buffer isn't persisted on disk (i.e. :set buftype=nofile), and then skips it.

Some plugins like session.vim plugin have functionality to handle special buffers; I don't think it can restore netrw buffers, though.

What you could easily do is hooking into the SessionLoadPost autocmd event, and reopen netrw then.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324