(Move categories to tip template) |
JohnBeckett (talk | contribs) m (Fix bad help template) |
||
Line 72: | Line 72: | ||
---- |
---- |
||
− | On RedHat Linux, I find it |
+ | On RedHat Linux, I find it inadvisable to set lines/columns=999. |
− | To maximize window: Alt-F10 |
+ | *To maximize window: Alt-F10 |
− | To restore window: Alt-F5 |
+ | *To restore window: Alt-F5 |
− | To maximize height within window size: Ctrl-w, Ctrl-_ |
+ | *To maximize height within window size: Ctrl-w, Ctrl-_ |
− | To maximize width within window size: Ctrl-w, Ctrl-| |
+ | *To maximize width within window size: Ctrl-w, Ctrl-| |
− | Resize window height to 45 lines: z45<Enter> |
+ | *Resize window height to 45 lines: z45<Enter> |
− | For more controls, see {{ |
+ | For more controls, see {{help|window-resize}} |
---- |
---- |
Revision as of 01:00, 26 April 2008
created January 17, 2006 · complexity basic · author Jang Junyeong · version 6.0
You can easily switch between the maximized and original window size using the following script. Unfortunately, this seems to work only in Win32 gvim.
F11: maximize/restore height
Shift-F11: maximize/restore width
Ctrl-F11: maximize/restore height and width
function ToggleWindowSize(act) if a:act < 0 || a:act > 2 | return | endif let posX = getwinposx() let posY = getwinposy() let actTab = "XXX__X_XR__XX_X__RRRR__R" let idx = ((exists("g:twsWM") + exists("g:twsHM") * 2) * 3 + a:act) * 2 let actW = strpart(actTab, idx, 1) let actH = strpart(actTab, idx + 1, 1) " note. g:tws + [Width,Height,X,Y] + [Maximized,Saved] if actW == "X" let g:twsWS = &columns | let g:twsXS = posX set columns=999 let posX = getwinposx() let g:twsWM = &columns | let g:twsXM = posX elseif actW == "R" if g:twsWM == &columns let &columns = g:twsWS if g:twsXM == posX | let posX = g:twsXS | endif endif unlet g:twsWM g:twsWS g:twsXM g:twsXS endif if actH == "X" let g:twsHS = &lines | let g:twsYS = posY set lines=999 let posY = getwinposy() let g:twsHM = &lines | let g:twsYM = posY elseif actH == "R" if g:twsHM == &lines let &lines = g:twsHS if g:twsYM == posY | let posY = g:twsYS | endif endif unlet g:twsHM g:twsHS g:twsYM g:twsYS endif execute "winpos " . posX . " " . posY endfunction nnoremap <F11> :call ToggleWindowSize(2)<CR> nnoremap <S-F11> :call ToggleWindowSize(1)<CR> nnoremap <C-F11> :call ToggleWindowSize(0)<CR> imap <F11> <C-O><F11> imap <S-F11> <C-O><S-F11> imap <C-F11> <C-O><C-F11>
Comments
The problem with something like lines=999 or columns=999 is that on some platforms (many Unix systems), the window is allowed to be arbitrarily large: it just won't fit on-screen and you won't be able to access it. In other words, it doesn't just assume that 999 means 'the largest size that will fit'.
On Windows, 999 makes the window as big as it can get, true, but it doesn't actually use the system maximize facility, forcing you to remember its previous size (the 'restore' size). A true maximize has the advantage that you don't need to remember the previous size: the operating system takes care of remembering the restoration point.
This points out the problems, but doesn't help outright, I realize. On Windows, the simalt mechanism seems to work for me. I use it to immediately maximize (true maximize) my GVim as soon as I start (I almost never work with an un-maximized window in most applications I use).
On RedHat Linux, I find it inadvisable to set lines/columns=999.
- To maximize window: Alt-F10
- To restore window: Alt-F5
- To maximize height within window size: Ctrl-w, Ctrl-_
- To maximize width within window size: Ctrl-w, Ctrl-|
- Resize window height to 45 lines: z45<Enter>
For more controls, see :help window-resize
See VimTip494.
I use the following mappings to change the size of my window (I believe these may only work on the Win32 version, see the help on simalt):
" maximize window size and make all split windows the same size map <unique> <Leader>mm <ESC>:simalt ~x<CR><C-W>= " maximize the window size map <unique> <Leader>mx <ESC>:simalt ~x<CR> " minimize the window size map <unique> <Leader>mn <ESC>:simalt ~n<CR> " restore the window size map <unique> <Leader>mr <ESC>:simalt ~r<CR>
On Windows, you can maximize by pressing Alt+Space then x.
However, it doesn't work when using UTF-8 as the character encoding.