如何在vim中发出蜂鸣声
有什么方法可以显式请求 vim 发出蜂鸣声,最好不需要运行外部命令?
原因是我经常运行需要很长时间的命令(例如 :make
),因此我开始做其他事情,但需要提醒我任务已完成。所以没有错误会导致 vim 发出蜂鸣声,但我可以运行任意命令,所以我需要一些命令让它发出蜂鸣声(好吧,运行外部程序是可行的,但我更喜欢更便携的方法)。
Is there any way to explicitly request vim to beep, preferably without having to run external commands?
The reason is that I often run commands (like :make
) that take quite long, so I start doing something else, but than I need to be alerted to the fact that the task finished. So there is no error that would cause vim to beep, but I can run arbitrary command, so I need some command that would make it beep (ok, with running external program it's doable, but I'd prefer more portable method).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是:
有关详细信息,请参阅:
:help beep
:help 'errorbells'
:help :echoerr
Yes:
For more information see:
:help beep
:help 'errorbells'
:help :echoerr
打印 Bell 字符 (Ctrl-G)。在 Windows 上
echo ^G
会发出蜂鸣声。根据您的终端设置,它也可以在 Linux 上运行。Print the Bell character (Ctrl-G). On Windows
echo ^G
will cause a beep. Depending on your terminal setup it also works on Linux.这是 @johnsyweb-supports-our-mods 的答案,处理了更多边缘情况并包装在可重用命令中:
说明:
set belloff-=esc
使得在中点击 Escape正常模式响铃。set novisualbell
使铃声响起。execute "normal! \" 确保我们处于正常模式。
。执行“正常!\”
响铃。正常!如果我们以其中一种模式开始,则 gv
将返回到“可视”或“选择”模式。Here's @johnsyweb-supports-our-mods's answer, with more edge cases taken care of and wrapped in a reusable command:
Explanation:
set belloff-=esc
makes hitting Escape in Normal mode ring the bell.set novisualbell
makes the bell audible.execute "normal! \<Esc>"
.execute "normal! \<Esc>"
rings the bell.normal! gv
returns us to Visual or Select mode if we started in one of those modes.