vim ~./vimrc
?
set nocompatible??????????????? ?"去掉有關vi一致性模式,避免以前版本的bug和局限 ? ?
set nu!????????????????????????????????????"顯示行號
set?guifont=Luxi/?Mono/?9?? "?設置字體,字體名稱和字號
filetype on???????????????????? ? ???? ??"檢測文件的類型 ? ??
set history=1000?????????? ????? ?"記錄歷史的行數
set background=dark???????? ?"背景使用黑色
syntax on???????????????????????????? ?? "語法高亮度顯示
set autoindent???????????????????????"vim使用自動對齊,也就是把當前行的對齊格式應用到下一行(自動縮進)
set cindent??????????????????????????? ?"(cindent是特別針對 C語言語法自動縮進)
set smartindent????????????????? ? "依據上面的對齊格式,智能的選擇對齊方式,對于類似C語言編寫上有用 ??
set tabstop=4????????????????????? ? "設置tab鍵為4個空格,
set shiftwidth?=4???????????????? ? "設置當行之間交錯時使用4個空格 ? ??
set?ai!????????????????????????????????????? "?設置自動縮進?
set showmatch??????????????????? ?"設置匹配模式,類似當輸入一個左括號時會匹配相應的右括號 ? ? ?
set guioptions-=T??????????????? ?"去除vim的GUI版本中得toolbar ??
set vb t_vb=????????????????????????? ? "當vim進行編輯時,如果命令錯誤,會發出警報,該設置去掉警報 ? ? ??
set ruler?????????????????????????????? ?? "在編輯過程中,在右下角顯示光標位置的狀態行 ? ??
set nohls?????????????????????????????? ?"默認情況下,尋找匹配是高亮度顯示,該設置關閉高亮顯示 ? ??
set incsearch?????????????????????? ?"在程序中查詢一單詞,自動匹配單詞的位置;如查詢desk單詞,當輸到/d時,會自動找到第一個d開頭的單詞,當輸入到/de時,會自動找到第一個以ds開頭的單詞,以此類推,進行查找;當找到要匹配的單詞時,別忘記回車?
set?backspace=2???????????"?設置退格鍵可用
?
set nocp??? "設置兼容
set expandtab?? "設置tab
set shiftwidth=4??? "設置tab的間隔
set tabstop=4?? "四個空格代表一個tab
set sts=4
set showmatch?? "在輸入括號時光標會短暫地跳到與之相匹配的括號處
set autoindent? "設置自動縮進
" set smartindent "設置智能縮進
set nowrap??? "設置自動換行
set tw=500
set lbr
set number? "設置是否顯示行
set guifont=Monospace\ 11? "設置字體大小
set encoding=utf-8? "設置編碼為utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,GB18030,cp936,big5,euc-jp,euc-kr,latin1
set helplang=cn "幫助中文支持
colorscheme tango "設置主體顏色
"set mouse=v " 設置粘貼和復制
?
"自動補全配置
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
?
" =================================進行Taglist的設置<Begin>============================
map <F3> :TlistToggle<CR>
"map <F3> :silent! Tlist<CR>???????????? "按下F3就可以呼出了
"let Tlist_Ctags_Cmd='/usr/bin/ctags'??? "因為我們放在環境變量里,所以可以直接執行
let Tlist_Use_Right_Window=1??????????? "讓窗口顯示在右邊,0的話就是顯示在左邊?
"let Tlist_Show_One_File=1?????????????? "讓taglist可以同時展示多個文件的函數列表
"let Tlist_File_Fold_Auto_Close=1??????? "非當前文件,函數列表折疊隱藏
"let Tlist_Exit_OnlyWindow=1???????????? "當taglist是最后一個分割窗口時,自動推出vim
"let Tlist_Process_File_Always=0???????? "是否一直處理tags.1:處理;0:不處理?
"let Tlist_Inc_Winwidth=0??????????????? "不是一直實時更新tags,因為沒有必要?
" =================================進行Taglist的設置<End>==============================
?
?
?
?
" ############################鍵盤映射設置區域###############################
map <F2> :NERDTreeToggle<CR>
map <F4> t :NERDTreeMirror<CR>
?
?
" 對應使用函數的配置
set guitablabel=%{ShortTabLabel()}
function ShortTabLabel ()
? let bufnrlist = tabpagebuflist (v:lnum)
? let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1])
? let filename = fnamemodify (label, ':t')
? return filename
endfunction
?
set tabline=%!MyTabLine()
function MyTabLine()
? let s = ''
? for i in range(tabpagenr('$'))
??? " 選擇高亮
??? if i + 1 == tabpagenr()
????? let s .= '%#TabLineSel#'
??? else
????? let s .= '%#TabLine#'
??? endif
??? " 設置標簽頁號 (用于鼠標點擊)
??? let s .= '%' . (i + 1) . 'T'
??? " MyTabLabel() 提供完整路徑標簽 MyShortTabLabel 提供文件名標簽
??? let s .= ' %{MyShortTabLabel(' . (i + 1) . ')} '
? endfor
? " 最后一個標簽頁之后用 TabLineFill 填充并復位標簽頁號
? let s .= '%#TabLineFill#%T'
? " 右對齊用于關閉當前標簽頁的標簽
? if tabpagenr('$') > 1
??? let s .= '%=%#TabLine#%999Xclose'
? endif
? return s
endfunction
" 文件名標簽
function MyShortTabLabel(n)
? let buflist = tabpagebuflist(a:n)
? let label = bufname (buflist[tabpagewinnr (a:n) -1])
? let filename = fnamemodify (label, ':t')
? return filename
endfunction
"完整路徑標簽
function MyTabLabel(n)
? let buflist = tabpagebuflist(a:n)
? let winnr = tabpagewinnr(a:n)
? return bufname(buflist[winnr - 1])
endfunction
" vim 標簽樣式
"? TabLineFill? tab pages line, where there are no labels
hi TabLineFill term=none
hi TabLineFill ctermfg=DarkGrey
hi TabLineFill guifg=#777777
"? TabLineSel?? tab pages line, active tab page label
hi TabLineSel term=inverse
hi TabLineSel cterm=none ctermfg=yellow ctermbg=Black
hi TabLineSel gui=none guifg=yellow guibg=Black
?
" Develop editing options
au FileType vim setl expandtab
au FileType vim setl shiftwidth=2
au FileType vim setl tabstop=2
?
" 顯示狀態欄(默認值為 1,無法顯示狀態欄)
set laststatus=2
" Format the statusline
set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}E5%h\ \ \ Line:\ %l/%L:%c
?
function! CurDir()
??? let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
??? return curdir
endfunction
?
"#######################設置PHP函數自動提醒#########################Start
"設置字典自動完成
set complete+=k
"設置字典
set dictionary=~/.vim/doc/php_funclist.txt
" 自動完成使用TAB鍵
function! InsertTabWrapper()
??? let col=col('.')-1
??? if !col || getline('.')[col-1] !~ '\k'
??????? return "\<TAB>"
??? else
??????? return "\<C-N>"
??? endif
endfunction
"將InsertTabWrapper映射到TAB上
inoremap <TAB> <C-R>=InsertTabWrapper()<CR>
"#######################設置PHP函數自動提醒#########################End
?
?
"#######中括號 大括號 小括號 自動補全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
?
function ClosePair(char)
??? if getline('.')[col('.') - 1] == a:char
??????? return "\<Right>"
??? else
??????? return a:char
??? endif
endfunction
"#######中括號 大括號 小括號 自動補全