本文介绍了重新映射"wq"以保存并关闭缓冲区,而不是保存并退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是新手.
当我':wq'时,我希望它保存和删除缓冲区,而不是保存并退出.同样,点击':q'将执行':bd'.
when I ':wq' I want it to save and delete the buffer instead of save and quit.Similarly hitting ':q' would execute ':bd' instead.
有什么建议吗?谢谢!
推荐答案
Vim允许在所有模式下为命令添加键映射(包括命令行模式),因此您可以定义这些映射(在您的.vimrc
中):
Vim allows to add key mappings for commands in all of the modesincluding Command-line mode, so you can define these mappings(in your .vimrc
):
:cnoreabbrev wq w<bar>bd
:cnoreabbrev q bd
命令告诉Vim,在其中按 命令行将扩展为w|bd
,类似地,将被扩展为bd
.参见:help key-mapping
有关更多详细信息.
The commands tell Vim that pressing incommand line are to be expanded into w|bd
and, similarly, that are to be expanded into bd
. See :help key-mapping
for more details.
这篇关于重新映射"wq"以保存并关闭缓冲区,而不是保存并退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!