Wikia

Vim Tips Wiki

Changes: Maximize or restore window

Edit

Back to page

(Remove html character entities)
(see also for related tip (should we merge?) and add category)
 
Line 9: Line 9:
 
|version=6.0
 
|version=6.0
 
|rating=8/2
 
|rating=8/2
|category1=
+
|category1=Windows
 
|category2=
 
|category2=
 
}}
 
}}
Line 31: Line 31:
 
map <F5> :call MaxRestoreWindow()<CR>
 
map <F5> :call MaxRestoreWindow()<CR>
 
</pre>
 
</pre>
  +
  +
==See also==
  +
* [[Maximize_or_set_initial_window_size]] for other systems
   
 
==Comments==
 
==Comments==

Latest revision as of 02:38, July 29, 2009

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

Around Wikia's network

Random Wiki