A .vimrc Discussion
So, I’ve recently converted to using VIm. Textedit irritates me to no end, and I don’t want to pay money for Textmate. I decided I would post my .vimrc file up here and talk about it a little bit. For those who just want to read the file, it’s attached at the bottom of the post. Snippets of code follow, however.
map <space> /
All you VIm users out there know how to search for text – this enables me to search with the space bar, which feels more natural and quicker than having to type a special character.
set nocompatible set number set columns=80 set ruler set background=light set wrap! syntax enable
This turns off emulation of bugs from Vi, enables line numbers, restricts my window to 80 columns, displays some basic information about where I am on a line, tells VIm to use fonts optimized for a light background (corresponds with my terminal colors), turns off word wrap, and turns on syntax highlighting. These options are all configured for programming.
set showmatch set ignorecase set hlsearch set incsearch
This is extremely useful for searching in a file. The first line highlights matching braces, which is very nice for nested statements and complex conditionals. It also makes searching case-insensitive, highlights search matches, and starts searching with the first letter that you type. If you pay close attention when searching you only ever have to type the minimum amount of letters to find what you want. I find this greatly speeds up moving through a document.
set autoindent set smartindent set tabstop=4 set shiftwidth=4 set expandtab
These settings tell VIm what to do with tabs and indents. The first two lines tell the program to format indents according to the file type. As long as you’re using a C type language, this works extremely well. The second two lines tell VIm to use 4 spaces when the tab key is pressed, and the final line expands all tabs into spaces. This helps remove compatibility problems between tabs and spaces.
set vb t_vb=
This just turns off those pesky beeps when you enter an invalid command. Instead, the screen flashes for an instant. Much nicer in my opinion.
set gfn=BitStream\ Vera\ Sans\ Mono:h14
This sets the default font for the editor – Monaco Size 10. My current favorite programming font on OS X. Anyway, that’s a bit of a discussion about my .vimrc. The full file is below for anyone who wants to read the whole thing or copy/paste it for their own use.
".vimrc "Author: Eric Hertz "Date: 10.14.2009 " "This is a configuration file for VIm, the terminal text editor. Feel free "to use this however you wish. "Key mappings map <space> / "Interface settings set nocompatible set number set columns=80 set ruler set background=light set wrap! syntax enable "Search settings set showmatch set ignorecase set hlsearch set incsearch "Indent settings set autoindent set smartindent set tabstop=4 set shiftwidth=4 set expandtab "Audio settings set vb t_vb= "Font settings set gfn=BitStream\ Vera\ Sans\ Mono:h14
