我的gVim配置文件
" {/ . .}
" ( (oo) )
" +-------------oOOo---︶︶︶︶---oOOo-------------+
" @author 木木(bluedjk@163.com) QQ:498937381
" @Last Change: 2010/04/05
" 沒有所謂的失敗,除非你自己不再嘗試,加油~!!!
" +-------------Oooo--------------------Oooo-------+
set nocompatible "去掉討厭的有關vi一致性模式,避免以前版本的一些bug和局限
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
if has("gui_running")
"設置編碼格式&幫助語言
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set helplang=cn,en
"解決菜單亂碼
set langmenu=chinese
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
endif
"字體設置
set guifont=Dejavu_Sans_Mono:h11:cANSI
"set gfn=YaHei\ Consolas\ Hybrid:h10
"set gfn=YaHei\ Consolas\ Hybrid:h11
"set guifontwide=YaHei\ Consolas\ Hybrid:h11
" set guifont=Courier_New:h11
" set guifontwide=YaHei\ Consolas\ Hybrid:h11
"if has("win32")
"set guifont=Courier_New:h12:cANSI
"set guifontwide=YouYuan:h12:cGB2312
"au GUIEnter simalt ~x
"elseif has("mac") || has("macunix")
" set guifont=Courier:h14
" set guifontwide=Hei_Regular:h14
" colorscheme tabula
"else
" set guifont=
" set guifontwide=
"endif
"設置窗口的起始位置和大小
winpos 300 200
"winpos 250 200
"set lines=22
set lines=30
set columns=100
"gvim啟動最大化
"autocmd GUIEnter simalt ~x
"Terminal(win下的終端)
if(has("win32") || has("win95") || has("win64") || has("win16"))
map <C-B> :!cmd <CR>
else
map <C-B> :!bash <CR>
endif
"colorscheme Murphy "配色方案
"colorscheme desert
"colorscheme inkpot
"colorscheme irblack
colorscheme koehler
"colorscheme wombat256
"set shortmess=atI "啟動的時候不顯示那個援助索馬里兒童的提示
"hi Comment ctermfg=DarkCyan "修改默認注釋顏色
syntax on "語法高亮
filetype on "偵測文件類型
filetype plugin on "載入文件類型插件
filetype indent on "為特定文件類型載入相關縮進文件
set showmatch "高亮顯示匹配的括號
set matchtime=2 "匹配括號高亮的時間(單位是十分之一秒)
set cmdheight=2 "命令行(在狀態行下)的高度,默認為1,這里是2
set noexpandtab "不要用空格代替制表符
set smarttab "在行和段開始處使用制表符
set wrap "自動換行顯示
set number "顯示行號兒
set report=0 "通過使用: commands命令,告訴我們文件的哪一行被改變過
set viminfo+=! "保存全局變量
set iskeyword+=,$,@,%,#,- "帶有如下符號的單詞不要被換行分割
set backspace=2 "使回格鍵(backspace)正常處理indent, eol, start等
set whichwrap+=<,>,h,l "允許backspace和光標鍵跨越行邊界
set linespace=1 "字符間插入的像素行數目
set wildmenu "增強模式中的命令行自動完成操作
set nolinebreak "不在單詞中間斷行
set showcmd "在狀態欄顯示目前所執行的指令,未完成的指令片段亦會顯示出來
set backspace=indent,eol,start "在insert模式下能用刪除鍵進行刪除
set completeopt=longest,menu "關掉智能補全時的預覽窗口,這樣可以防止閃屏現象
set textwidth=120 "設置最大列數,超出后自動換行
set history=400 "歷史記錄數
set autoread "當文件在外部被修改,自動更新該文件
set gdefault "行內替換
set clipboard+=unnamed "與windows共享剪貼板
set tabpagemax=40
"自動縮進
set autoindent " 繼承前一行的縮進方式,特別適用于多行注釋
set cindent " 使用C樣式的縮進
set smartindent "為C程序提供自動縮進
set expandtab
set foldmethod=marker
"Tab鍵的寬度
set tabstop=4
"統一縮進為4
set softtabstop=4
set shiftwidth=4
"關閉備份
set nobackup
set nowritebackup
set noswapfile
"搜索忽略大小寫
set ignorecase
"搜索逐字符高亮
set hlsearch
set incsearch
"設置語法折疊
set foldmethod=syntax
set foldcolumn=0 "設置折疊區域的寬度
set foldclose=all "設置為自動關閉折疊
"用空格鍵來開關折疊
set foldenable
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
"設定文件瀏覽器目錄為當前目錄
set bsdir=buffer
set autochdir
"讀文件時自動設定當前目錄為剛讀入文件所在的目錄
autocmd BufReadPost cd %:p:h
"不要生成swap文件,當buffer被丟棄的時候隱藏它
setlocal noswapfile
set bufhidden=hide
"先嘗試windows格式,再嘗試unix格式,然后嘗試mac格式
set fileformats=dos,unix,mac
"開啟底部滾動條
"set guioptions+=b
"Set magic on
set magic
"當有錯誤時不發出聲音
set flash
set noerrorbells
set novisualbell
set t_vb=
"使得注釋換行時自動加上前導的空格和星號
set formatoptions=tcqro
"在被分割的窗口間顯示空白,便于閱讀
"set fillchars=vert:\ ,stl:\ ,stlnc:\
"光標移動到buffer的頂部和底部時保持3行距離
set scrolloff=3
"可以在buffer的任何地方使用鼠標(類似office中在工作區雙擊鼠標定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"我的狀態行顯示的內容(包括文件類型和解碼)
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
"狀態欄設置:文件路徑、文件名、標記、文件類型、字符編碼、文件格式、當前位置、當前相對位置、文件總行數、日期、星期
"set statusline=%F\ %h%1%m%r%w%0[%{strlen(&filetype)?&filetype:'none'},%{&encoding},%{&fileformat}]%=%-14.(%l,%c%V%)\ %<%p%%\ \ \ [%L]\ \ \ %{strftime('%y-%m-%d\ %A')}
"在編輯過程中,在右下角顯示光標位置的狀態行
set ruler
set rulerformat=%20(%2%<%f%=\ %m%r\ %3l\ %c\ %p%%%)
"高亮鼠標位置
if has("gui_running")
"cursorline highlight(高亮當前行)
set cursorline
hi CursorLine guibg=#666666
hi CursorColumn guibg=#333333
"cursorcolumn highlight(高亮當前列)
"set cursorcolumn
"highlight CursorLine cterm=none ctermbg=2 ctermfg=0
endif
"進入插入模式時改變狀態欄顏色(僅限于Vim 7)
"總是顯示狀態行
set laststatus=2
if version >= 700
au InsertEnter hi StatusLine guibg=#818D29 guifg=#FCFCFC gui=none
au InsertLeave hi StatusLine guibg=#EEEEEE guifg=#363636 gui=none
endif
"用 Alt+n 切換 Vim 的標簽
function! TabPos_ActivateBuffer(num)
let s:count = a:num
exe "tabfirst"
exe "tabnext" s:count
endfunction
function! TabPos_Initialize()
for i in range(1, 9)
exe "map <M-" . i . "> :call TabPos_ActivateBuffer(" . i . ")<CR>"
endfor
exe "map <M-0> :call TabPos_ActivateBuffer(10)<CR>"
endfunction
autocmd VimEnter call TabPos_Initialize()
" 菜單欄和工具欄設置
"set guioptions=
"set guioptions-=m
"set guioptions-=T
map <silent> <F11> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>
\endif<CR>
"小菜單配置
source $VIMRUNTIME/menu.vim
set wildmenu
set cpo-=<
set wcm=<C-Z>
map <F6> :emenu <C-Z>
"tab設置
"set showtabline=2 "顯示tab
map tn :tabnext<cr>
map tp :tabprevious<cr>
map te :tabedit<cr>
map tc :tabclose<cr>
map bf :BufExplorer<cr>
"關掉智能補全時的預覽窗口
set completeopt=longest,menu
"==============================插件===========================
"jsbeautify
nnoremap <F4> :call g:Jsbeautify()<CR>
"html(讓html標簽是小寫)
let g:html_tag_case = "lowercase"
"snipMate(代碼提示)
"autocomplpop(代碼自動補全)
"omnicomplete
"autocmd FileType python set omnifunc=pythoncomplete#Complete
"autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
"autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
"autocmd FileType php set omnifunc=phpcomplete#CompletePHP
"autocmd FileType c set omnifunc=ccomplete#Complete
"minibufexpl
"ctrl+tab shift+ctrl+tab 切換緩沖區里的文件
"設置用Control + [hjkl]在緩沖區窗口移動
let g:miniBufExplorerMoreThanOne=0
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
map <Leader>t :TMiniBufExplorer<cr> "設置,t交替出現minibuffer窗口
"NERDTree 打開/關閉--文件目錄樹。
nmap <F3> :NERDTreeToggle<CR>
imap <F3> <C-O>:NERDTreeToggle<CR>
"winmanager的簡單配置 通過WinManager插件來將TagList窗口和netrw窗口(瀏覽文件)整合起來
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>
map <c-w><c-f> :FirstExplorerWindow<cr>
map <c-w><c-b> :BottomExplorerWindow<cr>
map <c-w><c-t> :WMToggle<cr>
"bufexplorer
"高亮的書簽 visualmark.vim
"用gvim打開源碼文件,將光標定位在需要添加書簽的地方,按下ctrl+F2,即添加了書簽
"使用F2在書簽之間正向切換,shift+F2反向切換
"ctags(這項必須設定,否則出錯,配置taglist的ctags路徑)
let Tlist_Ctags_Cmd = $VIM.'\vimfiles\plugin\ctags.exe'
set tags=tags;
set autochdir
"設置tags文件路徑
set tags=D:\tools\vimtags\tags
"TagList插件配置(需要安裝TagList插件)
"F7打開左側顯示當前文件的函數
nmap <F7> :Tlist<CR>
imap <F7> <C-O>:Tlist<CR>
"不同時顯示多個文件的tag,只顯示當前文件的
let Tlist_Show_One_File = 1
"如果taglist窗口是最后一個窗口,則退出vim
let Tlist_Exit_OnlyWindow = 1
"css3
au BufRead,BufNewFile .css set ft=css syntax=css3
"jquery
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
"""""""""""""""""""""代碼補全(Ctrl-x+Ctrl-o和Ctrl-x+Ctrl-p能實現相關的代碼補全,配置使得一個按鍵即可完成)"""""""""""""""""""""
"映射快捷鍵:<F5>實現Ctrl+x-Ctrl+o代碼補全,<F5>向下切換代碼補全,Alt+<F5>向上切換代碼補全
inoremap <expr> <F5> pumvisible()?"\<Down>":"\<C-X><C-O>"
inoremap <expr> <M-F5> pumvisible()?"\<Up>":"\<M-F5>"
"映射快捷鍵:<F6>實現Ctrl+x-Ctrl+p補全,<F6>向下切換補全,Alt+<F6>向上切換補全
"inoremap <expr> <F6> pumvisible()?"\<Down>":"\<C-X><C-P>"
"inoremap <expr> <M-F6> pumvisible()?"\<Up>":"\<M-F6>"
"設置全屏快捷鍵
map <F12> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
"VSTreeExplore
map <F9> :VSTreeExplore<cr>
map <F10> :x<cr>
map <F11> :q!<cr>