微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有办法在Vim中为新文件添加版权文本?

例如,如果我在 vim中打开一个全新的文件,它已经包含以下文本:
/*
  The MIT License

  copyright (c) 2009 Apphacker apphacker@gmail.com

  Permission is hereby granted,free of charge,to any person obtaining a copy
  of this software and associated documentation files (the "Software"),to deal
  in the Software without restriction,including without limitation the rights
  to use,copy,modify,merge,publish,distribute,sublicense,and/or sell
  copies of the Software,and to permit persons to whom the Software is
  furnished to do so,subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR
  IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,fitness FOR A PARTIculaR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR copYRIGHT HOLDERS BE LIABLE FOR ANY CLaim,damAGES OR OTHER
  LIABILITY,WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE,ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/

不得不输入/复制&将其粘贴到每个新文件中.

如何创建保存MIT许可证的文本文件〜/ .vim / mit.txt?然后是.vimrc中的以下内容
map :mit :0r ~/.vim/mit.txt

…所以你只需输入:用于插入许可证的mit.

或者,如果您确实一直想要这种行为:

autocmd BufNewFile *
\ 0r ~/.vim/mit.txt
augroup END

原文地址:https://www.jb51.cc/vim/384254.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐