DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Vim Configuration

05.05.2006
| 10958 views |
  • submit to reddit
        This is my .vimrc file -- configuration options for vim, the "vi improved" text editor for grown ups.

:autocmd!

set nohlsearch

" Press F2 to word-wrap a block of text. It's almost like using Word
" Star all over again.

map #2 !}fmt -65

" Personally, I wouldn't use a C++ keyword as a Java identifier, but
" if someone else does, I don't want an ugly display, so turn off
" flagging of this as an error:

let java_allow_cpp_keywords=1

set autoindent
set cmdheight=2

" Strewth, what a mess. Copied from the vim docs, if memory serves.

set comments=s:/*,mb:**,ex:*/,://,b:#,b:##,:%,:XCOMM,n:>,fb:-

set formatoptions=orc
set history=20
set incsearch
set ignorecase
set keywordprg=
set mouse=a
set mousehide
set mousemodel=popup_setpos
set nowrapscan
set path=.,/usr/include,/usr/local/include
set smartcase
set nosmartindent
set smarttab
set showmode
set textwidth=70
set viminfo='50,\"10000,n~/.viminfo
set wildchar=9
set wildignore+=*.class,*.pyc
set wildmenu

syntax on

:autocmd FileType *		set shiftwidth=4
:autocmd FileType xml,html	set shiftwidth=2
:autocmd FileType java,c,cc,cpp	set nocindent

set makeprg=ant

" Bleurgh! This makes sense of ant/jikes error messages so the ":make"
" command works. But, I ask you, how the f**k can anyone make sense of
" that mess?

set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,\%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#

" For the style of comments I like in 'C', C++ and Java.

autocmd BufNewFile,BufRead *.java set comments=s:/*,mb:**,ex:*/
autocmd BufNewFile,BufRead *.c set comments=s:/*,mb:**,ex:*/
autocmd BufNewFile,BufRead *.cc set comments=s:/*,mb:**,ex:*/