Created
August 13, 2012 20:56
-
-
Save aaronj1335/3344031 to your computer and use it in GitHub Desktop.
vimscript that maximizes the current window without resizing the quickfix window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.