这个是附件, 你可以不用管的
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@
" Last change: 2008 Jul 02
"
" To use it, copy it to
"
for Unix and OS/2:
~/.vimrc
"
for Amiga:
s:.vimrc
"
for MS-DOS and Win32:
$VIM\_vimrc
"
for OpenVMS:
sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
" allow backspacing over everything in insert mode
if has("vms")
set nobackup
" do not keep a backup file, use versions instead
else
set backup
" keep a backup file
endif
:let mapleader = ","
:let loaded_winmanager = 1
:let Tlist_Show_One_File=1
:let Tlist_Auto_Open=1
:let Tlist_Exit_OnlyWindow=1
:let Tlist_Use_Right_window=1
:let showmarks_enable=1
:let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
:let showmarks_ignore_type = "hqm"
:let showmarks_hlline_lower = 1
:let showmarks_hlline_upper = 1
:set backspace=indent,eol,start
:set nocompatible
:set guioptions+=b
:set noswapfile
:set matchpairs=(:),{:},[:],<:>
:set completeopt=longest,menu
:set comments=s1:/*,mb:*,ex:*/
:set formatoptions=qro
:set cmdheight=3
:set fo=croq
:set nu
:set nocp
:set makeprg=nmake.exe
:set showmatch
:set matchtime=10
:set nowrap
:set sidescroll=10
:set listchars=tab:>-,trail:-
:set softtabstop=4
:set cindent shiftwidth=4
:set history=50
" keep 50 lines of command line history
:set ruler
" show the cursor position all the time
:set showcmd
" display incomplete commands
:set incsearch
" do incremental searching
:set formatlistpat=1
:set path+=c:\SinaProject\Demo\Inc,c:\SinaProject\Demo\sdk
:map <F12> <Esc>:cs add C:\SinaProject\cscope.out<CR>
:map <F11> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q<CR>
:imap () ()<Left>
:imap [] []<Left>
:imap {} {}<Left>
:imap "" ""<Left>
:imap <> <><Left>
:vmap <silent> <unique> <Leader>cr <Plug>CRV_CRefVimVisual
:nmap <silent> <unique> <Leader>cr: C:\gVim\vimfiles\plugin\crefvim.vim
:map <silent> <unique> <Leader>cw <Plug>CRV_CRefVimAsk
:map <silent> <unique> <Leader>cc <Plug>CRV_CRefVimInvoke
:inoremap <C-U> <C-G>u<C-U>
:autocmd FileType c,cpp
setl fdm=syntax | setl fen
:colorscheme evening
:filetype plugin on
:filetype indent on
:highlight Comment ctermfg=green guifg=green
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
" CTRL-U in insert mode deletes a lot.
Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" 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
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'-:special:1:-") <= line("$") |
\
exe "normal! g`-:special:1:-" |
\ endif
augroup END
else
set autoindent
" always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
"功能说明:加入或删除注释//
"映射和绑定
nmap <F2> <Esc>:Setcomment<CR>
imap <F2> <Esc>:Setcomment<CR>
vmap <F2> <Esc>:SetcommentV<CR>
command! -nargs=0 Setcomment call s:SET_COMMENT()
command! -nargs=0 SetcommentV call s:SET_COMMENTV()
"非视图模式下所调用的函数
function! s:SET_COMMENT()
let lindex=line(".")
let str=getline(lindex)
"查看当前是否为注释行
let CommentMsg=s:IsComment(str)
call s:SET_COMMENTV_LINE(lindex,CommentMsg[1],CommentMsg[0])
endfunction
"视图模式下所调用的函数
function! s:SET_COMMENTV()
let lbeginindex=line("'<") "得到视图中的第一行的行数
let lendindex=line("'>") "得到视图中的最后一行的行数
let str=getline(lbeginindex)
"查看当前是否为注释行
let CommentMsg=s:IsComment(str)
"为各行设置
let i=lbeginindex
while i<=lendindex
call s:SET_COMMENTV_LINE(i,CommentMsg[1],CommentMsg[0])
let i=i+1
endwhile
endfunction
"设置注释
"index:在第几行
"pos:在第几列
"comment_flag: 0:添加注释符 1:删除注释符
function! s:SET_COMMENTV_LINE( index,pos, comment_flag )
let poscur = [0, 0,0, 0]
let poscur[1]=a:index
let poscur[2]=a:pos+1
call setpos(".",poscur) "设置光标的位置
if a:comment_flag==0
"插入//
exec "normal! i//"
else
"删除//
exec "normal! xx"
endif
endfunction
"*******************************************************
"查看当前是否为注释行并返回相关信息
"str:一行代码
function! s:IsComment(str)
let ret= [0, 0] "第一项为是否为注释行(0,1),第二项为要处理的列,
let i=0
let strlen=len(a:str)
while i<strlen
"空格和tab允许为"//"的前缀
if !(a:str[i]==' ' || a:str[i] == ' ' )
let ret[1]=i
if a:str[i]=='/' && a:str[i+1]=='/'
let ret[0]=1
else
let ret[0]=0
endif
return ret
endif
let i=i+1
endwhile
return [0,0] "空串处理
endfunction
"******************************************************
"Locate and return character "above" current cursor position...
function! LookUpwards()
"Locate current column and preceding line from which to copy...
let column_num
= virtcol('.')
let target_pattern
= '\%' . column_num . 'v.'
let target_line_num = search(target_pattern . '*\S', 'bnW')
"If target line found, return vertically copied character...
if !target_line_num
return ""
else
return matchstr(getline(target_line_num), target_pattern)
endif
endfunction
"Reimplement CTRL-Y within insert mode...
imap <silent>
<C-Y>
<C-R><C-R>=LookUpwards()<CR>
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
[
本帖最后由 BlueGuy 于 2010-5-27 18:55 编辑 ]