我自己用的vim配置

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'
Bundle 'Valloric/YouCompleteMe'

call vundle#end()
filetype plugin indent on

set nocompatible "非兼容模式,使用vim高级特性

set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,gb18030,latin1
"下面这四行在某些特殊情况下可以显示中文乱码,可以选择性使用
"set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
"set enc=utf8
"set fencs=utf8,gbk,gb2312,gb18030
"set encoding=prc

syntax on
set tabstop=4       " 文件中一个  占据的空格数。
set shiftwidth=4    " 每一级自动缩进的空格数。
set smarttab        " 当打开时,行首的  会按照 'shiftwidth' 插入空白
"set showcmd         " 在状态栏中显示(部分)命令。
set number          " 显示行号。
set cursorline      "突出显示当前行

set showmatch       " When a bracket is inserted, briefly jump to the matching
set hlsearch        " 当有一个符合之前搜索的值时,高亮所有匹配
set incsearch       " 当输入搜索命令时,离开显示符合与目前输入的模式匹配的内容
set ignorecase      " 在搜索中忽略大小写
set smartcase       " 如果搜索中有大写字符,忽略 'ignorecase' 选项
set backspace=2     " Influences the working of , , CTRL-W
set autoindent      " 当开始新行时复制当前行的缩进
"set textwidth=79    " Maximum width of text that is being inserted. A longer
set formatoptions=c,q,r,t " This is a sequence of letters which describes how
set ruler           " 显示当前光标位置的行号和列号,用逗号分割
set background=dark " 当设置为 "dark" 时,Vim 会尝试使用在暗色背景中合适的颜色。
set cinoptions=g0,N-s,:0,(0  " 设置缩进格式

set pastetoggle=    " 开启这个选项后粘贴原始格式

colorscheme delek
filetype plugin indent on
"vim跳转到上次的位置
"au BufReadPost * if line("'\"") > 0 |if line("'\"") <= line("$")|exe("norm'\"")|else|exe "norm $"
"|endif|endifset viminfo='1000,f1,<500
"set tags+=~/.vim/systags

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope setting
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
    set csprg=/usr/bin/cscope
    set csto=1
    set cst 
    set nocsverb
    " add any database in current directory
    if filereadable("/home/david/mytag/cscope.out")
        cs add ~/work/server/cscope.out
    endif
    set csverb
endif

nmap s :cs find s =expand("")
nmap g :cs find g =expand("")
nmap c :cs find c =expand("")
nmap t :cs find t =expand("")
nmap e :cs find e =expand("")
nmap f :cs find f =expand("")

"you complete me(YCM) setting
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_invoke_completion = ''

"进行版权声明的设置
"添加或更新头
map  :call TitleDet()
function AddTitle()
    if (&filetype == "lua")
        call append(0,"--[[===========================================================================")
    elseif (&filetype == "c" || &filetype == "cpp" || &filetype == "cxx" || &filetype == "cc")
        call append(0,"/*=============================================================================")
    else
        call append(0,"##============================================================================")
    endif
    call append(1,"# Author: david#gmail.com")
    call append(2,"# Last modified: ".strftime("%Y-%m-%d %H:%M:%S"))
    call append(3,"# Filename: ".expand("%:t"))
    call append(4,"# License: ")
    call append(5,"# Description: ")
    if &filetype == "lua"
        call append(6,"===========================================================================]]--")
    elseif (&filetype == "c" || &filetype == "cpp" || &filetype == "cxx" || &filetype == "cc")
        call append(6,"=============================================================================*/")
    else
        call append(6,"##============================================================================")
    endif
    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endf

"更新最近修改时间和文件名
function UpdateTitle()
    normal m'
    execute '/# *Last modified:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M:%S")@'
    normal ''
    normal mk
    execute '/# *Filename:/s@:.*$@\=": ".expand("%:t")@'
    execute "noh"
    normal 'k
    echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
"判断前10行代码里面,是否有Last modified这个单词,
"如果没有的话,代表没有添加过作者信息,需要新添加;
"如果有的话,那么只需要更新即可
function TitleDet()
    let n=1
    "默认为添加
    while n < 10
        let line = getline(n)
        if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction

你可能感兴趣的:(我自己用的vim配置)