blob: a78ed0c38ca7918723157f06ff2e1ee9be564c59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
" nedtree_workaroungs.vim - NERDTree and session restoration workarounds
"
" Author: Silvio Rhatto <rhatto@riseup.net>
"
" Ensure the window has maximized height
"
" This helps restoring the window size after reopening sessions after
" switching monitors (like from laptop screen to external HDMI monitor).
"
" https://superuser.com/questions/140419/how-to-start-gvim-maximized
" https://vim.fandom.com/wiki/Maximize_or_set_initial_window_size
set lines=999
" Fix NERDTree width
"
" Useful after restoring sessions between screen size changes (such
" as when you share sessions between different computers).
function FixNERDTreeWidth()
" Make sure NERDTree is focuses
execute ":NERDTreeFocus"
" Set a fixed width
execute ":vertical resize 30"
" Move to the left pane
wincmd l
endfunction
" In case you want to invoke FixNERDTreeWidth explicitly
command! -bang FixNERDTreeWidth :call FixNERDTreeWidth()
" Fix NERDTree width on all tabs
function FixAllNERDTreeWidths()
" Make sure to run this only once
if exists("did_fixed_nerdtree_widths")
return
endif
" Save the last active window
let l:current_win = win_getid()
tabdo :call FixNERDTreeWidth()
" Restore the active window
call win_gotoid(l:current_win)
" An additional, last move to the left pane
wincmd l
let dir_fixed_nerdtree_widths=1
endfunction
" Fix all NERDTree widths afert session load
augroup workaround
autocmd!
" This tends to fire for every buffer
autocmd workaround SessionLoadPost * call FixAllNERDTreeWidths()
" This seems to fire only once, but even when there's no session to be
" restored.
"autocmd workaround VimEnter * call FixAllNERDTreeWidths()
augroup END
|