美文网首页
我自己用的vim配置

我自己用的vim配置

作者: David栗子 | 来源:发表于2017-03-07 15:17 被阅读0次
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       " 文件中一个 <Tab> 占据的空格数。
set shiftwidth=4    " 每一级自动缩进的空格数。
set smarttab        " 当打开时,行首的 <Tab> 会按照 '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 <BS>, <Del>, 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=<F9>    " 开启这个选项后粘贴原始格式

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 <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>

"you complete me(YCM) setting
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_invoke_completion = '<C-L>'

"进行版权声明的设置
"添加或更新头
map <F4> :call TitleDet()<cr>
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配置

  • Universal Links链接跳转APP

    需要域名配置ssl证书,apache配置ssl证书,ssl证书我用的阿里云免费的 apache配置文件(vim /...

  • VIM编程环境

    Vim配置、插件和使用技巧 vim提供一个vimrc的配置文件来配置vim,并且自己可以定制一些插件来实现文件浏览...

  • 2022-06-21配置环境变量

    vim /etc/profile 配置完就可以直接用 mongo

  • vim调试php

    vdebug插件 vim-vdebug/vdebug 用vim-plug下载安装这款插件 具体配置如下 xdebu...

  • vim

    install VIM VIM官网下载安装包我是安装再D盘 基础配置 vim所有配置都在_vimrc里配置。例默认...

  • VIM终极配置spf13

    折腾来折腾去的搞vim配置,不如就用这个吧,开发配合vscode用。http://vim.spf13.com

  • 1. 配置 - vim

    参考: 自己的vim配置 说明: 效果预览效果 安装: 参考:从零开始配置你的个性化Vim: https://sa...

  • vim c++ 代码自动格式化配置

    安装 vim 插件 auto-format 安装 Artistic Style 配置 vim 配置文件 .vim...

  • Vim Latex 的使用和配置技巧 (一)

    在这篇文章里, 我将简单地介绍一下我用 vim 编辑 Latex的技巧, 以及一些相关的配置. 众所周知, Vim...

网友评论

      本文标题:我自己用的vim配置

      本文链接:https://www.haomeiwen.com/subject/iypmgttx.html