(Uploaded by JohnBot from a locally edited file) |
(Move categories to tip template) |
||
Line 9: | Line 9: | ||
|version=6.0 |
|version=6.0 |
||
|rating=15/10 |
|rating=15/10 |
||
+ | |category1= |
||
+ | |category2= |
||
}} |
}} |
||
I frequently have multiple windows open in Vim -- this reduces the number of lines each window displays -- i almost always have my windows either all the same size or the current one as big as possible. the following function can be toggled on or off by typing <Leader>max (i can do this quite quickly); just change the mapping at the bottom to something else if you prefer. this causes the current window to be as big as possible (moving into another window causes that one to become big) and all the others get very small. i actually use this ALL the time. turning it off (by typing the hotkey sequence again) will cause all windows to have the same height. |
I frequently have multiple windows open in Vim -- this reduces the number of lines each window displays -- i almost always have my windows either all the same size or the current one as big as possible. the following function can be toggled on or off by typing <Leader>max (i can do this quite quickly); just change the mapping at the bottom to something else if you prefer. this causes the current window to be as big as possible (moving into another window causes that one to become big) and all the others get very small. i actually use this ALL the time. turning it off (by typing the hotkey sequence again) will cause all windows to have the same height. |
Revision as of 11:16, 24 April 2008
created October 11, 2001 · complexity basic · author Salman Halim · version 6.0
I frequently have multiple windows open in Vim -- this reduces the number of lines each window displays -- i almost always have my windows either all the same size or the current one as big as possible. the following function can be toggled on or off by typing <Leader>max (i can do this quite quickly); just change the mapping at the bottom to something else if you prefer. this causes the current window to be as big as possible (moving into another window causes that one to become big) and all the others get very small. i actually use this ALL the time. turning it off (by typing the hotkey sequence again) will cause all windows to have the same height.
"toggles whether or not the current window is automatically zoomed function! ToggleMaxWins () if exists ('g:windowMax') au! maxCurrWin exe "normal \<c-w>=" unlet g:windowMax else augroup maxCurrWin " au BufEnter * exe "normal \<c-w>_\<c-w>\<bar>" " " only max it vertically au! BufEnter * exe "normal \<c-w>_" augroup END do maxCurrWin BufEnter let g:windowMax=1 endif endfunction map <Leader>max :call ToggleMaxWins ()<CR>
Comments
Note that the essential Vim commands are <c-_> which maximizes the current window by making all of the other windows 1-line high. And <c-=> which makes all window sizes the same.
The script just makes it easier to toggle.
I just like not having to explicitly maximize the current window every time. i never said it couldn't be done by hand at will. i just frequently have four or five source windows open and it's easier to just have them become bigger automatically.
I noticed that the bufenter commands only happen when moving from one buffer to another (in a different window) -- if you have two windows with the same buffer, the bufenter commands don't get triggered and the zooming doesn't happen. to make it happen for all WINDOWS, change all the above BufEnter occurrences to WinEnter.
For info on <leader> see :help mapleader.