Fandom

Vim Tips Wiki

Maximize or restore window

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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 alsoEdit

CommentsEdit

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

Also on Fandom

Random Wiki