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

前端之家收集整理的这篇文章主要介绍了有没有办法在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.f2er.com/bash/384254.html

猜你在找的Bash相关文章