3
I'm always typing :Wq
when I mean :wq
. Is there a way to alias :Wq=':wq'
in vim?
3
I'm always typing :Wq
when I mean :wq
. Is there a way to alias :Wq=':wq'
in vim?
5
I had the same problem, but I aliased ;
to :
instead.
nnoremap ; :
(Why worry about not releasing Shift in time if you can just not press it in the first place.)
A more direct answer:
command Wq :wq
(As it happens, user-defined commands must start with an upper-case letter.)
You'll likely want proper tab-completion though, as well as :W
:
command -complete=file -bang -nargs=? W :w<bang> <args>
command -complete=file -bang -nargs=? Wq :wq<bang> <args>
0
Check the answers for the same question on the stackoverflow on how to achieve what you asked.
But I think it is better to use ZZ
(which is also mentioned there), as it is shorter to type and avoid the problem altogether. Mappings are usually better than commands for frequent actions/tasks.
Thanks @mMontu. I thought this must have been asked before but couldn't find it via google
– isomorphismes – 2015-02-26T12:33:00.993
This is a line to be added in
~/.vimrc
? – isomorphismes – 2015-02-24T17:44:55.6031Since I tend to have a "lazy shift finger" when typing a colon, I have had to create user-commands that correspond to a number of internal Vim commands, including
:Help
. – Heptite – 2015-02-24T18:17:34.833