[英]how to remap “q!” and “q” in vim
I'm trying to remap q
and q!
我正在尝试重新映射
q
和q!
. 。 Here's what I'm trying:
这是我正在尝试的:
cnoremap q :call TabCloseLeft('q') cnoremap q! :call TabCloseLeft('q!')
That properly remaps :q
but doesn't capture :q!
可以正确地重映射
:q
但不能捕获:q!
. 。 I've read various help sections, but I'm obviously overlooking something.
我已经阅读了各个帮助部分,但显然我忽略了一些内容。
I see some problems: 我看到一些问题:
cnoremap
dangerously eg /q
cnoremap
例如/q
:quit
function :quit
函数 Do not use cnoremap
to try and create commands, use :command
. 不要使用
cnoremap
尝试和创建命令,使用:command
。 If you want to override a command then use a clever cabbrev
expression or plugin. 如果要覆盖命令,请使用聪明的
cabbrev
表达式或插件。 See vim change :x function to delete buffer instead of save & quit 查看vim change:x函数来删除缓冲区,而不是保存并退出
There are many ways for quiting a buffer in vim. 在vim中有很多退出缓冲区的方法。 Some do slightly different things.
有些做的事情略有不同。 As vimmers learn more commands they integrate them into their workflow.
随着Vimmer学习更多的命令,他们将它们集成到他们的工作流程中。 eg
<cw>c
to close a split/window and ZZ
to update and quite the current buffer. 例如,
<cw>c
关闭拆分/窗口, ZZ
更新并更新当前缓冲区。 If you go down this path you will be overriding many command or you will be disregarding useful commands. 如果您走这条路,将会覆盖许多命令,或者将忽略有用的命令。
Learn to use buffers effectively . 学习有效地使用缓冲区 。 Using tabs in Vim is great however they are not the only way and will certainly cause you pain down the road.
在Vim中使用制表符很不错,但是它们并不是唯一的方法,并且肯定会使您痛苦不已。 IMHO it is best to curtail these behaviors and encourage better habits.
恕我直言,最好是减少这些行为并鼓励更好的习惯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.