zoukankan      html  css  js  c++  java
  • vim 配置文件

    vim的配置文件如下_vimrc:

    set nocompatible
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/mswin.vim
    behave mswin

    set diffexpr=MyDiff()
    function MyDiff()
    let opt = '-a --binary '
    if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
    if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
    let arg1 = v:fname_in
    if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
    let arg2 = v:fname_new
    if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
    let arg3 = v:fname_out
    if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
    let eq = ''
    if $VIMRUNTIME =~ ' '
    if &sh =~ '<cmd'
    let cmd = '""' . $VIMRUNTIME . 'diff"'
    let eq = '"'
    else
    let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . 'diff"'
    endif
    else
    let cmd = $VIMRUNTIME . 'diff'
    endif
    silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
    endfunction

    set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
    colorscheme torte

    set nu " 显示行号
    set foldenable " 允许折叠
    set foldmethod=manual " 手动折叠
    set background=dark "背景使用黑色
    set ts=4 "(注:ts是tabstop的缩写,设TAB宽4个空格)
    set expandtab
    set smartindent
    set shiftwidth=4

    set guifont=consolas:h12:cANSI

    "进行版权声明的设置
    "添加或更新头
    map <F4> :call TitleDet()<cr>'s
    function AddTitle()
    call append(0,"/*===============================================")
    call append(1,"# Author: RollerCoaster")
    call append(2,"# Last modified:".strftime("%Y-%m-%d %H:%M"))
    call append(3,"# Filename: ".expand("%:t"))
    call append(4,"# Description: ")
    call append(5,"=================================================*/")
    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")@'
    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 < 7
    let line = getline(n)
    if line =~ '^#s*S*Lastsmodified:S*.*$'
    call UpdateTitle()
    return
    endif
    let n = n + 1
    endwhile
    call AddTitle()
    endfunction

    "代码补全
    set completeopt=preview,menu
    "从不备份
    set nobackup

    作者:BestNow
    出处:http://www.cnblogs.com/BestNow/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Spring中获取数据库表主键序列
    java学习:ArrayList的实现及原理
    MyBatis SQL动态装配
    Unsupported major.minor version 51.0解决方法
    spring自动装配
    c# 窗口关闭方法
    C# 自定义集合类
    C#接口的实现和继承实践
    C# 开发COM组件供c++使用
    C# 创建和引入动态链接库dll文件
  • 原文地址:https://www.cnblogs.com/tianxue/p/3933559.html
Copyright © 2011-2022 走看看