Skip to content

Instantly share code, notes, and snippets.

@levibrown
Forked from juanpabloaj/AdjustWindowHeight.vim
Created October 11, 2013 21:36
Show Gist options
  • Save levibrown/6942409 to your computer and use it in GitHub Desktop.
Save levibrown/6942409 to your computer and use it in GitHub Desktop.
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
let l = 1
let n_lines = 0
let w_width = winwidth(0)
while l <= line('$')
" number to float for division
let l_len = strlen(getline(l)) + 0.0
let line_width = l_len/w_width
let n_lines += float2nr(ceil(line_width))
let l += 1
endw
exe max([min([n_lines, a:maxheight]), a:minheight]) . "wincmd _"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment