首頁 > Linux&FreeBSD > 我的 vim 設定配置

我的 vim 設定配置

調了好久,統整好的vim設定終於完成。(有更新設定)

我的vim 設定檔,存放在~/.vimrc :

set nocompatible
colorscheme asmanian2
“colorscheme elflord
syntax on
set hls
set ls=2
set cursorline
set nu
set ai
set softtabstop=4
set shiftwidth=4
set ic
set t_Co=256
let g:AutoComplPop_IgnoreCaseOption=1
“let g:acp_completeOption = ‘.,t,i,b’
set ignorecase
set statusline=%<%f\ %m%=\ %h%r\ %-19([%p%%]\ %3l,%02c%03V%)%y
" Can edit big5
set fileencodings=utf-8,big5,gbk,sjis,euc-jp,euc-kr,utf-bom,iso8859-1
set encoding=utf-8
set termencoding=utf-8
highlight Cursorline ctermfg=none ctermbg=none cterm=none
highlight TabLineSel ctermfg=yellow ctermbg=darkblue cterm=bold
highlight StatusLine ctermfg=yellow ctermbg=darkblue cterm=bold
highlight LineNr ctermfg=yellow
" configure tags – add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/cpp
“set tags+=~/.vim/tags/gl
“set tags+=~/.vim/tags/sdl
“set tags+=~/.vim/tags/qt4
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
let OmniCpp_DefaultNamespaces = [“std", “_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
" Set F12 to use ctags for C++
map <F12> :!ctags -R –c++-kinds=+p –fields=+iaS –extra=+q .<CR>
setl omnifunc=nullcomplete#Complete
autocmd FileType * setl omnifunc=nullcomplete#Complete
autocmd FileType python setl omnifunc=pythoncomplete#Complete
autocmd FileType javascript setl omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html setl omnifunc=htmlcomplete#CompleteTags noci
autocmd FileType css setl omnifunc=csscomplete#CompleteCSS noci
autocmd FileType xml setl omnifunc=xmlcomplete#CompleteTags
autocmd FileType php setl omnifunc=phpcomplete#CompletePHP
autocmd FileType c setl omnifunc=ccomplete#Complete
" Set completement for C++
autocmd FileType h setl omnifunc=cppcomplete#Complete
autocmd FileType cpp setl omnifunc=cppcomplete#Complete
" Set F2 as nohls
map <silent> <F2> <ESC>:nohls<CR>
map <silent> <F4> <ESC>:qa<CR>
map <silent> <F5> <ESC>:wa<CR>
map <C-t>l <ESC>:tabnext<CR>
map <C-t>h <ESC>:tabprev<CR>
map <C-t>n <ESC>:tabnew<CR><ESC>:e
map <C-t>c <ESC>:tabclose<CR>
" Set F9 for Tlist
map <silent> <F9> :TlistToggle<cr>
“"""""""""""""""""""""""""""""
" Tag list (ctags)
“"""""""""""""""""""""""""""""
let Tlist_Ctags_Cmd = ‘/usr/bin/ctags’
let Tlist_Show_One_File = 1            “不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1          “如果taglist窗口是最后一个窗口,则退出vim
“"""""""""""""""""""""""""""""
" BufExplorer
“"""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0       " Do not show default help.
let g:bufExplorerShowRelativePath=1  " Show relative paths.
let g:bufExplorerSortBy=’mru’        " Sort by most recently used.
let g:bufExplorerSplitRight=0        " Split left.
let g:bufExplorerSplitVertical=1     " Split vertically.
let g:bufExplorerSplitVertSize = 30  " Split width
let g:bufExplorerUseCurrentWindow=1  " Open in new window.
autocmd BufWinEnter \[Buf\ List\] setl nonumber
“"""""""""""""""""""""""""""""
" winManager setting
“"""""""""""""""""""""""""""""
let g:winManagerWindowLayout = “BufExplorer,FileExplorer|TagList"
let g:winManagerWidth = 30
let g:defaultExplorer = 0
nmap <C-W><C-F> :FirstExplorerWindow<cr>
nmap <C-W><C-B> :BottomExplorerWindow<cr>
nmap <silent> <F8> :WMToggle<cr>
nmap <silent> <F7> :cw 10 <cr>
“""""""""""""""""""""""""""""
" Cscope setting
“""""""""""""""""""""""""""""
nmap <C-@>s :cs find s <C-R>=expand(“<cword>")<CR><CR>
nmap <C-@>g :cs find g <C-R>=expand(“<cword>")<CR><CR>
nmap <C-@>c :cs find c <C-R>=expand(“<cword>")<CR><CR>
nmap <C-@>t :cs find t <C-R>=expand(“<cword>")<CR><CR>
nmap <C-@>e :cs find e <C-R>=expand(“<cword>")<CR><CR>
nmap <C-@>f :cs find f <C-R>=expand(“<cfile>")<CR><CR>
nmap <C-@>i :cs find i ^<C-R>=expand(“<cfile>")<CR>mce_markerlt;CR>
nmap <C-@>d :cs find d <C-R>=expand(“<cword>")<CR><CR>
if has(“cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable(“cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != “"
cs add $CSCOPE_DB
endif
set csverb
set cscopetag
set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif

set nocompatiblecolorscheme asmanian2″colorscheme elflordsyntax onset hlsset ls=2set cursorlineset nuset aiset softtabstop=4set shiftwidth=4set icset t_Co=256let g:AutoComplPop_IgnoreCaseOption=1″let g:acp_completeOption = ‘.,t,i,b’set ignorecaseset statusline=%<%f\ %m%=\ %h%r\ %-19([%p%%]\ %3l,%02c%03V%)%y" Can edit big5set fileencodings=utf-8,big5,gbk,sjis,euc-jp,euc-kr,utf-bom,iso8859-1set encoding=utf-8set termencoding=utf-8
highlight Cursorline ctermfg=none ctermbg=none cterm=nonehighlight TabLineSel ctermfg=yellow ctermbg=darkblue cterm=boldhighlight StatusLine ctermfg=yellow ctermbg=darkblue cterm=boldhighlight LineNr ctermfg=yellow" configure tags – add additional tags here or comment out not-used onesset tags+=~/.vim/tags/cpp"set tags+=~/.vim/tags/gl"set tags+=~/.vim/tags/sdl"set tags+=~/.vim/tags/qt4
" OmniCppCompletelet OmniCpp_NamespaceSearch = 1let OmniCpp_GlobalScopeSearch = 1let OmniCpp_ShowAccess = 1let OmniCpp_MayCompleteDot = 1let OmniCpp_MayCompleteArrow = 1let OmniCpp_MayCompleteScope = 1let OmniCpp_DefaultNamespaces = [“std", “_GLIBCXX_STD"]" automatically open and close the popup menu / preview windowau CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endifset completeopt=menuone,menu,longest,preview" Set F12 to use ctags for C++map <F12> :!ctags -R –c++-kinds=+p –fields=+iaS –extra=+q .<CR>
setl omnifunc=nullcomplete#Completeautocmd FileType * setl omnifunc=nullcomplete#Completeautocmd FileType python setl omnifunc=pythoncomplete#Completeautocmd FileType javascript setl omnifunc=javascriptcomplete#CompleteJSautocmd FileType html setl omnifunc=htmlcomplete#CompleteTags nociautocmd FileType css setl omnifunc=csscomplete#CompleteCSS nociautocmd FileType xml setl omnifunc=xmlcomplete#CompleteTagsautocmd FileType php setl omnifunc=phpcomplete#CompletePHPautocmd FileType c setl omnifunc=ccomplete#Complete" Set completement for C++autocmd FileType h setl omnifunc=cppcomplete#Completeautocmd FileType cpp setl omnifunc=cppcomplete#Complete
" Set F2 as nohls map <silent> <F2> <ESC>:nohls<CR>map <silent> <F4> <ESC>:qa<CR>map <silent> <F5> <ESC>:wa<CR>
map <C-t>l <ESC>:tabnext<CR>map <C-t>h <ESC>:tabprev<CR>map <C-t>n <ESC>:tabnew<CR><ESC>:emap <C-t>c <ESC>:tabclose<CR>" Set F9 for Tlistmap <silent> <F9> :TlistToggle<cr>
“"""""""""""""""""""""""""""""" Tag list (ctags)""""""""""""""""""""""""""""""let Tlist_Ctags_Cmd = ‘/usr/bin/ctags’let Tlist_Show_One_File = 1            “不同时显示多个文件的tag,只显示当前文件的let Tlist_Exit_OnlyWindow = 1          “如果taglist窗口是最后一个窗口,则退出vim""""""""""""""""""""""""""""""" BufExplorer""""""""""""""""""""""""""""""let g:bufExplorerDefaultHelp=0       " Do not show default help.let g:bufExplorerShowRelativePath=1  " Show relative paths.let g:bufExplorerSortBy=’mru’        " Sort by most recently used.let g:bufExplorerSplitRight=0        " Split left.let g:bufExplorerSplitVertical=1     " Split vertically.let g:bufExplorerSplitVertSize = 30  " Split widthlet g:bufExplorerUseCurrentWindow=1  " Open in new window.autocmd BufWinEnter \[Buf\ List\] setl nonumber
“"""""""""""""""""""""""""""""" winManager setting""""""""""""""""""""""""""""""let g:winManagerWindowLayout = “BufExplorer,FileExplorer|TagList"let g:winManagerWidth = 30let g:defaultExplorer = 0nmap <C-W><C-F> :FirstExplorerWindow<cr>nmap <C-W><C-B> :BottomExplorerWindow<cr>nmap <silent> <F8> :WMToggle<cr> nmap <silent> <F7> :cw 10 <cr>
“""""""""""""""""""""""""""""" Cscope setting"""""""""""""""""""""""""""""nmap <C-@>s :cs find s <C-R>=expand(“<cword>")<CR><CR>nmap <C-@>g :cs find g <C-R>=expand(“<cword>")<CR><CR>nmap <C-@>c :cs find c <C-R>=expand(“<cword>")<CR><CR>nmap <C-@>t :cs find t <C-R>=expand(“<cword>")<CR><CR>nmap <C-@>e :cs find e <C-R>=expand(“<cword>")<CR><CR>nmap <C-@>f :cs find f <C-R>=expand(“<cfile>")<CR><CR>nmap <C-@>i :cs find i ^<C-R>=expand(“<cfile>")<CR>mce_markerlt;CR>nmap <C-@>d :cs find d <C-R>=expand(“<cword>")<CR><CR>
if has(“cscope")set csprg=/usr/bin/cscopeset csto=0set cstset nocsverb" add any database in current directoryif filereadable(“cscope.out")cs add cscope.out" else add database pointed to by environmentelseif $CSCOPE_DB != “"cs add $CSCOPE_DBendifset csverbset cscopetagset cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-endif

檔案下載

1. vimrc (下載後直接覆蓋掉家目錄的.vimrc即可)

下載點1 下載點2 下載點3

2.  .vim目錄的壓縮檔 (解壓縮後,直接覆蓋家目錄下的.vim資料夾即可)

下載點1 下載點2 下載點3

Reference

vimrc 自動回到最後離開編輯的位置

Make vim more powerful

褶疊功能的使用

vim7新功能 (加入了tab分頁與拼字檢查的功能)

強大的snippet

ctags+taglist+cppcomplete+global

vim 功能進階 強烈建議一定要看這一篇

ctags的使用

ctags with omnicppcomplete instal

vim+ctags+Taglist+cscope

vim的自動完成

vim Exercise:Wiki

分類:Linux&FreeBSD 標籤:,
  1. 仍無迴響。
  1. No trackbacks yet.

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: