如果在 vim 中写入只读文件,如何自动打开文件进行编辑?

发布于 2024-08-20 02:41:07 字数 295 浏览 3 评论 0原文

这非常类似于:

Vim 自动命令:写入只读文件?

除了这里提供的解决方案之外,我希望 vim 仅在文件仍然只读时才要求确认。

换句话说,如果我这样做 :w,我不希望 vim 说该文件是只读的。它应该使用 perforce 自动打开文件进行编辑,并且只有当文件仍然为只读时,它才会要求确认。

This is very similar to:

Vim auto commands: writing a read-only file?

Except that in addition to the solution presented there, I want vim to only ask for confirmation if the file is still read-only.

In other words, if I do :w, I do not want vim to say that the file is read-only. It should automatically open the file for edit using perforce, and only if the file is still read-only should it then ask for confirmation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北城孤痞 2024-08-27 02:41:07

您可能还对 vim 的Perforce 插件感兴趣。

You might also be interested in the Perforce plugin for vim.

王权女流氓 2024-08-27 02:41:07
autocmd! bufreadpost * :if &readonly && confirm('File is read only. Open for edit?', "&Yes\n&No", 1) == 1 | setlocal noreadonly writeany
autocmd! bufreadpost * :if &readonly && confirm('File is read only. Open for edit?', "&Yes\n&No", 1) == 1 | setlocal noreadonly writeany
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文