~/.vimrc

" changing line order can fuck things up
execute pathogen#infect()
if has("win32")
    language messages en
    behave mswin
    set nobackup nowritebackup noswapfile
    cd $USERPROFILE
    if has("gui_running")
        set guifont=Source_Code_pro:h11
        set guioptions-=T
    endif
endif

" Appearance
colorscheme solarized
set background=light
set cursorline colorcolumn=80
set hlsearch number
syntax on
highlight ShowTrailingWhitespace ctermbg=Red guibg=Red

" Indentation
set autoindent tabstop=4 shiftwidth=4
"set filetype plugin indent on

" Encoding
set encoding=utf-8 fileencoding=utf-8

" Status line
set laststatus=2 statusline=[%l,%v\ %P%M]\ %f\ %y%r%w[%{&ff}]

" Clears search highlight after pressing enter
nnoremap <silent> <CR> :noh<CR><CR>

set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//

File location

Linux: ~/.vimrc
Windows: \Users\username\vimrc

Plugins

UAC, and Configuring GVim on Windows 7

With all this new stuff about user access control (UAC), I tend to use Windows much more in the same way that I would use another Unix OS. The default UAC settings let us know each time we must use admin privileges to do something crazy on the computer.

Using Windows XP, it would be a pain to switch to an admin account everytime we want to do this crazy something. Because of this, I’m logged on admin full time when using XP, and I don’t like it. (If anyone knows another way, please tell me, or not because I won’t use it anymore). I’m glad this has changed. I think Vista also has this feature, but since it was Vista, I didn’t care.

All this to talk about Gvim‘s startup settings file, located under a system folder in Program Files. Under XP, I changed the settings right in this file. Of course, I would never do that under, say, Ubuntu — I have this file hidden right in the root of my home directory, as it is with pretty much any other software. Under 7, I was quickly reminded that I needed admin privileges to change it. “Good lord”, I thought to myself, “Not only Windows became more multi-user friendly, it even tells me to behave well!”. Good. Put your config files at home, you bastards.

Anyway, to change startup settings, I copied _vimrc from vim‘s folder into my home directory. To set font to Lucida Console, height 12, width 6.5:

set guifont=Lucida_Console:h12:w6.5

Backup and swap files are annoying:

set nobackup nowritebackup noswapfile

Also,

syntax on
colorscheme darkblue

Doc: http://www.vim.org/htmldoc/options.html

GVim on Windows 7 x64

EDIT: The latest installer works fine.

EDIT (2009-10-27): A way better solution is to use the x64 package of gVim from http://code.google.com/p/vim-win3264/. I say it’s way better because it adds diff with vim to the context menu when selecting 2 files, something I use really often. There is surely a way to add this one to the context menu using regedit, but I didn’t search for it.

After installing GVim on Windows 7 x64, we don’t get the useful edit with vim in the context menu.

Hack with registry:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
@="C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe \"%1\""