在vim中意外输入:W1而不是:WQ

发布于 2025-02-09 11:37:18 字数 68 浏览 2 评论 0原文

我经常不小心输入:在VIM中而不是:WQ。在这种情况下,创建了名称1的文件。

有什么方法可以防止这种情况吗?

very often I accidently enter :w1 in vim and not :wq. In that case a file with the name 1 is created.

Is there any way to prevent this?

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

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

发布评论

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

评论(1

阿楠 2025-02-16 11:37:18

AS phd 评论说,您可以创建一个命令行缩写:

:cnoreab w1 wq

也可以使用 ZZ 退出,

ZZ          Write current file, if modified, and close the current
            window (same as ":x").
            If there are several windows for the current file,
            only the current window is closed.

您 还可以考虑当前的缓冲区,就好像是刮擦缓冲区一样,并删除所有内容:

ZQ          Quit without checking for changes (same as ":q!").

As phd commented you can create a command line abbreviation:

:cnoreab w1 wq

You can also exit using ZZ:

ZZ          Write current file, if modified, and close the current
            window (same as ":x").
            If there are several windows for the current file,
            only the current window is closed.

You can also consider the current buffer as if it was a scratch buffer and discar everything:

ZQ          Quit without checking for changes (same as ":q!").
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文