How do I set the default window size in vim?

You can set the 'lines' and 'columns' options in ~/.gvimrc (~/_gvimrc on Windows). E.g:

:set lines=35 columns=150

I don't recommend you do this in your vimrc, because setting those options in console Vim can have odd effects, if it works at all; the gvimrc is only loaded when gVim is started.


This page suggests adding the following to _vimrc for avoiding problems with console Vim:

if has("gui_running")
  " GUI is running or is about to start.
  " Maximize gvim window.
  set lines=999 columns=999
else
  " This is console Vim.
  if exists("+lines")
    set lines=50
  endif
  if exists("+columns")
    set columns=100
  endif
endif

Also, this SO question looks at how to remember the previous session's window size.