Monday, November 15, 2010

My VI configuration file

After a few years using Eclipse, I've gone back to VI. I actually use VIM, an extended version of the original VI.

I won't expand on the reasons, but I just find it simpler, faster, and less distracting than a graphical IDE like Eclipse.

I've experimented a bit and found that I'm able to better focus on writing code with VI in a single barebones 24x80 window, instead of spending time and energy clicking and moving around outline views and windows.

I use exuberant-ctags to navigate big codebases, and Google search as a richer replacement for code-assist.

After I used VI to show and write code in my ApacheCon demos, a few folks asked me for my VI configuration supporting syntax highlighting, auto-indenting and code navigation.

Here's my $HOME/.vimrc file. Nothing fancy, but I find it useful:

" vi-improved mode
set nocompatible

" cycle buffers without writing
set hidden

" backup while writing
set writebackup

" file completion
set wildmenu
set wildmode=list:longest

" update window title
set title

" display cursor location
set ruler

" display current command
set showcmd

" short message prompts
set shortmess=atI

" silent
set noerrorbells

" switch to current file's directory
set autochdir

" remember marks, registers, searches, buffer list
set viminfo='20,<50,s10,h,%

" keep a big history
set history=1000

" syntax highligting
syntax on

" auto smart code indent
set autoindent
filetype indent on
set smartindent
set smarttab
set tabstop=4
set softtabstop=4
set expandtab
set shiftwidth=4
set shiftround

" allow backspacing in insert mode
set backspace=indent,eol,start

" incremental search
set incsearch
set nohlsearch

" ignore case
set ignorecase
set smartcase

" restore last cursor position
function! RESTORE_CURSOR()
    if line("'\"") > 0 && line ("'\"") <= line("$")
        exe "normal! g'\""
autocmd BufReadPost * call RESTORE_CURSOR()

" navigate code using exuberant ctags
set tags=tags;$HOME
set tags+=$HOME/.vim/tags/cpp
set tags+=$HOME/.vim/tags/curl
set tags+=$HOME/.vim/tags/httpd
set tags+=$HOME/.vim/tags/libmozjs
set tags+=$HOME/.vim/tags/libxml2

Hope this helps.

No comments:

The postings on this site are my own and don’t necessarily represent positions, strategies or opinions of my employer IBM.