My .vimrc
From xoa
Check out http://dotfiles.org/ for dozens more.
Also:
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
"============================================================================
" General settings
"----------------------------------------------------------------------------
set nocompatible " nocp: turn of vi compatibility
set undolevels=1000 " ul: lots and lots of undo
set history=50 " hi: size of :command history
set modelines=20
set modeline " ml: Turn on modelines
set ai " always set autoindenting on
set backup " keep a backup file
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
"============================================================================
" Colors
"----------------------------------------------------------------------------
set t_Sf=�[3%dm " set foreground (?)
set t_Sb=�[4%dm " set background (?)
"============================================================================
" Presentation
"----------------------------------------------------------------------------
set shortmess=aIoO " sm: really short messages, don't show intro
set showmode " smd: show the current input mode
set more " more: page on extended output
set errorbells " eb: ring bell on error messages
set novisualbell " novb: turn of visual bell
set noequalalways " noea: don't always keep windows at equal size
set splitbelow " sb: splitted window appears below current one
"============================================================================
" Statusline, Ruler
"----------------------------------------------------------------------------
set laststatus=2 " ls: always put a status line
set statusline=%([%-n]%y\ %f%M%R%)\ %=\ %(%l,%c%V\ %P\ [0x%02.2B]%)
"============================================================================
" Filename Autocompletion
"----------------------------------------------------------------------------
set wildchar=<Tab> " wc: tab does autocompletion
set wildmode=longest,list " wim: bash-style autocompletion
" wig: when autocompleting, ignore certain files
set wildignore=*~,#*#,*.sw?,*.o,*.class,*.java.html,*.cgi.html,*.html.html,.viminfo,*.pdf
"============================================================================
" Search and Replace
"----------------------------------------------------------------------------
set incsearch " is: show partial matches as search is entered
set hlsearch " hls: highlight search patterns
"set ignorecase " Ignore case distinction when searching
"set smartcase " ... unless there are capitals in the search string.
"============================================================================
" Tab standards
"----------------------------------------------------------------------------
set softtabstop=4
set shiftwidth=4
set shiftround " Shift to the next round tab stop
set expandtab
" Don't use Ex mode, use Q for formatting
map Q gq
" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
behave xterm
if &term == "xterm"
let &term = "xtermc"
" Restore the screen when we're exiting
set rs
set t_ti=�7�[r�[?47h
set t_te=�[?47l�8
endif
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
"============================================================================
" Autocommands
"----------------------------------------------------------------------------
" For all text files set 'textwidth' to 78 characters.
au FileType text setlocal tw=78
" *.t files are Perl test files
au FileType pl,pm,t set filetype=perl
" http://vimdoc.sourceforge.net/htmldoc/vimfaq.html
" 5.5. How do I configure Vim to open a file at the last edited location?
" Vim stores the cursor position of the last edited location for each buffer
" in the '"' register. You can use the following autocmd in your .vimrc or
" .gvimrc file to open a file at the last edited location:
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
autocmd FileType text call TextMode()
autocmd FileType mail call TextMode()
au BufNewFile,BufRead *.pl,*.pm,*.t setf perl
au BufNewFile,BufRead *.pmc,*.ops setf c
au BufNewFile,BufRead *.tt,*.ttml setf tt2html
autocmd FileType perl call PerlMode()
set showmatch " show matches on parens, bracketc, etc.
set matchpairs+=<:>
" Folding
set foldmethod=marker
let perl_fold=1
let perl_include_POD=1
set nofoldenable
"behave xterm
set background=dark
set autoindent
set cindent
set list listchars=tab:\|-,trail:.
set tags=./tags,./Tags,tags,~/parrot/tags
set backspace=indent,eol,start
" Stop the annoying behavior of leaving comments on far left
set fo+=r
au FileType vim set iskeyword+=. iskeyword+=/ iskeyword+=~
filetype on
syntax on
set showmode
" Don't do the auto-highlighting
" From :help matchparen
let loaded_matchparen=1
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
"============================================================================
" Abbreviations
"----------------------------------------------------------------------------
" imap udd {use Data::Dumper; local $Data::Dumper::Sortkeys=1;
print Dumper()}�hi
abbreviate udd {use Data::Dumper; local $Data::Dumper::Sortkeys=1;
print Dumper()}�hi
"============================================================================
" Functions
"----------------------------------------------------------------------------
function! TextMode() " Stolen from David Hand
set nocindent " nocin: don't use C-indenting
set nosmartindent " nosi: don't "smart" indent, either
set autoindent " ai: indent to match previous line
set noshowmatch " nosm: don't show matches on parens, brackets, etc.
set comments=n:>,n:#,fn:- " com: list of things to be treated as comments
set textwidth=72 " tw: wrap at 72 characters
set formatoptions=tcrq " fo: word wrap, format comments
set dictionary+=/usr/local/dict/* " dict: dict for word completion
set complete=.,w,b,u,t,i,k " cpt: complete words
endfunction
function! PerlMode() " Stolen from David Hand
set shiftwidth=4 " sw: a healthy tab stop
set textwidth=72 " tw: wrap at 72 characters
set autoindent " ai: indent to match previous line
set cindent " cin: Use C-indenting
set cinkeys=0{,0},!^F,o,O,e " cink: Perl-friendly reindent keys
set cinoptions=t0,+4,(0,)60,u0,*100 " cino: all sorts of options
set cinwords=if,else,while,do,for,elsif,sub
set comments=n:# " com: Perlish comments
set formatoptions=crql " fo: word wrap, format comments
set nosmartindent " nosi: Smart indent useless when C-indent is on
set showmatch " show matches on parens, bracketc, etc.
endfunction
