Tip 494 Printable Monobook Previous Next
created June 26, 2003 · complexity basic · author Hosup Chung · version 6.0
I used to define two different mapping for maximize and restore window. But I wanted a map that can toggle between them. So, I came up with this function. This function assumes you are using win32 version of gvim. If you are using different version, then substitute :simlat ~[rx] by the key combination for your window manager.
Add following lines to your vimrc.
let w:windowmaximized = 0
function! MaxRestoreWindow()
if w:windowmaximized == 1
let w:windowmaximized = 0
" restore the window
:simalt ~r
else
let w:windowmaximized = 1
" maximize the window
:simalt ~x
endif
endfunction
map <F5> :call MaxRestoreWindow()<CR>
See also[]
- Maximize_or_set_initial_window_size for other systems
Comments[]
I thought window scope should be used in this case, but it doesn't work when a window has multiple screen. It seems working with global variable.
let g:WindowMaximized = 0
function! MaxRestoreWindow()
if g:WindowMaximized == 1
let g:WindowMaximized = 0
" restore the window
:simalt ~r
else
let g:WindowMaximized = 1
" maximize the window
:simalt ~x
endif
endfunction