User:Int 80h/files/.gvimrc

.gvimrc

edit

My current gVim rc file.

" gVim rc file
"
" Maintainer:   Szymon 'Polemon' Bereziak <polemon@polemon.org>
" Last Change:  2012-10-05
" URL:          http://polemon.org
" Version:      0.6
"

" sane blinking pattern:
set guicursor=n-v-c:block-Cursor-blinkwait5000-blinkon2000-blinkoff100
set guicursor+=ve:ver35-Cursor-blinkwait5000-blinkon2000-blinkoff100
set guicursor+=o:hor50-Cursor-blinkwait5000-blinkon2000-blinkoff100
set guicursor+=i-ci:ver25-Cursor-blinkon0
set guicursor+=r-cr:hor20-Cursor-blinkon0
set guicursor+=sm:blocl-Cursor-blinkon0


" highlight current line
set cursorline

" set a nice font, pleasant for my eyes:
if has('gui_running')
  if has('gui_gtk2')
    set guifont=Terminus\ 12
  elseif has('xfontset')
    set guifont=Terminus-14
  else " this is usually Windows. (_gvimrc)
    set guifont=Consolas:h12:cDEFAULT
  endif
endif

" remove menubar and toolbar:
set guioptions-=m
set guioptions-=T

" add bottom scrollbar:
set guioptions+=b

" provide functions for changing font size
if has('gui_gtk2')
  let s:pattern = '^\(.* \)\([1-9][0-9]*\)$'
elseif has('xfontset')
  let s:pattern = '^\(.*-\)\([1-9][0-9]*\)$'
else
  let s:pattern = '^\(.*:.\)\([1-9][0-9]*\)\(:.*\)$'
endif

let s:minfontsize = 4
let s:maxfontsize = 24

function! AdjustFontSize(amount)
  if has('gui_running')
    let fontname = substitute(&guifont, s:pattern, '\1', '')
    let cursize = substitute(&guifont, s:pattern, '\2', '')
    let modifier = substitute(&guifont, s:pattern, '\3', '')
    let newsize = cursize + a:amount
 
    if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize)
      let newfont = fontname . newsize . modifier
      let &guifont = newfont
    endif
  else
    echoerr "You need to run the GTK2 version of Vim to use this function."
  endif
endfunction

" commands to change font size
command! LargerFont call AdjustFontSize(1)
command! SmallerFont call AdjustFontSize(-1)

" key bindings to change font size
nnoremap <silent><a-+> :call AdjustFontSize(1)<CR>
nnoremap <silent><a--> :call AdjustFontSize(-1)<CR>


Windows

edit

The file is tested, and works well in Windows XP and Windows 7.

When using Vim or gVim under Windows, .vimrc and .gvimrc must be renamed to _vimrc and _gvimrc respectively. The .vim folder is named vimfiles in Windows. All rc-files and the vimfiles folder are located in $HOME or %HOMEPATH%.

If you're a Windows XP user, you should make sure to have the Consolas font installed. The easiest way to get Consolas, is installing Microsoft PowerPoint Viewer 2007. You can download it for free from Microsoft.com

Consolas takes advantage of Microsofts ClearType technology. I therefore strongly recommend you enable ClearType. Consolas is not even nearly as well-defined with anti-aliasing disabled, than with enabled ClearType.