Skip to content

Instantly share code, notes, and snippets.

@philipmat
Created December 6, 2011 09:21
Show Gist options
  • Save philipmat/1437522 to your computer and use it in GitHub Desktop.
Save philipmat/1437522 to your computer and use it in GitHub Desktop.
Vim session with set sessionoptions="buffers,sesdir,folds,tabpages"
let SessionLoad = 1
if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
silent only
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +2 C:\temp\file1.txt
badd +0 C:\temp\file2.txt
badd +3 C:\temp\file3.txt
badd +2 C:\temp\file4.txt
badd +0 C:\temp\file5.txt
silent! argdel *
edit C:\temp\file3.txt
set splitbelow splitright
wincmd _ | wincmd |
split
1wincmd k
wincmd w
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
wincmd =
argglobal
let s:l = 1 - ((0 * winheight(0) + 15) / 31)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
lcd C:\temp
wincmd w
argglobal
edit C:\temp\file4.txt
let s:l = 2 - ((1 * winheight(0) + 15) / 31)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
2
normal! 03l
lcd C:\temp
wincmd w
argglobal
edit C:\temp\file5.txt
let s:l = 2 - ((1 * winheight(0) + 15) / 31)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
2
normal! 03l
lcd C:\temp
wincmd w
3wincmd w
wincmd =
if exists('s:wipebuf')
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=filnxtToO
let s:sx = expand("<sfile>:p:r")."x.vim"
if file_readable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &so = s:so_save | let &siso = s:siso_save
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :
let SessionLoad = 1
if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
silent only
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +2 ~/tmp/ssop/file1.txt
badd +2 ~/tmp/ssop/file2.txt
badd +3 ~/tmp/ssop/file3.txt
badd +2 ~/tmp/ssop/file4.txt
badd +0 ~/tmp/ssop/file5.txt
silent! argdel *
edit ~/tmp/ssop/file3.txt
set splitbelow splitright
wincmd _ | wincmd |
split
1wincmd k
wincmd w
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
wincmd t
set winheight=1 winwidth=1
wincmd =
argglobal
let s:l = 3 - ((2 * winheight(0) + 23) / 47)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
3
normal! 0
lcd ~/tmp/ssop
wincmd w
argglobal
edit ~/tmp/ssop/file4.txt
let s:l = 2 - ((1 * winheight(0) + 23) / 47)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
2
normal! 03l
lcd ~/tmp/ssop
wincmd w
argglobal
edit ~/tmp/ssop/file5.txt
let s:l = 1 - ((0 * winheight(0) + 23) / 47)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 05l
lcd ~/tmp/ssop
wincmd w
3wincmd w
wincmd =
if exists('s:wipebuf')
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=filnxtToO
let s:sx = expand("<sfile>:p:r")."x.vim"
if file_readable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &so = s:so_save | let &siso = s:siso_save
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :
@philipmat
Copy link
Author

Files in ~/tmp/ssop/ created with for i in $(jot 5) ; do touch ~/tmp/ssop/file$i.txt ; done
Split was: tab #1 vsplit file1 - left, file 2 right; tab #2 split file 3 top, vsplit file 4 left, file 5 right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment