Shortround.net Articles

GVim on Windows

Notepad just doesn't cut it, so I tend to use vi for just about everything. This is just a quick write-up on how I get gVim installed on my Windows boxes. It sticks pretty closely to the way it's used on UNIX, but it has some "Windows-isms".

Get the gVim self-installer from the Vim Homepage and install it with default settings. You can remove the desktop shortcuts if you want, but otherwise the defaults are fine.

Environment Variables

You'll have to edit some environment variables to get gVim working correctly. The VIM environment variable points to the installation directory of gVim. The TEMP directory is for storing swap files so you aren't popping up swap files everywhere you go, which would make network shares fun to work with. The EDITOR environment variable allows programs like Subversion to pop up GVim when they need it.

%TEMP% = C:\TEMP
%PATH% = %PATH%;C:\Program Files\Vim\Vim63
%EDITOR% = gvim -f

VIMRC

Create the file: C:\Program Files\Vim\_vimrc and add the following. It should be commented well enough to understand what options you would like to keep. I've forgotten what a few of these do, but anyway this is the config I have.

" Break string VI compatibility
set nocompatible

" Syntax highlighting
if &t_Co > 2 || has("gui_running")
    syntax on
endif

" Formatting Options
set backspace=indent,eol,start  " Backspace over everything
set ts=4                        " Tab = 4 spaces
set autoindent                  " Auto Indenting
set vb                          " Visual Bell
set showmatch                   " Show matching brackets
set nowrap                      " Don't line wrap
set nolinebreak                 " Don't break lines
set noexpandtab                 " Don't expand tabs
set ruler                       " Show the ruler
set showcmd                     " ??
set shm =I                      " No startup message

" File options
set nobackup                    " Don't use a backup file
set dir=C:\temp                 " Put swaps in a single directory
set isfname =\                  " Support windows file names

" Text Formatting
hi comment gui=italic guifg=RoyalBlue2  " Highlight comments
hi NonText gui=NONE guifg=grey70        " Highlight non-text

" Highlight trailing whitespace
highlight WhitespaceEOL guifg=grey70 guibg=grey70
match WhitespaceEOL /s $/

" Use a better font
if has("gui_running")
    set gfn=Courier_new:h10
endif

" Set the shell to the windows command line
set shell=C:\windows\system32\cmd.exe

" Set selection, keyboard and mouse models to MS-Windows
behave mswin
set selectmode=

" CTRL-S for saving
noremap <C-S>   :update<CR>
vnoremap <C-S>  <C-C>:update<CR>
inoremap <C-S>  <C-O>:update<CR>

" Inverse Color Scheme
colorscheme desert

This was posted on Friday, July 25, 2008 at 16:17. It is filed under Windows.
It is licensed under the Creative Commons Attribution 3.0 Unported License. View the markdown for this article.