-- Leo's gemini proxy

-- Connecting to republic.circumlunar.space:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Vim persistent buffer list combined with saved sessions


I like to use several saved Vim sessions to remember what files I was working on in a particular project.


I also like to have a list of buffers I have open on the left-hand side of the screen that is always visible and up-to-date.


Vim


Sometimes, the existence of a generated buffer like the list of buffers can confuse the session restore code, but I have found a way to make this work nicely using the Buffergator plugin and the built-in mksession command.


Here are the relevant snippets from my .vimrc.


I am a beginner: please comment if you see bugs or possible improvements.


Buffergator

mksession


" Prerequisites: install the Buffergator plugin

" Save session on exit, excluding problematic stuff like options

set sessionoptions=blank,buffers,curdir,tabpages,resize,winpos,winsize
au VimLeavePre * if v:this_session != '' | exec "mks! " . v:this_session | endif

" Open Buffergator when you press F5

nnoremap <F5> :BuffergatorOpen<CR>

" Various Buffergator options to make it persistent,
" and displayed how I like

let g:buffergator_autodismiss_on_select = 0
let g:buffergator_display_regime = "bufname"
let g:buffergator_sort_regime    = "filepath"
let g:buffergator_autoupdate = 1

" Suppress the error message about the Buffergator buffer
" when you restore a session

function! OpenBuffergatorIfItsBufferExists()
   if bufnr("[[buffergator-buffers]]") > ''
       BuffergatorOpen
       normal o
   endif
endfunction

autocmd VimEnter * call OpenBuffergatorIfItsBufferExists()


Now when I start vim with vim -S path/to/session.vim the session is restored and saved when I exit, with a persistent buffer list on the left, and no errors during the session restore.


Originally posted at 2015-01-08 11:47:06+00:00. Automatically generated from the original post : apologies for the errors introduced.


original post

-- Response ended

-- Page fetched on Mon May 27 00:05:04 2024