我的~/.vimrc设置

~/.vimrc设置

"-------------------------Basic Configuration Begin-------------------------"

"Support Chinese when logging in by ssh
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8

"Show line numbers
set nu

"Highlight current line
set cursorline

"Set TAB width to be 4
set tabstop=4
set softtabstop=4

"Replace tab by 4 space
set expandtab
set shiftwidth=4

"Set auto indent, as show below. 'int b' will indent according to 'int b'
"Set smart indent, as show below, 'int a' will indent according to the '{'
"void main() {
"	int a;
"	int b;
"}
set autoindent
set smartindent

"Set autoindent when using C/C++
set cindent

"Set concrete indent when using C/C++,refer to cinoptions-values
":help cinoptions-values
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s

"Set syntax highlight
syntax enable
syntax on

"Set color schema to elflord
colorscheme elflord

"Show search result when an char is inputed, not when enter key is pressed
set incsearch 

"Highlight search result
set hlsearch

"statusline
set statusline=%F%m%r%h%w\ %=[Column=%01v][%p%%]\ %<[Number\ of\ Rows=%L]
set laststatus=2

"Enable mouse usage (all modes)
set mouse=a

"-------------------------Basic Configuration End-------------------------"

"-------------------------Configuration for Ctags Begin,refer to usr_29-------------------------"

":help usr_29

"Quik key mapping, F1 to quik create tags file by traversing source file
map <F1> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>  

"-------------------------Configuration for Ctags End,refer to usr_29-------------------------"

"-------------------------Configuration for TagList Begin,refer to taglist.txt-------------------------"

":help taglist.txt

"Create a normal mode mapping for the <F3> key to toggle the taglist window
nnoremap <silent> <F3> :TlistToggle<CR>

"Automatically open the taglist window on Vim startup
"dlet Tlist_Auto_Open=1

"Exit Vim when only the taglist window is present
let Tlist_Exit_OnlyWindow=1

"Show tags for the current buffer only
let Tlist_Show_One_File=1

"Connect taglist with ctags  
let Tlist_Ctags_Cmd="/usr/bin/ctags" 

"-------------------------Configuration for TagList End,refer to taglist.txt-------------------------"

"-------------------------Configuration for Tagbar Begin,refer to tagbar.txt-------------------------"

":help tagbar.txt

"Create a normal mode mapping for the <F3> key to toggle the taglist window
"nmap <silent> <F3> :TagbarToggle<CR>

"Set this option to open the Tagbar window  on the left
"let g:tagbar_left = 1

"Set width of the Tagbar window in characters
"let g:tagbar_width = 30

"Show the visibility symbols (public/protected/private) to the left of the tag name
"let g:tagbar_show_visibility = 0

"Specify the location of your ctags executable
"let g:tagbar_ctags_bin = '/tmp/software/vim/ctags-5.8/ctags'

"-------------------------Configuration for Tagbar End,refer to tagbar.txt-------------------------"

"------------------------Configuration for NerdTree Begin,refer to NERD_tree.txt-------------------------"

":help NERD_tree.txt

let g:NERDTree_title="[NERDTree]"  
  
function! NERDTree_Start()  
    exec 'NERDTree'  
endfunction  
  
function! NERDTree_IsValid()  
    return 1  
endfunction 

map <F4> :NERDTreeMirror<CR>
map <F4> :NERDTreeToggle<CR>

"------------------------Configuration for NerdTree End,refer to NERD_tree.txt-------------------------"

"------------------------Configuration for MiniBufExplorer Begin,refer to minibufexpl.vim-------------------------"

"vim minibufexpl.vim

"Enable function <C-h,j,k,l>
let g:miniBufExplMapWindowNavVim = 1 

"Enable function <C-arrow>
let g:miniBufExplMapWindowNavArrows = 1 

"Enable function <C-Tab> and <C-S-Tab>
let g:miniBufExplMapCTabSwitchBufs = 1 

"force MBE to try to place selected buffers into a window that does not have a nonmodifiable buffer
let g:miniBufExplModSelTarget = 1

"Stop the -MiniBufExplorer- from opening automatically until more than one eligible buffer is available
let g:miniBufExplMoreThanOne=0

"------------------------Configuration for MiniBufExplorer End,refer to minibufexpl.vim-------------------------"

"-------------------------Configuration for WinManager Begin,refer to winmanager.txt-------------------------"

":help winmanager

"Set window layout
let g:winManagerWindowLayout='NERDTree|TagList'

"Set winmanager width, defalut = 25
let g:winManagerWidth = 30

"Quick key mapping
nmap <silent> <F5> :WMToggle<cr>

"Automatically open the winmanager window on Vim startup
let g:AutoOpenWinManager = 1

"-------------------------Configuration for WinManager End,refer to winmanager.txt-------------------------"

"-------------------------Configuration for Cscope Begin,refer to if_cscop.txt-------------------------"

"help if_cscop.txt

map <F6> :!cscope -Rb -q  <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 nocscopeverbose

"-------------------------Configuration for Cscope End,refer to if_cscop.txt-------------------------"

"------------------------Configuration for omnicppcomplete Begin,refer to omnicppcomplete.txt-------------------------"

":help omnicppcomplete.txt

"Enable omnicppcomplete plugins
set nocp

"Enable file type detection
filetype plugin on

"Set completeopt
set completeopt=menu,menuone

"Global scope search
let OmniCpp_GlobalScopeSearch=1

"search namespaces in the current buffer
let OmniCpp_NamespaceSearch=1			

"display the prototype of a function in the abbreviation part of the popup menu
let OmniCpp_ShowPrototypeInAbbr=1	

"Default namespace,it will be the same as inserting this declarations at the top of the
"current buffer :
		"using namespace std;
let OmniCpp_DefaultNamespace=["std"]

"May complete enabled for dot
let OmniCpp_MayCompleteDot=1	

"May complete enabled for arrow	
let OmniCpp_MayCompleteArrow=1

"May complete enabled for scope
let OmniCpp_MayCompleteScope=1	

"Select first popup item (without inserting it to the text)
let OmniCpp_SelectFirstItem = 2	

"------------------------Configuration for omnicppcomplete End,refer to omnicppcomplete.txt-------------------------"

"------------------------Configuration for SuperTab Begin,refer to supertab.txt-------------------------"

":help supertab.txt

"Setting the default completion to supertab's 'context' completion
let g:SuperTabDefaultCompletionType="context" 

"------------------------Configuration for SuperTab End,refer to supertab.txt-------------------------"

"------------------------Configuration for QuickFix Window Begin,refer to quickfix-------------------------"

":help quickfix

"Auto show QuickFix window, e.g. auto show make error message
autocmd QuickFixCmdPost [^1]* nested cwindow
autocmd QuickFixCmdPost    1* nested lwindow

"------------------------Configuration for QuickFix Window End,refer to quickfix-------------------------"

"------------------------Configuration for a.vim Begin-------------------------"

"For plugin a.vim which can switch between .h and .c/.cpp
"Here are the commands of a.vim
":A  switch c/h in new buffer
":AS switch c/h in new horizontal splited window
":AV switch c/h in new vertical   splited window
":AT switch c/h in new tap

"Quick key mapping
nnoremap <silent> <F7> :A<CR>
nnoremap <silent> <F8> :AS<CR>

"------------------------Configuration for a.vim End------------------------"
网上下载的csope_maps.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CSCOPE settings for vim           
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" This file contains some boilerplate settings for vim's cscope interface,
" plus some keyboard mappings that I've found useful.
"
" USAGE: 
" -- vim 6:     Stick this file in your ~/.vim/plugin directory (or in a
"               'plugin' directory in some other directory that is in your
"               'runtimepath'.
"
" -- vim 5:     Stick this file somewhere and 'source cscope.vim' it from
"               your ~/.vimrc file (or cut and paste it into your .vimrc).
"
" NOTE: 
" These key maps use multiple keystrokes (2 or 3 keys).  If you find that vim
" keeps timing you out before you can complete them, try changing your timeout
" settings, as explained below.
"
" Happy cscoping,
"
" Jason Duell       jduell@alumni.princeton.edu     2002/3/7
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


" This tests to see if vim was configured with the '--enable-cscope' option
" when it was compiled.  If it wasn't, time to recompile vim... 
if has("cscope")

    """"""""""""" Standard cscope/vim boilerplate

    " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
    set cscopetag

    " check cscope for definition of a symbol before checking ctags: set to 1
    " if you want the reverse search order.
    set csto=0

    " add any cscope database in current directory
    if filereadable("cscope.out")
        cs add ./cscope.out  
    " else add the database pointed to by environment variable 
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif

    " show msg when any other cscope db added
    set cscopeverbose  


    """"""""""""" My cscope/vim key mappings
    "
    " The following maps all invoke one of the following cscope search types:
    "
    "   's'   symbol: find all references to the token under cursor
    "   'g'   global: find global definition(s) of the token under cursor
    "   'c'   calls:  find all calls to the function name under cursor
    "   't'   text:   find all instances of the text under cursor
    "   'e'   egrep:  egrep search for the word under cursor
    "   'f'   file:   open the filename under cursor
    "   'i'   includes: find files that include the filename under cursor
    "   'd'   called: find functions that function under cursor calls
    "
    " Below are three sets of the maps: one set that just jumps to your
    " search result, one that splits the existing vim window horizontally and
    " diplays your search result in the new window, and one that does the same
    " thing, but does a vertical split instead (vim 6 only).
    "
    " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
    " unlikely that you need their default mappings (CTRL-\'s default use is
    " as part of CTRL-\ CTRL-N typemap, which basically just does the same
    " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
    " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
    " of these maps to use other keys.  One likely candidate is 'CTRL-_'
    " (which also maps to CTRL-/, which is easier to type).  By default it is
    " used to switch between Hebrew and English keyboard mode.
    "
    " All of the maps involving the <cfile> macro use '^<cfile>$': this is so
    " that searches over '#include <time.h>" return only references to
    " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
    " files that contain 'time.h' as part of their name).


    " To do the first type of search, hit 'CTRL-\', followed by one of the
    " cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope
    " search will be displayed in the current window.  You can use CTRL-T to
    " go back to where you were before the search.  
    "

    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>$<CR>
    nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>	


    " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
    " makes the vim window split horizontally, with search result displayed in
    " the new window.
    "
    " (Note: earlier versions of vim may not have the :scs command, but it
    " can be simulated roughly via:
    "    nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>	

    nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>	
    nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>	
    nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>	
    nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>	
    nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>	
    nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>	
    nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>	
    nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>	


    " Hitting CTRL-space *twice* before the search type does a vertical 
    " split instead of a horizontal one (vim 6 and up only)
    "
    " (Note: you may wish to put a 'set splitright' in your .vimrc
    " if you prefer the new window on the right instead of the left

    nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>	
    nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>	
    nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>


    """"""""""""" key map timeouts
    "
    " By default Vim will only wait 1 second for each keystroke in a mapping.
    " You may find that too short with the above typemaps.  If so, you should
    " either turn off mapping timeouts via 'notimeout'.
    "
    "set notimeout 
    "
    " Or, you can keep timeouts, by uncommenting the timeoutlen line below,
    " with your own personal favorite value (in milliseconds):
    "
    "set timeoutlen=4000
    "
    " Either way, since mapping timeout settings by default also set the
    " timeouts for multicharacter 'keys codes' (like <F1>), you should also
    " set ttimeout and ttimeoutlen: otherwise, you will experience strange
    " delays as vim waits for a keystroke after you hit ESC (it will be
    " waiting to see if the ESC is actually part of a key code like <F1>).
    "
    "set ttimeout 
    "
    " personally, I find a tenth of a second to work well for key code
    " timeouts. If you experience problems and have a slow terminal or network
    " connection, set it higher.  If you don't set ttimeoutlen, the value for
    " timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
    "
    "set ttimeoutlen=100

endif

最终的效果


参考:

http://blog.csdn.net/wooin/article/details/1858917

http://blog.csdn.net/bokee/article/details/6633193



版权声明:本文为博主原创文章,未经博主允许不得转载。

posted on 2015-10-10 21:24  ruan875417  阅读(404)  评论(0编辑  收藏  举报

导航