为了以后不再从头开始配置我的vim,我把当前的_vimrc贴在这里,挺乱的,以后慢慢整理吧,分分类,加上注释,并随着时间的延续,希望能成为适合自己习惯并有自己风格的一份详尽的vim配置文件。希望大家也把具有自己风格的vimrc贴出来,这样我们就可以为别人提供丰富的vimrc模板,别人直接拷回去用即可,不必费劲心思地研究vimrc怎么写。随着这样的模板越来越多,相信任何一个人都能从中找到适合自己的那个模板。

set nocompatible
source $VIMRUNTIME
/vimrc_example.vim
source $VIMRUNTIME
/mswin.vim
behave mswin

set diffexpr
=MyDiff()

function MyDiff()
  let opt 
= '-a --binary '
  
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 
= v:fname_in
  
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 
= v:fname_new
  
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 
= v:fname_out
  
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq 
= ''
  
if $VIMRUNTIME =~ ' '
    
if &sh =~ '\<cmd'
      let cmd 
= '""' . $VIMRUNTIME . '\diff"'
      let eq 
= '"'
    
else
      let cmd 
= substitute($VIMRUNTIME, ' ''''') . '\diff"'
    endif
  
else
    let cmd 
= $VIMRUNTIME . '\diff'
  endif
  silent execute 
'!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction


" Added by Soli
""""""""""""""""""""""""""""""""""""""""""""

" SVR -- a Smart Vim rc file
"
 LastModified: 2007 十月 11 0:28:59
"
 Maintainer: Soli <soli163@163.com>
""""""""""""""""""""""""""""""""""""""""""""

" General 

set nobackup
set noswapfile
set nowb

set helplang
=cn

"Sets how many lines of history VIM har to remember
set history=400

"Enable filetype plugin
filetype on
filetype plugin on
filetype indent on

"Set to auto read when a file is changed from the outside
set autoread

set autochdir

"Have the mouse enabled all the time:
set mouse=a

"Do not redraw, when running macros.. lazyredraw
set lz

let Tlist_Ctags_Cmd
="'D:\Program Files\Vim\CTags\ctags.exe'"
""""""""""""""""""""""""""""""""""""""""""""

""""""""""""""""""""""""""""""""""""""""""""
" About GUI

if has("gui_running")
  set guioptions
-=T
else
  set background
=dark
  colorscheme zellner
endif

winpos 
200 110

set tabpagemax
=25
set showtabline
=1
"set spl=en_us spell

set nu

"Enable folding, I find it very useful
set foldenable
set nofen
set fdl
=0
set foldmethod
=syntax

set showmatch

"Always show current position
set ruler

"No sound on errors.
set noerrorbells
set novisualbell
set t_vb
=

"How many tenths of a second to blink
set mat=2

"Highlight search things
set hlsearch

"statusline
set laststatus=1
"Format the statusline
"
set statusline=\ %F%m%r%h\ %w\ %15(%c\ %l/%L:%p%%%)

noremap 
<C-Tab> <C-Pagedown>
inoremap 
<C-Tab> <C-Pagedown>

""""""""""""""""""""""""""""""""""""""""""""

""""""""""""""""""""""""""""""""""""""""""""
" About Command-line

"Turn on WiLd menu
set wildmenu

"The commandbar is 1 high
set cmdheight=1

""""""""""""""""""""""""""""""""""""""""""""

""""""""""""""""""""""""""""""""""""""""""""
" About Text

set autoindent
set cindent

set lbr

set tabstop
=4
set softtabstop
=4
set shiftwidth
=4

set expandtab
set smarttab

"Enable syntax hl
syntax enable

" Auto Complete
set completeopt=menuone

"Omni menu colors
hi Pmenu guibg=#c8c8c8 guifg=#000000 
hi PmenuSel guibg=#c8c8fa guifg=#646464

""""""""""""""""""""
" Some smart key mapping
inoremap <C-CR> <C-P>
inoremap 
<expr> <C-J> pumvisible()?"\<C-N>":"\<C-X><C-O>"
inoremap 
<expr> <C-K> pumvisible()?"\<C-P>":"\<C-K>"
inoremap 
<expr> <C-U> pumvisible()?"\<C-E>":"\<C-U>"

"inoremap ( ()<Left>
"
inoremap () ()<Left>
"
inoremap [ []<Left>
"
inoremap [] []<Left>
"
inoremap { {}<Left><CR><Up><End><CR>
"
inoremap {} {}<Left><CR><Up><End><CR>

"inoremap /** /**<CR><CR>*/<Up> 

" About FileType
"
autocmd BufEnter * call CHANGE_CURR_DIR()  " same as ':set autochdir'
autocmd BufRead 
*.c,*.cpp compiler gcc
autocmd BufRead 
*.tcl compiler tcl
autocmd BufRead 
*.java compiler javac

autocmd BufWritePre,FileWritePre [._]vimrc   ks
|call LastModified()|'s
""""""""""""""""""""""""""""""""""""""""""""

""""""""""""""""""""""""""""""""""""""""""""
" functions
function! CHANGE_CURR_DIR() 
let _dir 
= expand("%:p:h"
exec "cd " . _dir 
unlet _dir 
endfunction 

fun LastModified()
    let l 
= line("$")

    exe 
"1," . l . "s/[L]astModified: .*/LastModified:" .
        \ strftime(
" %Y %b %d %X")

endfun

" Added by Soli


Posted on 2007-09-06 01:24  Soli  阅读(4040)  评论(0编辑  收藏  举报