Skip to content

Instantly share code, notes, and snippets.

@aaronj1335
Created August 13, 2012 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronj1335/3344031 to your computer and use it in GitHub Desktop.
Save aaronj1335/3344031 to your computer and use it in GitHub Desktop.
vimscript that maximizes the current window without resizing the quickfix window
" this just sets the current window to the specified number
"
" i think this is what really slows things down
function SetCurWinNr(tot, nr)
exe a:tot . ' winc k'
if a:nr > 1
exe (a:nr-1) . ' winc j'
endif
endfunction
" this maximizes the current window without resizing the quickfix window
function MaximizeWithoutResizingQuickfix()
" disable stuff to make this faster
set lazyredraw
set ei=WinEnter
let qfwinnr = -1 " quickfix window number
let tot = 0 " total number of windows
let curwinnr = winnr() " current window number
" this uses the one loop to get the quickfix window number and the total
" number of windows
windo let qfwinnr = getbufvar(winbufnr(winnr()), "&buftype") == "quickfix"? winnr() : -1 | let tot += 1
" :windo sets the current window to the last one, so go back to where we
" started
call SetCurWinNr(tot, curwinnr)
" we only need to do anything if we're NOT entering the quickfix window
if qfwinnr != curwinnr
" maximize this window
winc _
if qfwinnr > -1
let qfheight = winheight(qfwinnr)
call SetCurWinNr(tot, qfwinnr)
exe 'resize ' . qfheight
call SetCurWinNr(tot, curwinnr)
endif
endif
" re-enable stuff
set ei-=WinEnter
set nolazyredraw
endfunction
if !exists("*SetCurWinNr")
function SetCurWinNr(tot, nr)
exe a:tot . ' winc k'
if a:nr > 1
exe (a:nr-1) . ' winc j'
endif
endfunction
endif
if !exists("*MaximizeWithoutResizingQuickfix")
function MaximizeWithoutResizingQuickfix()
" disable stuff to make this faster
let g:jshint_disabled=1
set lazyredraw
set ei=WinEnter
let qfwinnr = -1
let tot = 0
let curwinnr = winnr()
windo let qfwinnr = getbufvar(winbufnr(winnr()), "&buftype") == "quickfix"? winnr() : -1 | let tot += 1
if qfwinnr > -1
let qfheight = winheight(qfwinnr)
endif
" this takes us back to the original window
call SetCurWinNr(tot, curwinnr)
if qfwinnr != curwinnr
" maximize this window
winc _
if qfwinnr > -1
call SetCurWinNr(tot, qfwinnr)
exe 'resize ' . qfheight
call SetCurWinNr(tot, curwinnr)
endif
" re-enable stuff
set ei-=WinEnter
set nolazyredraw
let g:jshint_disabled=0
endif
endfunction
endif
@aaronj1335
Copy link
Author

the whole purpose of this script is to maximize the current window without touching the quickfix window. if there's a better way, i'd love to hear it.

@dahu
Copy link

dahu commented Aug 14, 2012

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