重新映射"wq"以保存并关闭缓冲区,而不是保存并退出 [英] Remapping 'wq' to save and close buffer instead of save and quit

查看:126
本文介绍了重新映射"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 modes including Command-line mode, so you can define these mappings (in your .vimrc):

:cnoreabbrev wq w<bar>bd
:cnoreabbrev q bd

命令告诉Vim,在其中按 w q 命令行将扩展为w|bd,类似地, q 将被扩展为bd.参见:help key-mapping 有关更多详细信息.

The commands tell Vim that pressing wq in command line are to be expanded into w|bd and, similarly, that q are to be expanded into bd. See :help key-mapping for more details.

这篇关于重新映射"wq"以保存并关闭缓冲区,而不是保存并退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆