Vim Tips Wiki
(Insert subpage argument (where new tip discussed))
(Adjust previous/next navigation)
Line 2: Line 2:
 
|id=1536
 
|id=1536
 
|previous=1535
 
|previous=1535
|next=1537
+
|next=1538
 
|created=December 3, 2007
 
|created=December 3, 2007
 
|complexity=basic
 
|complexity=basic

Revision as of 10:07, 2 December 2008

Tip 1536 Printable Monobook Previous Next

created December 3, 2007 · complexity basic · author AOYAMA Shotaro · version 6.0


When I do :cw, a quickfix window opens with a 10-line height, even when the number of errors is 1 or 2. I think it's a waste of window space.

So I wrote the following code in my vimrc. With it, a quickfix window height is automatically adjusted to fit its contents (maximum 10 lines).

au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
  exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
endfunction

Of course, this function can be applied to other windows besides the quickfix window.

If you feel it's too tight, you may want to replace line("$") with line("$")+1.

Comments