I'm trying to remap q
and 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!
. I've read various help sections, but I'm obviously overlooking something.
I see some problems:
cnoremap
dangerously eg /q
:quit
function Do not use cnoremap
to try and create commands, use :command
. If you want to override a command then use a clever cabbrev
expression or plugin. See vim change :x function to delete buffer instead of save & quit
There are many ways for quiting a buffer in vim. Some do slightly different things. As vimmers learn more commands they integrate them into their workflow. eg <cw>c
to close a split/window and ZZ
to update and quite the current buffer. 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. IMHO it is best to curtail these behaviors and encourage better habits.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.