マイVimプロファイル(自動補完/ツリーブラウズ)

56001 ワード

プロファイルのダウンロードパスはこちらですhttp://files.cnblogs.com/files/oloroso/vim.configure.xz.gz 
これは実際にはxz形式のファイルで、gzファイルの接尾辞を追加したのはブログ園のアップロードファイルの制限のためです.
 
我的Vim配置(自动补全/树形文件浏览)_第1张图片
 
.vimrcファイルの内容は以下の通りです.
"==========================================================================
"=======================            ==================================
"==========================================================================

"---------------------------------------------------------------------------
"      
set ruler                   "              
set number                  "     
set cursorline              "        

"          (     colorscheme     )
if has("gui_running")
    highlight LineNr guifg=red        " gui         
    highlight LineNr guibg=white    " gui         
else
    highlight LineNr ctermfg=yellow    "            
    highlight LineNr ctermbg=blue    "            
endif

"---------------------------------------------------------------------------
"    (     tab    4   )
set tabstop=4               "   tab    
set shiftwidth=4            "          4   
" set cindent shiftwidth=4   "     4  
set softtabstop=4
" set expandtab               "        tab
set smarttab                "           tab   

" set list                     "   Tab ,
" set listchars=tab:\|\ ,      "                  |
" set listchars=tab:>-,trail:-
" set listchars=tab:\|\ ,nbsp:%,trail:-

" match LeaderTab /\t/        "     tab

"---------------------------------------------------------------------------
"   
set autoindent              "       (             )
set smartindent             "       

set cindent            "    C/C++          
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s     "  C/C++         

"---------------------------------------------------------------------------
"    
set linebreak               "             
set nocompatible            "      VI
"set textwidth=80           "     80       ,     
set wrap                   "       
"set nowrap                    "        

"---------------------------------------------------------------------------
"        
set laststatus=2                          "        
set cmdheight=1                           "       ,   1,    2
set showcmd                "           
set showmode            "     vim    

"          [      、    、  、    、   ]
" set statusline=%{fugitive#statusline()}\ %F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %y%r%m%*%=\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v]\ [%p%%]\ [LEN=%L]

" line color
" now set it up to change the status line based on mode
if version >= 700
    au InsertEnter * hi StatusLine term=reverse ctermbg=5 gui=undercurl guisp=Magenta
    au InsertLeave * hi StatusLine term=reverse ctermfg=0 ctermbg=2 gui=bold,reverse
endif

function! InsertStatuslineColor(mode)
    if a:mode == 'i'
        hi statusline guibg=magenta
    elseif a:mode == 'r'
        hi statusline guibg=blue
    else
        hi statusline guibg=red
    endif
endfunction

au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertChange * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline guibg=green

"---------------------------------------------------------------------------
"    
set showmatch               "         
set iskeyword+=_,$,@,%,#,-  "                 
"set wildmenu "   wildmenu   ,                 。
"set matchpairs=(:),{:},[:],<:>
"set whichwrap=b,s,<,>,[,]

"---------------------------------------------------------------------------
"     
"colorscheme default         "     


"==========================================================================
"=======================              ===============================
"==========================================================================


"   
set hlsearch                "         
set incsearch               "         (            )
"set noincsearch            "           
"set magic                  " Set magic on, for regular expressions
"set showmatch              " Show matching bracets when text indicator is over them
"set mat=2                  " How many tenths of a second to blink
set ignorecase              "         
set nowrapscan              "              

"---------------------------------------------------------------------------
"      
set nobackup
set nowb
"set noswapfile
set writebackup             "        

"---------------------------------------------------------------------------
"     
set complete=.,w,b,k,t,i
set completeopt=longest,menu "
set autoread                "

set autowrite        "          :         ,    :next、:rewind、:last、:first、:previous、:stop、:suspend、:tag、:!、:make、CTRL-]   CTRL-^     ;  :buffer、CTRL-O、CTRL-I、'{A-Z0-9}   `{A-Z0-9}            。

"---------------------------------------------------------------------------
"       
set backspace=2             "        
if has('mouse')
    set mouse=a                 "     
endif
set ve=block                "                
"set fullscreen             "        

"---------------------------------------------------------------------------
"         
set nocompatible            "   vi    
set hidden                  "                 
"set relativenumber          "     
set clipboard+=unnamed      "        
set autochdir               "               


set history=80              "  80     

" vim           
autocmd BufReadPost *
        \ if line("'\"")>0&&line("'\"")<=line("$") |
        \ exe "normal g'\"" |
        \ endif

"==========================================================================
"=======================            ==================================
"==========================================================================

"       
filetype indent on          "                   
filetype plugin on          "                 
filetype plugin indent on
filetype on                 " for taglist

"---------------------------------------------------------------------------
"     UTF-8   
"---------------------------------------------------------------------------
if has("multi_byte")    "         
    set encoding=utf-8    "     utf-8
    " English messages only
    "language messages zh_CN.utf-8
    set fillchars+=stl:\ ,stlnc:\

    if has('win32')        "windows 
        language english
        let &termencoding=&encoding "   consle    
    endif

    set fencs=utf-8,gbk,chinese,latin1
    set formatoptions+=mM
    set nobomb "     Unicode   

    if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
        set ambiwidth=double
    endif
else
    echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif

"---------------------------------------------------------------------------
"     
"---------------------------------------------------------------------------
"set fileencoding=utf-8
set encoding=utf-8 "    
set fileencodings=utf-8,cp936,gb18030,big5,gbk,euc-jp,latin1
set fileencoding=utf-8
set termencoding=utf-8 "    
"set fileformats=unix

"---------------------------------------------------------------------------
"      (win/unix)
"              UNIX   
autocmd FileType php,javascript,html,css,python,vim,vimwiki  set ff=unix

"     VIM    
" autocmd! bufwritepost vimrc source $MYVIMRC

"==========================================================================
"=======================               =============================
"==========================================================================

" Floding   
"set foldmethod=syntax "         
"set foldlevel=100 "       
"
set foldenable " Enables folding.
"       
" manual          
" indent              
" expr                 
" syntax              
" diff                    
" marker            ,       {{{   }}} 
set foldmethod=manual " Set fold method to 'manual'.
""set fdc=0 " Show where folds start and end, when they are opened.
"nnoremap @=((foldclosed(line('.')) < 0 )? 'zc':'zo')

set foldtext=MyFoldText()
function! MyFoldText()
    let line = getline(v:foldstart)
    let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
    return v:folddashes . sub
endfunction


"---------------------------------------------------------------------------
"      
syntax enable               "       
syntax on                   "         
autocmd BufRead,BufNewFile *.txt setlocal ft=txt
autocmd BufRead,BufNewFile *.tpl setlocal ft=smarty         "    Smarty
autocmd BufRead,BufNewFile *.as setlocal ft=actionscript    "    ActionScript
autocmd BufRead,BufNewFile *.mxml set filetype=mxml
autocmd BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
autocmd BufRead,BufNewFile *.txtfmt set filetype=txtfmt
autocmd BufRead,BufNewFile *.php set filetype=php
autocmd BufRead,BufNewFile *.c set filetype=c
autocmd BufRead,BufNewFile *.go set filetype=go
autocmd BufRead,BufNewFile *.md set filetype=markdown

autocmd BufNewFile,BufRead,BufEnter,WinEnter,FileType *.m,*.h setf objc  "    Objective-C     
"  qml        
autocmd BufNewFile,BufRead *.qml set filetype=JavaScript

" fencview            :FencView                
let g:fencview_autodetect=1


"     dict
"              
autocmd FileType javascript set dictionary=~/.vim/dict/javascript.dict
autocmd FileType css        set dictionary=~/.vim/dict/css.dict


"==========================================================================
"=======================           ====================================
"==========================================================================

"   ',' leader   
" let mapleader = ","
" let g:mapleader = ","
" 
" " Ctrl + S     
" map  <C-s> <ESC>:w <CR>
" imap <C-s> <ESC>:w <CR>
" vmap <C-s> <ESC>:w <CR>
" 
" " Ctrl + C        
" vnoremap <C-c> "+y
" 
" " Ctrl + V          
" map  <C-v> "+p
" imap <C-v> <esc>"+pa
" vmap <C-v> d"+P
" 
" "        
" map <C-a> gg0vG$<cr>
" 
" " nmap <C-t>   :tabnew<cr>
" " nmap <C-p>   :tabprevious<cr>
" " nmap <C-n>   :tabnext<cr>
" " nmap <C-k>   :tabclose<cr>
" " nmap <C-Tab> :tabnext<cr>
" 
" "                
" vnoremap  *  y/<C-h>=escape(@", '\\/.*$^~[]')<CR><CR>
" vnoremap  #  y?<C-h>=escape(@", '\\/.*$^~[]')<CR><CR>
" 
" "      
" nnoremap <leader>av :'<,'>Align =<cr>
" nnoremap <leader>al :'<,'>left<cr>
" nnoremap <leader>ac :'<,'>center<cr>
" nnoremap <leader>ar :'<,'>right<cr>
" 
" "          
" "      ,s
" "     (  ) ,w
" "     (   ) ,q
" nmap <leader>s :w!<cr>
" nmap <leader>w :wq!<cr>
" nmap <leader>q :q!<cr>
" 
" inoremap <expr> <leader>x "\<C-X><C-O>"
" 
" " plugins: markdown index
" nnoremap <leader>m :TocdownToggle<cr>
" 
" "  buffer
" nmap bn :bn<cr>
" nmap bp :bp<cr>



"==========================================================================
"==========================================================================
"\\\\\\\\\\\\\\\\\\\\\\\\             ///////////////////////////////
"==========================================================================
"==========================================================================


"==========================================================================
"=======================   Powerline   ====================================
"==========================================================================
"  powerline     
set guifont=PowerlineSymbols\ for\ Powerline
set nocompatible
set t_Co=256        "  256 
let g:Powerline_symbols = 'fancy'
 

"==========================================================================
"=======================   TagList   ======================================
"==========================================================================

" TagList   :Tlist  
" if MySys() == "windows"                "  windows   ctags     
"     let Tlist_Ctags_Cmd = 'ctags'
" elseif MySys() == "linux"              "  windows   ctags     
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
" endif
map <F4> :TlistToggle<cr>
let Tlist_Show_One_File = 1            "          tag,        
let Tlist_Compact_Format = 1            "      .
let Tlist_Exit_OnlyWindow = 1          "  taglist         ,   vim
let Tlist_Enable_Fold_Column = 0        "  taglist           
let Tlist_Use_Right_Window = 1         "        taglist  
"let Tlist_Use_Left_Window = 1          " Split to the left side of the screen.
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Inc_Winwidth = 0                "   taglist         
let Tlist_WinWidth = 25                " taglist    
let Tlist_Sort_Type = 'name'           "    name.

" ---------------------------------------------------------------------------
" Plugin: 
"---------------------------------------------------------------------------
"==========================================================================
"=======================   ctags         ===============================
"==========================================================================

set tags=tags
set tags+=./tags    "           ctags
set tags+=/usr/include/c++/cpptags    "      include      

set tags+=/usr/include/qt5/qt5tags  "qt5 
set tags+=~/pragrom_files/Qt5.4.1/5.4/gcc_64/include

"   F5    tag  ,   taglist
 map <F5> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>
 imap <F5> <ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>

" ctags   c++ tags     
" ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f cpptags

"==========================================================================
"=======================   omnicppcomplete   ==============================
"==========================================================================
"   F3      ,               ,  tab;    F3         
imap <F3> <C-X><C-O>
"   F2           
imap <F2> <C-X><C-I>
set completeopt=menu,menuone "             
let OmniCpp_MayCompleteDot = 1 "   '.'        omnicppcomplete      。0/1,    1
let OmniCpp_MayCompleteArrow = 1 "  "->"       omnicppcomplete      。0/1,    1
let OmniCpp_MayCompleteScope = 1 "       "::"       omnicppcomplete      。0/1,    0
let OmniCpp_SelectFirstItem = 2 ""completeopt"  "longest"
                                " 0 :       (  )
                                " 1 :              
                                " 2 :              
let OmniCpp_NamespaceSearch = 2 "         。0 :         
                                " 1 :                (  )
                                " 2 :                     
let OmniCpp_ShowPrototypeInAbbr = 1 "                   。0 :    (  ) 1 :     
let OmniCpp_GlobalScopeSearch=1 "       。0:  ;1:  (  )
let OmniCpp_DisplayMode=1 "        (        (public)  (private)  (protected)  )。  0 :     1 :       
let OmniCpp_DefaultNamespaces=["std"] "         ,     ','  。
let OmniCpp_ShowScopeInAbbr=1    "                  。     ,omni                                。
                                " 0 :               (  )
                                " 1 :         ,            
let OmniCpp_ShowAccess=1        "          ('+', '-', '#')。0/1,    1(  )
let OmniCpp_LocalSearchDecl=1        "  Vim      /  (local)    。
                                "Vim                               ,           。

"       
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


"==========================================================================
"=======================   NERDTree   =====================================
"==========================================================================

" plugin - NERD_tree.vim                 
" :NERDtree   NERD_tree         :NERDtreeClose      NERD_tree
" o                    t        
" T                     !      
" p                         P     
" K                        J        
" u                        m         (  、  、    )
" r                      R          
"---------------------------------------------------------------------------
let NERDTreeShowBookmarks=1                        "       
let loaded_netrwPlugin = 0                         "    netrw
let NERDTreeCaseSensitiveSort=1                    "         
let NERDTreeHijackNetrw = 0                        "   :e filename    netrw,    nerdtree
let NERDTreeChDirMode = 2                          "   tree             
let NERDTreeWinPos = 'left'                        " NERDTree         
let NERDTreeWinSize = 25                           " NERDTREE   
let NERDTreeIgnore = [ '^\.svn$','^\.git$','\~$' ] "   .svn .git   
" F3 NERDTree   
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC>:NERDTreeToggle<CR>

"---------------------------------------------------------------------------
" Plugin: miniBufExplorer                        
"   Bufe  
" <Tab>            buffer  
" <S-Tab>          buffer  
" <Enter>         buffer
" d              buffer
"---------------------------------------------------------------------------
" let g:miniBufExplorerMoreThanOne=0      "      ,         
" let g:miniBufExplMapWindowNavVim = 1    "    MinBuf    ctrl-h,j,k,l          
let g:miniBufExplMapWindowNavArrows = 1 "    MinBuf    C-           
let g:miniBufExplMapCTabSwitchBufs = 1  "    MiniBuf    Ctrl-Tab   Ctrl-S-Tab         
" let g:miniBufExplModSelTarget = 1