gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:16:24 25 4
gpt4 key购买 nike

例如,如果我在 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

关于vim - 有没有办法在 Vim 中为新文件添加版权文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/864118/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com