我的vimrc配置

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
    syntax on
endif

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd        " Show (partial) command in status line.
"set showmatch        " Show matching brackets.
"set ignorecase        " Do case insensitive matching
"set smartcase        " Do smart case matching
"set incsearch        " Incremental search
"set autowrite        " Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
"set mouse=a        " Enable mouse usage (all modes)
 
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""

         
  let Tlist_Ctags_Cmd = '/usr/bin/ctags'

   let Tlist_Show_One_File = 1            "不同时显示多个文件的tag,只显示当前文件的
   let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口,则退出vim
   let Tlist_Use_Right_Window = 1         "在右侧窗口中显示taglist窗口

""""""""""""""""""""""""""""""""""""""
" 语法着色与高亮设置
"""""""""""""""""""""""""""""""""""""""
"
" "开启语法高亮
syntax enable
syntax on
"
" "配色
colorscheme murphy

" "设置高亮搜索
set hlsearch
"
"""""""""""""""""""""""""""""""""""""""
" " 文件设置
"""""""""""""""""""""""""""""""""""""""
"
set encoding=utf-8
set fileencoding=chinese
set fileencodings=ucs-bom,utf-8,chinese
set ambiwidth=double
"
" "检测文件的类型
filetype on


" "默认无备份
set nobackup
set nowritebackup
"
"""""""""""""""""""""""""""""""""""""""
" " 鼠标设置
"""""""""""""""""""""""""""""""""""""""
" "鼠标支持
if has('mouse')
set mouse=a
endif
"
" "使鼠标用起来象微软 Windows,似乎正好解决连续多行缩进问题、退格问题
behave mswin
"
"""""""""""""""""""""""""""""""""""""""
" " 编辑器设置
"""""""""""""""""""""""""""""""""""""""
"
"显示行号
set number
"
"Tab 宽度
set ts=4
"
" "自动缩进
set sw=4
"
" "C/C++ 风格的自动缩进
set cin
" "设定 C/C++ 风格自动缩进的选项
set cino=:0g0t0(sus
"
" "打开普通文件类型的自动缩进
set ai
"
" "在编辑过程中,在右下角显示光标位置的状态行
set ruler
"
" "显示匹配括号
set showmatch
"
" "在insert模式下能用删除键进行删除
set backspace=indent,eol,start
"
" "代码折叠, 命令 za
set foldmethod=syntax
set foldlevel=100  "启动vim时不要自动折叠代码
"
" "设置字体
set guifont=Bitstream\ Vera\ Sans\ Mono\ 15
" "当右键单击窗口的时候,弹出快捷菜单
set mousemodel=popup
"
" "自动换行
 if (has("gui_running")) "图形界面下的设置
"
" "指定不折行。如果一行太长,超过屏幕宽度,则向右边延伸到屏幕外面
set nowrap
" "添加水平滚动条。如果你指定了不折行,那为窗口添加一个水平滚动条就非常有必要
" 了
set guioptions+=b
"
 else "字符界面下的设置
set wrap
endif
"
"""""""""""""""""""""""""""""""""""""""
" " 快捷键设置
"""""""""""""""""""""""""""""""""""""""

" "<F2>code_complete.vim插件:函数自动完成
if !exists("g:completekey")
let g:completekey = "<F2>"   "hotkey
endif
"
" "<F3><F4>大小写转换
 map <F3> :gu
 map <F4> :gU
"
" "当前目录生成tags语法文件,用于自动完成,函数提示:code_complete.vim
"OmniCppComplete.vim ...
map <F5> :!ctags -R --c-kinds=+p --fields=+S . <CR>
map <F5> :!ctags -R --c-kinds=+p --c++-kinds=+p --fields=+iaS--extra=+q .
"<CR>
"
" "函数和变量列表
map <F6> :TlistToggle<CR>
"
" "文件浏览器
map <F7> :WMToggle<CR>
let g:winManagerWindowLayout = "FileExplorer"
"
" "文件树状列表
map <F8> :NERDTree<CR>
"
" "映射复制、粘贴、剪贴ctrl+c ctrl+v ctrl+x
"map <C-V> "+pa<Esc>
"map! <C-V> <Esc>"+pa
"map <C-C> ":+y
"map <C-X> "+x
"
" " 映射全选 ctrl+a
map <C-A> :ggVG
map! <C-A> <Esc>ggVG
"
" " 多行缩进
map <Tab> >
map <S-Tab> <
"a修改 vmirc 后自动生效
"
autocmd! bufwritepost .vimrc source ~/.vimrc
"
"""""""""""""""""""""""""""""""""""""""
" " 插件设置
"""""""""""""""""""""""""""""""""""""""
"
" "开启OmniCppComplete.vim
set nocp
filetype plugin on
"
" "2Html插件,启用XHtml css
" :let html_number_lines=1
" :let html_use_css=1
" :let use_xhtml=1
"
" "fencview.vim 插件设置
let g:fencview_autodetect = 1  "打开文件时自动识别编码
let g:fencview_checklines = 10 "检查前后10行来判断编码
"
"autocomplpop.vim & supertab.vim 插件设置
let g:AutoComplPop_IgnoreCaseOption=1
set ignorecase
"
"""""""""""""""""""""""""""""""""""""""
" " 其他设置
"""""""""""""""""""""""""""""""""""""""
"
" "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible

"使用taglist
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

"使用C.vim
filetype plugin on

"所有用户使用vim功能一样
set nu

"设置自动补齐
filetype plugin indent on
set completeopt=longest,menu


if has("autocmd") && exists("+omnifunc")
     autocmd Filetype *
   \ if &omnifunc == "" |
   \   setlocal omnifunc=syntaxcomplete#Complete |
   \ endif
endif

let g:SuperTabDefaultCompletionType="<C-X><C-]>"
" 设置按下<Tab>后默认的补全方式, 默认是<C-P>,
" 现在改为<C-X><C-L>(其为根据自己定义的结构体自动补齐).
" 关于<C-P>的补全方式,
" 还有其他的补全方式, 你可以看看下面的一些帮助:
" :help ins-completion
" :help compl-omni

let g:SuperTabRetainCompletionType=2
" 0 - 不记录上次的补全方式
" 1 - 记住上次的补全方式,直到用其他的补全命令改变它
" 2 - 记住上次的补全方式,直到按ESC退出插入模式为止


" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

""将windows中的快捷键应用到gvim中

 source $VIMRUNTIME/mswin.vim

""cscope配置如下
  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

自己总结于网络!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值