介绍一些关于Gvim(windows 7 32位 Vim 7.4)的基本配置,除了特别说明,代码一律添加在安装目录下的_vimrc文件中。

1、取消自动备份,这行代码需要添加在 _vimrc文件中的behave mswin之后才能生效:

set nobackup

 2、F4一键添加作者信息: 

map <F4> :call TitleDet()<cr>'s
function AddTitle()
    call append(0,"/*============================================================================")
    call append(1,"* Author        : vitah")
    call append(2,"* Mail          : linw1225@163.com")
    call append(3,"* Last modified : ".strftime("%Y-%m-%d %H:%M"))
    call append(4,"* Filename      : ".expand("%:t"))
    call append(5,"* Description   :")
    call append(6,"*")
    call append(7,"=============================================================================*/")
    echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endf
"更新最近修改时间和文件名
function UpdateTitle()
    normal m'
   "" execute '/* Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%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 < 8
        let line = getline(n)
        if line =~ '^\*\s*\S*Last\smodified :\S*.*$'
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction
一键添加作者信息

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-05-18
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2021-09-22
  • 2022-01-27
  • 2021-08-15
相关资源
相似解决方案