Vim Tips Wiki

Nice window resizing

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 669 Printable Monobook Previous Next

created March 2, 2004 · complexity basic · author Yada · version 5.7

" Map F1 for gvim window resizing.
" Put this snippet of code in your vimrc for nice window resizing.
" Press F1 key to toggle between the three settings.
nmap <F1> :call ResizeWindow()<CR>
imap <F1> <Esc><F1>a " for insert mode
function! ResizeWindow()
  if (has("gui_running"))
    if s:selectedsize == 1
      let s:selectedsize = 2
      set number
      set columns=88 " 88 is exactly 80 with :set number
      set lines=35
    elseif s:selectedsize == 2
      set number
      let s:selectedsize = 3
      set columns=98
      set lines=45
    else " old school console goodness
      let s:selectedsize = 1
      set nonumber
      set columns=80
      set lines=25
let s:selectedsize=1
call ResizeWindow()


"use own map, this is mine
map <M-right> <Esc>:resize +2 <CR>
map <M-left> <Esc>:resize -2 <CR>

This tip (669) was due to be deleted, but I am keeping it temporarily. After merging any useful info from here, this will be replaced with a redirect to a suitable tip.

Related tips (will merge some, and put 'see also' on remainder):

JohnBeckett 03:30, March 9, 2010 (UTC)

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.

Also on Fandom

Random Wiki